From fd24e1905b479dcdea58b9445fc4c837df908df7 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 17 Sep 2018 20:41:20 +0200 Subject: crypto: turn Zinc into individual modules --- src/crypto/zinc/chacha20poly1305.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/crypto/zinc/chacha20poly1305.c') 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 #include #include +#include +#include #include 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 "); +#endif -- cgit v1.2.3-59-g8ed1b