Skip to content

Commit f7f89b3

Browse files
authored
crypto.sha3: be big-endian friendly (#24045)
1 parent f2b90bf commit f7f89b3

File tree

1 file changed

+3
-15
lines changed

1 file changed

+3
-15
lines changed

vlib/crypto/sha3/sha3_state_generic.v

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,7 @@ fn (s State) to_bytes() []u8 {
3636
for y in 0 .. 5 {
3737
for x in 0 .. 5 {
3838
unsafe {
39-
$if little_endian {
40-
binary.little_endian_put_u64_at(mut byte_array, s.a[x][y], index)
41-
} $else {
42-
binary.big_endian_put_u64_at(mut byte_array, s.a[x][y], index)
43-
}
39+
binary.little_endian_put_u64_at(mut byte_array, s.a[x][y], index)
4440
}
4541
index += 8
4642
}
@@ -61,11 +57,7 @@ fn (mut s State) from_bytes(byte_array []u8) {
6157

6258
for y in 0 .. 5 {
6359
for x in 0 .. 5 {
64-
$if little_endian {
65-
s.a[x][y] = binary.little_endian_u64_at(byte_array, index)
66-
} $else {
67-
s.a[x][y] = binary.big_endian_u64_at(byte_array, index)
68-
}
60+
s.a[x][y] = binary.little_endian_u64_at(byte_array, index)
6961
index += 8
7062
}
7163
}
@@ -87,11 +79,7 @@ fn (mut s State) xor_bytes(byte_array []u8, rate int) {
8779

8880
for y in 0 .. 5 {
8981
for x in 0 .. 5 {
90-
$if little_endian {
91-
s.a[x][y] ^= binary.little_endian_u64_at(byte_array, index)
92-
} $else {
93-
s.a[x][y] ^= binary.big_endian_u64_at(byte_array, index)
94-
}
82+
s.a[x][y] ^= binary.little_endian_u64_at(byte_array, index)
9583
index += 8
9684

9785
if index >= rate {

0 commit comments

Comments
 (0)