aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/sha1.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/crypto/sha1.c b/crypto/sha1.c
index 292dcc13ff92..7b1abca29365 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1.c
@@ -49,32 +49,33 @@ static void sha1_init(void *ctx)
49static void sha1_update(void *ctx, const u8 *data, unsigned int len) 49static void sha1_update(void *ctx, const u8 *data, unsigned int len)
50{ 50{
51 struct sha1_ctx *sctx = ctx; 51 struct sha1_ctx *sctx = ctx;
52 unsigned int i, j; 52 unsigned int partial, done;
53 const u8 *src; 53 const u8 *src;
54 54
55 j = (sctx->count >> 3) & 0x3f; 55 partial = (sctx->count >> 3) & 0x3f;
56 sctx->count += len << 3; 56 sctx->count += len << 3;
57 i = 0; 57 done = 0;
58 src = data; 58 src = data;
59 59
60 if ((j + len) > 63) { 60 if ((partial + len) > 63) {
61 u32 temp[SHA_WORKSPACE_WORDS]; 61 u32 temp[SHA_WORKSPACE_WORDS];
62 62
63 if (j) { 63 if (partial) {
64 memcpy(&sctx->buffer[j], data, (i = 64-j)); 64 done = 64 - partial;
65 memcpy(sctx->buffer + partial, data, done);
65 src = sctx->buffer; 66 src = sctx->buffer;
66 } 67 }
67 68
68 do { 69 do {
69 sha_transform(sctx->state, src, temp); 70 sha_transform(sctx->state, src, temp);
70 i += 64; 71 done += 64;
71 src = &data[i]; 72 src = data + done;
72 } while (i + 63 < len); 73 } while (done + 63 < len);
73 74
74 memset(temp, 0, sizeof(temp)); 75 memset(temp, 0, sizeof(temp));
75 j = 0; 76 partial = 0;
76 } 77 }
77 memcpy(&sctx->buffer[j], src, len - i); 78 memcpy(sctx->buffer + partial, src, len - done);
78} 79}
79 80
80 81