diff options
author | jsing <> | 2025-04-18 07:19:48 +0000 |
---|---|---|
committer | jsing <> | 2025-04-18 07:19:48 +0000 |
commit | 3866042aa772f2eec2b15cbdc9b65a1a8ac2f3f4 (patch) | |
tree | f1389cd7c0ca9845fbcaa67887ee41e1b6e266a0 /src | |
parent | 6f34b1f56143bc41374d32f1ad51d79d41501431 (diff) | |
download | openbsd-3866042aa772f2eec2b15cbdc9b65a1a8ac2f3f4.tar.gz openbsd-3866042aa772f2eec2b15cbdc9b65a1a8ac2f3f4.tar.bz2 openbsd-3866042aa772f2eec2b15cbdc9b65a1a8ac2f3f4.zip |
Use crypto_rol_u64() instead of a separate ROTL64 define.
ok tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/sha/sha3.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/lib/libcrypto/sha/sha3.c b/src/lib/libcrypto/sha/sha3.c index 6a7196d582..4611ef0001 100644 --- a/src/lib/libcrypto/sha/sha3.c +++ b/src/lib/libcrypto/sha/sha3.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sha3.c,v 1.16 2024/11/23 15:38:12 jsing Exp $ */ | 1 | /* $OpenBSD: sha3.c,v 1.17 2025/04/18 07:19:48 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * The MIT License (MIT) | 3 | * The MIT License (MIT) |
4 | * | 4 | * |
@@ -26,12 +26,11 @@ | |||
26 | #include <endian.h> | 26 | #include <endian.h> |
27 | #include <string.h> | 27 | #include <string.h> |
28 | 28 | ||
29 | #include "crypto_internal.h" | ||
29 | #include "sha3_internal.h" | 30 | #include "sha3_internal.h" |
30 | 31 | ||
31 | #define KECCAKF_ROUNDS 24 | 32 | #define KECCAKF_ROUNDS 24 |
32 | 33 | ||
33 | #define ROTL64(x, y) (((x) << (y)) | ((x) >> (64 - (y)))) | ||
34 | |||
35 | static const uint64_t sha3_keccakf_rndc[24] = { | 34 | static const uint64_t sha3_keccakf_rndc[24] = { |
36 | 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, | 35 | 0x0000000000000001, 0x0000000000008082, 0x800000000000808a, |
37 | 0x8000000080008000, 0x000000000000808b, 0x0000000080000001, | 36 | 0x8000000080008000, 0x000000000000808b, 0x0000000080000001, |
@@ -67,7 +66,7 @@ sha3_keccakf(uint64_t st[25]) | |||
67 | bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] ^ st[i + 15] ^ st[i + 20]; | 66 | bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] ^ st[i + 15] ^ st[i + 20]; |
68 | 67 | ||
69 | for (i = 0; i < 5; i++) { | 68 | for (i = 0; i < 5; i++) { |
70 | t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1); | 69 | t = bc[(i + 4) % 5] ^ crypto_rol_u64(bc[(i + 1) % 5], 1); |
71 | for (j = 0; j < 25; j += 5) | 70 | for (j = 0; j < 25; j += 5) |
72 | st[j + i] ^= t; | 71 | st[j + i] ^= t; |
73 | } | 72 | } |
@@ -77,7 +76,7 @@ sha3_keccakf(uint64_t st[25]) | |||
77 | for (i = 0; i < 24; i++) { | 76 | for (i = 0; i < 24; i++) { |
78 | j = sha3_keccakf_piln[i]; | 77 | j = sha3_keccakf_piln[i]; |
79 | bc[0] = st[j]; | 78 | bc[0] = st[j]; |
80 | st[j] = ROTL64(t, sha3_keccakf_rotc[i]); | 79 | st[j] = crypto_rol_u64(t, sha3_keccakf_rotc[i]); |
81 | t = bc[0]; | 80 | t = bc[0]; |
82 | } | 81 | } |
83 | 82 | ||