diff options
author | jsing <> | 2025-02-14 12:01:58 +0000 |
---|---|---|
committer | jsing <> | 2025-02-14 12:01:58 +0000 |
commit | 55a1827d4b1706532809a68f02c30336000e01a9 (patch) | |
tree | 606af9a8caef4eada19e055b0a35e755d199b0d1 /src/lib/libcrypto/sha/sha512.c | |
parent | aee4d44b17e8fc57dfaadf57efabb128712c9f72 (diff) | |
download | openbsd-55a1827d4b1706532809a68f02c30336000e01a9.tar.gz openbsd-55a1827d4b1706532809a68f02c30336000e01a9.tar.bz2 openbsd-55a1827d4b1706532809a68f02c30336000e01a9.zip |
Replace Makefile based SHA*_ASM defines with HAVE_SHA_* defines.
Currently, SHA{1,256,512}_ASM defines are used to remove the C
implementation of sha{1,256,512}_block_data_order() when it is provided
by assembly. However, this prevents the C implementation from being used
as a fallback.
Rename the C sha*_block_data_order() to sha*_block_generic() and provide
a sha*_block_data_order() that calls sha*_block_generic(). Replace the
Makefile based SHA*_ASM defines with two HAVE_SHA_* defines that allow
these functions to be compiled in or removed, such that machine specific
verisons can be provided. This should effectively be a no-op on any
platform that defined SHA{1,256,512}_ASM.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/sha/sha512.c')
-rw-r--r-- | src/lib/libcrypto/sha/sha512.c | 20 |
1 files changed, 13 insertions, 7 deletions
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. */ |
70 | CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t)); | 70 | CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t)); |
71 | 71 | ||
72 | #ifdef SHA512_ASM | ||
73 | void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); | 72 | void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); |
74 | #endif | 73 | void sha512_block_generic(SHA512_CTX *ctx, const void *in, size_t num); |
75 | 74 | ||
76 | #ifndef SHA512_ASM | 75 | #ifndef HAVE_SHA512_BLOCK_GENERIC |
77 | static const SHA_LONG64 K512[80] = { | 76 | static 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 | ||
185 | static void | 184 | void |
186 | sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) | 185 | sha512_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 |
309 | void | ||
310 | sha512_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 | ||
310 | int | 316 | int |
311 | SHA384_Init(SHA512_CTX *c) | 317 | SHA384_Init(SHA512_CTX *c) |