Skip to content

Commit 0cfb409

Browse files
Support SecureRandom strong algorithms in FIPS mode
This change overrides the default jdk.security.strongAlgorithms configuration used by SecureRandom.getInstanceStrong() when it runs in FIPS mode. A FIPS-compliant SecureRandom strong algorithm is configured so that SecureRandom.getInstanceStrong() works properly in FIPS mode, and the test java/security/SecureRandom/TestStrong.java passes successfully when FIPS mode is enabled. Signed-off-by: Mohit Rajbhar <mohit.rajbhar@ibm.com>
1 parent 4547500 commit 0cfb409

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

closed/src/java.base/share/classes/openj9/internal/security/RestrictedSecurity.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ private static void setProperties(Properties props) {
589589
propsMapping.put("jdk.tls.legacyAlgorithms", restricts.jdkTlsLegacyAlgorithms);
590590
propsMapping.put("jdk.certpath.disabledAlgorithms", restricts.jdkCertpathDisabledAlgorithms);
591591
propsMapping.put("jdk.security.legacyAlgorithms", restricts.jdkSecurityLegacyAlgorithms);
592+
propsMapping.put("securerandom.strongAlgorithms", restricts.jdkSecureRandomStrongAlgorithms);
592593

593594
if (restricts.descIsFIPS) {
594595
if (restricts.jdkFipsMode == null) {
@@ -783,6 +784,7 @@ private static final class RestrictedSecurityProperties {
783784
// For SecureRandom.
784785
final String jdkSecureRandomProvider;
785786
final String jdkSecureRandomAlgorithm;
787+
private final String jdkSecureRandomStrongAlgorithms;
786788

787789
final String jdkFipsMode;
788790

@@ -817,7 +819,8 @@ private RestrictedSecurityProperties(String profileID, ProfileParser parser) {
817819
// For SecureRandom.
818820
this.jdkSecureRandomProvider = parser.getProperty("jdkSecureRandomProvider");
819821
this.jdkSecureRandomAlgorithm = parser.getProperty("jdkSecureRandomAlgorithm");
820-
822+
this.jdkSecureRandomStrongAlgorithms = parser.getProperty("jdkSecureRandomStrongAlgorithms");
823+
821824
this.jdkFipsMode = parser.getProperty("jdkFipsMode");
822825

823826
this.providers = new ArrayList<>(parser.providers);
@@ -1514,6 +1517,9 @@ private String getExistingValue(String property) {
15141517
case "jdkTlsLegacyAlgorithms":
15151518
propertyKey = "jdk.tls.legacyAlgorithms";
15161519
break;
1520+
case "jdkSecureRandomStrongAlgorithms":
1521+
propertyKey = "securerandom.strongAlgorithms";
1522+
break;
15171523
default:
15181524
return null;
15191525
}
@@ -1567,6 +1573,8 @@ private void loadProperties(String profileID, List<String> allInfo) {
15671573
profileID + ".securerandom.provider", allInfo);
15681574
setProperty("jdkSecureRandomAlgorithm",
15691575
profileID + ".securerandom.algorithm", allInfo);
1576+
setProperty("jdkSecureRandomStrongAlgorithms",
1577+
profileID + ".securerandom.strongAlgorithms", allInfo);
15701578
setProperty("jdkFipsMode",
15711579
profileID + ".fips.mode", allInfo);
15721580

@@ -1912,6 +1920,7 @@ private static boolean isPropertyAppendable(String property) {
19121920
case "jdkTlsDisabledAlgorithms":
19131921
case "jdkTlsDisabledNamedCurves":
19141922
case "jdkTlsLegacyAlgorithms":
1923+
case "jdkSecureRandomStrongAlgorithms":
19151924
return true;
19161925
default:
19171926
return false;

src/java.base/share/conf/security/java.security

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ RestrictedSecurity.NSS.140-2.securerandom.algorithm = PKCS11
212212
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.name = OpenJCEPlusFIPS Cryptographic Module FIPS 140-3
213213
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.default = false
214214
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.fips = true
215-
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.hash = SHA256:db77222175971874d5681342bb2ee2f95258e6bc7e9957a7c027a7a41b03af90
215+
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.hash = SHA256:488826302be498c47d45f798b8705297241434e522b983be5bd8abc759d8aab5
216216
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.number = Certificate #4755
217217
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.policy = https://csrc.nist.gov/projects/cryptographic-module-validation-program/certificate/4755
218218
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.desc.sunsetDate = 2029-08-08
@@ -352,6 +352,7 @@ RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.jce.provider.3 = sun.security.ssl.S
352352

353353
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.provider = OpenJCEPlusFIPS
354354
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.algorithm = SHA512DRBG
355+
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.strongAlgorithms = SHA512DRBG:OpenJCEPlusFIPS
355356

356357
# Strongly enforced restricted security mode profile for FIPS 140-3.
357358
#

0 commit comments

Comments
 (0)