aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak_hmac_fast_update.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2024-09-15 02:15:08 +0200
committerMattias Andrée <maandree@kth.se>2024-09-15 02:15:08 +0200
commitd4ce8327ff902b5ecd42d057063c03793e6d91c2 (patch)
tree7ec1db1573f12225d6f6c324865b1b49a5a9580d /libkeccak_hmac_fast_update.c
parentm (diff)
downloadlibkeccak-d4ce8327ff902b5ecd42d057063c03793e6d91c2.tar.gz
libkeccak-d4ce8327ff902b5ecd42d057063c03793e6d91c2.tar.bz2
libkeccak-d4ce8327ff902b5ecd42d057063c03793e6d91c2.tar.xz
Organise files
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak_hmac_fast_update.c')
-rw-r--r--libkeccak_hmac_fast_update.c52
1 files changed, 0 insertions, 52 deletions
diff --git a/libkeccak_hmac_fast_update.c b/libkeccak_hmac_fast_update.c
deleted file mode 100644
index 50c34dd..0000000
--- a/libkeccak_hmac_fast_update.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/* See LICENSE file for copyright and license details. */
-#include "common.h"
-
-
-/**
- * Absorb more, or the first part, of the message
- * without wiping sensitive data when possible
- *
- * @param state The hashing state
- * @param msg_ The partial message
- * @param msglen The length of the partial message, in bytes
- * @return Zero on success, -1 on error
- */
-int
-libkeccak_hmac_fast_update(struct libkeccak_hmac_state *restrict state, const void *restrict msg_, size_t msglen)
-{
- const unsigned char *restrict msg = msg_;
- void *new;
- size_t i;
- int n, cn;
-
- if (state->key_ipad) {
- if (libkeccak_fast_update(&state->sponge, state->key_ipad, state->key_length >> 3) < 0)
- return -1;
- if (state->key_length & 7)
- state->leftover = state->key_ipad[state->key_length >> 3];
- state->key_ipad = NULL;
- }
-
- if (!msg || !msglen)
- return 0;
-
- if (!(state->key_length & 7))
- return libkeccak_fast_update(&state->sponge, msg, msglen);
-
- if (msglen != state->buffer_size) {
- new = realloc(state->buffer, msglen);
- if (!new)
- return -1;
- state->buffer = new;
- state->buffer_size = msglen;
- }
-
- n = (int)(state->key_length & 7);
- cn = 8 - n;
- for (i = 1; i < msglen; i++)
- 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);
-
- return libkeccak_fast_update(&state->sponge, state->buffer, msglen);
-}