mirror of
https://github.com/cryb-to/cryb-to.git
synced 2024-12-18 10:34:53 +00:00
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:
parent
4467480786
commit
cc13b6a16a
2 changed files with 3 additions and 4 deletions
|
@ -52,9 +52,9 @@ extern digest_algorithm sha1_digest;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t block[64];
|
uint8_t block[64];
|
||||||
size_t blocklen;
|
uint32_t blocklen;
|
||||||
|
uint32_t h[5];
|
||||||
uint64_t bitlen;
|
uint64_t bitlen;
|
||||||
uint32_t h[5], k[4];
|
|
||||||
} sha1_ctx;
|
} sha1_ctx;
|
||||||
|
|
||||||
extern digest_algorithm sha1_algorithm;
|
extern digest_algorithm sha1_algorithm;
|
||||||
|
|
|
@ -64,7 +64,6 @@ sha1_init(sha1_ctx *ctx)
|
||||||
|
|
||||||
memset(ctx, 0, sizeof *ctx);
|
memset(ctx, 0, sizeof *ctx);
|
||||||
memcpy(ctx->h, sha1_h, sizeof ctx->h);
|
memcpy(ctx->h, sha1_h, sizeof ctx->h);
|
||||||
memcpy(ctx->k, sha1_k, sizeof ctx->k);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -95,7 +94,7 @@ sha1_compute(sha1_ctx *ctx, const uint8_t *block)
|
||||||
f = (b & c) | (b & d) | (c & d);
|
f = (b & c) | (b & d) | (c & d);
|
||||||
else
|
else
|
||||||
f = b ^ c ^ d;
|
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;
|
e = d;
|
||||||
d = c;
|
d = c;
|
||||||
c = ror(b, 2);
|
c = ror(b, 2);
|
||||||
|
|
Loading…
Reference in a new issue