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 <berra...@redhat.com> > > > --- > > > 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 <f...@redhat.com>