summaryrefslogtreecommitdiff
path: root/crypto/shash.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2009-07-15 21:26:41 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2009-07-15 21:26:41 +0800
commit92649b66601ac4c834c1778ebcb2378f4777aa61 (patch)
tree92fc75bb04e9cf339f0342b81ce75abfefc04b9e /crypto/shash.c
parentf9b6c2feec61da989c5a090cf2344842b6743b2c (diff)
downloadlinux-crypto-92649b66601ac4c834c1778ebcb2378f4777aa61.tar.gz
linux-crypto-92649b66601ac4c834c1778ebcb2378f4777aa61.zip
crypto: shash - Fix async finup handling of null digest
When shash_ahash_finup encounters a null request, we end up not calling the underlying final function. This patch fixes that. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--crypto/shash.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/crypto/shash.c b/crypto/shash.c
index 834d9d24..7713b520 100644
--- a/crypto/shash.c
+++ b/crypto/shash.c
@@ -240,12 +240,17 @@ int shash_ahash_finup(struct ahash_request *req, struct shash_desc *desc)
struct crypto_hash_walk walk;
int nbytes;
- for (nbytes = crypto_hash_walk_first(req, &walk); nbytes > 0;
- nbytes = crypto_hash_walk_done(&walk, nbytes))
+ nbytes = crypto_hash_walk_first(req, &walk);
+ if (!nbytes)
+ return crypto_shash_final(desc, req->result);
+
+ do {
nbytes = crypto_hash_walk_last(&walk) ?
crypto_shash_finup(desc, walk.data, nbytes,
req->result) :
crypto_shash_update(desc, walk.data, nbytes);
+ nbytes = crypto_hash_walk_done(&walk, nbytes);
+ } while (nbytes > 0);
return nbytes;
}