From: Herbert Xu Subject: crypto: shash - Fix async finup handling of null digest Date: Wed, 15 Jul 2009 21:30:38 +0800 Message-ID: <20090715133038.GA22980@gondor.apana.org.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: Linux Crypto Mailing List Return-path: Received: from rhun.apana.org.au ([64.62.148.172]:45215 "EHLO arnor.apana.org.au" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754397AbZGONak (ORCPT ); Wed, 15 Jul 2009 09:30:40 -0400 Received: from gondolin.me.apana.org.au ([192.168.0.6]) by arnor.apana.org.au with esmtp (Exim 4.63 #1 (Debian)) id 1MR4ZD-0000to-7v for ; Wed, 15 Jul 2009 23:30:39 +1000 Received: from herbert by gondolin.me.apana.org.au with local (Exim 4.69) (envelope-from ) id 1MR4ZC-0005z9-J2 for linux-crypto@vger.kernel.org; Wed, 15 Jul 2009 21:30:38 +0800 Content-Disposition: inline Sender: linux-crypto-owner@vger.kernel.org List-ID: Hi: commit cbc86b9161b40f95caee0e56381b68956fc28cc4 Author: Herbert Xu Date: Wed Jul 15 21:26:41 2009 +0800 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 diff --git a/crypto/shash.c b/crypto/shash.c index 834d9d2..7713b52 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; } Cheers, -- Visit Openswan at http://www.openswan.org/ Email: Herbert Xu ~{PmV>HI~} Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt