diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-11 17:56:37 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-11 17:56:37 +0100 |
commit | 5cee9b9c6394cffee6f31fab00323d9e559f0702 (patch) | |
tree | d21ba3da234c46b4f3c96e0065eb83d8c3cc8e96 /libkeccak_hmac_update.c | |
parent | Deprecate typedefs (diff) | |
download | libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.gz libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.bz2 libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.xz |
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak_hmac_update.c')
-rw-r--r-- | libkeccak_hmac_update.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/libkeccak_hmac_update.c b/libkeccak_hmac_update.c index 6182a0a..535b099 100644 --- a/libkeccak_hmac_update.c +++ b/libkeccak_hmac_update.c @@ -1,4 +1,5 @@ /* See LICENSE file for copyright and license details. */ +#define NEED_EXPLICIT_BZERO 1 #include "common.h" @@ -14,7 +15,7 @@ int libkeccak_hmac_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg_, size_t msglen) { - const char *restrict msg = msg_; + const unsigned char *restrict msg = msg_; size_t i; int n, cn, r; @@ -42,9 +43,9 @@ libkeccak_hmac_update(struct libkeccak_hmac_state *restrict state, const void *r n = (int)(state->key_length & 7); cn = 8 - n; for (i = 1; i < msglen; i++) - state->buffer[i] = (char)(((unsigned char)msg[i - 1] >> cn) | (msg[i] << n)); - state->buffer[0] = (char)((state->leftover & ((1 << n) - 1)) | (msg[0] << n)); - state->leftover = (char)((unsigned char)msg[msglen - 1] >> cn); + state->buffer[i] = (unsigned char)((msg[i - 1] >> cn) | (msg[i] << n)); + state->buffer[0] = (unsigned char)((state->leftover & ((1 << n) - 1)) | (msg[0] << n)); + state->leftover = (unsigned char)(msg[msglen - 1] >> cn); r = libkeccak_update(&state->sponge, state->buffer, msglen); my_explicit_bzero(state->buffer, msglen); |