Replace two more memcpy() with a local loop

This commit is contained in:
Frank Denis 2016-04-12 07:30:54 +02:00
parent d7294320c4
commit 34aeee6ba5
2 changed files with 12 additions and 4 deletions

View File

@ -220,10 +220,14 @@ crypto_hash_sha256_update(crypto_hash_sha256_state *state,
state->count += (uint64_t)(inlen) << 3;
if (inlen < 64 - r) {
memcpy(&state->buf[r], in, inlen);
for (i = 0; i < inlen; i++) {
state->buf[r + i] = in[i];
}
return 0;
}
memcpy(&state->buf[r], in, 64 - r);
for (i = 0; i < 64 - r; i++) {
state->buf[r + i] = in[i];
}
SHA256_Transform(state->state, state->buf);
in += 64 - r;
inlen -= 64 - r;

View File

@ -249,10 +249,14 @@ crypto_hash_sha512_update(crypto_hash_sha512_state *state,
state->count[0] += bitlen[0];
if (inlen < 128 - r) {
memcpy(&state->buf[r], in, inlen);
for (i = 0; i < inlen; i++) {
state->buf[r + i] = in[i];
}
return 0;
}
memcpy(&state->buf[r], in, 128 - r);
for (i = 0; i < 128 - r; i++) {
state->buf[r + i] = in[i];
}
SHA512_Transform(state->state, state->buf);
in += 128 - r;
inlen -= 128 - r;