From f0882e2c21ce58d8b5b32366d8bee39bb48173b1 Mon Sep 17 00:00:00 2001 From: Justin Smith Date: Fri, 7 Jun 2024 16:38:06 -0400 Subject: [PATCH] sha1 - fixes for ppc64le --- crypto/fipsmodule/sha/internal.h | 8 +++++++- crypto/fipsmodule/sha/sha1.c | 4 ++-- crypto/fipsmodule/sha/sha_test.cc | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crypto/fipsmodule/sha/internal.h b/crypto/fipsmodule/sha/internal.h index 076f69b4341..86b8cd1b1f2 100644 --- a/crypto/fipsmodule/sha/internal.h +++ b/crypto/fipsmodule/sha/internal.h @@ -72,7 +72,13 @@ struct keccak_st { // Define SHA{n}[_{variant}]_ASM if sha{n}_block_data_order[_{variant}] is // defined in assembly. -#if !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_ARM)) +#if defined(OPENSSL_PPC64LE) +#define SHA1_ALTIVEC + +void sha1_block_data_order(uint32_t *state, const uint8_t *data, + size_t num_blocks); + +#elif !defined(OPENSSL_NO_ASM) && (defined(OPENSSL_X86) || defined(OPENSSL_ARM)) #define SHA1_ASM #define SHA256_ASM #define SHA512_ASM diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index af3decca022..ed7136c1de7 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c @@ -91,7 +91,7 @@ uint8_t *SHA1(const uint8_t *data, size_t len, uint8_t out[SHA_DIGEST_LENGTH]) { return out; } -#if !defined(SHA1_ASM) +#if !defined(SHA1_ASM) && !defined(SHA1_ALTIVEC) static void sha1_block_data_order(uint32_t *state, const uint8_t *data, size_t num); #endif @@ -196,7 +196,7 @@ int SHA1_Final(uint8_t out[SHA_DIGEST_LENGTH], SHA_CTX *c) { * */ #define X(i) XX##i -#if !defined(SHA1_ASM) +#if !defined(SHA1_ASM) && !defined(SHA1_ALTIVEC) #if !defined(SHA1_ASM_NOHW) static void sha1_block_data_order_nohw(uint32_t *state, const uint8_t *data, diff --git a/crypto/fipsmodule/sha/sha_test.cc b/crypto/fipsmodule/sha/sha_test.cc index 3c989c261e7..d6700ffd8e5 100644 --- a/crypto/fipsmodule/sha/sha_test.cc +++ b/crypto/fipsmodule/sha/sha_test.cc @@ -21,8 +21,7 @@ #include "../../test/abi_test.h" #include "internal.h" -#if defined(SUPPORTS_ABI_TEST) - +#if defined(SHA1_ASM) && defined(SUPPORTS_ABI_TEST) TEST(SHATest, SHA1ABI) { SHA_CTX ctx; SHA1_Init(&ctx);