Skip to content

Commit

Permalink
crypto: hash - Fix handling of unaligned buffers
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
slipszi authored and herbertx committed Mar 3, 2010
1 parent 77ba115 commit cbb9bf6
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion crypto/ahash.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
walk->data -= walk->offset;

if (nbytes && walk->offset & alignmask && !err) {
walk->offset += alignmask - 1;
walk->offset = ALIGN(walk->offset, alignmask + 1);
walk->data += walk->offset;

Expand Down

0 comments on commit cbb9bf6

Please sign in to comment.