diff options
author | jsing <> | 2024-03-28 08:37:03 +0000 |
---|---|---|
committer | jsing <> | 2024-03-28 08:37:03 +0000 |
commit | ee0f90420eb2f8c6d285d232e26748d0b8dc727a (patch) | |
tree | 045594dce4747e607c9dccc7eedac98031efcfe7 | |
parent | 72a12f4c37ca1feaa60b3a86de5fbb823b79cd57 (diff) | |
download | openbsd-ee0f90420eb2f8c6d285d232e26748d0b8dc727a.tar.gz openbsd-ee0f90420eb2f8c6d285d232e26748d0b8dc727a.tar.bz2 openbsd-ee0f90420eb2f8c6d285d232e26748d0b8dc727a.zip |
Expand ROTATE macro to crypto_rol_u32().
-rw-r--r-- | src/lib/libcrypto/sm3/sm3.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/lib/libcrypto/sm3/sm3.c b/src/lib/libcrypto/sm3/sm3.c index 2b3a8e3728..d3c7c5b2ea 100644 --- a/src/lib/libcrypto/sm3/sm3.c +++ b/src/lib/libcrypto/sm3/sm3.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sm3.c,v 1.13 2024/03/28 08:33:14 jsing Exp $ */ | 1 | /* $OpenBSD: sm3.c,v 1.14 2024/03/28 08:37:03 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2018, Ribose Inc | 3 | * Copyright (c) 2018, Ribose Inc |
4 | * | 4 | * |
@@ -21,6 +21,8 @@ | |||
21 | 21 | ||
22 | #include <openssl/sm3.h> | 22 | #include <openssl/sm3.h> |
23 | 23 | ||
24 | #include "crypto_internal.h" | ||
25 | |||
24 | #ifndef OPENSSL_NO_SM3 | 26 | #ifndef OPENSSL_NO_SM3 |
25 | 27 | ||
26 | #define DATA_ORDER_IS_BIG_ENDIAN | 28 | #define DATA_ORDER_IS_BIG_ENDIAN |
@@ -42,8 +44,8 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data); | |||
42 | 44 | ||
43 | #include "md32_common.h" | 45 | #include "md32_common.h" |
44 | 46 | ||
45 | #define P0(X) (X ^ ROTATE(X, 9) ^ ROTATE(X, 17)) | 47 | #define P0(X) (X ^ crypto_rol_u32(X, 9) ^ crypto_rol_u32(X, 17)) |
46 | #define P1(X) (X ^ ROTATE(X, 15) ^ ROTATE(X, 23)) | 48 | #define P1(X) (X ^ crypto_rol_u32(X, 15) ^ crypto_rol_u32(X, 23)) |
47 | 49 | ||
48 | #define FF0(X, Y, Z) (X ^ Y ^ Z) | 50 | #define FF0(X, Y, Z) (X ^ Y ^ Z) |
49 | #define GG0(X, Y, Z) (X ^ Y ^ Z) | 51 | #define GG0(X, Y, Z) (X ^ Y ^ Z) |
@@ -52,17 +54,17 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data); | |||
52 | #define GG1(X, Y, Z) ((Z ^ (X & (Y ^ Z)))) | 54 | #define GG1(X, Y, Z) ((Z ^ (X & (Y ^ Z)))) |
53 | 55 | ||
54 | #define EXPAND(W0, W7, W13, W3, W10) \ | 56 | #define EXPAND(W0, W7, W13, W3, W10) \ |
55 | (P1(W0 ^ W7 ^ ROTATE(W13, 15)) ^ ROTATE(W3, 7) ^ W10) | 57 | (P1(W0 ^ W7 ^ crypto_rol_u32(W13, 15)) ^ crypto_rol_u32(W3, 7) ^ W10) |
56 | 58 | ||
57 | #define ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) do { \ | 59 | #define ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF, GG) do { \ |
58 | const SM3_WORD A12 = ROTATE(A, 12); \ | 60 | const SM3_WORD A12 = crypto_rol_u32(A, 12); \ |
59 | const SM3_WORD A12_SM = A12 + E + TJ; \ | 61 | const SM3_WORD A12_SM = A12 + E + TJ; \ |
60 | const SM3_WORD SS1 = ROTATE(A12_SM, 7); \ | 62 | const SM3_WORD SS1 = crypto_rol_u32(A12_SM, 7); \ |
61 | const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \ | 63 | const SM3_WORD TT1 = FF(A, B, C) + D + (SS1 ^ A12) + (Wj); \ |
62 | const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \ | 64 | const SM3_WORD TT2 = GG(E, F, G) + H + SS1 + Wi; \ |
63 | B = ROTATE(B, 9); \ | 65 | B = crypto_rol_u32(B, 9); \ |
64 | D = TT1; \ | 66 | D = TT1; \ |
65 | F = ROTATE(F, 19); \ | 67 | F = crypto_rol_u32(F, 19); \ |
66 | H = P0(TT2); \ | 68 | H = P0(TT2); \ |
67 | } while(0) | 69 | } while(0) |
68 | 70 | ||