diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-20 11:29:39 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-20 11:29:39 +0100 |
commit | 4319d104ceb3ed1e62e7831b9f232c6b4186a7b4 (patch) | |
tree | 8cc9a6e6770d55f964631664defcd9baa542ff9a | |
parent | Add more tests for BLAKE2b and BLAKE2s and update init functions (breaks API; were broken for keyed mode with zero-length message) (diff) | |
download | libblake-4319d104ceb3ed1e62e7831b9f232c6b4186a7b4.tar.gz libblake-4319d104ceb3ed1e62e7831b9f232c6b4186a7b4.tar.bz2 libblake-4319d104ceb3ed1e62e7831b9f232c6b4186a7b4.tar.xz |
Update init for BLAKE2Xb and BLAKE2Xs according to previous commmit
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libblake.h | 22 | ||||
-rw-r--r-- | libblake_blake2xb_init.c | 8 | ||||
-rw-r--r-- | libblake_blake2xs_init.c | 7 |
3 files changed, 5 insertions, 32 deletions
@@ -1071,18 +1071,9 @@ struct libblake_blake2xb_state { * * @param state The state to initialise * @param params Hashing parameters - * @param key Key to use. The key's length is set in - * `params->key_len`, but unless this value - * is 0 (hash in unkeyed mode), this buffer - * must be padded with NUL bytes, to the end, - * such that it's length is at least 64 bytes. - * (The maximum allowed key length is 32, the - * buffer's size shall be twice this.) The - * key is used for MAC and PRF. */ LIBBLAKE_PUBLIC__ void -libblake_blake2xs_init(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params, - const unsigned char *key /* append null bytes until 64 bytes; if key is used */); +libblake_blake2xs_init(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params); /** * Process data for hashing with BLAKE2Xs @@ -1199,18 +1190,9 @@ libblake_blake2xs_digest(const struct libblake_blake2xs_state *state, uint_least * * @param state The state to initialise * @param params Hashing parameters - * @param key Key to use. The key's length is set in - * `params->key_len`, but unless this value - * is 0 (hash in unkeyed mode), this buffer - * must be padded with NUL bytes, to the end, - * such that it's length is at least 128 bytes. - * (The maximum allowed key length is 64, the - * buffer's size shall be twice this.) The - * key is used for MAC and PRF. */ LIBBLAKE_PUBLIC__ void -libblake_blake2xb_init(struct libblake_blake2xb_state *state, const struct libblake_blake2xb_params *params, - const unsigned char *key /* append null bytes until 128 bytes; if key is used */); +libblake_blake2xb_init(struct libblake_blake2xb_state *state, const struct libblake_blake2xb_params *params); /** * Process data for hashing with BLAKE2Xb diff --git a/libblake_blake2xb_init.c b/libblake_blake2xb_init.c index 1064bae..da59755 100644 --- a/libblake_blake2xb_init.c +++ b/libblake_blake2xb_init.c @@ -2,11 +2,12 @@ #include "common.h" void -libblake_blake2xb_init(struct libblake_blake2xb_state *state, const struct libblake_blake2xb_params *params, const unsigned char *key) +libblake_blake2xb_init(struct libblake_blake2xb_state *state, const struct libblake_blake2xb_params *params) { libblake_internal_blake2xb_init0(state, params); memcpy(&state->xof_params, params, sizeof(state->xof_params)); + state->xof_params.digest_len = 64; state->xof_params.key_len = 0; state->xof_params.fanout = 0; state->xof_params.depth = 0; @@ -16,9 +17,4 @@ libblake_blake2xb_init(struct libblake_blake2xb_state *state, const struct libbl state->xof_params.inner_len = 64; memset(&state->intermediate, 0, sizeof(state->intermediate)); - - if (params->key_len) { - state->b2b.t[0] = 128; - libblake_internal_blake2b_compress(&state->b2b, key); - } } diff --git a/libblake_blake2xs_init.c b/libblake_blake2xs_init.c index 5404eee..1857f19 100644 --- a/libblake_blake2xs_init.c +++ b/libblake_blake2xs_init.c @@ -2,7 +2,7 @@ #include "common.h" void -libblake_blake2xs_init(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params, const unsigned char *key) +libblake_blake2xs_init(struct libblake_blake2xs_state *state, const struct libblake_blake2xs_params *params) { libblake_internal_blake2xs_init0(state, params); @@ -17,9 +17,4 @@ libblake_blake2xs_init(struct libblake_blake2xs_state *state, const struct libbl state->xof_params.inner_len = 32; memset(&state->intermediate, 0, sizeof(state->intermediate)); - - if (params->key_len) { - state->b2s.t[0] = 64; - libblake_internal_blake2s_compress(&state->b2s, key); - } } |