aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/chacha20
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-18 15:58:36 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-18 16:33:11 +0200
commit9ee449fd0152dab11883c024dbafd5cfebef9b42 (patch)
tree986cea8944da54c0534725fd84974051e9589fb0 /src/crypto/zinc/chacha20
parentchacha20poly1305: add __init to selftest helper functions (diff)
downloadwireguard-monolithic-historical-9ee449fd0152dab11883c024dbafd5cfebef9b42.tar.xz
wireguard-monolithic-historical-9ee449fd0152dab11883c024dbafd5cfebef9b42.zip
chacha20: add independent self test
This was already tested from the chacha20poly1305 test, but it's useful to be able to test this in isolation too.
Diffstat (limited to 'src/crypto/zinc/chacha20')
-rw-r--r--src/crypto/zinc/chacha20/chacha20.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/crypto/zinc/chacha20/chacha20.c b/src/crypto/zinc/chacha20/chacha20.c
index ef2404f..a7c7adc 100644
--- a/src/crypto/zinc/chacha20/chacha20.c
+++ b/src/crypto/zinc/chacha20/chacha20.c
@@ -172,6 +172,8 @@ void hchacha20(u8 derived_key[CHACHA20_KEY_SIZE],
}
EXPORT_SYMBOL(hchacha20);
+#include "../selftest/chacha20.h"
+
static bool nosimd __initdata = false;
#ifndef COMPAT_ZINC_IS_A_MODULE
@@ -182,6 +184,10 @@ static int __init mod_init(void)
{
if (!nosimd)
chacha20_fpu_init();
+#ifdef DEBUG
+ if (!chacha20_selftest())
+ return -ENOTRECOVERABLE;
+#endif
return 0;
}