crypto: aead - Add multiple algorithm registration interface
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 28 May 2015 14:07:59 +0000 (22:07 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Wed, 3 Jun 2015 02:48:35 +0000 (10:48 +0800)
This patch adds the helpers that allow the registration and removal
of multiple algorithms.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
crypto/aead.c
include/crypto/internal/aead.h

index ac4479297864d53a6511fd39e817998140f376f6..07bf99773548bf9f088b6ff8380edb4caf7cda4a 100644 (file)
@@ -896,6 +896,35 @@ void crypto_unregister_aead(struct aead_alg *alg)
 }
 EXPORT_SYMBOL_GPL(crypto_unregister_aead);
 
+int crypto_register_aeads(struct aead_alg *algs, int count)
+{
+       int i, ret;
+
+       for (i = 0; i < count; i++) {
+               ret = crypto_register_aead(&algs[i]);
+               if (ret)
+                       goto err;
+       }
+
+       return 0;
+
+err:
+       for (--i; i >= 0; --i)
+               crypto_unregister_aead(&algs[i]);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(crypto_register_aeads);
+
+void crypto_unregister_aeads(struct aead_alg *algs, int count)
+{
+       int i;
+
+       for (i = count - 1; i >= 0; --i)
+               crypto_unregister_aead(&algs[i]);
+}
+EXPORT_SYMBOL_GPL(crypto_unregister_aeads);
+
 int aead_register_instance(struct crypto_template *tmpl,
                           struct aead_instance *inst)
 {
index 3cb35d8829304ade97777de3c889960793957fd1..ba52c37b8c40e4d6c3261d2f733fc9e4b79f4979 100644 (file)
@@ -152,6 +152,8 @@ static inline unsigned int crypto_aead_maxauthsize(struct crypto_aead *aead)
 
 int crypto_register_aead(struct aead_alg *alg);
 void crypto_unregister_aead(struct aead_alg *alg);
+int crypto_register_aeads(struct aead_alg *algs, int count);
+void crypto_unregister_aeads(struct aead_alg *algs, int count);
 int aead_register_instance(struct crypto_template *tmpl,
                           struct aead_instance *inst);