summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/sha
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/sha')
-rw-r--r--src/lib/libcrypto/sha/sha1.c19
-rw-r--r--src/lib/libcrypto/sha/sha256.c21
-rw-r--r--src/lib/libcrypto/sha/sha512.c20
3 files changed, 40 insertions, 20 deletions
diff --git a/src/lib/libcrypto/sha/sha1.c b/src/lib/libcrypto/sha/sha1.c
index 52338812db..ab05709818 100644
--- a/src/lib/libcrypto/sha/sha1.c
+++ b/src/lib/libcrypto/sha/sha1.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha1.c,v 1.15 2024/06/01 07:36:16 tb Exp $ */ 1/* $OpenBSD: sha1.c,v 1.16 2025/02/14 12:01:58 jsing Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -71,11 +71,10 @@
71/* Ensure that SHA_LONG and uint32_t are equivalent sizes. */ 71/* Ensure that SHA_LONG and uint32_t are equivalent sizes. */
72CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t)); 72CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t));
73 73
74#ifdef SHA1_ASM
75void sha1_block_data_order(SHA_CTX *ctx, const void *p, size_t num); 74void sha1_block_data_order(SHA_CTX *ctx, const void *p, size_t num);
76#endif 75void sha1_block_generic(SHA_CTX *ctx, const void *p, size_t num);
77 76
78#ifndef SHA1_ASM 77#ifndef HAVE_SHA1_BLOCK_GENERIC
79static inline SHA_LONG 78static inline SHA_LONG
80Ch(SHA_LONG x, SHA_LONG y, SHA_LONG z) 79Ch(SHA_LONG x, SHA_LONG y, SHA_LONG z)
81{ 80{
@@ -164,8 +163,8 @@ sha1_round4(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e,
164 *a = T; 163 *a = T;
165} 164}
166 165
167static void 166void
168sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num) 167sha1_block_generic(SHA_CTX *ctx, const void *_in, size_t num)
169{ 168{
170 const uint8_t *in = _in; 169 const uint8_t *in = _in;
171 const SHA_LONG *in32; 170 const SHA_LONG *in32;
@@ -382,6 +381,14 @@ sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num)
382} 381}
383#endif 382#endif
384 383
384#ifndef HAVE_SHA1_BLOCK_DATA_ORDER
385void
386sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num)
387{
388 sha1_block_generic(ctx, _in, num);
389}
390#endif
391
385int 392int
386SHA1_Init(SHA_CTX *c) 393SHA1_Init(SHA_CTX *c)
387{ 394{
diff --git a/src/lib/libcrypto/sha/sha256.c b/src/lib/libcrypto/sha/sha256.c
index ab00c17878..5d002ca62c 100644
--- a/src/lib/libcrypto/sha/sha256.c
+++ b/src/lib/libcrypto/sha/sha256.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha256.c,v 1.32 2024/06/01 07:36:16 tb Exp $ */ 1/* $OpenBSD: sha256.c,v 1.33 2025/02/14 12:01:58 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -68,11 +68,10 @@
68/* Ensure that SHA_LONG and uint32_t are equivalent. */ 68/* Ensure that SHA_LONG and uint32_t are equivalent. */
69CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t)); 69CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t));
70 70
71#ifdef SHA256_ASM
72void sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num); 71void sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num);
73#endif 72void sha256_block_generic(SHA256_CTX *ctx, const void *_in, size_t num);
74 73
75#ifndef SHA256_ASM 74#ifndef HAVE_SHA256_BLOCK_GENERIC
76static const SHA_LONG K256[64] = { 75static const SHA_LONG K256[64] = {
77 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 76 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL,
78 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 77 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL,
@@ -155,8 +154,8 @@ sha256_round(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e,
155 *a = T1 + T2; 154 *a = T1 + T2;
156} 155}
157 156
158static void 157void
159sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) 158sha256_block_generic(SHA256_CTX *ctx, const void *_in, size_t num)
160{ 159{
161 const uint8_t *in = _in; 160 const uint8_t *in = _in;
162 const SHA_LONG *in32; 161 const SHA_LONG *in32;
@@ -277,7 +276,15 @@ sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num)
277 ctx->h[7] += h; 276 ctx->h[7] += h;
278 } 277 }
279} 278}
280#endif /* SHA256_ASM */ 279#endif
280
281#ifndef HAVE_SHA256_BLOCK_DATA_ORDER
282void
283sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num)
284{
285 sha256_block_generic(ctx, _in, num);
286}
287#endif
281 288
282int 289int
283SHA224_Init(SHA256_CTX *c) 290SHA224_Init(SHA256_CTX *c)
diff --git a/src/lib/libcrypto/sha/sha512.c b/src/lib/libcrypto/sha/sha512.c
index 7a2a40d3df..43d25eb119 100644
--- a/src/lib/libcrypto/sha/sha512.c
+++ b/src/lib/libcrypto/sha/sha512.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sha512.c,v 1.42 2024/06/01 07:36:16 tb Exp $ */ 1/* $OpenBSD: sha512.c,v 1.43 2025/02/14 12:01:58 jsing Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -69,11 +69,10 @@
69/* Ensure that SHA_LONG64 and uint64_t are equivalent. */ 69/* Ensure that SHA_LONG64 and uint64_t are equivalent. */
70CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t)); 70CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t));
71 71
72#ifdef SHA512_ASM
73void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); 72void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num);
74#endif 73void sha512_block_generic(SHA512_CTX *ctx, const void *in, size_t num);
75 74
76#ifndef SHA512_ASM 75#ifndef HAVE_SHA512_BLOCK_GENERIC
77static const SHA_LONG64 K512[80] = { 76static const SHA_LONG64 K512[80] = {
78 U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd), 77 U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd),
79 U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc), 78 U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc),
@@ -182,8 +181,8 @@ sha512_round(SHA_LONG64 *a, SHA_LONG64 *b, SHA_LONG64 *c, SHA_LONG64 *d,
182 *a = T1 + T2; 181 *a = T1 + T2;
183} 182}
184 183
185static void 184void
186sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) 185sha512_block_generic(SHA512_CTX *ctx, const void *_in, size_t num)
187{ 186{
188 const uint8_t *in = _in; 187 const uint8_t *in = _in;
189 const SHA_LONG64 *in64; 188 const SHA_LONG64 *in64;
@@ -304,8 +303,15 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num)
304 ctx->h[7] += h; 303 ctx->h[7] += h;
305 } 304 }
306} 305}
306#endif
307 307
308#endif /* SHA512_ASM */ 308#ifndef HAVE_SHA512_BLOCK_DATA_ORDER
309void
310sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num)
311{
312 sha512_block_generic(ctx, _in, num);
313}
314#endif
309 315
310int 316int
311SHA384_Init(SHA512_CTX *c) 317SHA384_Init(SHA512_CTX *c)