diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-08-28 23:50:35 -0600 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-09-03 23:52:11 -0600 |
commit | 4a0e319af86c0d38304535293f6fc32fe436ef1d (patch) | |
tree | 6fca1e89becf3ff1afdcec7b6bc725e256af5811 /src/crypto/zinc/curve25519/curve25519-arm-glue.h | |
parent | uapi: reformat (diff) | |
download | wireguard-monolithic-historical-4a0e319af86c0d38304535293f6fc32fe436ef1d.tar.xz wireguard-monolithic-historical-4a0e319af86c0d38304535293f6fc32fe436ef1d.zip |
crypto: import zinc
Diffstat (limited to '')
-rw-r--r-- | src/crypto/zinc/curve25519/curve25519-arm-glue.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/crypto/zinc/curve25519/curve25519-arm-glue.h b/src/crypto/zinc/curve25519/curve25519-arm-glue.h new file mode 100644 index 0000000..36e8002 --- /dev/null +++ b/src/crypto/zinc/curve25519/curve25519-arm-glue.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 + * + * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. + */ + +#include <zinc/curve25519.h> +#include <asm/hwcap.h> +#include <asm/neon.h> +#include <asm/simd.h> + +#if IS_ENABLED(CONFIG_KERNEL_MODE_NEON) && __LINUX_ARM_ARCH__ == 7 +#define ARM_USE_NEON +asmlinkage void curve25519_neon(u8 mypublic[CURVE25519_POINT_SIZE], + const u8 secret[CURVE25519_POINT_SIZE], + const u8 basepoint[CURVE25519_POINT_SIZE]); +#endif + +static bool curve25519_use_neon __ro_after_init; + +void __init curve25519_fpu_init(void) +{ + curve25519_use_neon = elf_hwcap & HWCAP_NEON; +} + +static inline bool curve25519_arch(u8 mypublic[CURVE25519_POINT_SIZE], + const u8 secret[CURVE25519_POINT_SIZE], + const u8 basepoint[CURVE25519_POINT_SIZE]) +{ +#ifdef ARM_USE_NEON + if (curve25519_use_neon && may_use_simd()) { + kernel_neon_begin(); + curve25519_neon(mypublic, secret, basepoint); + kernel_neon_end(); + return true; + } +#endif + return false; +} + +static inline bool curve25519_base_arch(u8 pub[CURVE25519_POINT_SIZE], + const u8 secret[CURVE25519_POINT_SIZE]) +{ + return false; +} + +#define HAVE_CURVE25519_ARCH_IMPLEMENTATION |