diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2015-04-20 22:46:40 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2015-04-21 21:30:16 -0400 |
commit | 881cd6c570af412c2fab278b0656f7597dc5ee74 (patch) | |
tree | 8086185484f8185be5cb365a45d35cf19d75d6dc | |
parent | 7ca99d814821e8a8ac6d7c48b2ccfc24bda27b1f (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.c | 29 | ||||
-rw-r--r-- | include/crypto/internal/rng.h | 2 |
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 | } |
234 | EXPORT_SYMBOL_GPL(crypto_unregister_rng); | 234 | EXPORT_SYMBOL_GPL(crypto_unregister_rng); |
235 | 235 | ||
236 | int 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 | |||
248 | err: | ||
249 | for (--i; i >= 0; --i) | ||
250 | crypto_unregister_rng(algs + i); | ||
251 | |||
252 | return ret; | ||
253 | } | ||
254 | EXPORT_SYMBOL_GPL(crypto_register_rngs); | ||
255 | |||
256 | void 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 | } | ||
263 | EXPORT_SYMBOL_GPL(crypto_unregister_rngs); | ||
264 | |||
236 | MODULE_LICENSE("GPL"); | 265 | MODULE_LICENSE("GPL"); |
237 | MODULE_DESCRIPTION("Random Number Generator"); | 266 | MODULE_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 | ||
21 | int crypto_register_rng(struct rng_alg *alg); | 21 | int crypto_register_rng(struct rng_alg *alg); |
22 | void crypto_unregister_rng(struct rng_alg *alg); | 22 | void crypto_unregister_rng(struct rng_alg *alg); |
23 | int crypto_register_rngs(struct rng_alg *algs, int count); | ||
24 | void crypto_unregister_rngs(struct rng_alg *algs, int count); | ||
23 | 25 | ||
24 | static inline void *crypto_rng_ctx(struct crypto_rng *tfm) | 26 | static inline void *crypto_rng_ctx(struct crypto_rng *tfm) |
25 | { | 27 | { |