summaryrefslogtreecommitdiffhomepage
path: root/src/crypto/zinc/blake2s/blake2s.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
commit023db2863e36fe648b62e21c30fda0f38765323b (patch)
treed3338db146361b72bfb406ba601c628e67bfbfde /src/crypto/zinc/blake2s/blake2s.c
parent1906c279fbe3420e31a5a48a19b6daac5fbf1904 (diff)
crypto: turn Zinc into individual modules
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/crypto/zinc/blake2s/blake2s.c')
-rw-r--r--src/crypto/zinc/blake2s/blake2s.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c
index bedff1e..8cbaa6f 100644
--- a/src/crypto/zinc/blake2s/blake2s.c
+++ b/src/crypto/zinc/blake2s/blake2s.c
@@ -14,6 +14,8 @@
#include <linux/types.h>
#include <linux/string.h>
#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/init.h>
#include <linux/bug.h>
#include <asm/unaligned.h>
@@ -114,9 +116,10 @@ EXPORT_SYMBOL(blake2s_init_key);
#if defined(CONFIG_ZINC_ARCH_X86_64)
#include "blake2s-x86_64-glue.h"
#else
-void __init blake2s_fpu_init(void)
+static void __init blake2s_fpu_init(void)
{
}
+
static inline bool blake2s_arch(struct blake2s_state *state, const u8 *block,
const size_t nblocks, const u32 inc)
{
@@ -274,3 +277,29 @@ void blake2s_hmac(u8 *out, const u8 *in, const u8 *key, const size_t outlen,
EXPORT_SYMBOL(blake2s_hmac);
#include "../selftest/blake2s.h"
+
+#ifndef COMPAT_ZINC_IS_A_MODULE
+int __init blake2s_mod_init(void)
+#else
+static int __init mod_init(void)
+#endif
+{
+ blake2s_fpu_init();
+#ifdef DEBUG
+ if (!blake2s_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("BLAKE2s hash function");
+MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>");
+#endif