From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33597) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1afJ64-0002V5-Mh for qemu-devel@nongnu.org; Sun, 13 Mar 2016 23:23:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1afJ63-0005wu-QI for qemu-devel@nongnu.org; Sun, 13 Mar 2016 23:23:08 -0400 Date: Mon, 14 Mar 2016 11:23:00 +0800 From: Fam Zheng Message-ID: <20160314032300.GG2112@ad.usersys.redhat.com> References: <1456747261-22032-1-git-send-email-berrange@redhat.com> <1456747261-22032-5-git-send-email-berrange@redhat.com> <20160307055140.GC21446@ad.usersys.redhat.com> <20160311165512.GF30098@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160311165512.GF30098@redhat.com> Subject: Re: [Qemu-devel] [PATCH v4 04/26] crypto: add support for anti-forensic split algorithm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org On Fri, 03/11 16:55, Daniel P. Berrange wrote: > On Mon, Mar 07, 2016 at 01:51:40PM +0800, Fam Zheng wrote: > > On Mon, 02/29 12:00, Daniel P. Berrange wrote: > > > The LUKS format specifies an anti-forensic split algorithm which > > > is used to artificially expand the size of the key material on > > > disk. This is an implementation of that algorithm. > > > > > > Signed-off-by: Daniel P. Berrange > > > --- > > > crypto/Makefile.objs | 1 + > > > crypto/afsplit.c | 158 ++++++++++++++++++++++++++++++++++++ > > > include/crypto/afsplit.h | 135 +++++++++++++++++++++++++++++++ > > > tests/.gitignore | 1 + > > > tests/Makefile | 2 + > > > tests/test-crypto-afsplit.c | 190 ++++++++++++++++++++++++++++++++++++++++++++ > > > 6 files changed, 487 insertions(+) > > > create mode 100644 crypto/afsplit.c > > > create mode 100644 include/crypto/afsplit.h > > > create mode 100644 tests/test-crypto-afsplit.c > > > > > > > +static int qcrypto_afsplit_hash(QCryptoHashAlgorithm hash, > > > + size_t blocklen, > > > + uint8_t *block, > > > + Error **errp) > > > +{ > > > + size_t digestlen = qcrypto_hash_digest_len(hash); > > > + > > > + size_t hashcount = blocklen / digestlen; > > > > Do you want to use DIV_ROUND_UP? Because if blocklen < digestlen, hashcount is > > 0, and your for loop below will be skipped. > > It is not needed actually - look a couple of lines > further where we do 'if (finallen) { hashcount ++ }'. > This achieves the same end result. Yes you're right. Reviewed-by: Fam Zheng