aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-08 06:46:23 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-08 07:00:38 -0400
commit619a6ebd2547f3a8ec2fbc5245daaa1f2056eb32 (patch)
tree4b32cd84e9eb31c1068a7397ffa9e29f5cc79ec1 /crypto/shash.c
parent7d6f56400a695af497a8b7c23ea0ff9c3d9d99f4 (diff)
crypto: shash - Add shash_register_instance
This patch adds shash_register_instance so that shash instances can be registered without bypassing the shash checks applied to normal algorithms. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/shash.c')
-rw-r--r--crypto/shash.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 21bcff6be5b0..3d242425d692 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -480,7 +480,7 @@ struct crypto_shash *crypto_alloc_shash(const char *alg_name, u32 type,
480} 480}
481EXPORT_SYMBOL_GPL(crypto_alloc_shash); 481EXPORT_SYMBOL_GPL(crypto_alloc_shash);
482 482
483int crypto_register_shash(struct shash_alg *alg) 483static int shash_prepare_alg(struct shash_alg *alg)
484{ 484{
485 struct crypto_alg *base = &alg->base; 485 struct crypto_alg *base = &alg->base;
486 486
@@ -491,6 +491,17 @@ int crypto_register_shash(struct shash_alg *alg)
491 base->cra_type = &crypto_shash_type; 491 base->cra_type = &crypto_shash_type;
492 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK; 492 base->cra_flags &= ~CRYPTO_ALG_TYPE_MASK;
493 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH; 493 base->cra_flags |= CRYPTO_ALG_TYPE_SHASH;
494 return 0;
495}
496
497int crypto_register_shash(struct shash_alg *alg)
498{
499 struct crypto_alg *base = &alg->base;
500 int err;
501
502 err = shash_prepare_alg(alg);
503 if (err)
504 return err;
494 505
495 return crypto_register_alg(base); 506 return crypto_register_alg(base);
496} 507}
@@ -502,6 +513,19 @@ int crypto_unregister_shash(struct shash_alg *alg)
502} 513}
503EXPORT_SYMBOL_GPL(crypto_unregister_shash); 514EXPORT_SYMBOL_GPL(crypto_unregister_shash);
504 515
516int shash_register_instance(struct crypto_template *tmpl,
517 struct shash_instance *inst)
518{
519 int err;
520
521 err = shash_prepare_alg(&inst->alg);
522 if (err)
523 return err;
524
525 return crypto_register_instance(tmpl, shash_crypto_instance(inst));
526}
527EXPORT_SYMBOL_GPL(shash_register_instance);
528
505void shash_free_instance(struct crypto_instance *inst) 529void shash_free_instance(struct crypto_instance *inst)
506{ 530{
507 crypto_drop_spawn(crypto_instance_ctx(inst)); 531 crypto_drop_spawn(crypto_instance_ctx(inst));