From 1873da1f71a0ac1d32f8a00f3ecace28ac8f5ced Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Fri, 15 Aug 2025 12:42:56 -0700 Subject: [PATCH 1/8] Update to new 512AVX check style --- crypto/CMakeLists.txt | 3 ++- crypto/chacha/chacha.c | 14 +++++++++++++- crypto/chacha/chacha_test.cc | 2 +- crypto/chacha/internal.h | 3 +++ crypto/fipsmodule/sha/internal.h | 6 ++++++ crypto/fipsmodule/sha/sha1.c | 24 ++++++++++++++++++++++-- crypto/fipsmodule/sha/sha256.c | 14 +++++++++++++- crypto/fipsmodule/sha/sha512.c | 14 +++++++++++++- crypto/fipsmodule/sha/sha_test.cc | 8 ++++---- 9 files changed, 77 insertions(+), 11 deletions(-) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index a98159a01a..a93d553dad 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -324,7 +324,8 @@ else() file(COPY ${GENERATE_CODE_ROOT}/err_data.c DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) endif() -set(CRYPTO_ARCH_OBJECTS "") +set(CRYPTO_ARCH_OBJECTS "" +) if (ARCH STREQUAL "aarch64" AND CMAKE_GENERATOR MATCHES "Visual Studio") msbuild_aarch64_asm(TARGET crypto_objects ASM_FILES ${CRYPTO_ARCH_SOURCES} OUTPUT_OBJECTS CRYPTO_ARCH_OBJECTS) endif() diff --git a/crypto/chacha/chacha.c b/crypto/chacha/chacha.c index 21274bc874..85693b2bed 100644 --- a/crypto/chacha/chacha.c +++ b/crypto/chacha/chacha.c @@ -92,7 +92,7 @@ static void ChaCha20_ctr32(uint8_t *out, const uint8_t *in, size_t in_len, return; } #endif -#if defined(CHACHA20_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) +#if defined(CHACHA20_ASM_AVX2) if (ChaCha20_ctr32_avx2_capable(in_len)) { ChaCha20_ctr32_avx2(out, in, in_len, key, counter); return; @@ -245,3 +245,15 @@ void CRYPTO_chacha_20(uint8_t *out, const uint8_t *in, size_t in_len, } #endif + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + +#if defined(CHACHA20_ASM_AVX2) +void ChaCha20_ctr32_avx2(uint8_t *out, const uint8_t *in, size_t in_len, + const uint32_t key[8], const uint32_t counter[4]) { + perror("ChaCha20_ctr32_avx2"); + abort(); +} +#endif // defined(CHACHA20_ASM_AVX2) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) diff --git a/crypto/chacha/chacha_test.cc b/crypto/chacha/chacha_test.cc index 3a379a9e88..c1a45a6bb4 100644 --- a/crypto/chacha/chacha_test.cc +++ b/crypto/chacha/chacha_test.cc @@ -356,7 +356,7 @@ static void check_abi(uint8_t *out, const uint8_t *in, size_t in_len, CHECK_ABI(ChaCha20_ctr32_neon, out, in, in_len, key, counter); } #endif -#if defined(CHACHA20_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) +#if defined(CHACHA20_ASM_AVX2) if (ChaCha20_ctr32_avx2_capable(in_len)) { CHECK_ABI(ChaCha20_ctr32_avx2, out, in, in_len, key, counter); } diff --git a/crypto/chacha/internal.h b/crypto/chacha/internal.h index bcdcf2f576..9f4fdfd288 100644 --- a/crypto/chacha/internal.h +++ b/crypto/chacha/internal.h @@ -59,6 +59,9 @@ void ChaCha20_ctr32_neon(uint8_t *out, const uint8_t *in, size_t in_len, #define CHACHA20_ASM_AVX2 OPENSSL_INLINE int ChaCha20_ctr32_avx2_capable(size_t len) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) return len > 128 && CRYPTO_is_AVX2_capable(); } void ChaCha20_ctr32_avx2(uint8_t *out, const uint8_t *in, size_t in_len, diff --git a/crypto/fipsmodule/sha/internal.h b/crypto/fipsmodule/sha/internal.h index 99afc11697..84e09f4c60 100644 --- a/crypto/fipsmodule/sha/internal.h +++ b/crypto/fipsmodule/sha/internal.h @@ -245,6 +245,9 @@ OPENSSL_INLINE int sha1_hw_capable(void) { #define SHA1_ASM_AVX2 OPENSSL_INLINE int sha1_avx2_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX2 imply SSSE3? // * sha1_block_data_order_avx2 does not seem to use SSSE3 instructions. @@ -256,6 +259,9 @@ void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, #define SHA1_ASM_AVX OPENSSL_INLINE int sha1_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha1_block_data_order_avx does not seem to use SSSE3 instructions. diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index c1b2dcb9a8..17a9d15e41 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c @@ -396,13 +396,13 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data, return; } #endif -#if defined(SHA1_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX2) if (sha1_avx2_capable()) { sha1_block_data_order_avx2(state, data, num); return; } #endif -#if defined(SHA1_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX) if (sha1_avx_capable()) { sha1_block_data_order_avx(state, data, num); return; @@ -441,3 +441,23 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data, #undef BODY_40_59 #undef BODY_60_79 #undef X + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) + +#if defined(ASH1_ASM_AVX2) +void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, + size_t num) { + perror("sha1_block_data_order_avx2"); + abort(); +} +#endif // defined(ASH1_ASM_AVX2) + +#if defined(SHA1_ASM_AVX) +void sha1_block_data_order_avx(uint32_t state[5], const uint8_t *data, + size_t num) { + perror("sha1_block_data_order_avx"); + abort(); +} +#endif // defined(SHA1_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) diff --git a/crypto/fipsmodule/sha/sha256.c b/crypto/fipsmodule/sha/sha256.c index f36fb8b716..ffe5d4b2a9 100644 --- a/crypto/fipsmodule/sha/sha256.c +++ b/crypto/fipsmodule/sha/sha256.c @@ -392,7 +392,7 @@ static void sha256_block_data_order(uint32_t state[8], const uint8_t *data, return; } #endif -#if defined(SHA256_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA256_ASM_AVX) if (sha256_avx_capable()) { sha256_block_data_order_avx(state, data, num); return; @@ -429,3 +429,15 @@ void SHA256_TransformBlocks(uint32_t state[8], const uint8_t *data, #undef Maj #undef ROUND_00_15 #undef ROUND_16_63 + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + +#if defined(SHA256_ASM_AVX) +void sha256_block_data_order_avx(uint32_t state[8], const uint8_t *data, + size_t num) { + perror("sha256_block_data_order_avx"); + abort(); +} +#endif // defined(SHA256_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) diff --git a/crypto/fipsmodule/sha/sha512.c b/crypto/fipsmodule/sha/sha512.c index a5d0bab5c6..a5a124d01c 100644 --- a/crypto/fipsmodule/sha/sha512.c +++ b/crypto/fipsmodule/sha/sha512.c @@ -689,7 +689,7 @@ static void sha512_block_data_order(uint64_t state[8], const uint8_t *data, return; } #endif -#if defined(SHA512_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA512_ASM_AVX) if (sha512_avx_capable()) { sha512_block_data_order_avx(state, data, num); return; @@ -714,3 +714,15 @@ static void sha512_block_data_order(uint64_t state[8], const uint8_t *data, #undef Maj #undef ROUND_00_15 #undef ROUND_16_80 + +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + +#if defined(SHA512_ASM_AVX) +void sha512_block_data_order_avx(uint64_t state[8], const uint8_t *data, + size_t num) { + perror("sha512_block_data_order_avx"); + abort(); +} +#endif // defined(SHA512_ASM_AVX) + +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) diff --git a/crypto/fipsmodule/sha/sha_test.cc b/crypto/fipsmodule/sha/sha_test.cc index e8854fd8bf..14931c512c 100644 --- a/crypto/fipsmodule/sha/sha_test.cc +++ b/crypto/fipsmodule/sha/sha_test.cc @@ -36,12 +36,12 @@ TEST(SHATest, SHA1ABI) { CHECK_ABI(sha1_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA1_ASM_AVX2) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX2) if (sha1_avx2_capable()) { CHECK_ABI(sha1_block_data_order_avx2, ctx.h, kBuf, blocks); } #endif -#if defined(SHA1_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA1_ASM_AVX) if (sha1_avx_capable()) { CHECK_ABI(sha1_block_data_order_avx, ctx.h, kBuf, blocks); } @@ -76,7 +76,7 @@ TEST(SHATest, SHA256ABI) { CHECK_ABI(sha256_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA256_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA256_ASM_AVX) if (sha256_avx_capable()) { CHECK_ABI(sha256_block_data_order_avx, ctx.h, kBuf, blocks); } @@ -111,7 +111,7 @@ TEST(SHATest, SHA512ABI) { CHECK_ABI(sha512_block_data_order_hw, ctx.h, kBuf, blocks); } #endif -#if defined(SHA512_ASM_AVX) && !defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) +#if defined(SHA512_ASM_AVX) if (sha512_avx_capable()) { CHECK_ABI(sha512_block_data_order_avx, ctx.h, kBuf, blocks); } From 5975483f6a2506be410bcc258a2ddeff7903481e Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:01:55 -0700 Subject: [PATCH 2/8] Add 512AVX checks --- crypto/CMakeLists.txt | 3 +-- crypto/fipsmodule/sha/internal.h | 8 +++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/crypto/CMakeLists.txt b/crypto/CMakeLists.txt index a93d553dad..a98159a01a 100644 --- a/crypto/CMakeLists.txt +++ b/crypto/CMakeLists.txt @@ -324,8 +324,7 @@ else() file(COPY ${GENERATE_CODE_ROOT}/err_data.c DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/) endif() -set(CRYPTO_ARCH_OBJECTS "" -) +set(CRYPTO_ARCH_OBJECTS "") if (ARCH STREQUAL "aarch64" AND CMAKE_GENERATOR MATCHES "Visual Studio") msbuild_aarch64_asm(TARGET crypto_objects ASM_FILES ${CRYPTO_ARCH_SOURCES} OUTPUT_OBJECTS CRYPTO_ARCH_OBJECTS) endif() diff --git a/crypto/fipsmodule/sha/internal.h b/crypto/fipsmodule/sha/internal.h index 84e09f4c60..ea96f3417e 100644 --- a/crypto/fipsmodule/sha/internal.h +++ b/crypto/fipsmodule/sha/internal.h @@ -287,6 +287,9 @@ OPENSSL_INLINE int sha256_hw_capable(void) { #define SHA256_ASM_AVX OPENSSL_INLINE int sha256_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha256_block_data_order_avx does not seem to use SSSE3 instructions. @@ -306,7 +309,10 @@ void sha256_block_data_order_ssse3(uint32_t state[8], const uint8_t *data, size_t num); #define SHA512_ASM_AVX -OPENSSL_INLINE int sha512_avx_capable(void) { + OPENSSL_INLINE int sha512_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // TODO: Simplify this logic, which was extracted from the assembly: // * Does AVX imply SSSE3? // * sha512_block_data_order_avx does not seem to use SSSE3 instructions. From 5c33b682e5b5a5e1591201d54d113179df37d7a6 Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Fri, 15 Aug 2025 13:39:28 -0700 Subject: [PATCH 3/8] Add AVX checks --- crypto/fipsmodule/sha/internal.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crypto/fipsmodule/sha/internal.h b/crypto/fipsmodule/sha/internal.h index ea96f3417e..9c35db02a1 100644 --- a/crypto/fipsmodule/sha/internal.h +++ b/crypto/fipsmodule/sha/internal.h @@ -192,6 +192,9 @@ void sha1_block_data_order_ssse3(uint32_t state[5], const uint8_t *data, #define SHA1_ASM_AVX OPENSSL_INLINE int sha1_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // Pre-Zen AMD CPUs had slow SHLD/SHRD; Zen added the SHA extension; see the // discussion in sha1-586.pl. // @@ -215,6 +218,9 @@ void sha256_block_data_order_ssse3(uint32_t state[8], const uint8_t *data, #define SHA256_ASM_AVX OPENSSL_INLINE int sha256_avx_capable(void) { +#if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) + return 0; +#endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) // Pre-Zen AMD CPUs had slow SHLD/SHRD; Zen added the SHA extension; see the // discussion in sha1-586.pl. // @@ -309,7 +315,7 @@ void sha256_block_data_order_ssse3(uint32_t state[8], const uint8_t *data, size_t num); #define SHA512_ASM_AVX - OPENSSL_INLINE int sha512_avx_capable(void) { +OPENSSL_INLINE int sha512_avx_capable(void) { #if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) return 0; #endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_AVX) From 2f667b1868971dc187d9dd4f3c867c0b8ab99d6b Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:22:47 -0700 Subject: [PATCH 4/8] Only include assembly definition if assembler is new enough --- crypto/chacha/asm/chacha-x86_64.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/chacha/asm/chacha-x86_64.pl b/crypto/chacha/asm/chacha-x86_64.pl index 7ce140f06f..890d6c4b26 100755 --- a/crypto/chacha/asm/chacha-x86_64.pl +++ b/crypto/chacha/asm/chacha-x86_64.pl @@ -1263,6 +1263,7 @@ sub AVX2_lane_ROUND { my $xframe = $win64 ? 0xa8 : 8; $code.=<<___; +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl ChaCha20_ctr32_avx2 .type ChaCha20_ctr32_avx2,\@function,5 .align 32 @@ -1781,6 +1782,7 @@ sub AVX2_lane_ROUND { ret .cfi_endproc .size ChaCha20_ctr32_avx2,.-ChaCha20_ctr32_avx2 +#endif ___ } From 97f22a5c9f6ac6e3dbab8a8e55639a17049d2a9d Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:28:44 -0700 Subject: [PATCH 5/8] Fix typo in SHA --- crypto/fipsmodule/sha/sha1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index 17a9d15e41..d897a1cf16 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c @@ -444,7 +444,7 @@ static void sha1_block_data_order(uint32_t state[5], const uint8_t *data, #if defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) -#if defined(ASH1_ASM_AVX2) +#if defined(SHA1_ASM_AVX2) void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, size_t num) { perror("sha1_block_data_order_avx2"); From dda81c5a0a9e60ebea35f7fcb26a7bbc1404367f Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Mon, 13 Oct 2025 18:37:46 -0700 Subject: [PATCH 6/8] Aseembler guard for sha1_block_data_order_avx --- crypto/fipsmodule/sha/asm/sha1-x86_64.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl index acd77d9326..7e1a38d04e 100755 --- a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl +++ b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl @@ -938,6 +938,7 @@ () my $_ror=sub { &shrd(@_[0],@_) }; $code.=<<___; +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx .type sha1_block_data_order_avx,\@function,3 .align 16 @@ -1300,6 +1301,7 @@ () ret .cfi_endproc .size sha1_block_data_order_avx,.-sha1_block_data_order_avx +#endif ___ if ($avx>1) { From b32b2e9f66430238232fa8d0b2c69733395f0891 Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Tue, 14 Oct 2025 13:53:49 -0700 Subject: [PATCH 7/8] Put guard around sha1 block data order avx2 --- crypto/fipsmodule/sha/asm/sha1-x86_64.pl | 2 ++ generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S | 2 ++ generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S | 4 ++++ generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S | 2 ++ generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S | 4 ++++ generated-src/win-x86_64/crypto/chacha/chacha-x86_64.asm | 2 ++ generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm | 4 ++++ 7 files changed, 20 insertions(+) diff --git a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl index 7e1a38d04e..6e2d2d3178 100755 --- a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl +++ b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl @@ -1320,6 +1320,7 @@ () my $frame="%r13"; $code.=<<___; +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx2 .type sha1_block_data_order_avx2,\@function,3 .align 16 @@ -1794,6 +1795,7 @@ () ret .cfi_endproc .size sha1_block_data_order_avx2,.-sha1_block_data_order_avx2 +#endif ___ } } diff --git a/generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S b/generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S index b4809fa07b..0d6f1502eb 100644 --- a/generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S +++ b/generated-src/linux-x86_64/crypto/chacha/chacha-x86_64.S @@ -998,6 +998,7 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size ChaCha20_ctr32_ssse3_4x,.-ChaCha20_ctr32_ssse3_4x +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl ChaCha20_ctr32_avx2 .hidden ChaCha20_ctr32_avx2 .type ChaCha20_ctr32_avx2,@function @@ -1607,3 +1608,4 @@ _CET_ENDBR .cfi_endproc .size ChaCha20_ctr32_avx2,.-ChaCha20_ctr32_avx2 #endif +#endif diff --git a/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S b/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S index 9596e29024..2958014530 100644 --- a/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S +++ b/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S @@ -2605,6 +2605,7 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_ssse3,.-sha1_block_data_order_ssse3 +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx .hidden sha1_block_data_order_avx .type sha1_block_data_order_avx,@function @@ -3735,6 +3736,8 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_avx,.-sha1_block_data_order_avx +#endif +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx2 .hidden sha1_block_data_order_avx2 .type sha1_block_data_order_avx2,@function @@ -5430,6 +5433,7 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_avx2,.-sha1_block_data_order_avx2 +#endif .section .rodata .align 64 K_XX_XX: diff --git a/generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S b/generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S index 5eec46097c..540d63172e 100644 --- a/generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S +++ b/generated-src/mac-x86_64/crypto/chacha/chacha-x86_64.S @@ -992,6 +992,7 @@ L$4x_epilogue: .byte 0xf3,0xc3 +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl _ChaCha20_ctr32_avx2 .private_extern _ChaCha20_ctr32_avx2 @@ -1601,3 +1602,4 @@ L$8x_epilogue: #endif +#endif diff --git a/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S b/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S index c2da422bbe..c9784182d8 100644 --- a/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S +++ b/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S @@ -2605,6 +2605,7 @@ L$epilogue_ssse3: .byte 0xf3,0xc3 +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl _sha1_block_data_order_avx .private_extern _sha1_block_data_order_avx @@ -3735,6 +3736,8 @@ L$epilogue_avx: .byte 0xf3,0xc3 +#endif +#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl _sha1_block_data_order_avx2 .private_extern _sha1_block_data_order_avx2 @@ -5430,6 +5433,7 @@ L$epilogue_avx2: .byte 0xf3,0xc3 +#endif .section __DATA,__const .p2align 6 K_XX_XX: diff --git a/generated-src/win-x86_64/crypto/chacha/chacha-x86_64.asm b/generated-src/win-x86_64/crypto/chacha/chacha-x86_64.asm index 7674887d8a..2d48fcf944 100644 --- a/generated-src/win-x86_64/crypto/chacha/chacha-x86_64.asm +++ b/generated-src/win-x86_64/crypto/chacha/chacha-x86_64.asm @@ -1065,6 +1065,7 @@ $L$4x_epilogue: DB 0F3h,0C3h ;repret $L$SEH_end_ChaCha20_ctr32_ssse3_4x: +%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX global ChaCha20_ctr32_avx2 ALIGN 32 @@ -1706,6 +1707,7 @@ $L$8x_epilogue: DB 0F3h,0C3h ;repret $L$SEH_end_ChaCha20_ctr32_avx2: +%endif EXTERN __imp_RtlVirtualUnwind ALIGN 16 diff --git a/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm b/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm index d2a7cf43aa..c3a36cd2b4 100644 --- a/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm +++ b/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm @@ -2666,6 +2666,7 @@ $L$epilogue_ssse3: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_ssse3: +%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX global sha1_block_data_order_avx ALIGN 16 @@ -3819,6 +3820,8 @@ $L$epilogue_avx: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_avx: +%endif +%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX global sha1_block_data_order_avx2 ALIGN 16 @@ -5538,6 +5541,7 @@ $L$epilogue_avx2: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_avx2: +%endif section .rdata rdata align=8 ALIGN 64 K_XX_XX: From a71851f709fe5dced35639c5d31408c9f7be45cb Mon Sep 17 00:00:00 2001 From: Erin Chapman <13040499+m271828@users.noreply.github.com> Date: Tue, 14 Oct 2025 14:12:59 -0700 Subject: [PATCH 8/8] Test remove sha1_block_data_order_avx default implementation --- crypto/fipsmodule/sha/asm/sha1-x86_64.pl | 2 -- crypto/fipsmodule/sha/sha1.c | 8 -------- .../linux-x86_64/crypto/fipsmodule/sha1-x86_64.S | 2 -- generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S | 2 -- .../win-x86_64/crypto/fipsmodule/sha1-x86_64.asm | 2 -- 5 files changed, 16 deletions(-) diff --git a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl index 6e2d2d3178..3b5efdcd40 100755 --- a/crypto/fipsmodule/sha/asm/sha1-x86_64.pl +++ b/crypto/fipsmodule/sha/asm/sha1-x86_64.pl @@ -938,7 +938,6 @@ () my $_ror=sub { &shrd(@_[0],@_) }; $code.=<<___; -#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx .type sha1_block_data_order_avx,\@function,3 .align 16 @@ -1301,7 +1300,6 @@ () ret .cfi_endproc .size sha1_block_data_order_avx,.-sha1_block_data_order_avx -#endif ___ if ($avx>1) { diff --git a/crypto/fipsmodule/sha/sha1.c b/crypto/fipsmodule/sha/sha1.c index d897a1cf16..5e1bea41cc 100644 --- a/crypto/fipsmodule/sha/sha1.c +++ b/crypto/fipsmodule/sha/sha1.c @@ -452,12 +452,4 @@ void sha1_block_data_order_avx2(uint32_t state[5], const uint8_t *data, } #endif // defined(ASH1_ASM_AVX2) -#if defined(SHA1_ASM_AVX) -void sha1_block_data_order_avx(uint32_t state[5], const uint8_t *data, - size_t num) { - perror("sha1_block_data_order_avx"); - abort(); -} -#endif // defined(SHA1_ASM_AVX) - #endif // defined(MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX) diff --git a/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S b/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S index 2958014530..8dea3b72c6 100644 --- a/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S +++ b/generated-src/linux-x86_64/crypto/fipsmodule/sha1-x86_64.S @@ -2605,7 +2605,6 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_ssse3,.-sha1_block_data_order_ssse3 -#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx .hidden sha1_block_data_order_avx .type sha1_block_data_order_avx,@function @@ -3736,7 +3735,6 @@ _CET_ENDBR .byte 0xf3,0xc3 .cfi_endproc .size sha1_block_data_order_avx,.-sha1_block_data_order_avx -#endif #ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl sha1_block_data_order_avx2 .hidden sha1_block_data_order_avx2 diff --git a/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S b/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S index c9784182d8..71d6d2de40 100644 --- a/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S +++ b/generated-src/mac-x86_64/crypto/fipsmodule/sha1-x86_64.S @@ -2605,7 +2605,6 @@ L$epilogue_ssse3: .byte 0xf3,0xc3 -#ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl _sha1_block_data_order_avx .private_extern _sha1_block_data_order_avx @@ -3736,7 +3735,6 @@ L$epilogue_avx: .byte 0xf3,0xc3 -#endif #ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX .globl _sha1_block_data_order_avx2 .private_extern _sha1_block_data_order_avx2 diff --git a/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm b/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm index c3a36cd2b4..6caddd7c72 100644 --- a/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm +++ b/generated-src/win-x86_64/crypto/fipsmodule/sha1-x86_64.asm @@ -2666,7 +2666,6 @@ $L$epilogue_ssse3: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_ssse3: -%ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX global sha1_block_data_order_avx ALIGN 16 @@ -3820,7 +3819,6 @@ $L$epilogue_avx: DB 0F3h,0C3h ;repret $L$SEH_end_sha1_block_data_order_avx: -%endif %ifndef MY_ASSEMBLER_IS_TOO_OLD_FOR_512AVX global sha1_block_data_order_avx2