aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak_hmac_set_key.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2023-07-02 16:22:54 +0200
committerMattias Andrée <maandree@kth.se>2023-07-02 16:22:54 +0200
commit2c13d7a29b7b6a16401e9ef3a9f6d9793e2250be (patch)
tree48b9cc13933e17f9dfd0e94bb73ea48f3b6f2dde /libkeccak_hmac_set_key.c
parentUpdate DEPENDENCIES (diff)
downloadlibkeccak-2c13d7a29b7b6a16401e9ef3a9f6d9793e2250be.tar.gz
libkeccak-2c13d7a29b7b6a16401e9ef3a9f6d9793e2250be.tar.bz2
libkeccak-2c13d7a29b7b6a16401e9ef3a9f6d9793e2250be.tar.xz
Fix false warnings1.4
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak_hmac_set_key.c')
-rw-r--r--libkeccak_hmac_set_key.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libkeccak_hmac_set_key.c b/libkeccak_hmac_set_key.c
index 60ef775..2795e4f 100644
--- a/libkeccak_hmac_set_key.c
+++ b/libkeccak_hmac_set_key.c
@@ -14,7 +14,7 @@ int
libkeccak_hmac_set_key(struct libkeccak_hmac_state *restrict state, const void *restrict key, size_t key_length)
{
size_t i, size, new_key_length, key_bytes;
- unsigned char *old;
+ void *new;
size = (size_t)(state->sponge.r) > key_length ? (size_t)(state->sponge.r) : key_length;
new_key_length = size;
@@ -22,11 +22,10 @@ libkeccak_hmac_set_key(struct libkeccak_hmac_state *restrict state, const void *
key_bytes = (key_length + 7) >> 3;
if (size != key_bytes) {
- state->key_opad = realloc(old = state->key_opad, 2 * size);
- if (!state->key_opad) {
- state->key_opad = old;
+ new = realloc(state->key_opad, 2 * size);
+ if (!new)
return -1;
- }
+ state->key_opad = new;
state->key_ipad = state->key_opad + size;
}