The implicit algorithm fetch causes a lock contention and significant slowdown for small input buffers. For more details, see: https://github.com/openssl/openssl/issues/19612 Instead of using EVP_DigestInit_ex() initialize empty MD_CTX objects for each algorithm and use EVP_MD_CTX_copy_ex() to initialize MD_CTX from a static copy. Additionally avoid implicit algorithm fetching by using EVP_MD_fetch() for OpenSSL 3.0.