]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: hash - add crypto_(un)register_ahashes()
authorRabin Vincent <rabinv@axis.com>
Thu, 10 Aug 2017 12:53:52 +0000 (14:53 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 22 Aug 2017 06:54:52 +0000 (14:54 +0800)
There are already helpers to (un)register multiple normal
and AEAD algos.  Add one for ahashes too.

Signed-off-by: Lars Persson <larper@axis.com>
Signed-off-by: Rabin Vincent <rabinv@axis.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/ahash.c
include/crypto/internal/hash.h

index 826cd7ab4d4a2ec830438b40e987e230bd03f32f..5e8666e6ccaeaa430f85266ee92f73178c993f6a 100644 (file)
@@ -588,6 +588,35 @@ int crypto_unregister_ahash(struct ahash_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_ahash);
 
+int crypto_register_ahashes(struct ahash_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = 0; i < count; i++) {
+               ret = crypto_register_ahash(&algs[i]);
+               if (ret)
+                       goto err;
+       }
+
+       return 0;
+
+err:
+       for (--i; i >= 0; --i)
+               crypto_unregister_ahash(&algs[i]);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_register_ahashes);
+
+void crypto_unregister_ahashes(struct ahash_alg *algs, int count)
+{
+       int i;
+
+       for (i = count - 1; i >= 0; --i)
+               crypto_unregister_ahash(&algs[i]);
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_ahashes);
+
 int ahash_register_instance(struct crypto_template *tmpl,
                            struct ahash_instance *inst)
 {
index f6d9af3efa45a6cc8eb448a71f5d43d72d8fcbd1..f0b44c16e88f241721a4296019475abae6b7a3b0 100644 (file)
@@ -76,6 +76,8 @@ static inline int crypto_ahash_walk_last(struct crypto_hash_walk *walk)
 
 int crypto_register_ahash(struct ahash_alg *alg);
 int crypto_unregister_ahash(struct ahash_alg *alg);
+int crypto_register_ahashes(struct ahash_alg *algs, int count);
+void crypto_unregister_ahashes(struct ahash_alg *algs, int count);
 int ahash_register_instance(struct crypto_template *tmpl,
                            struct ahash_instance *inst);
 void ahash_free_instance(struct crypto_instance *inst);