UPSTREAM PR #30926: SHA3: code refactor#680
Conversation
Remove macro tables to make debugging easier. The low level platform specific code has been moved into the crypto layer. sha3, shake, keccak and cshake-keccak now have seperate creator functions. (The intention is to remove higher level EVP calls from algorithms such as cshake, tuplehash and kmac).
OverviewThis SHA3 provider refactoring improves performance across all 11 modified digest context initialization functions. Out of 20,086 total functions analyzed, 13 were modified, 4 added, and 6 removed. Response times improved 5-11% (19-46 ns), while throughput times improved 82-87% (81-113 ns) through code consolidation. Binaries analyzed:
Function AnalysisHigh-impact functions:
Moderate-impact functions:
Six additional SHA3/Keccak/SHAKE variants show similar 5-6% response time improvements and 82-83% throughput time reductions. Code changes: Eliminated ~355 lines of macro-based code generation, replacing inline initialization (CRYPTO_zalloc + ossl_sha3_init) with delegation to four centralized helper functions. Control flow simplified from 11-13 basic blocks to 7-9 blocks, branching reduced from 3-4 to 1-2 branches, stack frames reduced from 32 to 16 bytes. Platform-specific hardware acceleration (S390X, ARMv8.2) moved from inline code to helpers. Flame Graph ComparisonBase version shows flat call structure with direct CRYPTO_zalloc (168 ns) and ossl_keccak_init (111 ns) calls. Target introduces Additional FindingsThis refactoring is part of OpenSSL's provider architecture modernization, replacing macro-generated code with explicit, maintainable implementations. The changes affect SHA3 digest context creation—called once per digest operation in TLS handshakes, signature verification, and cryptographic hashing. While not the primary computational bottleneck (actual hashing dominates), the improvements contribute to overall efficiency in high-throughput scenarios. No GPU/ML operations affected; changes are CPU-only cryptographic provider code. 💬 Questions? Tag @loci-dev |
421b135 to
770bf14
Compare


Note
Source pull request: openssl/openssl#30926
Remove macro tables to make debugging easier.
The low level platform specific code has been moved into the crypto layer. sha3, shake, keccak and cshake-keccak now have seperate creator functions. (The intention is to remove higher level EVP calls from algorithms such as cshake, tuplehash and kmac).
Checklist