aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorMandeep Singh Baines <msb@chromium.org>2011-06-27 03:41:56 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2011-06-29 19:44:06 -0400
commit36ca239b245dbdec3b0c94976e956226bdd4108c (patch)
tree2edff3bb1c78edf1b8d8daca05048d01de1e7e9f /crypto
parent52527cf3f95d437b02f54437d5c3d7fda06474d1 (diff)
crypto: sha1_generic - use SHA1_BLOCK_SIZE
Modify sha1_update to use SHA1_BLOCK_SIZE. Signed-off-by: Mandeep Singh Baines <msb@chromium.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/sha1_generic.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto/sha1_generic.c b/crypto/sha1_generic.c
index 0416091bf45a..00ae60eb9254 100644
--- a/crypto/sha1_generic.c
+++ b/crypto/sha1_generic.c
@@ -43,25 +43,26 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
43 unsigned int partial, done; 43 unsigned int partial, done;
44 const u8 *src; 44 const u8 *src;
45 45
46 partial = sctx->count & 0x3f; 46 partial = sctx->count % SHA1_BLOCK_SIZE;
47 sctx->count += len; 47 sctx->count += len;
48 done = 0; 48 done = 0;
49 src = data; 49 src = data;
50 50
51 if ((partial + len) > 63) { 51 if ((partial + len) >= SHA1_BLOCK_SIZE) {
52 u32 temp[SHA_WORKSPACE_WORDS]; 52 u32 temp[SHA_WORKSPACE_WORDS];
53 53
54 if (partial) { 54 if (partial) {
55 done = -partial; 55 done = -partial;
56 memcpy(sctx->buffer + partial, data, done + 64); 56 memcpy(sctx->buffer + partial, data,
57 done + SHA1_BLOCK_SIZE);
57 src = sctx->buffer; 58 src = sctx->buffer;
58 } 59 }
59 60
60 do { 61 do {
61 sha_transform(sctx->state, src, temp); 62 sha_transform(sctx->state, src, temp);
62 done += 64; 63 done += SHA1_BLOCK_SIZE;
63 src = data + done; 64 src = data + done;
64 } while (done + 63 < len); 65 } while (done + SHA1_BLOCK_SIZE <= len);
65 66
66 memset(temp, 0, sizeof(temp)); 67 memset(temp, 0, sizeof(temp));
67 partial = 0; 68 partial = 0;