diff options
Diffstat (limited to 'src/crypto/zinc/curve25519')
-rw-r--r-- | src/crypto/zinc/curve25519/curve25519-arm-glue.h | 2 | ||||
-rw-r--r-- | src/crypto/zinc/curve25519/curve25519-x86_64-glue.h | 2 | ||||
-rw-r--r-- | src/crypto/zinc/curve25519/curve25519.c | 28 |
3 files changed, 30 insertions, 2 deletions
diff --git a/src/crypto/zinc/curve25519/curve25519-arm-glue.h b/src/crypto/zinc/curve25519/curve25519-arm-glue.h index 1b39920..a547732 100644 --- a/src/crypto/zinc/curve25519/curve25519-arm-glue.h +++ b/src/crypto/zinc/curve25519/curve25519-arm-glue.h @@ -16,7 +16,7 @@ asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_POINT_SIZE], static bool curve25519_use_neon __ro_after_init; -void __init curve25519_fpu_init(void) +static void __init curve25519_fpu_init(void) { curve25519_use_neon = elf_hwcap & HWCAP_NEON; } diff --git a/src/crypto/zinc/curve25519/curve25519-x86_64-glue.h b/src/crypto/zinc/curve25519/curve25519-x86_64-glue.h index 9159460..1b9b719 100644 --- a/src/crypto/zinc/curve25519/curve25519-x86_64-glue.h +++ b/src/crypto/zinc/curve25519/curve25519-x86_64-glue.h @@ -11,7 +11,7 @@ static bool curve25519_use_bmi2 __ro_after_init; static bool curve25519_use_adx __ro_after_init; -void __init curve25519_fpu_init(void) +static void __init curve25519_fpu_init(void) { curve25519_use_bmi2 = boot_cpu_has(X86_FEATURE_BMI2); curve25519_use_adx = boot_cpu_has(X86_FEATURE_BMI2) && diff --git a/src/crypto/zinc/curve25519/curve25519.c b/src/crypto/zinc/curve25519/curve25519.c index 7d19fb9..fca327f 100644 --- a/src/crypto/zinc/curve25519/curve25519.c +++ b/src/crypto/zinc/curve25519/curve25519.c @@ -15,6 +15,8 @@ #include <linux/version.h> #include <linux/string.h> #include <linux/random.h> +#include <linux/module.h> +#include <linux/init.h> #include <crypto/algapi.h> #if defined(CONFIG_ZINC_ARCH_X86_64) @@ -85,3 +87,29 @@ void curve25519_generate_secret(u8 secret[CURVE25519_POINT_SIZE]) EXPORT_SYMBOL(curve25519_generate_secret); #include "../selftest/curve25519.h" + +#ifndef COMPAT_ZINC_IS_A_MODULE +int __init curve25519_mod_init(void) +#else +static int __init mod_init(void) +#endif +{ + curve25519_fpu_init(); +#ifdef DEBUG + if (!curve25519_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("Curve25519 scalar multiplication"); +MODULE_AUTHOR("Jason A. Donenfeld <Jason@zx2c4.com>"); +#endif |