linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: ahash - Fix handling of unaligned buffers
@ 2010-02-23 11:50 Szilveszter Ordog
  2010-03-02 14:37 ` Herbert Xu
  0 siblings, 1 reply; 5+ messages in thread
From: Szilveszter Ordog @ 2010-02-23 11:50 UTC (permalink / raw)
  To: linux-crypto

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>
---
 crypto/ahash.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/crypto/ahash.c b/crypto/ahash.c
index f347637..db42202 100644
--- a/crypto/ahash.c
+++ b/crypto/ahash.c
@@ -65,7 +65,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;

-- 
1.5.5.6
--
To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-03-04  0:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-23 11:50 [PATCH] crypto: ahash - Fix handling of unaligned buffers Szilveszter Ordog
2010-03-02 14:37 ` Herbert Xu
2010-03-02 23:10   ` Szilveszter Ordog
2010-03-03  0:04     ` Herbert Xu
2010-03-04  0:48       ` Szilveszter Ordog

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).