Keep PKCS5S2 usable on a FIPS-restricted JCE, and name the key wrapping property when the runtime has no RSA-OAEP - #1058
Open
vharseko wants to merge 2 commits into
Conversation
PKCS5S2PasswordStorageScheme asked for SecureRandom "SHA1PRNG" by name, at initialization and again in the offline encoder. A FIPS-restricted JCE (SunPKCS11-NSS-FIPS, BC-FIPS) registers no such algorithm, so the scheme threw a message-less InitializationException and the server refused to start — the failure OpenIdentityPlatform#1054 works around by disabling the scheme in the config template, which would also stop {PKCS5S2} hashes imported from Atlassian products from binding on every new installation. Take the provider's default SecureRandom instead, as the PBKDF2 family already does, and let the InitializationException of both PKCS5S2 and the PBKDF2 schemes name the algorithm that is missing rather than leaving the administrator with no reason for the failed start. The SHA1PRNG constant has no user left and goes. The tests withdraw the providers which register the service — SUN for SHA1PRNG, with BC-FIPS standing in for the digests, SunJCE for PBKDF2WithHmacSHA1 — run the scheme without them, and put them back.
… the runtime has no RSA-OAEP The crypto manager validates its key wrapping transformation when it is created, so a Java runtime whose only RSA cipher is PKCS#1 v1.5 — a SunPKCS11 provider on its own, as on a Linux system in FIPS mode (JDK-6190389 is still open) — cannot start the server with the default, RSA-OAEP. Setup noticed as much in ConfigureDS.updateCryptoCipher and, since OpenIdentityPlatform#776 left it no secure transformation to fall back to, silently kept the default; the failed start which followed named the cipher it could not get and nothing else. Setup now prints a warning naming the transformation, the reason and the property to set before the first start, and the crypto manager's refusal names the property as well. The choice itself stays with the administrator: the install guide gains a procedure for a FIPS 140 runtime which says what the bundled BC-FIPS provider offers, what a SunPKCS11-only runtime does not, and how to set key-wrapping-transformation in config.ldif between setup --doNotStart and start-ds.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#1054 changes the config template to get a server installed on a FIPS 140-3 Java runtime: it disables the PKCS5S2 password storage scheme and sets
key-wrapping-transformationtoRSA/ECB/PKCS1Padding. The review there explains why neither belongs in the template — PKCS5S2 is PBKDF2-HMAC-SHA1 like thePBKDF2scheme which stays enabled, and PKCS#1 v1.5 is the transformation #776 removed as a CodeQLjava/rsa-without-oaepfinding. What actually fails on such a runtime:PKCS5S2PasswordStorageSchemeasked forSecureRandom"SHA1PRNG" by name, at initialization and in the offline encoder. A FIPS-restricted JCE registers no such algorithm, the scheme threw a message-lessInitializationException, and the server refused to start.SunPKCS11provider on its own, as on a Linux system in FIPS mode; JDK-6190389 is still open — cannot start the server with the RSA-OAEP default. Setup noticed (ConfigureDS.updateCryptoCipher), had no secure fallback left after Fix java/rsa-without-oaep CodeQL alert by dropping the RSA PKCS#1 v1.5 fallback #776, and silently kept the default; the failed start which followed named the cipher it could not get and nothing else.Change
PKCS5S2PasswordStorageSchemetakes the provider's defaultSecureRandom, as the PBKDF2 family does, and itsInitializationException— like the PBKDF2 schemes' — names the algorithm which is missing. TheSHA1PRNGconstant goes. The template keeps the scheme enabled.setupprints a warning naming the transformation, the reason and the property to set before the first start (WARN_CONFIGDS_KEY_WRAPPING_TRANSFORMATION_UNSUPPORTED), and the crypto manager's refusal (ERR_CRYPTOMGR_CANNOT_GET_PREFERRED_KEY_WRAPPING_CIPHER) names the property too. The choice itself stays with the administrator: the install guide gains "To Install OpenDJ Directory Server on a FIPS 140 Java Runtime" — with the bundled BC-FIPS provider, which offers RSA-OAEP, the default configuration works as it is; a SunPKCS11-only runtime gets thesetup --doNotStart→ldifmodify→start-dsprocedure, with the caveat that PKCS#1 v1.5 is disallowed for key transport by NIST SP 800-131A Rev. 2 and that every replica must use the same transformation.RSA/ECB/NoPadding) is Crypto manager: a FIPS-approved key transport for JVMs whose only RSA cipher is PKCS#1 v1.5 (SunPKCS11) #1056.Testing
The new tests withdraw the JCE providers which register a service, run the code without them, and put the providers back where they were (
TestCaseUtils.withoutJceService):PKCS5S2PasswordStorageSchemeTestCase: the scheme initializes and encodes, online and offline, withoutSHA1PRNG(SUN withdrawn, BC-FIPS standing in for the digests); its initialization failure namesPBKDF2WithHmacSHA1(SunJCE withdrawn). The same failure test forPBKDF2PasswordStorageSchemeTestCase.ConfigureDSTestCase(new): the default transformation stays where the runtime has it; withoutCipher.RSAnone is chosen and the exception names the default.CryptoManagerTestCase: an unsupported transformation is refused, and the refusal nameskey-wrapping-transformation.Each test was run red before its fix and green after:
PKCS5S2PasswordStorageSchemeTestCase56/56,PBKDF2PasswordStorageSchemeTestCase40/40,PBKDF2HmacSHA256/512PasswordStorageSchemeTestCase39/39 each,CryptoManagerTestCase31/31,ConfigureDSTestCase2/2.Alternative to #1054. Related: #776, #1056.