aboutsummaryrefslogtreecommitdiffstats
path: root/libkeccak_state_unmarshal.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2019-02-12 18:46:12 +0100
committerMattias Andrée <maandree@kth.se>2019-02-12 18:46:12 +0100
commit47139985115e175ed9c3f7d648d6d9ec7c48b89b (patch)
tree846111020e7a2bb3bcd85cf00ceb158d07dc0c28 /libkeccak_state_unmarshal.c
parentUpdate makefile (diff)
downloadlibkeccak-47139985115e175ed9c3f7d648d6d9ec7c48b89b.tar.gz
libkeccak-47139985115e175ed9c3f7d648d6d9ec7c48b89b.tar.bz2
libkeccak-47139985115e175ed9c3f7d648d6d9ec7c48b89b.tar.xz
Deprecate libkeccak_{state,hmac}_{unmarshal_skip,marshal_size} and replace with the functions without the _skip or _size suffix
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--libkeccak_state_unmarshal.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libkeccak_state_unmarshal.c b/libkeccak_state_unmarshal.c
index af1f7de..e46db54 100644
--- a/libkeccak_state_unmarshal.c
+++ b/libkeccak_state_unmarshal.c
@@ -5,7 +5,8 @@
/**
* Unmarshal a `struct libkeccak_state` from a buffer
*
- * @param state The slot for the unmarshalled state, must not be initialised (memory leak otherwise)
+ * @param state The slot for the unmarshalled state, must not be
+ * initialised (memory leak otherwise), can be `NULL`
* @param data The input buffer
* @return The number of bytes read from `data`, 0 on error
*/
@@ -14,6 +15,10 @@ libkeccak_state_unmarshal(struct libkeccak_state *restrict state, const void *re
{
#define get(type, var) state->var = *((const type *)data), data += sizeof(type) / sizeof(char)
const unsigned char *restrict data = data_;
+ if (!state) {
+ data += (7 * sizeof(long int) + 26 * sizeof(int64_t)) / sizeof(char);
+ return sizeof(struct libkeccak_state) - sizeof(char *) + *(const size_t *)data * sizeof(char);
+ }
get(long int, r);
get(long int, c);
get(long int, n);