Skip to content

Commit

Permalink
crypto: rng - Add multiple algorithm registration interface
Browse files Browse the repository at this point in the history
This patch adds the helpers that allow the registration and removal
of multiple RNG algorithms.

Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Apr 22, 2015
1 parent 7ca99d8 commit 881cd6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crypto/rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,5 +233,34 @@ void crypto_unregister_rng(struct rng_alg *alg)
}
EXPORT_SYMBOL_GPL(crypto_unregister_rng);

int crypto_register_rngs(struct rng_alg *algs, int count)
{
int i, ret;

for (i = 0; i < count; i++) {
ret = crypto_register_rng(algs + i);
if (ret)
goto err;
}

return 0;

err:
for (--i; i >= 0; --i)
crypto_unregister_rng(algs + i);

return ret;
}
EXPORT_SYMBOL_GPL(crypto_register_rngs);

void crypto_unregister_rngs(struct rng_alg *algs, int count)
{
int i;

for (i = count - 1; i >= 0; --i)
crypto_unregister_rng(algs + i);
}
EXPORT_SYMBOL_GPL(crypto_unregister_rngs);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Random Number Generator");
2 changes: 2 additions & 0 deletions include/crypto/internal/rng.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ extern const struct crypto_type crypto_rng_type;

int crypto_register_rng(struct rng_alg *alg);
void crypto_unregister_rng(struct rng_alg *alg);
int crypto_register_rngs(struct rng_alg *algs, int count);
void crypto_unregister_rngs(struct rng_alg *algs, int count);

static inline void *crypto_rng_ctx(struct crypto_rng *tfm)
{
Expand Down

0 comments on commit 881cd6c

Please sign in to comment.