aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-01 04:03:09 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-02 14:37:53 +0200
commit01698421ef7b621442f1d4a7a6fe768718ec1479 (patch)
tree0f89e57afaeb834750427354280f7e03a2a6f0b6 /src/crypto
parentpoly1305: document rationale for base 2^26->2^64/32 conversion (diff)
downloadwireguard-monolithic-historical-01698421ef7b621442f1d4a7a6fe768718ec1479.tar.xz
wireguard-monolithic-historical-01698421ef7b621442f1d4a7a6fe768718ec1479.zip
global: change BUG_ON to WARN_ON
Suggested-by: Andrew Lunn <andrew@lunn.ch>
Diffstat (limited to 'src/crypto')
-rw-r--r--src/crypto/include/zinc/blake2s.h9
-rw-r--r--src/crypto/zinc/blake2s/blake2s.c20
2 files changed, 11 insertions, 18 deletions
diff --git a/src/crypto/include/zinc/blake2s.h b/src/crypto/include/zinc/blake2s.h
index 3dbe4b5..701a08b 100644
--- a/src/crypto/include/zinc/blake2s.h
+++ b/src/crypto/include/zinc/blake2s.h
@@ -8,6 +8,7 @@
#include <linux/types.h>
#include <linux/kernel.h>
+#include <asm/bug.h>
enum blake2s_lengths {
BLAKE2S_BLOCK_SIZE = 64,
@@ -36,11 +37,9 @@ static inline void blake2s(u8 *out, const u8 *in, const u8 *key,
{
struct blake2s_state state;
-#ifdef DEBUG
- BUG_ON((!in && inlen > 0) || !out || !outlen ||
- outlen > BLAKE2S_HASH_SIZE || keylen > BLAKE2S_KEY_SIZE ||
- (!key && keylen));
-#endif
+ WARN_ON(IS_ENABLED(DEBUG) && ((!in && inlen > 0) || !out || !outlen ||
+ outlen > BLAKE2S_HASH_SIZE || keylen > BLAKE2S_KEY_SIZE ||
+ (!key && keylen)));
if (keylen)
blake2s_init_key(&state, outlen, key, keylen);
diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index abe7202..08d3947 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -86,9 +86,7 @@ void blake2s_init(struct blake2s_state *state, const size_t outlen)
.depth = 1
};
-#ifdef CONFIG_ZINC_SELFTEST
- BUG_ON(!outlen || outlen > BLAKE2S_HASH_SIZE);
-#endif
+ WARN_ON(IS_ENABLED(DEBUG) && (!outlen || outlen > BLAKE2S_HASH_SIZE));
blake2s_init_param(state, &param);
}
EXPORT_SYMBOL(blake2s_init);
@@ -102,10 +100,8 @@ void blake2s_init_key(struct blake2s_state *state, const size_t outlen,
.depth = 1 };
u8 block[BLAKE2S_BLOCK_SIZE] = { 0 };
-#ifdef CONFIG_ZINC_SELFTEST
- BUG_ON(!outlen || outlen > BLAKE2S_HASH_SIZE || !key || !keylen ||
- keylen > BLAKE2S_KEY_SIZE);
-#endif
+ WARN_ON(IS_ENABLED(DEBUG) && (!outlen || outlen > BLAKE2S_HASH_SIZE ||
+ !key || !keylen || keylen > BLAKE2S_KEY_SIZE));
blake2s_init_param(state, &param);
memcpy(block, key, keylen);
blake2s_update(state, block, BLAKE2S_BLOCK_SIZE);
@@ -135,9 +131,8 @@ static inline void blake2s_compress(struct blake2s_state *state,
u32 v[16];
int i;
-#ifdef CONFIG_ZINC_SELFTEST
- BUG_ON(nblocks > 1 && inc != BLAKE2S_BLOCK_SIZE);
-#endif
+ WARN_ON(IS_ENABLED(DEBUG) &&
+ (nblocks > 1 && inc != BLAKE2S_BLOCK_SIZE));
if (blake2s_compress_arch(state, block, nblocks, inc))
return;
@@ -227,9 +222,8 @@ EXPORT_SYMBOL(blake2s_update);
void blake2s_final(struct blake2s_state *state, u8 *out, const size_t outlen)
{
-#ifdef CONFIG_ZINC_SELFTEST
- BUG_ON(!out || !outlen || outlen > BLAKE2S_HASH_SIZE);
-#endif
+ WARN_ON(IS_ENABLED(DEBUG) &&
+ (!out || !outlen || outlen > BLAKE2S_HASH_SIZE));
blake2s_set_lastblock(state);
memset(state->buf + state->buflen, 0,
BLAKE2S_BLOCK_SIZE - state->buflen); /* Padding */