aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/poly1305
diff options
context:
space:
mode:
Diffstat (limited to 'src/crypto/zinc/poly1305')
-rw-r--r--src/crypto/zinc/poly1305/poly1305-arm-glue.h2
-rw-r--r--src/crypto/zinc/poly1305/poly1305-mips-glue.h2
-rw-r--r--src/crypto/zinc/poly1305/poly1305-x86_64-glue.h2
-rw-r--r--src/crypto/zinc/poly1305/poly1305.c28
4 files changed, 31 insertions, 3 deletions
diff --git a/src/crypto/zinc/poly1305/poly1305-arm-glue.h b/src/crypto/zinc/poly1305/poly1305-arm-glue.h
index 50fb519..dd3fa5a 100644
--- a/src/crypto/zinc/poly1305/poly1305-arm-glue.h
+++ b/src/crypto/zinc/poly1305/poly1305-arm-glue.h
@@ -20,7 +20,7 @@ asmlinkage void poly1305_emit_neon(void *ctx, u8 mac[16], const u32 nonce[4]);
static bool poly1305_use_neon __ro_after_init;
-void __init poly1305_fpu_init(void)
+static void __init poly1305_fpu_init(void)
{
#if defined(CONFIG_ARM64)
poly1305_use_neon = elf_hwcap & HWCAP_ASIMD;
diff --git a/src/crypto/zinc/poly1305/poly1305-mips-glue.h b/src/crypto/zinc/poly1305/poly1305-mips-glue.h
index 6af3f57..2932bb9 100644
--- a/src/crypto/zinc/poly1305/poly1305-mips-glue.h
+++ b/src/crypto/zinc/poly1305/poly1305-mips-glue.h
@@ -7,7 +7,7 @@ asmlinkage void poly1305_init_mips(void *ctx, const u8 key[16]);
asmlinkage void poly1305_blocks_mips(void *ctx, const u8 *inp, const size_t len,
const u32 padbit);
asmlinkage void poly1305_emit_mips(void *ctx, u8 mac[16], const u32 nonce[4]);
-void __init poly1305_fpu_init(void)
+static void __init poly1305_fpu_init(void)
{
}
diff --git a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
index 63e2a5c..0ca3485 100644
--- a/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
+++ b/src/crypto/zinc/poly1305/poly1305-x86_64-glue.h
@@ -32,7 +32,7 @@ static bool poly1305_use_avx __ro_after_init;
static bool poly1305_use_avx2 __ro_after_init;
static bool poly1305_use_avx512 __ro_after_init;
-void __init poly1305_fpu_init(void)
+static void __init poly1305_fpu_init(void)
{
poly1305_use_avx =
boot_cpu_has(X86_FEATURE_AVX) &&
diff --git a/src/crypto/zinc/poly1305/poly1305.c b/src/crypto/zinc/poly1305/poly1305.c
index aad6587..5377721 100644
--- a/src/crypto/zinc/poly1305/poly1305.c
+++ b/src/crypto/zinc/poly1305/poly1305.c
@@ -12,6 +12,8 @@
#include <asm/unaligned.h>
#include <linux/kernel.h>
#include <linux/string.h>
+#include <linux/module.h>
+#include <linux/init.h>
#if defined(CONFIG_ZINC_ARCH_X86_64)
#include "poly1305-x86_64-glue.h"
@@ -133,3 +135,29 @@ void poly1305_final(struct poly1305_ctx *ctx, u8 mac[POLY1305_MAC_SIZE],
EXPORT_SYMBOL(poly1305_final);
#include "../selftest/poly1305.h"
+
+#ifndef COMPAT_ZINC_IS_A_MODULE
+int __init poly1305_mod_init(void)
+#else
+static int __init mod_init(void)
+#endif
+{
+ poly1305_fpu_init();
+#ifdef DEBUG
+ if (!poly1305_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("Poly1305 one-time MAC");
+MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>");
+#endif