diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-11-07 00:11:59 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-11-07 00:11:59 +0100 |
commit | a96f611d83db8fb367efd284de5d54cedb495d6e (patch) | |
tree | af407b7178ccb1f23f09d968c2df20ac28cc5a8f /src | |
parent | more manual optimisations (diff) | |
download | libkeccak-a96f611d83db8fb367efd284de5d54cedb495d6e.tar.gz libkeccak-a96f611d83db8fb367efd284de5d54cedb495d6e.tar.bz2 libkeccak-a96f611d83db8fb367efd284de5d54cedb495d6e.tar.xz |
optimise libkeccak_squeezing_phase
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/libkeccak/digest.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/libkeccak/digest.c b/src/libkeccak/digest.c index ed6d153..08f98a1 100644 --- a/src/libkeccak/digest.c +++ b/src/libkeccak/digest.c @@ -297,7 +297,8 @@ static __attribute__((nonnull, nothrow)) void libkeccak_absorption_phase(libkeccak_state_t* restrict state, size_t len) { /* TODO optimise function */ - long rr = state->r >> 3, ww = state->w >> 3; + long rr = state->r >> 3; + long ww = state->w >> 3; long i = (long)len / rr; const char* restrict message = state->M; if (__builtin_expect(ww >= 8, 1)) /* ww > 8 is impossible, it is just for optimisation possibilities. */ @@ -336,22 +337,24 @@ static __attribute__((nonnull, nothrow, hot)) void libkeccak_squeezing_phase(register libkeccak_state_t* restrict state, long rr, long nn, long ww, register char* restrict hashsum) { - /* TODO optimise this */ - long i, j = 0, k, ptr = 0, ni = rr > 25 ? 25 : rr, olen = state->n; - int_fast64_t v; + register int_fast64_t v; + register long ni = rr > 25 ? 25 : rr; + auto long olen = state->n; + auto long i, j = 0; + register long k; while (olen > 0) { for (i = 0; (i < ni) && (j < nn); i++) { v = state->S[LANE_TRANSPOSE_MAP[i]]; for (k = 0; (k++ < ww) && (j++ < nn); v >>= 8) - hashsum[ptr++] = (char)v; + *hashsum++ = (char)v; } if (olen -= state->r, olen > 0) libkeccak_f(state); } if (state->n & 7) - hashsum[nn - 1] &= (char)((1 << (state->n & 7)) - 1); + hashsum[-1] &= (char)((1 << (state->n & 7)) - 1); } |