Skip to content

Commit 48b8d0a

Browse files
committed
SP ECC: ecc_point - add padding when 16 byte aligned
To make 16-byte aligned points, add padding to end.
1 parent 6264c11 commit 48b8d0a

9 files changed

Lines changed: 69 additions & 0 deletions

File tree

wolfcrypt/src/sp_arm32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99504,6 +99504,9 @@ typedef struct sp_point_521 {
9950499504
sp_digit z[2 * 17];
9950599505
/* Indicates point is at infinity. */
9950699506
int infinity;
99507+
#ifdef SP_ALIGN_16
99508+
byte pad[16-sizeof(int)];
99509+
#endif
9950799510
} sp_point_521;
9950899511

9950999512
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_arm64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67605,6 +67605,9 @@ typedef struct sp_point_521 {
6760567605
sp_digit z[2 * 9];
6760667606
/* Indicates point is at infinity. */
6760767607
int infinity;
67608+
#ifdef SP_ALIGN_16
67609+
byte pad[16-sizeof(int)];
67610+
#endif
6760867611
} sp_point_521;
6760967612

6761067613
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_armthumb.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118312,6 +118312,9 @@ typedef struct sp_point_521 {
118312118312
sp_digit z[2 * 17];
118313118313
/* Indicates point is at infinity. */
118314118314
int infinity;
118315+
#ifdef SP_ALIGN_16
118316+
byte pad[16-sizeof(int)];
118317+
#endif
118315118318
} sp_point_521;
118316118319

118317118320
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_c32.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32707,6 +32707,9 @@ typedef struct sp_point_521 {
3270732707
sp_digit z[2 * 21];
3270832708
/* Indicates point is at infinity. */
3270932709
int infinity;
32710+
#ifdef SP_ALIGN_16
32711+
byte pad[16-sizeof(int)];
32712+
#endif
3271032713
} sp_point_521;
3271132714

3271232715
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_c64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32635,6 +32635,9 @@ typedef struct sp_point_521 {
3263532635
sp_digit z[2 * 9];
3263632636
/* Indicates point is at infinity. */
3263732637
int infinity;
32638+
#ifdef SP_ALIGN_16
32639+
byte pad[16-sizeof(int)];
32640+
#endif
3263832641
} sp_point_521;
3263932642

3264032643
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_cortexm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51918,6 +51918,9 @@ typedef struct sp_point_521 {
5191851918
sp_digit z[2 * 17];
5191951919
/* Indicates point is at infinity. */
5192051920
int infinity;
51921+
#ifdef SP_ALIGN_16
51922+
byte pad[16-sizeof(int)];
51923+
#endif
5192151924
} sp_point_521;
5192251925

5192351926
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_x86_64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50649,6 +50649,9 @@ typedef struct sp_point_521 {
5064950649
sp_digit z[2 * 9];
5065050650
/* Indicates point is at infinity. */
5065150651
int infinity;
50652+
#ifdef SP_ALIGN_16
50653+
byte pad[16-sizeof(int)];
50654+
#endif
5065250655
} sp_point_521;
5065350656

5065450657
/* The modulus (prime) of the curve P521. */

wolfcrypt/src/sp_x86_64_asm.S

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66736,7 +66736,11 @@ _sp_521_get_point_33_9:
6673666736
movq $0x01, %r12
6673766737
movq $0x01, %rax
6673866738
movd %edx, %xmm13
66739+
#ifndef SP_ALIGN_16
6673966740
addq $0x1b8, %rsi
66741+
#else
66742+
addq $0x1c0, %rsi
66743+
#endif /* !SP_ALIGN_16 */
6674066744
movd %eax, %xmm15
6674166745
movq $32, %rax
6674266746
pshufd $0x00, %xmm15, %xmm15
@@ -66767,7 +66771,11 @@ L_521_get_point_33_9_start_1:
6676766771
movq 64(%rsi), %r8
6676866772
movdqu 144(%rsi), %xmm10
6676966773
movdqu 160(%rsi), %xmm11
66774+
#ifndef SP_ALIGN_16
6677066775
addq $0x1b8, %rsi
66776+
#else
66777+
addq $0x1c0, %rsi
66778+
#endif /* !SP_ALIGN_16 */
6677166779
pand %xmm12, %xmm6
6677266780
pand %xmm12, %xmm7
6677366781
pand %xmm12, %xmm8
@@ -66794,7 +66802,11 @@ L_521_get_point_33_9_start_1:
6679466802
movq $0x01, %r12
6679566803
movq $0x01, %rax
6679666804
movd %edx, %xmm13
66805+
#ifndef SP_ALIGN_16
6679766806
subq $0x3700, %rsi
66807+
#else
66808+
subq $0x1b800, %rsi
66809+
#endif /* !SP_ALIGN_16 */
6679866810
movd %eax, %xmm15
6679966811
movq $32, %rax
6680066812
pshufd $0x00, %xmm15, %xmm15
@@ -66826,7 +66838,11 @@ L_521_get_point_33_9_start_2:
6682666838
movdqu 320(%rsi), %xmm10
6682766839
movdqu 336(%rsi), %xmm11
6682866840
movq 352(%rsi), %r9
66841+
#ifndef SP_ALIGN_16
6682966842
addq $0x1b8, %rsi
66843+
#else
66844+
addq $0x1c0, %rsi
66845+
#endif /* !SP_ALIGN_16 */
6683066846
pand %xmm12, %xmm6
6683166847
pand %xmm12, %xmm7
6683266848
pand %xmm12, %xmm8
@@ -66883,7 +66899,11 @@ _sp_521_get_point_33_avx2_9:
6688366899
movq $0x01, %r14
6688466900
movq $0x01, %rax
6688566901
movd %edx, %xmm13
66902+
#ifndef SP_ALIGN_16
6688666903
addq $0x1b8, %rsi
66904+
#else
66905+
addq $0x1c0, %rsi
66906+
#endif /* !SP_ALIGN_16 */
6688766907
movd %eax, %xmm15
6688866908
movq $32, %rax
6688966909
vpxor %ymm14, %ymm14, %ymm14
@@ -66916,7 +66936,11 @@ L_521_get_point_33_avx2_9_start:
6691666936
movq 64(%rsi), %r11
6691766937
movq 208(%rsi), %r12
6691866938
movq 352(%rsi), %r13
66939+
#ifndef SP_ALIGN_16
6691966940
addq $0x1b8, %rsi
66941+
#else
66942+
addq $0x1c0, %rsi
66943+
#endif /* !SP_ALIGN_16 */
6692066944
vpand %ymm12, %ymm6, %ymm6
6692166945
vpand %ymm12, %ymm7, %ymm7
6692266946
vpand %ymm12, %ymm8, %ymm8

wolfcrypt/src/sp_x86_64_asm.asm

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65067,7 +65067,11 @@ sp_521_get_point_33_9 PROC
6506765067
mov r14, 1
6506865068
mov rax, 1
6506965069
movd xmm13, r8d
65070+
IFNDEF SP_ALIGN_16
6507065071
add rdx, 440
65072+
ELSE
65073+
add rdx, 448
65074+
ENDIF
6507165075
movd xmm15, eax
6507265076
mov rax, 32
6507365077
pshufd xmm15, xmm15, 0
@@ -65098,7 +65102,11 @@ L_521_get_point_33_9_start_1:
6509865102
mov r10, QWORD PTR [rdx+64]
6509965103
movdqu xmm10, OWORD PTR [rdx+144]
6510065104
movdqu xmm11, OWORD PTR [rdx+160]
65105+
IFNDEF SP_ALIGN_16
6510165106
add rdx, 440
65107+
ELSE
65108+
add rdx, 448
65109+
ENDIF
6510265110
pand xmm6, xmm12
6510365111
pand xmm7, xmm12
6510465112
pand xmm8, xmm12
@@ -65125,7 +65133,11 @@ L_521_get_point_33_9_start_1:
6512565133
mov r14, 1
6512665134
mov rax, 1
6512765135
movd xmm13, r8d
65136+
IFNDEF SP_ALIGN_16
6512865137
sub rdx, 14080
65138+
ELSE
65139+
sub rdx, 112640
65140+
ENDIF
6512965141
movd xmm15, eax
6513065142
mov rax, 32
6513165143
pshufd xmm15, xmm15, 0
@@ -65157,7 +65169,11 @@ L_521_get_point_33_9_start_2:
6515765169
movdqu xmm10, OWORD PTR [rdx+320]
6515865170
movdqu xmm11, OWORD PTR [rdx+336]
6515965171
mov r11, QWORD PTR [rdx+352]
65172+
IFNDEF SP_ALIGN_16
6516065173
add rdx, 440
65174+
ELSE
65175+
add rdx, 448
65176+
ENDIF
6516165177
pand xmm6, xmm12
6516265178
pand xmm7, xmm12
6516365179
pand xmm8, xmm12
@@ -65229,7 +65245,11 @@ sp_521_get_point_33_avx2_9 PROC
6522965245
mov rdi, 1
6523065246
mov rax, 1
6523165247
movd xmm13, r8d
65248+
IFNDEF SP_ALIGN_16
6523265249
add rdx, 440
65250+
ELSE
65251+
add rdx, 448
65252+
ENDIF
6523365253
movd xmm15, eax
6523465254
mov rax, 32
6523565255
vpxor ymm14, ymm14, ymm14
@@ -65262,7 +65282,11 @@ L_521_get_point_33_avx2_9_start:
6526265282
mov r13, QWORD PTR [rdx+64]
6526365283
mov r14, QWORD PTR [rdx+208]
6526465284
mov r15, QWORD PTR [rdx+352]
65285+
IFNDEF SP_ALIGN_16
6526565286
add rdx, 440
65287+
ELSE
65288+
add rdx, 448
65289+
ENDIF
6526665290
vpand ymm6, ymm6, ymm12
6526765291
vpand ymm7, ymm7, ymm12
6526865292
vpand ymm8, ymm8, ymm12

0 commit comments

Comments
 (0)