Skip to content

Commit

Permalink
Take other part of fix
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Feb 28, 2024
1 parent ee0887a commit 1d7fc9f
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 9 deletions.
19 changes: 16 additions & 3 deletions crypto/fipsmodule/sha/asm/sha256-armv4.pl
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ sub BODY_16_XX {
ldr r12,[r12]
#endif
tst r12,#ARMV8_SHA256
bne .LARMv8
bne .LK256_add_armv8
tst r12,#ARMV7_NEON
bne .LNEON
#endif
Expand Down Expand Up @@ -639,12 +639,25 @@ ()
# define INST(a,b,c,d) .byte a,b,c,d
# endif
.LK256_shortcut_armv8:
@ PC is 8 bytes ahead in Arm mode and 4 bytes ahead in Thumb mode.
#if defined(__thumb2__)
.word K256-(.LK256_add_armv8+4)
#else
.word K256-(.LK256_add_armv8+8)
#endif
.type sha256_block_data_order_armv8,%function
.align 5
sha256_block_data_order_armv8:
.LARMv8:
@ K256 is too far to reference from one ADR command in Thumb mode. In
@ Arm mode, we could make it fit by aligning the ADR offset to a 64-byte
@ boundary. For simplicity, just load the offset from .LK256_shortcut_armv8.
ldr $Ktbl,.LK256_shortcut_armv8
.LK256_add_armv8:
add $Ktbl,pc,$Ktbl
vld1.32 {$ABCD,$EFGH},[$ctx]
sub $Ktbl,$Ktbl,#256+32
add $len,$inp,$len,lsl#6 @ len to point at the end of inp
b .Loop_v8
Expand Down
19 changes: 16 additions & 3 deletions generated-src/ios-arm/crypto/fipsmodule/sha256-armv4.S
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Lsha256_block_data_order:
ldr r12,[r12]
#endif
tst r12,#ARMV8_SHA256
bne LARMv8
bne LK256_add_armv8
tst r12,#ARMV7_NEON
bne LNEON
#endif
Expand Down Expand Up @@ -2705,14 +2705,27 @@ L_00_48:
# define INST(a,b,c,d) .byte a,b,c,d
# endif

LK256_shortcut_armv8:
@ PC is 8 bytes ahead in Arm mode and 4 bytes ahead in Thumb mode.
#if defined(__thumb2__)
.word K256-(LK256_add_armv8+4)
#else
.word K256-(LK256_add_armv8+8)
#endif

#ifdef __thumb2__
.thumb_func sha256_block_data_order_armv8
#endif
.align 5
sha256_block_data_order_armv8:
LARMv8:
@ K256 is too far to reference from one ADR command in Thumb mode. In
@ Arm mode, we could make it fit by aligning the ADR offset to a 64-byte
@ boundary. For simplicity, just load the offset from .LK256_shortcut_armv8.
ldr r3,LK256_shortcut_armv8
LK256_add_armv8:
add r3,pc,r3

vld1.32 {q0,q1},[r0]
sub r3,r3,#256+32
add r2,r1,r2,lsl#6 @ len to point at the end of inp
b Loop_v8

Expand Down
19 changes: 16 additions & 3 deletions generated-src/linux-arm/crypto/fipsmodule/sha256-armv4.S
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ sha256_block_data_order:
ldr r12,[r12]
#endif
tst r12,#ARMV8_SHA256
bne .LARMv8
bne .LK256_add_armv8
tst r12,#ARMV7_NEON
bne .LNEON
#endif
Expand Down Expand Up @@ -2701,12 +2701,25 @@ sha256_block_data_order_neon:
# define INST(a,b,c,d) .byte a,b,c,d
# endif

.LK256_shortcut_armv8:
@ PC is 8 bytes ahead in Arm mode and 4 bytes ahead in Thumb mode.
#if defined(__thumb2__)
.word K256-(.LK256_add_armv8+4)
#else
.word K256-(.LK256_add_armv8+8)
#endif

.type sha256_block_data_order_armv8,%function
.align 5
sha256_block_data_order_armv8:
.LARMv8:
@ K256 is too far to reference from one ADR command in Thumb mode. In
@ Arm mode, we could make it fit by aligning the ADR offset to a 64-byte
@ boundary. For simplicity, just load the offset from .LK256_shortcut_armv8.
ldr r3,.LK256_shortcut_armv8
.LK256_add_armv8:
add r3,pc,r3

vld1.32 {q0,q1},[r0]
sub r3,r3,#256+32
add r2,r1,r2,lsl#6 @ len to point at the end of inp
b .Loop_v8

Expand Down

0 comments on commit 1d7fc9f

Please sign in to comment.