aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/chacha20poly1305.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-17 20:41:20 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-18 04:21:16 +0200
commitfd24e1905b479dcdea58b9445fc4c837df908df7 (patch)
treef9a675256d7a02b1edd1b65b2be44f7263cc1d55 /src/crypto/zinc/chacha20poly1305.c
parentcrypto: do not use -include trick (diff)
downloadwireguard-monolithic-historical-fd24e1905b479dcdea58b9445fc4c837df908df7.tar.xz
wireguard-monolithic-historical-fd24e1905b479dcdea58b9445fc4c837df908df7.zip
crypto: turn Zinc into individual modules
Diffstat (limited to 'src/crypto/zinc/chacha20poly1305.c')
-rw-r--r--src/crypto/zinc/chacha20poly1305.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/crypto/zinc/chacha20poly1305.c b/src/crypto/zinc/chacha20poly1305.c
index 7a8e03f..d5ebade 100644
--- a/src/crypto/zinc/chacha20poly1305.c
+++ b/src/crypto/zinc/chacha20poly1305.c
@@ -12,6 +12,8 @@
#include <zinc/poly1305.h>
#include <asm/unaligned.h>
#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
#include <crypto/scatterwalk.h>
static const u8 pad0[16] = { 0 };
@@ -334,3 +336,28 @@ bool xchacha20poly1305_decrypt(u8 *dst, const u8 *src, const size_t src_len,
EXPORT_SYMBOL(xchacha20poly1305_decrypt);
#include "selftest/chacha20poly1305.h"
+
+#ifndef COMPAT_ZINC_IS_A_MODULE
+int __init chacha20poly1305_mod_init(void)
+#else
+static int __init mod_init(void)
+#endif
+{
+#ifdef DEBUG
+ if (!chacha20poly1305_selftest())
+ return -ENOTRECOVERABLE;
+#endif
+ return 0;
+}
+
+#ifdef COMPAT_ZINC_IS_A_MODULE
+static void __exit mod_exit(void)
+{
+}
+
+module_init(mod_init);
+module_exit(mod_exit);
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("ChaCha20Poly1305 AEAD construction");
+MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>");
+#endif