aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/crypto/zinc/curve25519/curve25519-arm-glue.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-10-05 23:20:40 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-10-06 01:03:16 +0200
commitad5e42105059b23545b6958b3d8d4a65e7c78f01 (patch)
tree2aaad03f36ba8c27c051ffeb6272d4f9c851c693 /src/crypto/zinc/curve25519/curve25519-arm-glue.c
parentallowedips: remove ifdefs in favor of IS_ENABLED (diff)
downloadwireguard-monolithic-historical-ad5e42105059b23545b6958b3d8d4a65e7c78f01.tar.xz
wireguard-monolithic-historical-ad5e42105059b23545b6958b3d8d4a65e7c78f01.zip
global: rename include'd C files to be .c
This is done by 259 other files in the kernel tree: linux $ rg '#include.*\.c' -l | wc -l 259 Suggested-by: Sultan Alsawaf <sultanxda@gmail.com>
Diffstat (limited to 'src/crypto/zinc/curve25519/curve25519-arm-glue.c')
-rw-r--r--src/crypto/zinc/curve25519/curve25519-arm-glue.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/crypto/zinc/curve25519/curve25519-arm-glue.c b/src/crypto/zinc/curve25519/curve25519-arm-glue.c
new file mode 100644
index 0000000..cea06f3
--- /dev/null
+++ b/src/crypto/zinc/curve25519/curve25519-arm-glue.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0 OR MIT
+/*
+ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ */
+
+#include <linux/simd.h>
+#include <asm/hwcap.h>
+#include <asm/neon.h>
+
+asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE],
+ const u8 basepoint[CURVE25519_KEY_SIZE]);
+
+static bool curve25519_use_neon __ro_after_init;
+
+static void __init curve25519_fpu_init(void)
+{
+ curve25519_use_neon = elf_hwcap & HWCAP_NEON;
+}
+
+static inline bool curve25519_arch(u8 mypublic[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE],
+ const u8 basepoint[CURVE25519_KEY_SIZE])
+{
+ simd_context_t simd_context;
+ bool used_arch = false;
+
+ simd_get(&simd_context);
+ if (IS_ENABLED(CONFIG_KERNEL_MODE_NEON) &&
+ !IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && curve25519_use_neon &&
+ simd_use(&simd_context)) {
+ curve25519_neon(mypublic, secret, basepoint);
+ used_arch = true;
+ }
+ simd_put(&simd_context);
+ return used_arch;
+}
+
+static inline bool curve25519_base_arch(u8 pub[CURVE25519_KEY_SIZE],
+ const u8 secret[CURVE25519_KEY_SIZE])
+{
+ return false;
+}