Commit 36ca239b authored by Mandeep Singh Baines's avatar Mandeep Singh Baines Committed by Herbert Xu

crypto: sha1_generic - use SHA1_BLOCK_SIZE

Modify sha1_update to use SHA1_BLOCK_SIZE.
Signed-off-by: default avatarMandeep Singh Baines <msb@chromium.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 52527cf3
...@@ -43,25 +43,26 @@ static int sha1_update(struct shash_desc *desc, const u8 *data, ...@@ -43,25 +43,26 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
unsigned int partial, done; unsigned int partial, done;
const u8 *src; const u8 *src;
partial = sctx->count & 0x3f; partial = sctx->count % SHA1_BLOCK_SIZE;
sctx->count += len; sctx->count += len;
done = 0; done = 0;
src = data; src = data;
if ((partial + len) > 63) { if ((partial + len) >= SHA1_BLOCK_SIZE) {
u32 temp[SHA_WORKSPACE_WORDS]; u32 temp[SHA_WORKSPACE_WORDS];
if (partial) { if (partial) {
done = -partial; done = -partial;
memcpy(sctx->buffer + partial, data, done + 64); memcpy(sctx->buffer + partial, data,
done + SHA1_BLOCK_SIZE);
src = sctx->buffer; src = sctx->buffer;
} }
do { do {
sha_transform(sctx->state, src, temp); sha_transform(sctx->state, src, temp);
done += 64; done += SHA1_BLOCK_SIZE;
src = data + done; src = data + done;
} while (done + 63 < len); } while (done + SHA1_BLOCK_SIZE <= len);
memset(temp, 0, sizeof(temp)); memset(temp, 0, sizeof(temp));
partial = 0; partial = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment