Commit cbb9bf65ae25dee772e85589136e7dd1c3e743ae

Authored by Szilveszter Ördög
Committed by Herbert Xu
1 parent 77ba115c47

crypto: hash - Fix handling of unaligned buffers

The correct way to calculate the start of the aligned part of an
unaligned buffer is:

  offset = ALIGN(offset, alignmask + 1);

However, crypto_hash_walk_done() has:

  offset += alignmask - 1;
  offset = ALIGN(offset, alignmask + 1);

which actually skips a whole block unless offset % (alignmask + 1) == 1.

This patch fixes the problem.

Signed-off-by: Szilveszter Ördög <slipszi@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Showing 1 changed file with 0 additions and 1 deletions Side-by-side Diff

... ... @@ -78,7 +78,6 @@
78 78 walk->data -= walk->offset;
79 79  
80 80 if (nbytes && walk->offset & alignmask && !err) {
81   - walk->offset += alignmask - 1;
82 81 walk->offset = ALIGN(walk->offset, alignmask + 1);
83 82 walk->data += walk->offset;
84 83