summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2024-03-28 08:33:14 +0000
committerjsing <>2024-03-28 08:33:14 +0000
commit1e741e76201fe09a0aacb60e858e040d166e899e (patch)
tree3efad2bbd2ffd4e1a5330f34a440e9d7425ace21
parent8d7ad3a370412e51dd43ef467691fdb315012e2e (diff)
downloadopenbsd-1e741e76201fe09a0aacb60e858e040d166e899e.tar.gz
openbsd-1e741e76201fe09a0aacb60e858e040d166e899e.tar.bz2
openbsd-1e741e76201fe09a0aacb60e858e040d166e899e.zip
Inline initial hash values.
-rw-r--r--src/lib/libcrypto/sm3/sm3.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/lib/libcrypto/sm3/sm3.c b/src/lib/libcrypto/sm3/sm3.c
index d98288a670..2b3a8e3728 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.12 2024/03/28 08:31:11 jsing Exp $ */ 1/* $OpenBSD: sm3.c,v 1.13 2024/03/28 08:33:14 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, Ribose Inc 3 * Copyright (c) 2018, Ribose Inc
4 * 4 *
@@ -72,15 +72,6 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data);
72#define R2(A, B, C, D, E, F, G, H, TJ, Wi, Wj) \ 72#define R2(A, B, C, D, E, F, G, H, TJ, Wi, Wj) \
73 ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF1, GG1) 73 ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF1, GG1)
74 74
75#define SM3_A 0x7380166fUL
76#define SM3_B 0x4914b2b9UL
77#define SM3_C 0x172442d7UL
78#define SM3_D 0xda8a0600UL
79#define SM3_E 0xa96f30bcUL
80#define SM3_F 0x163138aaUL
81#define SM3_G 0xe38dee4dUL
82#define SM3_H 0xb0fb0e4eUL
83
84void 75void
85SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num) 76SM3_block_data_order(SM3_CTX *ctx, const void *p, size_t num)
86{ 77{
@@ -252,14 +243,16 @@ int
252SM3_Init(SM3_CTX *c) 243SM3_Init(SM3_CTX *c)
253{ 244{
254 memset(c, 0, sizeof(*c)); 245 memset(c, 0, sizeof(*c));
255 c->A = SM3_A; 246
256 c->B = SM3_B; 247 c->A = 0x7380166fUL;
257 c->C = SM3_C; 248 c->B = 0x4914b2b9UL;
258 c->D = SM3_D; 249 c->C = 0x172442d7UL;
259 c->E = SM3_E; 250 c->D = 0xda8a0600UL;
260 c->F = SM3_F; 251 c->E = 0xa96f30bcUL;
261 c->G = SM3_G; 252 c->F = 0x163138aaUL;
262 c->H = SM3_H; 253 c->G = 0xe38dee4dUL;
254 c->H = 0xb0fb0e4eUL;
255
263 return 1; 256 return 1;
264} 257}
265LCRYPTO_ALIAS(SM3_Init); 258LCRYPTO_ALIAS(SM3_Init);