From 55a1827d4b1706532809a68f02c30336000e01a9 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Fri, 14 Feb 2025 12:01:58 +0000 Subject: 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@ --- src/lib/libcrypto/arch/alpha/Makefile.inc | 3 +-- src/lib/libcrypto/arch/alpha/crypto_arch.h | 5 ++++- src/lib/libcrypto/arch/amd64/Makefile.inc | 5 +---- src/lib/libcrypto/arch/amd64/crypto_arch.h | 11 ++++++++++- src/lib/libcrypto/arch/arm/Makefile.inc | 3 --- src/lib/libcrypto/arch/arm/crypto_arch.h | 11 ++++++++++- src/lib/libcrypto/arch/hppa/Makefile.inc | 4 +--- src/lib/libcrypto/arch/hppa/crypto_arch.h | 8 +++++++- src/lib/libcrypto/arch/i386/Makefile.inc | 5 +---- src/lib/libcrypto/arch/i386/crypto_arch.h | 11 ++++++++++- src/lib/libcrypto/arch/mips64/Makefile.inc | 5 +---- src/lib/libcrypto/arch/mips64/crypto_arch.h | 11 ++++++++++- src/lib/libcrypto/arch/powerpc/Makefile.inc | 4 +--- src/lib/libcrypto/arch/powerpc/crypto_arch.h | 12 +++++++++++- src/lib/libcrypto/arch/powerpc64/Makefile.inc | 4 +--- src/lib/libcrypto/arch/sparc64/Makefile.inc | 5 +---- src/lib/libcrypto/arch/sparc64/crypto_arch.h | 11 ++++++++++- src/lib/libcrypto/sha/sha1.c | 19 +++++++++++++------ src/lib/libcrypto/sha/sha256.c | 21 ++++++++++++++------- src/lib/libcrypto/sha/sha512.c | 20 +++++++++++++------- 20 files changed, 120 insertions(+), 58 deletions(-) diff --git a/src/lib/libcrypto/arch/alpha/Makefile.inc b/src/lib/libcrypto/arch/alpha/Makefile.inc index 3e42c42f5e..1073ac3c1e 100644 --- a/src/lib/libcrypto/arch/alpha/Makefile.inc +++ b/src/lib/libcrypto/arch/alpha/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.14 2024/03/29 07:24:09 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.15 2025/02/14 12:01:58 jsing Exp $ # alpha-specific libcrypto build rules @@ -9,7 +9,6 @@ CFLAGS+= -DOPENSSL_BN_ASM_MONT CFLAGS+= -DGHASH_ASM SSLASM+= modes ghash-alpha # sha -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha1-alpha .for dir f in ${SSLASM} diff --git a/src/lib/libcrypto/arch/alpha/crypto_arch.h b/src/lib/libcrypto/arch/alpha/crypto_arch.h index a3dd98d0ce..1d553b7e07 100644 --- a/src/lib/libcrypto/arch/alpha/crypto_arch.h +++ b/src/lib/libcrypto/arch/alpha/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -18,4 +18,7 @@ #ifndef HEADER_CRYPTO_ARCH_H #define HEADER_CRYPTO_ARCH_H +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + #endif diff --git a/src/lib/libcrypto/arch/amd64/Makefile.inc b/src/lib/libcrypto/arch/amd64/Makefile.inc index f4410e8059..b1a6563931 100644 --- a/src/lib/libcrypto/arch/amd64/Makefile.inc +++ b/src/lib/libcrypto/arch/amd64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.36 2025/01/24 13:35:04 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.37 2025/02/14 12:01:58 jsing Exp $ # amd64-specific libcrypto build rules @@ -48,15 +48,12 @@ SSLASM+= modes ghash-x86_64 SSLASM+= rc4 rc4-x86_64 # ripemd # sha -CFLAGS+= -DSHA1_ASM SRCS+= sha1_amd64.c SRCS+= sha1_amd64_generic.S SRCS+= sha1_amd64_shani.S -CFLAGS+= -DSHA256_ASM SRCS+= sha256_amd64.c SRCS+= sha256_amd64_generic.S SRCS+= sha256_amd64_shani.S -CFLAGS+= -DSHA512_ASM SRCS+= sha512_amd64.c SRCS+= sha512_amd64_generic.S diff --git a/src/lib/libcrypto/arch/amd64/crypto_arch.h b/src/lib/libcrypto/arch/amd64/crypto_arch.h index 7546fb0dfd..951374250d 100644 --- a/src/lib/libcrypto/arch/amd64/crypto_arch.h +++ b/src/lib/libcrypto/arch/amd64/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.4 2024/11/16 13:05:35 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.5 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -40,6 +40,15 @@ extern uint64_t crypto_cpu_caps_amd64; #define HAVE_RC4_INTERNAL #define HAVE_RC4_SET_KEY_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#define HAVE_SHA512_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_GENERIC + #endif #endif diff --git a/src/lib/libcrypto/arch/arm/Makefile.inc b/src/lib/libcrypto/arch/arm/Makefile.inc index b09b54a564..e078c51d98 100644 --- a/src/lib/libcrypto/arch/arm/Makefile.inc +++ b/src/lib/libcrypto/arch/arm/Makefile.inc @@ -12,11 +12,8 @@ SSLASM+= bn armv4-mont CFLAGS+= -DGHASH_ASM SSLASM+= modes ghash-armv4 # sha -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha1-armv4-large -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha256-armv4 -CFLAGS+= -DSHA512_ASM SSLASM+= sha sha512-armv4 .for dir f in ${SSLASM} diff --git a/src/lib/libcrypto/arch/arm/crypto_arch.h b/src/lib/libcrypto/arch/arm/crypto_arch.h index 4276dc31ea..07d7829fe3 100644 --- a/src/lib/libcrypto/arch/arm/crypto_arch.h +++ b/src/lib/libcrypto/arch/arm/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -25,6 +25,15 @@ #define HAVE_AES_ENCRYPT_INTERNAL #define HAVE_AES_DECRYPT_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#define HAVE_SHA512_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_GENERIC + #endif #endif diff --git a/src/lib/libcrypto/arch/hppa/Makefile.inc b/src/lib/libcrypto/arch/hppa/Makefile.inc index 4e2675a600..11bfa4a5d3 100644 --- a/src/lib/libcrypto/arch/hppa/Makefile.inc +++ b/src/lib/libcrypto/arch/hppa/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.25 2024/08/11 13:02:39 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.26 2025/02/14 12:01:58 jsing Exp $ # hppa-specific libcrypto build rules @@ -12,9 +12,7 @@ CFLAGS+= -DOPENSSL_BN_ASM_MONT -DBN_DIV2W CFLAGS+= -DGHASH_ASM SSLASM+= modes ghash-parisc ghash-parisc # sha -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha1-parisc sha1-parisc -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha512-parisc sha256-parisc .for dir src dst in ${SSLASM} diff --git a/src/lib/libcrypto/arch/hppa/crypto_arch.h b/src/lib/libcrypto/arch/hppa/crypto_arch.h index 7f1fc36cac..08fcaca045 100644 --- a/src/lib/libcrypto/arch/hppa/crypto_arch.h +++ b/src/lib/libcrypto/arch/hppa/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -23,6 +23,12 @@ #define HAVE_AES_ENCRYPT_INTERNAL #define HAVE_AES_DECRYPT_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + #endif #endif diff --git a/src/lib/libcrypto/arch/i386/Makefile.inc b/src/lib/libcrypto/arch/i386/Makefile.inc index 2101304703..6989b35686 100644 --- a/src/lib/libcrypto/arch/i386/Makefile.inc +++ b/src/lib/libcrypto/arch/i386/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.26 2024/10/18 14:44:02 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.27 2025/02/14 12:01:58 jsing Exp $ # i386-specific libcrypto build rules @@ -28,11 +28,8 @@ SSLASM+= modes ghash-x86 # rc4 SSLASM+= rc4 rc4-586 # sha -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha1-586 -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha256-586 -CFLAGS+= -DSHA512_ASM SSLASM+= sha sha512-586 .for dir f in ${SSLASM} diff --git a/src/lib/libcrypto/arch/i386/crypto_arch.h b/src/lib/libcrypto/arch/i386/crypto_arch.h index 64b2da587b..3df3963d0b 100644 --- a/src/lib/libcrypto/arch/i386/crypto_arch.h +++ b/src/lib/libcrypto/arch/i386/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.3 2024/10/19 13:06:11 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.4 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -32,6 +32,15 @@ #define HAVE_RC4_INTERNAL #define HAVE_RC4_SET_KEY_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#define HAVE_SHA512_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_GENERIC + #endif #endif diff --git a/src/lib/libcrypto/arch/mips64/Makefile.inc b/src/lib/libcrypto/arch/mips64/Makefile.inc index 9e08b442ac..64e806289d 100644 --- a/src/lib/libcrypto/arch/mips64/Makefile.inc +++ b/src/lib/libcrypto/arch/mips64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.18 2024/08/11 13:02:39 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.19 2025/02/14 12:01:58 jsing Exp $ # mips64-specific libcrypto build rules @@ -11,11 +11,8 @@ SSLASM+= bn mips-mont mips-mont CFLAGS+= -DOPENSSL_BN_ASM_MONT # sha SSLASM+= sha sha1-mips sha1-mips -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha512-mips sha256-mips -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha512-mips sha512-mips -CFLAGS+= -DSHA512_ASM .for dir src dst in ${SSLASM} SRCS+= ${dst}.S diff --git a/src/lib/libcrypto/arch/mips64/crypto_arch.h b/src/lib/libcrypto/arch/mips64/crypto_arch.h index 4276dc31ea..07d7829fe3 100644 --- a/src/lib/libcrypto/arch/mips64/crypto_arch.h +++ b/src/lib/libcrypto/arch/mips64/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -25,6 +25,15 @@ #define HAVE_AES_ENCRYPT_INTERNAL #define HAVE_AES_DECRYPT_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#define HAVE_SHA512_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_GENERIC + #endif #endif diff --git a/src/lib/libcrypto/arch/powerpc/Makefile.inc b/src/lib/libcrypto/arch/powerpc/Makefile.inc index 6957abddaf..c5218e53f4 100644 --- a/src/lib/libcrypto/arch/powerpc/Makefile.inc +++ b/src/lib/libcrypto/arch/powerpc/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.13 2024/11/01 12:56:38 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.14 2025/02/14 12:01:58 jsing Exp $ # powerpc-specific libcrypto build rules @@ -10,9 +10,7 @@ SSLASM+= bn ppc bn-ppc SSLASM+= bn ppc-mont ppc-mont CFLAGS+= -DOPENSSL_BN_ASM_MONT # sha -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha1-ppc sha1-ppc -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha512-ppc sha256-ppc .for dir src dst in ${SSLASM} diff --git a/src/lib/libcrypto/arch/powerpc/crypto_arch.h b/src/lib/libcrypto/arch/powerpc/crypto_arch.h index a3dd98d0ce..d2730af0fb 100644 --- a/src/lib/libcrypto/arch/powerpc/crypto_arch.h +++ b/src/lib/libcrypto/arch/powerpc/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -18,4 +18,14 @@ #ifndef HEADER_CRYPTO_ARCH_H #define HEADER_CRYPTO_ARCH_H +#ifndef OPENSSL_NO_ASM + +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#endif + #endif diff --git a/src/lib/libcrypto/arch/powerpc64/Makefile.inc b/src/lib/libcrypto/arch/powerpc64/Makefile.inc index da81a63cdf..c309ab8b40 100644 --- a/src/lib/libcrypto/arch/powerpc64/Makefile.inc +++ b/src/lib/libcrypto/arch/powerpc64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.15 2024/11/01 12:56:38 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.16 2025/02/14 12:01:58 jsing Exp $ # powerpc-specific libcrypto build rules @@ -10,9 +10,7 @@ #SSLASM+= bn ppc-mont ppc-mont #CFLAGS+= -DOPENSSL_BN_ASM_MONT # sha -#CFLAGS+= -DSHA1_ASM #SSLASM+= sha sha1-ppc sha1-ppc -#CFLAGS+= -DSHA256_ASM #SSLASM+= sha sha512-ppc sha256-ppc .for dir src dst in ${SSLASM} diff --git a/src/lib/libcrypto/arch/sparc64/Makefile.inc b/src/lib/libcrypto/arch/sparc64/Makefile.inc index 43b4b199cd..cbf63e033e 100644 --- a/src/lib/libcrypto/arch/sparc64/Makefile.inc +++ b/src/lib/libcrypto/arch/sparc64/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.20 2024/10/19 11:55:32 jsing Exp $ +# $OpenBSD: Makefile.inc,v 1.21 2025/02/14 12:01:58 jsing Exp $ # sparc64-specific libcrypto build rules @@ -11,11 +11,8 @@ CFLAGS+= -DGHASH_ASM SSLASM+= modes ghash-sparcv9 ghash-sparcv9 # sha SSLASM+= sha sha1-sparcv9 sha1-sparcv9 -CFLAGS+= -DSHA1_ASM SSLASM+= sha sha512-sparcv9 sha256-sparcv9 -CFLAGS+= -DSHA256_ASM SSLASM+= sha sha512-sparcv9 sha512-sparcv9 -CFLAGS+= -DSHA512_ASM .for dir src dst in ${SSLASM} SRCS+= ${dst}.S diff --git a/src/lib/libcrypto/arch/sparc64/crypto_arch.h b/src/lib/libcrypto/arch/sparc64/crypto_arch.h index 7f1fc36cac..251957a5bc 100644 --- a/src/lib/libcrypto/arch/sparc64/crypto_arch.h +++ b/src/lib/libcrypto/arch/sparc64/crypto_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: crypto_arch.h,v 1.1 2024/08/11 13:02:39 jsing Exp $ */ +/* $OpenBSD: crypto_arch.h,v 1.2 2025/02/14 12:01:58 jsing Exp $ */ /* * Copyright (c) 2024 Joel Sing * @@ -23,6 +23,15 @@ #define HAVE_AES_ENCRYPT_INTERNAL #define HAVE_AES_DECRYPT_INTERNAL +#define HAVE_SHA1_BLOCK_DATA_ORDER +#define HAVE_SHA1_BLOCK_GENERIC + +#define HAVE_SHA256_BLOCK_DATA_ORDER +#define HAVE_SHA256_BLOCK_GENERIC + +#define HAVE_SHA512_BLOCK_DATA_ORDER +#define HAVE_SHA512_BLOCK_GENERIC + #endif #endif 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 @@ -/* $OpenBSD: sha1.c,v 1.15 2024/06/01 07:36:16 tb Exp $ */ +/* $OpenBSD: sha1.c,v 1.16 2025/02/14 12:01:58 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -71,11 +71,10 @@ /* Ensure that SHA_LONG and uint32_t are equivalent sizes. */ CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t)); -#ifdef SHA1_ASM void sha1_block_data_order(SHA_CTX *ctx, const void *p, size_t num); -#endif +void sha1_block_generic(SHA_CTX *ctx, const void *p, size_t num); -#ifndef SHA1_ASM +#ifndef HAVE_SHA1_BLOCK_GENERIC static inline SHA_LONG Ch(SHA_LONG x, SHA_LONG y, SHA_LONG z) { @@ -164,8 +163,8 @@ sha1_round4(SHA_LONG *a, SHA_LONG *b, SHA_LONG *c, SHA_LONG *d, SHA_LONG *e, *a = T; } -static void -sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num) +void +sha1_block_generic(SHA_CTX *ctx, const void *_in, size_t num) { const uint8_t *in = _in; const SHA_LONG *in32; @@ -382,6 +381,14 @@ sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num) } #endif +#ifndef HAVE_SHA1_BLOCK_DATA_ORDER +void +sha1_block_data_order(SHA_CTX *ctx, const void *_in, size_t num) +{ + sha1_block_generic(ctx, _in, num); +} +#endif + int SHA1_Init(SHA_CTX *c) { 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 @@ -/* $OpenBSD: sha256.c,v 1.32 2024/06/01 07:36:16 tb Exp $ */ +/* $OpenBSD: sha256.c,v 1.33 2025/02/14 12:01:58 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -68,11 +68,10 @@ /* Ensure that SHA_LONG and uint32_t are equivalent. */ CTASSERT(sizeof(SHA_LONG) == sizeof(uint32_t)); -#ifdef SHA256_ASM void sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num); -#endif +void sha256_block_generic(SHA256_CTX *ctx, const void *_in, size_t num); -#ifndef SHA256_ASM +#ifndef HAVE_SHA256_BLOCK_GENERIC static const SHA_LONG K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 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, *a = T1 + T2; } -static void -sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) +void +sha256_block_generic(SHA256_CTX *ctx, const void *_in, size_t num) { const uint8_t *in = _in; const SHA_LONG *in32; @@ -277,7 +276,15 @@ sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) ctx->h[7] += h; } } -#endif /* SHA256_ASM */ +#endif + +#ifndef HAVE_SHA256_BLOCK_DATA_ORDER +void +sha256_block_data_order(SHA256_CTX *ctx, const void *_in, size_t num) +{ + sha256_block_generic(ctx, _in, num); +} +#endif int SHA224_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 @@ -/* $OpenBSD: sha512.c,v 1.42 2024/06/01 07:36:16 tb Exp $ */ +/* $OpenBSD: sha512.c,v 1.43 2025/02/14 12:01:58 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2011 The OpenSSL Project. All rights reserved. * @@ -69,11 +69,10 @@ /* Ensure that SHA_LONG64 and uint64_t are equivalent. */ CTASSERT(sizeof(SHA_LONG64) == sizeof(uint64_t)); -#ifdef SHA512_ASM void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); -#endif +void sha512_block_generic(SHA512_CTX *ctx, const void *in, size_t num); -#ifndef SHA512_ASM +#ifndef HAVE_SHA512_BLOCK_GENERIC static const SHA_LONG64 K512[80] = { U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd), U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc), @@ -182,8 +181,8 @@ sha512_round(SHA_LONG64 *a, SHA_LONG64 *b, SHA_LONG64 *c, SHA_LONG64 *d, *a = T1 + T2; } -static void -sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) +void +sha512_block_generic(SHA512_CTX *ctx, const void *_in, size_t num) { const uint8_t *in = _in; const SHA_LONG64 *in64; @@ -304,8 +303,15 @@ sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) ctx->h[7] += h; } } +#endif -#endif /* SHA512_ASM */ +#ifndef HAVE_SHA512_BLOCK_DATA_ORDER +void +sha512_block_data_order(SHA512_CTX *ctx, const void *_in, size_t num) +{ + sha512_block_generic(ctx, _in, num); +} +#endif int SHA384_Init(SHA512_CTX *c) -- cgit v1.2.3-55-g6feb