aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libkeccak_hmac_fast_update.c9
-rw-r--r--libkeccak_hmac_set_key.c9
2 files changed, 8 insertions, 10 deletions
diff --git a/libkeccak_hmac_fast_update.c b/libkeccak_hmac_fast_update.c
index 2f541d4..50c34dd 100644
--- a/libkeccak_hmac_fast_update.c
+++ b/libkeccak_hmac_fast_update.c
@@ -15,7 +15,7 @@ int
libkeccak_hmac_fast_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg_, size_t msglen)
{
const unsigned char *restrict msg = msg_;
- unsigned char *old;
+ void *new;
size_t i;
int n, cn;
@@ -34,11 +34,10 @@ libkeccak_hmac_fast_update(struct libkeccak_hmac_state *restrict state, const vo
return libkeccak_fast_update(&state->sponge, msg, msglen);
if (msglen != state->buffer_size) {
- state->buffer = realloc(old = state->buffer, msglen);
- if (!state->buffer) {
- state->buffer = old;
+ new = realloc(state->buffer, msglen);
+ if (!new)
return -1;
- }
+ state->buffer = new;
state->buffer_size = msglen;
}
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;
}