]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
crypto: add crypto_[un]register_shashes for [un]registering multiple shash entries...
authorJussi Kivilinna <jussi.kivilinna@mbnet.fi>
Wed, 11 Jul 2012 11:20:20 +0000 (14:20 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 1 Aug 2012 09:47:26 +0000 (17:47 +0800)
Add crypto_[un]register_shashes() to allow simplifying init/exit code of shash
crypto modules that register multiple algorithms.

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/shash.c
include/crypto/internal/hash.h

index 32067f47e6c7bfbeea673d039e7ad5bc2bf90492..f426330f101755493a529d4dd8f9bcd900b51f73 100644 (file)
@@ -629,6 +629,42 @@ int crypto_unregister_shash(struct shash_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_shash);
 
+int crypto_register_shashes(struct shash_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = 0; i < count; i++) {
+               ret = crypto_register_shash(&algs[i]);
+               if (ret)
+                       goto err;
+       }
+
+       return 0;
+
+err:
+       for (--i; i >= 0; --i)
+               crypto_unregister_shash(&algs[i]);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_register_shashes);
+
+int crypto_unregister_shashes(struct shash_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = count - 1; i >= 0; --i) {
+               ret = crypto_unregister_shash(&algs[i]);
+               if (ret)
+                       pr_err("Failed to unregister %s %s: %d\n",
+                              algs[i].base.cra_driver_name,
+                              algs[i].base.cra_name, ret);
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_shashes);
+
 int shash_register_instance(struct crypto_template *tmpl,
                            struct shash_instance *inst)
 {
index 5bfad8c8059580d9668c72e9acf9f056f24b928c..821eae8cbd8cf131bdbcc41dd46de828e700269a 100644 (file)
@@ -83,6 +83,8 @@ struct hash_alg_common *ahash_attr_alg(struct rtattr *rta, u32 type, u32 mask);
 
 int crypto_register_shash(struct shash_alg *alg);
 int crypto_unregister_shash(struct shash_alg *alg);
+int crypto_register_shashes(struct shash_alg *algs, int count);
+int crypto_unregister_shashes(struct shash_alg *algs, int count);
 int shash_register_instance(struct crypto_template *tmpl,
                            struct shash_instance *inst);
 void shash_free_instance(struct crypto_instance *inst);