Remove k from the sha1 context structure, as it is a constant.

Rearrange the sha1 context structure to improve alignment.
This commit is contained in:
Dag-Erling Smørgrav 2014-07-11 09:17:05 +00:00 committed by des
parent 4467480786
commit cc13b6a16a
2 changed files with 3 additions and 4 deletions

View file

@ -52,9 +52,9 @@ extern digest_algorithm sha1_digest;
typedef struct {
uint8_t block[64];
size_t blocklen;
uint32_t blocklen;
uint32_t h[5];
uint64_t bitlen;
uint32_t h[5], k[4];
} sha1_ctx;
extern digest_algorithm sha1_algorithm;

View file

@ -64,7 +64,6 @@ sha1_init(sha1_ctx *ctx)
memset(ctx, 0, sizeof *ctx);
memcpy(ctx->h, sha1_h, sizeof ctx->h);
memcpy(ctx->k, sha1_k, sizeof ctx->k);
}
static void
@ -95,7 +94,7 @@ sha1_compute(sha1_ctx *ctx, const uint8_t *block)
f = (b & c) | (b & d) | (c & d);
else
f = b ^ c ^ d;
temp = rol(a, 5) + f + e + w[t] + ctx->k[t/20];
temp = rol(a, 5) + f + e + w[t] + sha1_k[t/20];
e = d;
d = c;
c = ror(b, 2);