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_fast_digest.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_fast_digest.c')
-rw-r--r-- | libkeccak_hmac_fast_digest.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/libkeccak_hmac_fast_digest.c b/libkeccak_hmac_fast_digest.c index c203716..d8b4509 100644 --- a/libkeccak_hmac_fast_digest.c +++ b/libkeccak_hmac_fast_digest.c @@ -20,10 +20,10 @@ int libkeccak_hmac_fast_digest(struct libkeccak_hmac_state *restrict state, const void *restrict msg_, size_t msglen, size_t bits, const char *restrict suffix, void *restrict hashsum) { - const char *restrict msg = msg_; + const unsigned char *restrict msg = msg_; size_t hashsize = (size_t)state->sponge.n >> 3; - char *tmp = malloc((size_t)((state->sponge.n + 7) >> 3) * sizeof(char)); - char leftover[2]; + unsigned char *tmp = malloc((size_t)((state->sponge.n + 7) >> 3) * sizeof(char)); + unsigned char leftover[2]; size_t newlen; if (!tmp) @@ -39,8 +39,8 @@ libkeccak_hmac_fast_digest(struct libkeccak_hmac_state *restrict state, const vo goto fail; leftover[0] = state->leftover; if (bits) { - leftover[0] |= (char)(msg[msglen] >> (state->key_length & 7)); - leftover[1] = (char)((unsigned char)msg[msglen] << (8 - (state->key_length & 7))); + leftover[0] |= (unsigned char)(msg[msglen] >> (state->key_length & 7)); + leftover[1] = (unsigned char)(msg[msglen] << (8 - (state->key_length & 7))); } newlen = (state->key_length & 7) + bits; if (libkeccak_fast_digest(&state->sponge, leftover, newlen >> 3, newlen & 7, suffix, tmp) < 0) @@ -62,8 +62,8 @@ stage_2: goto fail; leftover[0] = state->leftover; if (bits) { - leftover[0] |= (char)(tmp[hashsize] >> (state->key_length & 7)); - leftover[1] = (char)((unsigned char)tmp[hashsize] << (8 - (state->key_length & 7))); + leftover[0] |= (unsigned char)(tmp[hashsize] >> (state->key_length & 7)); + leftover[1] = (unsigned char)(tmp[hashsize] << (8 - (state->key_length & 7))); } newlen = (state->key_length & 7) + bits; if (libkeccak_fast_digest(&state->sponge, leftover, newlen >> 3, newlen & 7, suffix, tmp) < 0) |