Skip to content

Commit

Permalink
more consistency with openssl for ASM
Browse files Browse the repository at this point in the history
  • Loading branch information
jakemas committed Sep 12, 2024
1 parent a8c5c5d commit ef1949c
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 53 deletions.
25 changes: 12 additions & 13 deletions crypto/fipsmodule/sha/asm/keccak1600-armv8.pl
Original file line number Diff line number Diff line change
Expand Up @@ -458,27 +458,26 @@
mov $out,x1
mov $len,x2
mov $bsz,x3
cmp x4, #0
bne .Lfirst_squeeze // if (first != 0) -> first block -> skip first Keccak
.Loop_squeeze: // Squeeze loop (Keccak & Store)
mov x0,$A_flat
bl KeccakF1600
.Lfirst_squeeze:
mov x0,$A_flat
mov x3,$bsz
.L_squeeze: // Store loop
cmp x4, #0 // x4 = 'next' argument
bne .Lnext_block
.Loop_squeeze:
ldr x4,[x0],#8
cmp $len,#8
blo .Lsqueeze_tail // Store tail only
blo .Lsqueeze_tail
#ifdef __AARCH64EB__
rev x4,x4
#endif
str x4,[$out],#8
subs $len,$len,#8
ble .Lsqueeze_done
beq .Lsqueeze_done
subs x3,x3,#8
bhi .L_squeeze // End store loop
b .Loop_squeeze // End Squeeze loop (Keccak & Store)
bhi .Loop_squeeze
.Lnext_block:
mov x0,$A_flat
bl KeccakF1600
mov x0,$A_flat
mov x3,$bsz
b .Loop_squeeze
.align 4
.Lsqueeze_tail:
strb w4,[$out],#1
Expand Down
2 changes: 1 addition & 1 deletion crypto/fipsmodule/sha/sha3.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int SHA3_Final(uint8_t *md, KECCAK1600_CTX *ctx) {
}
}

SHA3_Squeeze(ctx->A, md, ctx->md_size, block_size, !(ctx->padded));
SHA3_Squeeze(ctx->A, md, ctx->md_size, block_size, ctx->padded);
ctx->padded = 1;

FIPS_service_indicator_update_state();
Expand Down
25 changes: 12 additions & 13 deletions generated-src/ios-aarch64/crypto/fipsmodule/keccak1600-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -489,27 +489,26 @@ _SHA3_Squeeze_hw:
mov x20,x1
mov x21,x2
mov x22,x3
cmp x4, #0
bne Lfirst_squeeze // if (first != 0) -> first block -> skip first Keccak
Loop_squeeze: // Squeeze loop (Keccak & Store)
mov x0,x19
bl KeccakF1600
Lfirst_squeeze:
mov x0,x19
mov x3,x22
L_squeeze: // Store loop
cmp x4, #0 // x4 = 'next' argument
bne Lnext_block
Loop_squeeze:
ldr x4,[x0],#8
cmp x21,#8
blo Lsqueeze_tail // Store tail only
blo Lsqueeze_tail
#ifdef __AARCH64EB__
rev x4,x4
#endif
str x4,[x20],#8
subs x21,x21,#8
ble Lsqueeze_done
beq Lsqueeze_done
subs x3,x3,#8
bhi L_squeeze // End store loop
b Loop_squeeze // End Squeeze loop (Keccak & Store)
bhi Loop_squeeze
Lnext_block:
mov x0,x19
bl KeccakF1600
mov x0,x19
mov x3,x22
b Loop_squeeze
.align 4
Lsqueeze_tail:
strb w4,[x20],#1
Expand Down
25 changes: 12 additions & 13 deletions generated-src/linux-aarch64/crypto/fipsmodule/keccak1600-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -489,27 +489,26 @@ SHA3_Squeeze_hw:
mov x20,x1
mov x21,x2
mov x22,x3
cmp x4, #0
bne .Lfirst_squeeze // if (first != 0) -> first block -> skip first Keccak
.Loop_squeeze: // Squeeze loop (Keccak & Store)
mov x0,x19
bl KeccakF1600
.Lfirst_squeeze:
mov x0,x19
mov x3,x22
.L_squeeze: // Store loop
cmp x4, #0 // x4 = 'next' argument
bne .Lnext_block
.Loop_squeeze:
ldr x4,[x0],#8
cmp x21,#8
blo .Lsqueeze_tail // Store tail only
blo .Lsqueeze_tail
#ifdef __AARCH64EB__
rev x4,x4
#endif
str x4,[x20],#8
subs x21,x21,#8
ble .Lsqueeze_done
beq .Lsqueeze_done
subs x3,x3,#8
bhi .L_squeeze // End store loop
b .Loop_squeeze // End Squeeze loop (Keccak & Store)
bhi .Loop_squeeze
.Lnext_block:
mov x0,x19
bl KeccakF1600
mov x0,x19
mov x3,x22
b .Loop_squeeze
.align 4
.Lsqueeze_tail:
strb w4,[x20],#1
Expand Down
25 changes: 12 additions & 13 deletions generated-src/win-aarch64/crypto/fipsmodule/keccak1600-armv8.S
Original file line number Diff line number Diff line change
Expand Up @@ -497,27 +497,26 @@ SHA3_Squeeze_hw:
mov x20,x1
mov x21,x2
mov x22,x3
cmp x4, #0
bne Lfirst_squeeze // if (first != 0) -> first block -> skip first Keccak
Loop_squeeze: // Squeeze loop (Keccak & Store)
mov x0,x19
bl KeccakF1600
Lfirst_squeeze:
mov x0,x19
mov x3,x22
L_squeeze: // Store loop
cmp x4, #0 // x4 = 'next' argument
bne Lnext_block
Loop_squeeze:
ldr x4,[x0],#8
cmp x21,#8
blo Lsqueeze_tail // Store tail only
blo Lsqueeze_tail
#ifdef __AARCH64EB__
rev x4,x4
#endif
str x4,[x20],#8
subs x21,x21,#8
ble Lsqueeze_done
beq Lsqueeze_done
subs x3,x3,#8
bhi L_squeeze // End store loop
b Loop_squeeze // End Squeeze loop (Keccak & Store)
bhi Loop_squeeze
Lnext_block:
mov x0,x19
bl KeccakF1600
mov x0,x19
mov x3,x22
b Loop_squeeze
.align 4
Lsqueeze_tail:
strb w4,[x20],#1
Expand Down

0 comments on commit ef1949c

Please sign in to comment.