Skip to content

Commit

Permalink
crypto: hash - add crypto_(un)register_ahashes()
Browse files Browse the repository at this point in the history
There are already helpers to (un)register multiple normal
and AEAD algos.  Add one for ahashes too.

Signed-off-by: Lars Persson <[email protected]>
Signed-off-by: Rabin Vincent <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
vwax authored and herbertx committed Aug 22, 2017
1 parent ac6b6f4 commit 6f7473c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
29 changes: 29 additions & 0 deletions crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,35 @@ int crypto_unregister_ahash(struct ahash_alg *alg)
}
EXPORT_SYMBOL_GPL(crypto_unregister_ahash);

int crypto_register_ahashes(struct ahash_alg *algs, int count)
{
int i, ret;

for (i = 0; i < count; i++) {
ret = crypto_register_ahash(&algs[i]);
if (ret)
goto err;
}

return 0;

err:
for (--i; i >= 0; --i)
crypto_unregister_ahash(&algs[i]);

return ret;
}
EXPORT_SYMBOL_GPL(crypto_register_ahashes);

void crypto_unregister_ahashes(struct ahash_alg *algs, int count)
{
int i;

for (i = count - 1; i >= 0; --i)
crypto_unregister_ahash(&algs[i]);
}
EXPORT_SYMBOL_GPL(crypto_unregister_ahashes);

int ahash_register_instance(struct crypto_template *tmpl,
struct ahash_instance *inst)
{
Expand Down
2 changes: 2 additions & 0 deletions include/crypto/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static inline int crypto_ahash_walk_last(struct crypto_hash_walk *walk)

int crypto_register_ahash(struct ahash_alg *alg);
int crypto_unregister_ahash(struct ahash_alg *alg);
int crypto_register_ahashes(struct ahash_alg *algs, int count);
void crypto_unregister_ahashes(struct ahash_alg *algs, int count);
int ahash_register_instance(struct crypto_template *tmpl,
struct ahash_instance *inst);
void ahash_free_instance(struct crypto_instance *inst);
Expand Down

0 comments on commit 6f7473c

Please sign in to comment.