From ff489fb4725b120a9da05d339595bc7799c53802 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 28 Nov 2017 16:19:57 +0000 Subject: [PATCH] Integrate Curve448 into the build system Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/5105) --- crypto/ec/build.info | 11 +++++++++++ crypto/ec/curve448/word.h | 19 ++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/crypto/ec/build.info b/crypto/ec/build.info index 4e9de4b9e7..15d6ccc58c 100644 --- a/crypto/ec/build.info +++ b/crypto/ec/build.info @@ -6,6 +6,9 @@ SOURCE[../../libcrypto]=\ ecp_nistp224.c ecp_nistp256.c ecp_nistp521.c ecp_nistputil.c \ ecp_oct.c ec2_oct.c ec_oct.c ec_kmeth.c ecdh_ossl.c ecdh_kdf.c \ ecdsa_ossl.c ecdsa_sign.c ecdsa_vrf.c curve25519.c ecx_meth.c \ + curve448/arch_32/f_impl.c curve448/f_arithmetic.c curve448/f_generic.c \ + curve448/scalar.c curve448/curve448_tables.c curve448/eddsa.c \ + curve448/curve448.c \ {- $target{ec_asm_src} -} GENERATE[ecp_nistz256-x86.s]=asm/ecp_nistz256-x86.pl \ @@ -28,3 +31,11 @@ BEGINRAW[Makefile] {- $builddir -}/ecp_nistz256-%.S: {- $sourcedir -}/asm/ecp_nistz256-%.pl CC="$(CC)" $(PERL) $< $(PERLASM_SCHEME) $@ ENDRAW[Makefile] + +INCLUDE[curve448/arch_32/f_impl.o]=curve448/arch_32 curve448 +INCLUDE[curve448/f_arithmetic.o]=curve448/arch_32 curve448 +INCLUDE[curve448/f_generic.o]=curve448/arch_32 curve448 +INCLUDE[curve448/scalar.o]=curve448/arch_32 curve448 +INCLUDE[curve448/curve448_tables.o]=curve448/arch_32 curve448 +INCLUDE[curve448/eddsa.o]=curve448/arch_32 curve448 +INCLUDE[curve448/curve448.o]=curve448/arch_32 curve448 diff --git a/crypto/ec/curve448/word.h b/crypto/ec/curve448/word.h index 9f62654b6e..5afe85a166 100644 --- a/crypto/ec/curve448/word.h +++ b/crypto/ec/curve448/word.h @@ -26,7 +26,7 @@ #if defined(__ARM_NEON__) #include #elif defined(__SSE2__) - #if !defined(__GNUC__) || __clang__ || __GNUC__ >= 5 || (__GNUC__==4 && __GNUC_MINOR__ >= 4) + #if !defined(__GNUC__) || defined(__clang__) || __GNUC__ >= 5 || (__GNUC__==4 && __GNUC_MINOR__ >= 4) #include #else #include @@ -60,7 +60,7 @@ #ifdef __ARM_NEON__ typedef uint32x4_t vecmask_t; -#elif __clang__ +#elif defined(__clang__) typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2))); typedef int64_t int64x2_t __attribute__((ext_vector_type(2))); typedef uint64_t uint64x4_t __attribute__((ext_vector_type(4))); @@ -86,7 +86,7 @@ typedef word_t vecmask_t __attribute__((vector_size(32))); #endif -#if __AVX2__ +#if defined(__AVX2__) #define VECTOR_ALIGNED __attribute__((aligned(32))) typedef uint32x8_t big_register_t; typedef uint64x4_t uint64xn_t; @@ -98,7 +98,7 @@ big_register_t ret = {y,y,y,y,y,y,y,y}; return ret; } -#elif __SSE2__ +#elif defined(__SSE2__) #define VECTOR_ALIGNED __attribute__((aligned(16))) typedef uint32x4_t big_register_t; typedef uint64x2_t uint64xn_t; @@ -110,7 +110,7 @@ big_register_t ret = {y,y,y,y}; return ret; } -#elif __ARM_NEON__ +#elif defined(__ARM_NEON__) #define VECTOR_ALIGNED __attribute__((aligned(16))) typedef uint32x4_t big_register_t; typedef uint64x2_t uint64xn_t; @@ -120,7 +120,8 @@ br_set_to_mask(mask_t x) { return vdupq_n_u32(x); } -#elif _WIN64 || __amd64__ || __X86_64__ || __aarch64__ +#elif defined(_WIN64) || defined(__amd64__) || defined(__X86_64__) \ + || defined(__aarch64__) #define VECTOR_ALIGNED __attribute__((aligned(8))) typedef uint64_t big_register_t, uint64xn_t; @@ -141,18 +142,18 @@ } #endif -#if __AVX2__ +#if defined(__AVX2__) static ossl_inline big_register_t br_is_zero(big_register_t x) { return (big_register_t)(x == br_set_to_mask(0)); } -#elif __SSE2__ +#elif defined(__SSE2__) static ossl_inline big_register_t br_is_zero(big_register_t x) { return (big_register_t)_mm_cmpeq_epi32((__m128i)x, _mm_setzero_si128()); //return (big_register_t)(x == br_set_to_mask(0)); } -#elif __ARM_NEON__ +#elif defined(__ARM_NEON__) static ossl_inline big_register_t br_is_zero(big_register_t x) { return vceqq_u32(x,x^x); -- 2.25.1