From 5cee9b9c6394cffee6f31fab00323d9e559f0702 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 11 Feb 2019 17:56:37 +0100 Subject: General improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libkeccak_state_initialise.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'libkeccak_state_initialise.c') diff --git a/libkeccak_state_initialise.c b/libkeccak_state_initialise.c index 390fb87..aa77051 100644 --- a/libkeccak_state_initialise.c +++ b/libkeccak_state_initialise.c @@ -13,21 +13,25 @@ int libkeccak_state_initialise(struct libkeccak_state *restrict state, const struct libkeccak_spec *restrict spec) { long int x; + state->r = spec->bitrate; state->n = spec->output; state->c = spec->capacity; state->b = state->r + state->c; state->w = x = state->b / 25; state->l = 0; + if (x & 0xF0L) state->l |= 4, x >>= 4; if (x & 0x0CL) state->l |= 2, x >>= 2; if (x & 0x02L) state->l |= 1; + state->nr = 12 + (state->l << 1); state->wmod = (state->w == 64) ? ~0LL : (int64_t)((1ULL << state->w) - 1); for (x = 0; x < 25; x++) state->S[x] = 0; state->mptr = 0; state->mlen = (size_t)(state->r * state->b) >> 2; + state->M = malloc(state->mlen * sizeof(char)); return state->M == NULL ? -1 : 0; } -- cgit v1.2.3-70-g09d2