Skip to content

Commit

Permalink
crypto: sha1_generic - use SHA1_BLOCK_SIZE
Browse files Browse the repository at this point in the history
Modify sha1_update to use SHA1_BLOCK_SIZE.

Signed-off-by: Mandeep Singh Baines <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
Mandeep Singh Baines authored and herbertx committed Jun 29, 2011
1 parent 52527cf commit 36ca239
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions crypto/sha1_generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,26 @@ static int sha1_update(struct shash_desc *desc, const u8 *data,
unsigned int partial, done;
const u8 *src;

partial = sctx->count & 0x3f;
partial = sctx->count % SHA1_BLOCK_SIZE;
sctx->count += len;
done = 0;
src = data;

if ((partial + len) > 63) {
if ((partial + len) >= SHA1_BLOCK_SIZE) {
u32 temp[SHA_WORKSPACE_WORDS];

if (partial) {
done = -partial;
memcpy(sctx->buffer + partial, data, done + 64);
memcpy(sctx->buffer + partial, data,
done + SHA1_BLOCK_SIZE);
src = sctx->buffer;
}

do {
sha_transform(sctx->state, src, temp);
done += 64;
done += SHA1_BLOCK_SIZE;
src = data + done;
} while (done + 63 < len);
} while (done + SHA1_BLOCK_SIZE <= len);

memset(temp, 0, sizeof(temp));
partial = 0;
Expand Down

0 comments on commit 36ca239

Please sign in to comment.