summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2015-04-20 22:46:40 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2015-04-21 21:30:16 -0400
commit881cd6c570af412c2fab278b0656f7597dc5ee74 (patch)
tree8086185484f8185be5cb365a45d35cf19d75d6dc
parent7ca99d814821e8a8ac6d7c48b2ccfc24bda27b1f (diff)
crypto: rng - Add multiple algorithm registration interface
This patch adds the helpers that allow the registration and removal of multiple RNG algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--crypto/rng.c29
-rw-r--r--include/crypto/internal/rng.h2
2 files changed, 31 insertions, 0 deletions
diff --git a/crypto/rng.c b/crypto/rng.c
index 5e0425a24657..e98ce1ca527d 100644
--- a/crypto/rng.c
+++ b/crypto/rng.c
@@ -233,5 +233,34 @@ void crypto_unregister_rng(struct rng_alg *alg)
233} 233}
234EXPORT_SYMBOL_GPL(crypto_unregister_rng); 234EXPORT_SYMBOL_GPL(crypto_unregister_rng);
235 235
236int crypto_register_rngs(struct rng_alg *algs, int count)
237{
238 int i, ret;
239
240 for (i = 0; i < count; i++) {
241 ret = crypto_register_rng(algs + i);
242 if (ret)
243 goto err;
244 }
245
246 return 0;
247
248err:
249 for (--i; i >= 0; --i)
250 crypto_unregister_rng(algs + i);
251
252 return ret;
253}
254EXPORT_SYMBOL_GPL(crypto_register_rngs);
255
256void crypto_unregister_rngs(struct rng_alg *algs, int count)
257{
258 int i;
259
260 for (i = count - 1; i >= 0; --i)
261 crypto_unregister_rng(algs + i);
262}
263EXPORT_SYMBOL_GPL(crypto_unregister_rngs);
264
236MODULE_LICENSE("GPL"); 265MODULE_LICENSE("GPL");
237MODULE_DESCRIPTION("Random Number Generator"); 266MODULE_DESCRIPTION("Random Number Generator");
diff --git a/include/crypto/internal/rng.h b/include/crypto/internal/rng.h
index 93d41bcc444e..2c9a865c66e2 100644
--- a/include/crypto/internal/rng.h
+++ b/include/crypto/internal/rng.h
@@ -20,6 +20,8 @@ extern const struct crypto_type crypto_rng_type;
20 20
21int crypto_register_rng(struct rng_alg *alg); 21int crypto_register_rng(struct rng_alg *alg);
22void crypto_unregister_rng(struct rng_alg *alg); 22void crypto_unregister_rng(struct rng_alg *alg);
23int crypto_register_rngs(struct rng_alg *algs, int count);
24void crypto_unregister_rngs(struct rng_alg *algs, int count);
23 25
24static inline void *crypto_rng_ctx(struct crypto_rng *tfm) 26static inline void *crypto_rng_ctx(struct crypto_rng *tfm)
25{ 27{