X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=crypto%2Fsha1_generic.c;h=00ae60eb925435efe5295a9d7315283bd258e613;hb=36ca239b245dbdec3b0c94976e956226bdd4108c;hp=0416091bf45ad3854a5987a0d05d2c227cfdaeb3;hpb=7cc88fdcff3cc7f0d5d2384ffd7f6d4ce9a745f1;p=deliverable%2Flinux.git 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, 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;