aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/cryptd.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-21 23:10:22 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-21 23:10:22 -0400
commit6fba00d176ab73b15bb8e31f261582943429a92b (patch)
tree4a29cb4a018ae708b80f8e7a9af19e60770f864c /crypto/cryptd.c
parent2a549c364aa11e658ae14b71861d25474e5808cf (diff)
crypto: cryptd - Add finup/export/import for hash
This patch adds the finup/export/import functions to the cryptd ahash implementation. We simply invoke the underlying shash operations. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto/cryptd.c')
-rw-r--r--crypto/cryptd.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/crypto/cryptd.c b/crypto/cryptd.c
index fbd26f9dd329..2eb705822f2b 100644
--- a/crypto/cryptd.c
+++ b/crypto/cryptd.c
@@ -478,6 +478,29 @@ static int cryptd_hash_final_enqueue(struct ahash_request *req)
478 return cryptd_hash_enqueue(req, cryptd_hash_final); 478 return cryptd_hash_enqueue(req, cryptd_hash_final);
479} 479}
480 480
481static void cryptd_hash_finup(struct crypto_async_request *req_async, int err)
482{
483 struct ahash_request *req = ahash_request_cast(req_async);
484 struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req);
485
486 if (unlikely(err == -EINPROGRESS))
487 goto out;
488
489 err = shash_ahash_finup(req, &rctx->desc);
490
491 req->base.complete = rctx->complete;
492
493out:
494 local_bh_disable();
495 rctx->complete(&req->base, err);
496 local_bh_enable();
497}
498
499static int cryptd_hash_finup_enqueue(struct ahash_request *req)
500{
501 return cryptd_hash_enqueue(req, cryptd_hash_finup);
502}
503
481static void cryptd_hash_digest(struct crypto_async_request *req_async, int err) 504static void cryptd_hash_digest(struct crypto_async_request *req_async, int err)
482{ 505{
483 struct cryptd_hash_ctx *ctx = crypto_tfm_ctx(req_async->tfm); 506 struct cryptd_hash_ctx *ctx = crypto_tfm_ctx(req_async->tfm);
@@ -507,6 +530,20 @@ static int cryptd_hash_digest_enqueue(struct ahash_request *req)
507 return cryptd_hash_enqueue(req, cryptd_hash_digest); 530 return cryptd_hash_enqueue(req, cryptd_hash_digest);
508} 531}
509 532
533static int cryptd_hash_export(struct ahash_request *req, void *out)
534{
535 struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req);
536
537 return crypto_shash_export(&rctx->desc, out);
538}
539
540static int cryptd_hash_import(struct ahash_request *req, const void *in)
541{
542 struct cryptd_hash_request_ctx *rctx = ahash_request_ctx(req);
543
544 return crypto_shash_import(&rctx->desc, in);
545}
546
510static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb, 547static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
511 struct cryptd_queue *queue) 548 struct cryptd_queue *queue)
512{ 549{
@@ -546,6 +583,9 @@ static int cryptd_create_hash(struct crypto_template *tmpl, struct rtattr **tb,
546 inst->alg.init = cryptd_hash_init_enqueue; 583 inst->alg.init = cryptd_hash_init_enqueue;
547 inst->alg.update = cryptd_hash_update_enqueue; 584 inst->alg.update = cryptd_hash_update_enqueue;
548 inst->alg.final = cryptd_hash_final_enqueue; 585 inst->alg.final = cryptd_hash_final_enqueue;
586 inst->alg.finup = cryptd_hash_finup_enqueue;
587 inst->alg.export = cryptd_hash_export;
588 inst->alg.import = cryptd_hash_import;
549 inst->alg.setkey = cryptd_hash_setkey; 589 inst->alg.setkey = cryptd_hash_setkey;
550 inst->alg.digest = cryptd_hash_digest_enqueue; 590 inst->alg.digest = cryptd_hash_digest_enqueue;
551 591