1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-24 04:25:10 -07:00

SHA512: just use memcpy() to initialize the state

This commit is contained in:
Frank Denis 2015-06-06 12:33:11 +02:00
parent ba1cd6a128
commit 86d92bc11d

View File

@ -244,16 +244,15 @@ SHA512_Pad(crypto_hash_sha512_state *state)
int
crypto_hash_sha512_init(crypto_hash_sha512_state *state)
{
state->count[0] = state->count[1] = 0;
static const uint64_t sha512_initstate[8] = {
0x6a09e667f3bcc908ULL, 0xbb67ae8584caa73bULL,
0x3c6ef372fe94f82bULL, 0xa54ff53a5f1d36f1ULL,
0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL,
0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL
};
state->state[0] = 0x6a09e667f3bcc908ULL;
state->state[1] = 0xbb67ae8584caa73bULL;
state->state[2] = 0x3c6ef372fe94f82bULL;
state->state[3] = 0xa54ff53a5f1d36f1ULL;
state->state[4] = 0x510e527fade682d1ULL;
state->state[5] = 0x9b05688c2b3e6c1fULL;
state->state[6] = 0x1f83d9abfb41bd6bULL;
state->state[7] = 0x5be0cd19137e2179ULL;
state->count[0] = state->count[1] = (uint64_t) 0U;
memcpy(state->state, sha512_initstate, sizeof sha512_initstate);
return 0;
}