diff --git a/.wolfssl_known_macro_extras b/.wolfssl_known_macro_extras index 49353bc671..436de477fc 100644 --- a/.wolfssl_known_macro_extras +++ b/.wolfssl_known_macro_extras @@ -506,6 +506,7 @@ SNIFFER_SINGLE_SESSION_CACHE SOFTDEVICE_PRESENT SO_NOSIGPIPE SO_REUSEPORT +SP_ALIGN_16 SP_INT_NO_ASM SP_MATH_NEED_ADD_OFF SP_USE_DIVTI3 diff --git a/wolfcrypt/src/sp_arm32.c b/wolfcrypt/src/sp_arm32.c index 168168f094..43f3f3ce14 100644 --- a/wolfcrypt/src/sp_arm32.c +++ b/wolfcrypt/src/sp_arm32.c @@ -99504,6 +99504,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 17]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_arm64.c b/wolfcrypt/src/sp_arm64.c index 71a31716dc..51679142bf 100644 --- a/wolfcrypt/src/sp_arm64.c +++ b/wolfcrypt/src/sp_arm64.c @@ -67605,6 +67605,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 9]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_armthumb.c b/wolfcrypt/src/sp_armthumb.c index 98516b9018..7871754ae0 100644 --- a/wolfcrypt/src/sp_armthumb.c +++ b/wolfcrypt/src/sp_armthumb.c @@ -118312,6 +118312,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 17]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_c32.c b/wolfcrypt/src/sp_c32.c index f52cf44859..d2107da8fd 100644 --- a/wolfcrypt/src/sp_c32.c +++ b/wolfcrypt/src/sp_c32.c @@ -32707,6 +32707,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 21]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_c64.c b/wolfcrypt/src/sp_c64.c index 21473732ad..a6dc93d996 100644 --- a/wolfcrypt/src/sp_c64.c +++ b/wolfcrypt/src/sp_c64.c @@ -32635,6 +32635,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 9]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_cortexm.c b/wolfcrypt/src/sp_cortexm.c index 801978d128..e84fde0864 100644 --- a/wolfcrypt/src/sp_cortexm.c +++ b/wolfcrypt/src/sp_cortexm.c @@ -51918,6 +51918,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 17]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_x86_64.c b/wolfcrypt/src/sp_x86_64.c index b792175971..1b39f1b959 100644 --- a/wolfcrypt/src/sp_x86_64.c +++ b/wolfcrypt/src/sp_x86_64.c @@ -50649,6 +50649,9 @@ typedef struct sp_point_521 { sp_digit z[2 * 9]; /* Indicates point is at infinity. */ int infinity; +#ifdef SP_ALIGN_16 + byte pad[16-sizeof(int)]; +#endif } sp_point_521; /* The modulus (prime) of the curve P521. */ diff --git a/wolfcrypt/src/sp_x86_64_asm.S b/wolfcrypt/src/sp_x86_64_asm.S index 9281f10170..ee87242c13 100644 --- a/wolfcrypt/src/sp_x86_64_asm.S +++ b/wolfcrypt/src/sp_x86_64_asm.S @@ -66736,7 +66736,11 @@ _sp_521_get_point_33_9: movq $0x01, %r12 movq $0x01, %rax movd %edx, %xmm13 +#ifndef SP_ALIGN_16 addq $0x1b8, %rsi +#else + addq $0x1c0, %rsi +#endif /* !SP_ALIGN_16 */ movd %eax, %xmm15 movq $32, %rax pshufd $0x00, %xmm15, %xmm15 @@ -66767,7 +66771,11 @@ L_521_get_point_33_9_start_1: movq 64(%rsi), %r8 movdqu 144(%rsi), %xmm10 movdqu 160(%rsi), %xmm11 +#ifndef SP_ALIGN_16 addq $0x1b8, %rsi +#else + addq $0x1c0, %rsi +#endif /* !SP_ALIGN_16 */ pand %xmm12, %xmm6 pand %xmm12, %xmm7 pand %xmm12, %xmm8 @@ -66794,7 +66802,11 @@ L_521_get_point_33_9_start_1: movq $0x01, %r12 movq $0x01, %rax movd %edx, %xmm13 +#ifndef SP_ALIGN_16 subq $0x3700, %rsi +#else + subq $0x1b800, %rsi +#endif /* !SP_ALIGN_16 */ movd %eax, %xmm15 movq $32, %rax pshufd $0x00, %xmm15, %xmm15 @@ -66826,7 +66838,11 @@ L_521_get_point_33_9_start_2: movdqu 320(%rsi), %xmm10 movdqu 336(%rsi), %xmm11 movq 352(%rsi), %r9 +#ifndef SP_ALIGN_16 addq $0x1b8, %rsi +#else + addq $0x1c0, %rsi +#endif /* !SP_ALIGN_16 */ pand %xmm12, %xmm6 pand %xmm12, %xmm7 pand %xmm12, %xmm8 @@ -66883,7 +66899,11 @@ _sp_521_get_point_33_avx2_9: movq $0x01, %r14 movq $0x01, %rax movd %edx, %xmm13 +#ifndef SP_ALIGN_16 addq $0x1b8, %rsi +#else + addq $0x1c0, %rsi +#endif /* !SP_ALIGN_16 */ movd %eax, %xmm15 movq $32, %rax vpxor %ymm14, %ymm14, %ymm14 @@ -66916,7 +66936,11 @@ L_521_get_point_33_avx2_9_start: movq 64(%rsi), %r11 movq 208(%rsi), %r12 movq 352(%rsi), %r13 +#ifndef SP_ALIGN_16 addq $0x1b8, %rsi +#else + addq $0x1c0, %rsi +#endif /* !SP_ALIGN_16 */ vpand %ymm12, %ymm6, %ymm6 vpand %ymm12, %ymm7, %ymm7 vpand %ymm12, %ymm8, %ymm8 diff --git a/wolfcrypt/src/sp_x86_64_asm.asm b/wolfcrypt/src/sp_x86_64_asm.asm index fcce0f5ea4..638f874949 100644 --- a/wolfcrypt/src/sp_x86_64_asm.asm +++ b/wolfcrypt/src/sp_x86_64_asm.asm @@ -65067,7 +65067,11 @@ sp_521_get_point_33_9 PROC mov r14, 1 mov rax, 1 movd xmm13, r8d +IFNDEF SP_ALIGN_16 add rdx, 440 +ELSE + add rdx, 448 +ENDIF movd xmm15, eax mov rax, 32 pshufd xmm15, xmm15, 0 @@ -65098,7 +65102,11 @@ L_521_get_point_33_9_start_1: mov r10, QWORD PTR [rdx+64] movdqu xmm10, OWORD PTR [rdx+144] movdqu xmm11, OWORD PTR [rdx+160] +IFNDEF SP_ALIGN_16 add rdx, 440 +ELSE + add rdx, 448 +ENDIF pand xmm6, xmm12 pand xmm7, xmm12 pand xmm8, xmm12 @@ -65125,7 +65133,11 @@ L_521_get_point_33_9_start_1: mov r14, 1 mov rax, 1 movd xmm13, r8d +IFNDEF SP_ALIGN_16 sub rdx, 14080 +ELSE + sub rdx, 112640 +ENDIF movd xmm15, eax mov rax, 32 pshufd xmm15, xmm15, 0 @@ -65157,7 +65169,11 @@ L_521_get_point_33_9_start_2: movdqu xmm10, OWORD PTR [rdx+320] movdqu xmm11, OWORD PTR [rdx+336] mov r11, QWORD PTR [rdx+352] +IFNDEF SP_ALIGN_16 add rdx, 440 +ELSE + add rdx, 448 +ENDIF pand xmm6, xmm12 pand xmm7, xmm12 pand xmm8, xmm12 @@ -65229,7 +65245,11 @@ sp_521_get_point_33_avx2_9 PROC mov rdi, 1 mov rax, 1 movd xmm13, r8d +IFNDEF SP_ALIGN_16 add rdx, 440 +ELSE + add rdx, 448 +ENDIF movd xmm15, eax mov rax, 32 vpxor ymm14, ymm14, ymm14 @@ -65262,7 +65282,11 @@ L_521_get_point_33_avx2_9_start: mov r13, QWORD PTR [rdx+64] mov r14, QWORD PTR [rdx+208] mov r15, QWORD PTR [rdx+352] +IFNDEF SP_ALIGN_16 add rdx, 440 +ELSE + add rdx, 448 +ENDIF vpand ymm6, ymm6, ymm12 vpand ymm7, ymm7, ymm12 vpand ymm8, ymm8, ymm12