summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2024-03-28 12:04:38 +0000
committerjsing <>2024-03-28 12:04:38 +0000
commit3ac703c88a06e302eee3cb0925d470f72868c66c (patch)
tree38e6eb1d98f2bb909f426f483b352fd767d9133c /src/lib
parent6207482ac6552e6d48b760a595a698165cc21046 (diff)
downloadopenbsd-3ac703c88a06e302eee3cb0925d470f72868c66c.tar.gz
openbsd-3ac703c88a06e302eee3cb0925d470f72868c66c.tar.bz2
openbsd-3ac703c88a06e302eee3cb0925d470f72868c66c.zip
Rename SM3_block_data_order() and make static.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/sm3/sm3.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/lib/libcrypto/sm3/sm3.c b/src/lib/libcrypto/sm3/sm3.c
index 615a5c8a07..9cbda402ac 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.15 2024/03/28 11:22:58 jsing Exp $ */ 1/* $OpenBSD: sm3.c,v 1.16 2024/03/28 12:04:38 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018, Ribose Inc 3 * Copyright (c) 2018, Ribose Inc
4 * 4 *
@@ -28,7 +28,6 @@ CTASSERT(sizeof(SM3_WORD) == sizeof(uint32_t));
28 28
29#ifndef OPENSSL_NO_SM3 29#ifndef OPENSSL_NO_SM3
30 30
31void SM3_block_data_order(SM3_CTX *c, const void *p, size_t num);
32void SM3_transform(SM3_CTX *c, const unsigned char *data); 31void SM3_transform(SM3_CTX *c, const unsigned char *data);
33 32
34#define P0(X) (X ^ crypto_rol_u32(X, 9) ^ crypto_rol_u32(X, 17)) 33#define P0(X) (X ^ crypto_rol_u32(X, 9) ^ crypto_rol_u32(X, 17))
@@ -61,8 +60,8 @@ void SM3_transform(SM3_CTX *c, const unsigned char *data);
61#define R2(A, B, C, D, E, F, G, H, TJ, Wi, Wj) \ 60#define R2(A, B, C, D, E, F, G, H, TJ, Wi, Wj) \
62 ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF1, GG1) 61 ROUND(A, B, C, D, E, F, G, H, TJ, Wi, Wj, FF1, GG1)
63 62
64void 63static void
65SM3_block_data_order(SM3_CTX *ctx, const void *_in, size_t num) 64sm3_block_data_order(SM3_CTX *ctx, const void *_in, size_t num)
66{ 65{
67 const uint8_t *in = _in; 66 const uint8_t *in = _in;
68 const SM3_WORD *in32; 67 const SM3_WORD *in32;
@@ -295,7 +294,7 @@ SM3_Update(SM3_CTX *c, const void *data_, size_t len)
295 294
296 if (len >= SM3_CBLOCK || len + n >= SM3_CBLOCK) { 295 if (len >= SM3_CBLOCK || len + n >= SM3_CBLOCK) {
297 memcpy(p + n, data, SM3_CBLOCK - n); 296 memcpy(p + n, data, SM3_CBLOCK - n);
298 SM3_block_data_order(c, p, 1); 297 sm3_block_data_order(c, p, 1);
299 n = SM3_CBLOCK - n; 298 n = SM3_CBLOCK - n;
300 data += n; 299 data += n;
301 len -= n; 300 len -= n;
@@ -310,7 +309,7 @@ SM3_Update(SM3_CTX *c, const void *data_, size_t len)
310 309
311 n = len / SM3_CBLOCK; 310 n = len / SM3_CBLOCK;
312 if (n > 0) { 311 if (n > 0) {
313 SM3_block_data_order(c, data, n); 312 sm3_block_data_order(c, data, n);
314 n *= SM3_CBLOCK; 313 n *= SM3_CBLOCK;
315 data += n; 314 data += n;
316 len -= n; 315 len -= n;
@@ -328,7 +327,7 @@ LCRYPTO_ALIAS(SM3_Update);
328void 327void
329SM3_Transform(SM3_CTX *c, const unsigned char *data) 328SM3_Transform(SM3_CTX *c, const unsigned char *data)
330{ 329{
331 SM3_block_data_order(c, data, 1); 330 sm3_block_data_order(c, data, 1);
332} 331}
333 332
334int 333int
@@ -343,14 +342,14 @@ SM3_Final(unsigned char *md, SM3_CTX *c)
343 if (n > (SM3_CBLOCK - 8)) { 342 if (n > (SM3_CBLOCK - 8)) {
344 memset(p + n, 0, SM3_CBLOCK - n); 343 memset(p + n, 0, SM3_CBLOCK - n);
345 n = 0; 344 n = 0;
346 SM3_block_data_order(c, p, 1); 345 sm3_block_data_order(c, p, 1);
347 } 346 }
348 347
349 memset(p + n, 0, SM3_CBLOCK - 8 - n); 348 memset(p + n, 0, SM3_CBLOCK - 8 - n);
350 c->data[SM3_LBLOCK - 2] = htobe32(c->Nh); 349 c->data[SM3_LBLOCK - 2] = htobe32(c->Nh);
351 c->data[SM3_LBLOCK - 1] = htobe32(c->Nl); 350 c->data[SM3_LBLOCK - 1] = htobe32(c->Nl);
352 351
353 SM3_block_data_order(c, p, 1); 352 sm3_block_data_order(c, p, 1);
354 c->num = 0; 353 c->num = 0;
355 memset(p, 0, SM3_CBLOCK); 354 memset(p, 0, SM3_CBLOCK);
356 355