summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/zinc/blake2s
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-19 02:56:34 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-19 23:29:45 +0200
commitcb8af686daad9b45451a91906441f9749ea3ed71 (patch)
tree2ab5c6d14458cee94cba94b87f07103b418bb480 /src/crypto/zinc/blake2s
parent57fd00dbd4da0c9ba6da84aefb80f4f4920a051c (diff)
blake2s: simplify final function
Suggested-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/blake2s')
-rw-r--r--src/crypto/zinc/blake2s/blake2s.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index 69b2b4e..29382da 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -230,14 +230,20 @@ void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen)
}
EXPORT_SYMBOL(blake2s_update);
-void __blake2s_final(struct blake2s_state *state)
+void blake2s_final(struct blake2s_state *state, u8 *out, const size_t outlen)
{
+#ifdef DEBUG
+ BUG_ON(!out || !outlen || outlen > BLAKE2S_OUTBYTES);
+#endif
blake2s_set_lastblock(state);
memset(state->buf + state->buflen, 0,
BLAKE2S_BLOCKBYTES - state->buflen); /* Padding */
blake2s_compress(state, state->buf, 1, state->buflen);
+ cpu_to_le32_array(state->h, ARRAY_SIZE(state->h));
+ memcpy(out, state->h, outlen);
+ memzero_explicit(state, sizeof(*state));
}
-EXPORT_SYMBOL(__blake2s_final);
+EXPORT_SYMBOL(blake2s_final);
void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
const size_t inlen, const size_t keylen)