Rename the state block buffers from m{,len} to b{,len}
This commit is contained in:
parent
230dedac16
commit
21251045f4
@ -58,9 +58,9 @@ poly1305_init(void *arg, void *initparams)
|
|||||||
state->s2 = load32le(¶ms->key[24]);
|
state->s2 = load32le(¶ms->key[24]);
|
||||||
state->s3 = load32le(¶ms->key[28]);
|
state->s3 = load32le(¶ms->key[28]);
|
||||||
|
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
for (i = 0; i < LC_POLY1305_BLOCKLEN; i++)
|
for (i = 0; i < LC_POLY1305_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -71,15 +71,15 @@ poly1305_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
struct poly1305_state *state = arg;
|
struct poly1305_state *state = arg;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i + state->mlen < LC_POLY1305_BLOCKLEN && i < inlen; i++)
|
for (i = 0; i + state->blen < LC_POLY1305_BLOCKLEN && i < inlen; i++)
|
||||||
state->m[i + state->mlen] = in[i];
|
state->b[i + state->blen] = in[i];
|
||||||
state->mlen += i;
|
state->blen += i;
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
if (state->mlen == LC_POLY1305_BLOCKLEN) {
|
if (state->blen == LC_POLY1305_BLOCKLEN) {
|
||||||
poly1305_block(state, 1);
|
poly1305_block(state, 1);
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlen == 0)
|
if (inlen == 0)
|
||||||
@ -87,7 +87,7 @@ poly1305_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
|
|
||||||
while (inlen >= LC_POLY1305_BLOCKLEN) {
|
while (inlen >= LC_POLY1305_BLOCKLEN) {
|
||||||
for (i = 0; i < LC_POLY1305_BLOCKLEN; i++)
|
for (i = 0; i < LC_POLY1305_BLOCKLEN; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
poly1305_block(state, 1);
|
poly1305_block(state, 1);
|
||||||
|
|
||||||
in += LC_POLY1305_BLOCKLEN;
|
in += LC_POLY1305_BLOCKLEN;
|
||||||
@ -95,8 +95,8 @@ poly1305_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < inlen; i++)
|
for (i = 0; i < inlen; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
state->mlen = inlen;
|
state->blen = inlen;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -112,12 +112,12 @@ poly1305_final(void *arg, uint8_t *out, size_t *outlen)
|
|||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
i = state->mlen;
|
i = state->blen;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
if (i < LC_POLY1305_BLOCKLEN) {
|
if (i < LC_POLY1305_BLOCKLEN) {
|
||||||
state->m[i++] = 1;
|
state->b[i++] = 1;
|
||||||
for (; i < LC_POLY1305_BLOCKLEN; i++)
|
for (; i < LC_POLY1305_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
poly1305_block(state, 0);
|
poly1305_block(state, 0);
|
||||||
} else
|
} else
|
||||||
poly1305_block(state, 1);
|
poly1305_block(state, 1);
|
||||||
|
@ -44,7 +44,7 @@ chacha20_anycrypt_init(void *arg, void *initparams)
|
|||||||
state->n[0] = params->counter;
|
state->n[0] = params->counter;
|
||||||
for (i = 1; i < CHACHA20_NONCE_WORDS; i++)
|
for (i = 1; i < CHACHA20_NONCE_WORDS; i++)
|
||||||
state->n[i] = load32le(¶ms->nonce[(i - 1) * 4]);
|
state->n[i] = load32le(¶ms->nonce[(i - 1) * 4]);
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ xchacha20_anycrypt_init(void *arg, void *initparams)
|
|||||||
state->k[i] = load32le(¶ms->key[i * 4]);
|
state->k[i] = load32le(¶ms->key[i * 4]);
|
||||||
for (i = 0; i < CHACHA20_NONCE_WORDS; i++)
|
for (i = 0; i < CHACHA20_NONCE_WORDS; i++)
|
||||||
state->n[i] = load32le(¶ms->nonce[i * 4]);
|
state->n[i] = load32le(¶ms->nonce[i * 4]);
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
|
|
||||||
hchacha20_block(state);
|
hchacha20_block(state);
|
||||||
|
|
||||||
@ -91,35 +91,35 @@ chacha20_anycrypt_update(void *arg, uint8_t *out, size_t *outlen,
|
|||||||
uint32_t h;
|
uint32_t h;
|
||||||
|
|
||||||
*outlen = 0;
|
*outlen = 0;
|
||||||
if (inlen > SIZE_MAX - (LC_CHACHA20_BLOCKLEN - 1) - state->mlen)
|
if (inlen > SIZE_MAX - (LC_CHACHA20_BLOCKLEN - 1) - state->blen)
|
||||||
return 0;
|
return 0;
|
||||||
blocks = (inlen + state->mlen + LC_CHACHA20_BLOCKLEN - 1) /
|
blocks = (inlen + state->blen + LC_CHACHA20_BLOCKLEN - 1) /
|
||||||
LC_CHACHA20_BLOCKLEN;
|
LC_CHACHA20_BLOCKLEN;
|
||||||
if (blocks + state->n[0] > CHACHA20_CTRMAX)
|
if (blocks + state->n[0] > CHACHA20_CTRMAX)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*outlen = state->mlen + inlen -
|
*outlen = state->blen + inlen -
|
||||||
((state->mlen + inlen) % LC_CHACHA20_BLOCKLEN);
|
((state->blen + inlen) % LC_CHACHA20_BLOCKLEN);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (i = 0; i + state->mlen < LC_CHACHA20_BLOCKLEN && i < inlen; i++)
|
for (i = 0; i + state->blen < LC_CHACHA20_BLOCKLEN && i < inlen; i++)
|
||||||
state->m[i + state->mlen] = in[i];
|
state->b[i + state->blen] = in[i];
|
||||||
state->mlen += i;
|
state->blen += i;
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
if (state->mlen == LC_CHACHA20_BLOCKLEN) {
|
if (state->blen == LC_CHACHA20_BLOCKLEN) {
|
||||||
chacha20_block(state);
|
chacha20_block(state);
|
||||||
state->n[0]++;
|
state->n[0]++;
|
||||||
|
|
||||||
for (i = 0; i < CHACHA20_BLOCKLEN_WORDS; i++) {
|
for (i = 0; i < CHACHA20_BLOCKLEN_WORDS; i++) {
|
||||||
h = load32le(&state->m[i * 4]);
|
h = load32le(&state->b[i * 4]);
|
||||||
h ^= state->s[i];
|
h ^= state->s[i];
|
||||||
store32le(&out[i * 4], h);
|
store32le(&out[i * 4], h);
|
||||||
}
|
}
|
||||||
out += LC_CHACHA20_BLOCKLEN;
|
out += LC_CHACHA20_BLOCKLEN;
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlen == 0)
|
if (inlen == 0)
|
||||||
@ -140,8 +140,8 @@ chacha20_anycrypt_update(void *arg, uint8_t *out, size_t *outlen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < inlen; i++)
|
for (i = 0; i < inlen; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
state->mlen = inlen;
|
state->blen = inlen;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -154,25 +154,25 @@ chacha20_anycrypt_final(void *arg, uint8_t *out, size_t *outlen)
|
|||||||
uint32_t h;
|
uint32_t h;
|
||||||
uint8_t s[4];
|
uint8_t s[4];
|
||||||
|
|
||||||
*outlen = state->mlen;
|
*outlen = state->blen;
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (state->mlen > 0)
|
if (state->blen > 0)
|
||||||
chacha20_block(state);
|
chacha20_block(state);
|
||||||
|
|
||||||
for (i = 0; i < state->mlen / 4; i++) {
|
for (i = 0; i < state->blen / 4; i++) {
|
||||||
h = load32le(&state->m[i * 4]);
|
h = load32le(&state->b[i * 4]);
|
||||||
h ^= state->s[i];
|
h ^= state->s[i];
|
||||||
store32le(&out[i * 4], h);
|
store32le(&out[i * 4], h);
|
||||||
}
|
}
|
||||||
off = i * 4;
|
off = i * 4;
|
||||||
state->mlen -= off;
|
state->blen -= off;
|
||||||
out += off;
|
out += off;
|
||||||
|
|
||||||
store32le(&s[0], state->s[i]);
|
store32le(&s[0], state->s[i]);
|
||||||
for (i = 0; i < state->mlen; i++)
|
for (i = 0; i < state->blen; i++)
|
||||||
out[i] = state->m[i + off] ^ s[i];
|
out[i] = state->b[i + off] ^ s[i];
|
||||||
|
|
||||||
lc_scrub(state, sizeof(*state));
|
lc_scrub(state, sizeof(*state));
|
||||||
|
|
||||||
|
@ -70,9 +70,9 @@ sha224_init(void *arg)
|
|||||||
|
|
||||||
state->sz = 0;
|
state->sz = 0;
|
||||||
|
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -94,9 +94,9 @@ sha256_init(void *arg)
|
|||||||
|
|
||||||
state->sz = 0;
|
state->sz = 0;
|
||||||
|
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -111,15 +111,15 @@ sha224_sha256_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
return 0;
|
return 0;
|
||||||
state->sz += inlen;
|
state->sz += inlen;
|
||||||
|
|
||||||
for (i = 0; i + state->mlen < LC_SHA256_BLOCKLEN && i < inlen; i++)
|
for (i = 0; i + state->blen < LC_SHA256_BLOCKLEN && i < inlen; i++)
|
||||||
state->m[i + state->mlen] = in[i];
|
state->b[i + state->blen] = in[i];
|
||||||
state->mlen += i;
|
state->blen += i;
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
if (state->mlen == LC_SHA256_BLOCKLEN) {
|
if (state->blen == LC_SHA256_BLOCKLEN) {
|
||||||
sha256_block(state);
|
sha256_block(state);
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlen == 0)
|
if (inlen == 0)
|
||||||
@ -127,7 +127,7 @@ sha224_sha256_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
|
|
||||||
while (inlen >= LC_SHA256_BLOCKLEN) {
|
while (inlen >= LC_SHA256_BLOCKLEN) {
|
||||||
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA256_BLOCKLEN; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ sha224_sha256_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < inlen; i++)
|
for (i = 0; i < inlen; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
state->mlen = inlen;
|
state->blen = inlen;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -158,19 +158,19 @@ sha224_sha256_final(struct sha256_state *state)
|
|||||||
{
|
{
|
||||||
size_t i, mlen;
|
size_t i, mlen;
|
||||||
|
|
||||||
mlen = state->mlen;
|
mlen = state->blen;
|
||||||
state->m[mlen++] = 0x80;
|
state->b[mlen++] = 0x80;
|
||||||
|
|
||||||
if (mlen >= LC_SHA256_BLOCKLEN - sizeof(uint64_t)) {
|
if (mlen >= LC_SHA256_BLOCKLEN - sizeof(uint64_t)) {
|
||||||
for (i = mlen; i < LC_SHA256_BLOCKLEN; i++)
|
for (i = mlen; i < LC_SHA256_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
sha256_block(state);
|
sha256_block(state);
|
||||||
mlen = 0;
|
mlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = mlen; i < LC_SHA256_BLOCKLEN - sizeof(uint64_t); i++)
|
for (i = mlen; i < LC_SHA256_BLOCKLEN - sizeof(uint64_t); i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
store64be(&state->m[i], state->sz << 3);
|
store64be(&state->b[i], state->sz << 3);
|
||||||
sha256_block(state);
|
sha256_block(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ sha384_init(void *arg)
|
|||||||
|
|
||||||
state->szhi = state->szlo = 0;
|
state->szhi = state->szlo = 0;
|
||||||
|
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -95,9 +95,9 @@ sha512_init(void *arg)
|
|||||||
|
|
||||||
state->szhi = state->szlo = 0;
|
state->szhi = state->szlo = 0;
|
||||||
|
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -116,15 +116,15 @@ sha384_sha512_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
} else
|
} else
|
||||||
state->szlo += inlen;
|
state->szlo += inlen;
|
||||||
|
|
||||||
for (i = 0; i + state->mlen < LC_SHA512_BLOCKLEN && i < inlen; i++)
|
for (i = 0; i + state->blen < LC_SHA512_BLOCKLEN && i < inlen; i++)
|
||||||
state->m[i + state->mlen] = in[i];
|
state->b[i + state->blen] = in[i];
|
||||||
state->mlen += i;
|
state->blen += i;
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
if (state->mlen == LC_SHA512_BLOCKLEN) {
|
if (state->blen == LC_SHA512_BLOCKLEN) {
|
||||||
sha512_block(state);
|
sha512_block(state);
|
||||||
state->mlen = 0;
|
state->blen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inlen == 0)
|
if (inlen == 0)
|
||||||
@ -132,7 +132,7 @@ sha384_sha512_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
|
|
||||||
while (inlen >= LC_SHA512_BLOCKLEN) {
|
while (inlen >= LC_SHA512_BLOCKLEN) {
|
||||||
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
for (i = 0; i < LC_SHA512_BLOCKLEN; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
in += i;
|
in += i;
|
||||||
inlen -= i;
|
inlen -= i;
|
||||||
|
|
||||||
@ -140,8 +140,8 @@ sha384_sha512_update(void *arg, const uint8_t *in, size_t inlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < inlen; i++)
|
for (i = 0; i < inlen; i++)
|
||||||
state->m[i] = in[i];
|
state->b[i] = in[i];
|
||||||
state->mlen = inlen;
|
state->blen = inlen;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -163,20 +163,20 @@ sha384_sha512_final(struct sha512_state *state)
|
|||||||
{
|
{
|
||||||
size_t i, mlen;
|
size_t i, mlen;
|
||||||
|
|
||||||
mlen = state->mlen;
|
mlen = state->blen;
|
||||||
state->m[mlen++] = 0x80;
|
state->b[mlen++] = 0x80;
|
||||||
|
|
||||||
if (mlen >= LC_SHA512_BLOCKLEN - 2 * sizeof(uint64_t)) {
|
if (mlen >= LC_SHA512_BLOCKLEN - 2 * sizeof(uint64_t)) {
|
||||||
for (i = mlen; i < LC_SHA512_BLOCKLEN; i++)
|
for (i = mlen; i < LC_SHA512_BLOCKLEN; i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
sha512_block(state);
|
sha512_block(state);
|
||||||
mlen = 0;
|
mlen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = mlen; i < LC_SHA512_BLOCKLEN - 2 * sizeof(uint64_t); i++)
|
for (i = mlen; i < LC_SHA512_BLOCKLEN - 2 * sizeof(uint64_t); i++)
|
||||||
state->m[i] = 0;
|
state->b[i] = 0;
|
||||||
store64be(&state->m[i], (state->szhi << 3) | (state->szlo >> 63));
|
store64be(&state->b[i], (state->szhi << 3) | (state->szlo >> 63));
|
||||||
store64be(&state->m[i + sizeof(uint64_t)], state->szlo << 3);
|
store64be(&state->b[i + sizeof(uint64_t)], state->szlo << 3);
|
||||||
sha512_block(state);
|
sha512_block(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ struct chacha20_state {
|
|||||||
uint32_t s[CHACHA20_BLOCKLEN_WORDS];
|
uint32_t s[CHACHA20_BLOCKLEN_WORDS];
|
||||||
uint32_t k[CHACHA20_KEY_WORDS];
|
uint32_t k[CHACHA20_KEY_WORDS];
|
||||||
uint32_t n[CHACHA20_NONCE_WORDS];
|
uint32_t n[CHACHA20_NONCE_WORDS];
|
||||||
size_t mlen;
|
size_t blen;
|
||||||
uint8_t m[LC_CHACHA20_BLOCKLEN];
|
uint8_t b[LC_CHACHA20_BLOCKLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,10 +167,10 @@ poly1305_block(struct poly1305_state *state, uint32_t hibit)
|
|||||||
x3 = state->x3;
|
x3 = state->x3;
|
||||||
x4 = state->x4;
|
x4 = state->x4;
|
||||||
|
|
||||||
t0 = load32le(&state->m[0]);
|
t0 = load32le(&state->b[0]);
|
||||||
t1 = load32le(&state->m[4]);
|
t1 = load32le(&state->b[4]);
|
||||||
t2 = load32le(&state->m[8]);
|
t2 = load32le(&state->b[8]);
|
||||||
t3 = load32le(&state->m[12]);
|
t3 = load32le(&state->b[12]);
|
||||||
t4 = hibit;
|
t4 = hibit;
|
||||||
|
|
||||||
h0 += t0 & 0x3ffffff;
|
h0 += t0 & 0x3ffffff;
|
||||||
|
@ -25,8 +25,8 @@ struct poly1305_state {
|
|||||||
uint32_t r0, r1, r2, r3, r4;
|
uint32_t r0, r1, r2, r3, r4;
|
||||||
uint32_t x1, x2, x3, x4;
|
uint32_t x1, x2, x3, x4;
|
||||||
uint32_t s0, s1, s2, s3;
|
uint32_t s0, s1, s2, s3;
|
||||||
size_t mlen;
|
size_t blen;
|
||||||
uint8_t m[LC_POLY1305_BLOCKLEN];
|
uint8_t b[LC_POLY1305_BLOCKLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ sha256_block(struct sha256_state *state)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < SHA256_BLOCKLEN_WORDS; i++)
|
for (i = 0; i < SHA256_BLOCKLEN_WORDS; i++)
|
||||||
W[i] = m[i] = load32be(&state->m[i * 4]);
|
W[i] = m[i] = load32be(&state->b[i * 4]);
|
||||||
for (; i < SHA256_ROUNDS; i++)
|
for (; i < SHA256_ROUNDS; i++)
|
||||||
W[i] = SSIG1(W[i - 2]) + W[i - 7] + SSIG0(W[i - 15]) +
|
W[i] = SSIG1(W[i - 2]) + W[i - 7] + SSIG0(W[i - 15]) +
|
||||||
W[i - 16];
|
W[i - 16];
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
struct sha256_state {
|
struct sha256_state {
|
||||||
uint32_t h0, h1, h2, h3, h4, h5, h6, h7;
|
uint32_t h0, h1, h2, h3, h4, h5, h6, h7;
|
||||||
uint64_t sz;
|
uint64_t sz;
|
||||||
size_t mlen;
|
size_t blen;
|
||||||
uint8_t m[LC_SHA256_BLOCKLEN];
|
uint8_t b[LC_SHA256_BLOCKLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ sha512_block(struct sha512_state *state)
|
|||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < SHA512_BLOCKLEN_WORDS; i++)
|
for (i = 0; i < SHA512_BLOCKLEN_WORDS; i++)
|
||||||
W[i] = m[i] = load64be(&state->m[i * 8]);
|
W[i] = m[i] = load64be(&state->b[i * 8]);
|
||||||
for (; i < SHA512_ROUNDS; i++)
|
for (; i < SHA512_ROUNDS; i++)
|
||||||
W[i] = SSIG1(W[i - 2]) + W[i - 7] + SSIG0(W[i - 15]) +
|
W[i] = SSIG1(W[i - 2]) + W[i - 7] + SSIG0(W[i - 15]) +
|
||||||
W[i - 16];
|
W[i - 16];
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
struct sha512_state {
|
struct sha512_state {
|
||||||
uint64_t h0, h1, h2, h3, h4, h5, h6, h7;
|
uint64_t h0, h1, h2, h3, h4, h5, h6, h7;
|
||||||
uint64_t szhi, szlo;
|
uint64_t szhi, szlo;
|
||||||
size_t mlen;
|
size_t blen;
|
||||||
uint8_t m[LC_SHA512_BLOCKLEN];
|
uint8_t b[LC_SHA512_BLOCKLEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user