You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
crypto: SM4-GCM and SM4-CCM not available despite OpenSSL 3.5 bundling the implementation #64866
SM4-GCM and SM4-CCM are documented as available in OpenSSL 3.x default provider (EVP_CIPHER-SM4), and the source files (cipher_sm4_gcm.c, cipher_sm4_ccm.c) are included in Node.js's OpenSSL build (deps/openssl/config/archs/*/openssl.gypi and providers/implementations/ciphers/build.info). However, these ciphers are not registered at runtime.
This affects cross-language interoperability for projects using SM4-GCM (e.g., Java BouncyCastle) that need Node.js decryption support, and China compliance (GM/T 0002) scenarios requiring authenticated encryption with SM4.
build.info includes them unconditionally (given !$disabled{sm4}, and SM4-CBC works).
No no-sm4 in Configure options (deps/openssl/config/Makefile COPTS).
Suspected root cause
Node.js builds OpenSSL with enable-fips. The FIPS module build process may regenerate or filter the default provider's OSSL_ALGORITHM dispatch table, causing SM4-GCM/CCM/XTS registration entries to be dropped while basic SM4 modes (CBC, CTR, ECB, OFB, CFB) are retained.
Additionally, deps/ncrypto/ncrypto.cc line 4304 uses the legacy API:
Even if the provider registration is fixed, EVP_get_cipherbyname() may not resolve provider-only ciphers that lack a legacy EVP_CIPHER object (per openssl/openssl#13667: "There never will be an evp_sm4_gcm() function"). A fallback to EVP_CIPHER_fetch(NULL, name, NULL) may be needed.
What is the feature you are proposing?
Investigate why SM4-GCM/CCM/XTS are not registered in the default provider at runtime despite being compiled.
If the enable-fips build path is the cause, ensure non-FIPS algorithms remain registered in the default provider.
Consider adding an EVP_CIPHER_fetch fallback in Cipher::FromName() for forward compatibility with provider-only ciphers.
The root cause analysis pointing to EVP_get_cipherbyname() vs EVP_CIPHER_fetch() in deps/ncrypto/ncrypto.cc is spot on. Since OpenSSL 3.x provider-only ciphers lack legacy objects, explicit fetching is definitely required.
I would love to help investigate and resolve this issue. Here is my proposed
plan:Replicate the build locally with the enable-fips flag.T
race the runtime registration drop for SM4-GCM/CCM/XTS.
Implement and test the EVP_CIPHER_fetch fallback mechanism inside Cipher::FromName.
Could you please assign this to me, or let me know if there are any internal build constraints I should keep in mind before digging into ncrypto.cc?
Activity
Shivang9983 commentedon Aug 3, 2026
Hi @emmansun and Node.js maintainers,
The root cause analysis pointing to EVP_get_cipherbyname() vs EVP_CIPHER_fetch() in deps/ncrypto/ncrypto.cc is spot on. Since OpenSSL 3.x provider-only ciphers lack legacy objects, explicit fetching is definitely required.
I would love to help investigate and resolve this issue. Here is my proposed
plan:Replicate the build locally with the enable-fips flag.T
race the runtime registration drop for SM4-GCM/CCM/XTS.
Implement and test the EVP_CIPHER_fetch fallback mechanism inside Cipher::FromName.
Could you please assign this to me, or let me know if there are any internal build constraints I should keep in mind before digging into ncrypto.cc?
Thanks!
crypto: support provider-only SM4 cipher modes
crypto: discover ciphers from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers
crypto: discover hashes from OpenSSL providers
crypto: discover ciphers from OpenSSL providers