aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2016-06-25 01:28:18 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2016-06-25 16:48:39 +0200
commit3e8c04a03f4070e23fc737f30c25a79d5958d734 (patch)
tree23354ba5aec33b7068421524c3e514767a1e42fb /src/crypto
parentnonce: switch to RFC6479 to better support packet reordering (diff)
downloadwireguard-monolithic-historical-3e8c04a03f4070e23fc737f30c25a79d5958d734.tar.xz
wireguard-monolithic-historical-3e8c04a03f4070e23fc737f30c25a79d5958d734.zip
tests: make fatal
Diffstat (limited to '')
-rw-r--r--src/crypto/blake2s.c3
-rw-r--r--src/crypto/blake2s.h2
-rw-r--r--src/crypto/chacha20poly1305.c3
-rw-r--r--src/crypto/chacha20poly1305.h2
-rw-r--r--src/crypto/curve25519.c5
-rw-r--r--src/crypto/curve25519.h2
-rw-r--r--src/crypto/siphash24.c3
-rw-r--r--src/crypto/siphash24.h2
8 files changed, 13 insertions, 9 deletions
diff --git a/src/crypto/blake2s.c b/src/crypto/blake2s.c
index 0a7170e..1182ca9 100644
--- a/src/crypto/blake2s.c
+++ b/src/crypto/blake2s.c
@@ -804,7 +804,7 @@ static const uint8_t blake2s_keyed_testvecs[][BLAKE2S_OUTBYTES] = {
{ 0x3F, 0xB7, 0x35, 0x06, 0x1A, 0xBC, 0x51, 0x9D, 0xFE, 0x97, 0x9E, 0x54, 0xC1, 0xEE, 0x5B, 0xFA, 0xD0, 0xA9, 0xD8, 0x58, 0xB3, 0x31, 0x5B, 0xAD, 0x34, 0xBD, 0xE9, 0x99, 0xEF, 0xD7, 0x24, 0xDD }
};
-void blake2s_selftest(void)
+bool blake2s_selftest(void)
{
uint8_t key[BLAKE2S_KEYBYTES];
uint8_t buf[ARRAY_SIZE(blake2s_testvecs)];
@@ -836,5 +836,6 @@ void blake2s_selftest(void)
if (success)
pr_info("blake2s self-tests: pass\n");
+ return success;
}
#endif
diff --git a/src/crypto/blake2s.h b/src/crypto/blake2s.h
index 1b42141..b48937f 100644
--- a/src/crypto/blake2s.h
+++ b/src/crypto/blake2s.h
@@ -30,7 +30,7 @@ void blake2s_final(struct blake2s_state *state, uint8_t *out, uint8_t outlen);
void blake2s_hmac(uint8_t *out, const uint8_t *in, const uint8_t *key, const uint8_t outlen, const uint64_t inlen, const uint64_t keylen);
#ifdef DEBUG
-void blake2s_selftest(void);
+bool blake2s_selftest(void);
#endif
#endif
diff --git a/src/crypto/chacha20poly1305.c b/src/crypto/chacha20poly1305.c
index c05fe1c..e4d2e0a 100644
--- a/src/crypto/chacha20poly1305.c
+++ b/src/crypto/chacha20poly1305.c
@@ -770,7 +770,7 @@ static const struct chacha20poly1305_testvec chacha20poly1305_dec_vectors[] = {
.result = "\x49\x6e\x74\x65\x72\x6e\x65\x74\x2d\x44\x72\x61\x66\x74\x73\x20\x61\x72\x65\x20\x64\x72\x61\x66\x74\x20\x64\x6f\x63\x75\x6d\x65\x6e\x74\x73\x20\x76\x61\x6c\x69\x64\x20\x66\x6f\x72\x20\x61\x20\x6d\x61\x78\x69\x6d\x75\x6d\x20\x6f\x66\x20\x73\x69\x78\x20\x6d\x6f\x6e\x74\x68\x73\x20\x61\x6e\x64\x20\x6d\x61\x79\x20\x62\x65\x20\x75\x70\x64\x61\x74\x65\x64\x2c\x20\x72\x65\x70\x6c\x61\x63\x65\x64\x2c\x20\x6f\x72\x20\x6f\x62\x73\x6f\x6c\x65\x74\x65\x64\x20\x62\x79\x20\x6f\x74\x68\x65\x72\x20\x64\x6f\x63\x75\x6d\x65\x6e\x74\x73\x20\x61\x74\x20\x61\x6e\x79\x20\x74\x69\x6d\x65\x2e\x20\x49\x74\x20\x69\x73\x20\x69\x6e\x61\x70\x70\x72\x6f\x70\x72\x69\x61\x74\x65\x20\x74\x6f\x20\x75\x73\x65\x20\x49\x6e\x74\x65\x72\x6e\x65\x74\x2d\x44\x72\x61\x66\x74\x73\x20\x61\x73\x20\x72\x65\x66\x65\x72\x65\x6e\x63\x65\x20\x6d\x61\x74\x65\x72\x69\x61\x6c\x20\x6f\x72\x20\x74\x6f\x20\x63\x69\x74\x65\x20\x74\x68\x65\x6d\x20\x6f\x74\x68\x65\x72\x20\x74\x68\x61\x6e\x20\x61\x73\x20\x2f\xe2\x80\x9c\x77\x6f\x72\x6b\x20\x69\x6e\x20\x70\x72\x6f\x67\x72\x65\x73\x73\x2e\x2f\xe2\x80\x9d"
} };
-void chacha20poly1305_selftest(void)
+bool chacha20poly1305_selftest(void)
{
size_t i;
uint8_t computed_result[512];
@@ -794,5 +794,6 @@ void chacha20poly1305_selftest(void)
}
if (success)
pr_info("chacha20poly1305 self-tests: pass\n");
+ return success;
}
#endif
diff --git a/src/crypto/chacha20poly1305.h b/src/crypto/chacha20poly1305.h
index c44a17e..d1986f7 100644
--- a/src/crypto/chacha20poly1305.h
+++ b/src/crypto/chacha20poly1305.h
@@ -29,7 +29,7 @@ bool chacha20poly1305_decrypt_sg(struct scatterlist *dst, struct scatterlist *sr
const uint64_t nonce, const uint8_t key[CHACHA20POLY1305_KEYLEN]);
#ifdef DEBUG
-void chacha20poly1305_selftest(void);
+bool chacha20poly1305_selftest(void);
#endif
#endif
diff --git a/src/crypto/curve25519.c b/src/crypto/curve25519.c
index 8b75aa0..d3d7fa7 100644
--- a/src/crypto/curve25519.c
+++ b/src/crypto/curve25519.c
@@ -1282,7 +1282,7 @@ static const struct curve25519_test_vector curve25519_test_vectors[] = {
.result = { 0 }
}
};
-void curve25519_selftest(void)
+bool curve25519_selftest(void)
{
bool success = true;
size_t i = 0;
@@ -1294,11 +1294,12 @@ void curve25519_selftest(void)
if (memcmp(out, curve25519_test_vectors[i].result, CURVE25519_POINT_SIZE)) {
pr_info("curve25519 self-test %zu: FAIL\n", i + 1);
success = false;
- return;
+ break;
}
}
if (success)
pr_info("curve25519 self-tests: pass\n");
+ return success;
}
#endif
diff --git a/src/crypto/curve25519.h b/src/crypto/curve25519.h
index b8f68e7..f16fc30 100644
--- a/src/crypto/curve25519.h
+++ b/src/crypto/curve25519.h
@@ -14,7 +14,7 @@ void curve25519_generate_secret(uint8_t secret[CURVE25519_POINT_SIZE]);
void curve25519_generate_public(uint8_t pub[CURVE25519_POINT_SIZE], const uint8_t secret[CURVE25519_POINT_SIZE]);
#ifdef DEBUG
-void curve25519_selftest(void);
+bool curve25519_selftest(void);
#endif
#endif
diff --git a/src/crypto/siphash24.c b/src/crypto/siphash24.c
index 093c837..5a29a80 100644
--- a/src/crypto/siphash24.c
+++ b/src/crypto/siphash24.c
@@ -131,7 +131,7 @@ static const uint8_t test_vectors[64][8] = {
{ 0x72, 0x45, 0x06, 0xeb, 0x4c, 0x32, 0x8a, 0x95 }
};
-void siphash24_selftest(void)
+bool siphash24_selftest(void)
{
uint8_t in[64], k[16];
uint64_t out;
@@ -151,5 +151,6 @@ void siphash24_selftest(void)
}
if (success)
pr_info("siphash24 self-tests: pass\n");
+ return success;
}
#endif
diff --git a/src/crypto/siphash24.h b/src/crypto/siphash24.h
index 5ce5a3a..f06a87c 100644
--- a/src/crypto/siphash24.h
+++ b/src/crypto/siphash24.h
@@ -10,7 +10,7 @@ enum siphash24_lengths {
uint64_t siphash24(const uint8_t *data, size_t len, const uint8_t key[SIPHASH24_KEY_LEN]);
#ifdef DEBUG
-void siphash24_selftest(void);
+bool siphash24_selftest(void);
#endif
#endif