From a242424abe125ed461b6518a310bcc29cdd13754 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Thu, 27 Jan 2022 09:35:50 +1000 Subject: [PATCH] Generated files: fixes Fixups from updating scripts that generate the files. Include settings.h for ARM32 assembly. ARM32 SHA-512 ASM has only one function, Transform_Sha512_Len(). The implementation is dependent on defines. --- wolfcrypt/src/fe_448.c | 2 +- wolfcrypt/src/fe_x25519_128.i | 19 ++++++++++++------- wolfcrypt/src/ge_448.c | 2 +- wolfcrypt/src/port/arm/armv8-32-curve25519.S | 11 +++++++++-- wolfcrypt/src/port/arm/armv8-32-curve25519.c | 11 +++++++++-- wolfcrypt/src/port/arm/armv8-32-sha512-asm.S | 9 +++++++-- wolfcrypt/src/port/arm/armv8-32-sha512-asm.c | 9 +++++++-- wolfcrypt/src/port/arm/armv8-sha512.c | 5 +++++ 8 files changed, 51 insertions(+), 17 deletions(-) diff --git a/wolfcrypt/src/fe_448.c b/wolfcrypt/src/fe_448.c index 786400706..1dc16f6d4 100644 --- a/wolfcrypt/src/fe_448.c +++ b/wolfcrypt/src/fe_448.c @@ -1,6 +1,6 @@ /* fe_448.c * - * Copyright (C) 2006-2021 wolfSSL Inc. + * Copyright (C) 2006-2022 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/fe_x25519_128.i b/wolfcrypt/src/fe_x25519_128.i index aa47a16d9..7116564ac 100644 --- a/wolfcrypt/src/fe_x25519_128.i +++ b/wolfcrypt/src/fe_x25519_128.i @@ -1,6 +1,6 @@ /* fe_x25519_128.i * - * Copyright (C) 2006-2021 wolfSSL Inc. + * Copyright (C) 2006-2022 wolfSSL Inc. * * This file is part of wolfSSL. * @@ -19,6 +19,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* Generated using (from wolfssl): + * cd ../scripts + * ruby ./x25519/fe_x25519_128_gen.rb > ../wolfssl/wolfcrypt/src/fe_x25519_128.i + */ + void fe_init(void) { } @@ -189,9 +194,9 @@ void fe_copy(fe r, const fe a) /* Constant time, conditional swap of field elements a and b. * - * a A field element. - * b A field element. - * c If 1 then swap and if 0 then don't swap. + * f A field element. + * g A field element. + * b If 1 then swap and if 0 then don't swap. */ void fe_cswap(fe f, fe g, int b) { @@ -501,9 +506,9 @@ void fe_neg(fe r, const fe a) /* Constant time, conditional move of b into a. * a is not changed if the condition is 0. * - * a A field element. - * b A field element. - * c If 1 then copy and if 0 then don't copy. + * f A field element. + * g A field element. + * b If 1 then copy and if 0 then don't copy. */ void fe_cmov(fe f, const fe g, int b) { diff --git a/wolfcrypt/src/ge_448.c b/wolfcrypt/src/ge_448.c index f87cc79a2..9ceea56ad 100644 --- a/wolfcrypt/src/ge_448.c +++ b/wolfcrypt/src/ge_448.c @@ -1,6 +1,6 @@ /* ge_448.c * - * Copyright (C) 2006-2021 wolfSSL Inc. + * Copyright (C) 2006-2022 wolfSSL Inc. * * This file is part of wolfSSL. * diff --git a/wolfcrypt/src/port/arm/armv8-32-curve25519.S b/wolfcrypt/src/port/arm/armv8-32-curve25519.S index 26fe61855..a089d3170 100644 --- a/wolfcrypt/src/port/arm/armv8-32-curve25519.S +++ b/wolfcrypt/src/port/arm/armv8-32-curve25519.S @@ -23,8 +23,13 @@ * cd ../scripts * ruby ./x25519/x25519.rb arm32 ../wolfssl/wolfcrypt/src/port/arm/armv8-32-curve25519.S */ -#if defined(WOLFSSL_ARMASM) && defined(HAVE_CURVE25519) + +#include + +#ifdef WOLFSSL_ARMASM #ifndef __aarch64__ +#ifdef HAVE_CURVE25519 + .text .align 2 .globl fe_init @@ -6007,8 +6012,10 @@ fe_ge_sub: add sp, sp, #0x60 pop {r4, r5, r6, r7, r8, r9, r10, r11, pc} .size fe_ge_sub,.-fe_ge_sub + +#endif /* HAVE_CURVE25519 */ #endif /* !__aarch64__ */ -#endif /* WOLFSSL_ARMASM && HAVE_CURVE25519 */ +#endif /* WOLFSSL_ARMASM */ #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/wolfcrypt/src/port/arm/armv8-32-curve25519.c b/wolfcrypt/src/port/arm/armv8-32-curve25519.c index ddc08f644..1ff277f50 100644 --- a/wolfcrypt/src/port/arm/armv8-32-curve25519.c +++ b/wolfcrypt/src/port/arm/armv8-32-curve25519.c @@ -23,7 +23,10 @@ * cd ../scripts * ruby ./x25519/x25519.rb arm32 ../wolfssl/wolfcrypt/src/port/arm/armv8-32-curve25519.c */ -#if defined(WOLFSSL_ARMASM) && defined(HAVE_CURVE25519) + +#include + +#ifdef WOLFSSL_ARMASM #ifndef __aarch64__ #include #ifdef HAVE_CONFIG_H @@ -32,6 +35,8 @@ #include #include +#ifdef HAVE_CURVE25519 + void fe_init() { __asm__ __volatile__ ( @@ -5572,5 +5577,7 @@ void fe_ge_sub(fe rx, fe ry, fe rz, fe rt, const fe px, const fe py, const fe pz (void)qyminusx; } + +#endif /* HAVE_CURVE25519 */ #endif /* !__aarch64__ */ -#endif /* WOLFSSL_ARMASM && HAVE_CURVE25519 */ +#endif /* WOLFSSL_ARMASM */ diff --git a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S index c42cf63b1..14342ac96 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S +++ b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S @@ -23,8 +23,12 @@ * cd ../scripts * ruby ./sha2/sha512.rb arm32 ../wolfssl/wolfcrypt/src/port/arm/armv8-32-sha512-asm.S */ -#if defined(WOLFSSL_ARMASM) && defined(WOLFSSL_SHA512) + +#include + +#ifdef WOLFSSL_ARMASM #ifndef __aarch64__ +#ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_ARMASM_NO_NEON .text .type L_SHA512_transform_len_k, %object @@ -5330,8 +5334,9 @@ L_sha512_len_neon_start: bx lr .size Transform_Sha512_Len,.-Transform_Sha512_Len #endif /* !WOLFSSL_ARMASM_NO_NEON */ +#endif /* WOLFSSL_SHA512 */ #endif /* !__aarch64__ */ -#endif /* WOLFSSL_ARMASM && WOLFSSL_SHA512 */ +#endif /* WOLFSSL_ARMASM */ #if defined(__linux__) && defined(__ELF__) .section .note.GNU-stack,"",%progbits diff --git a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.c b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.c index 53e5b9743..a46046d7c 100644 --- a/wolfcrypt/src/port/arm/armv8-32-sha512-asm.c +++ b/wolfcrypt/src/port/arm/armv8-32-sha512-asm.c @@ -23,13 +23,17 @@ * cd ../scripts * ruby ./sha2/sha512.rb arm32 ../wolfssl/wolfcrypt/src/port/arm/armv8-32-sha512-asm.c */ -#if defined(WOLFSSL_ARMASM) && defined(WOLFSSL_SHA512) + +#include + +#ifdef WOLFSSL_ARMASM #ifndef __aarch64__ #include #ifdef HAVE_CONFIG_H #include #endif /* HAVE_CONFIG_H */ #include +#ifdef WOLFSSL_SHA512 #include #ifdef WOLFSSL_ARMASM_NO_NEON @@ -4775,5 +4779,6 @@ void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, word32 len) } #endif /* !WOLFSSL_ARMASM_NO_NEON */ +#endif /* WOLFSSL_SHA512 */ #endif /* !__aarch64__ */ -#endif /* WOLFSSL_ARMASM && WOLFSSL_SHA512 */ +#endif /* WOLFSSL_ARMASM */ diff --git a/wolfcrypt/src/port/arm/armv8-sha512.c b/wolfcrypt/src/port/arm/armv8-sha512.c index c6c0147da..358cf06ab 100644 --- a/wolfcrypt/src/port/arm/armv8-sha512.c +++ b/wolfcrypt/src/port/arm/armv8-sha512.c @@ -147,6 +147,7 @@ static int InitSha512_256(wc_Sha512* sha512) #ifdef WOLFSSL_SHA512 #ifdef WOLFSSL_ARMASM +#ifdef __aarch64__ #ifndef WOLFSSL_ARMASM_CRYPTO_SHA512 extern void Transform_Sha512_Len_neon(wc_Sha512* sha512, const byte* data, word32 len); @@ -156,6 +157,10 @@ static int InitSha512_256(wc_Sha512* sha512) word32 len); #define Transform_Sha512_Len Transform_Sha512_Len_crypto #endif +#else +extern void Transform_Sha512_Len(wc_Sha512* sha512, const byte* data, + word32 len); +#endif #endif static int InitSha512_Family(wc_Sha512* sha512, void* heap, int devId,