aboutsummaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
Diffstat (limited to 'crypto')
-rw-r--r--crypto/sha1.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/crypto/sha1.c b/crypto/sha1.c
index c686e7826174..292dcc13ff92 100644
--- a/crypto/sha1.c
+++ b/crypto/sha1.c
@@ -50,22 +50,31 @@ static 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 i, j;
53 u32 temp[SHA_WORKSPACE_WORDS]; 53 const u8 *src;
54 54
55 j = (sctx->count >> 3) & 0x3f; 55 j = (sctx->count >> 3) & 0x3f;
56 sctx->count += len << 3; 56 sctx->count += len << 3;
57 i = 0;
58 src = data;
57 59
58 if ((j + len) > 63) { 60 if ((j + len) > 63) {
59 memcpy(&sctx->buffer[j], data, (i = 64-j)); 61 u32 temp[SHA_WORKSPACE_WORDS];
60 sha_transform(sctx->state, sctx->buffer, temp); 62
61 for ( ; i + 63 < len; i += 64) { 63 if (j) {
62 sha_transform(sctx->state, &data[i], temp); 64 memcpy(&sctx->buffer[j], data, (i = 64-j));
65 src = sctx->buffer;
63 } 66 }
67
68 do {
69 sha_transform(sctx->state, src, temp);
70 i += 64;
71 src = &data[i];
72 } while (i + 63 < len);
73
74 memset(temp, 0, sizeof(temp));
64 j = 0; 75 j = 0;
65 } 76 }
66 else i = 0; 77 memcpy(&sctx->buffer[j], src, len - i);
67 memset(temp, 0, sizeof(temp));
68 memcpy(&sctx->buffer[j], &data[i], len - i);
69} 78}
70 79
71 80