aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/include/zinc
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
commita849803dc9aa139ce209d7b8ccf0bd57b52929c8 (patch)
treec44054cc6450b0b02613de05175ab94b38b2b373 /src/crypto/include/zinc
parentpoly1305: better module description (diff)
downloadwireguard-monolithic-historical-a849803dc9aa139ce209d7b8ccf0bd57b52929c8.tar.xz
wireguard-monolithic-historical-a849803dc9aa139ce209d7b8ccf0bd57b52929c8.zip
blake2s: simplify final function
Suggested-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'src/crypto/include/zinc')
-rw-r--r--src/crypto/include/zinc/blake2s.h39
1 files changed, 1 insertions, 38 deletions
diff --git a/src/crypto/include/zinc/blake2s.h b/src/crypto/include/zinc/blake2s.h
index 9512815..7a4382c 100644
--- a/src/crypto/include/zinc/blake2s.h
+++ b/src/crypto/include/zinc/blake2s.h
@@ -29,44 +29,7 @@ void blake2s_init(struct blake2s_state *state, const size_t outlen);
void blake2s_init_key(struct blake2s_state *state, const size_t outlen,
const void *key, const size_t keylen);
void blake2s_update(struct blake2s_state *state, const u8 *in, size_t inlen);
-void __blake2s_final(struct blake2s_state *state);
-static inline void blake2s_final(struct blake2s_state *state, u8 *out,
- const size_t outlen)
-{
- int i;
-
-#ifdef DEBUG
- BUG_ON(!out || !outlen || outlen > BLAKE2S_OUTBYTES);
-#endif
- __blake2s_final(state);
-
- if (__builtin_constant_p(outlen) && !(outlen % sizeof(u32))) {
- if (IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ||
- IS_ALIGNED((unsigned long)out, __alignof__(u32))) {
- __le32 *outwords = (__le32 *)out;
-
- for (i = 0; i < outlen / sizeof(u32); ++i)
- outwords[i] = cpu_to_le32(state->h[i]);
- } else {
- __le32 buffer[BLAKE2S_OUTBYTES];
-
- for (i = 0; i < outlen / sizeof(u32); ++i)
- buffer[i] = cpu_to_le32(state->h[i]);
- memcpy(out, buffer, outlen);
- memzero_explicit(buffer, sizeof(buffer));
- }
- } else {
- u8 buffer[BLAKE2S_OUTBYTES] __aligned(__alignof__(u32));
- __le32 *outwords = (__le32 *)buffer;
-
- for (i = 0; i < 8; ++i)
- outwords[i] = cpu_to_le32(state->h[i]);
- memcpy(out, buffer, outlen);
- memzero_explicit(buffer, sizeof(buffer));
- }
-
- memzero_explicit(state, sizeof(*state));
-}
+void blake2s_final(struct blake2s_state *state, u8 *out, const size_t outlen);
static inline void blake2s(u8 *out, const u8 *in, const u8 *key,
const size_t outlen, const size_t inlen,