Skip to content

Commit a7edcc1

Browse files
Support SecureRandom strong algorithms in FIPS mode
This change overrides the default securerandom.strongAlgorithms configuration used by SecureRandom.getInstanceStrong() when it runs in FIPS mode. Signed-off-by: Mohit Rajbhar <mohit.rajbhar@ibm.com>
1 parent 84ae0b3 commit a7edcc1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

Lines changed: 10 additions & 0 deletions
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,6 +819,7 @@ private RestrictedSecurityProperties(String profileID, ProfileParser parser) {
817819
// For SecureRandom.
818820
this.jdkSecureRandomProvider = parser.getProperty("jdkSecureRandomProvider");
819821
this.jdkSecureRandomAlgorithm = parser.getProperty("jdkSecureRandomAlgorithm");
822+
this.jdkSecureRandomStrongAlgorithms = parser.getProperty("jdkSecureRandomStrongAlgorithms");
820823

821824
this.jdkFipsMode = parser.getProperty("jdkFipsMode");
822825

@@ -1111,6 +1114,7 @@ private void listUsedProfile() {
11111114
printProperty(profileID + ".javax.net.ssl.keyStore: ", keyStore);
11121115
printProperty(profileID + ".securerandom.provider: ", jdkSecureRandomProvider);
11131116
printProperty(profileID + ".securerandom.algorithm: ", jdkSecureRandomAlgorithm);
1117+
printProperty(profileID + ".securerandom.strongAlgorithms: ", jdkSecureRandomStrongAlgorithms);
11141118
System.out.println();
11151119
}
11161120

@@ -1514,6 +1518,9 @@ private String getExistingValue(String property) {
15141518
case "jdkTlsLegacyAlgorithms":
15151519
propertyKey = "jdk.tls.legacyAlgorithms";
15161520
break;
1521+
case "jdkSecureRandomStrongAlgorithms":
1522+
propertyKey = "securerandom.strongAlgorithms";
1523+
break;
15171524
default:
15181525
return null;
15191526
}
@@ -1567,6 +1574,8 @@ private void loadProperties(String profileID, List<String> allInfo) {
15671574
profileID + ".securerandom.provider", allInfo);
15681575
setProperty("jdkSecureRandomAlgorithm",
15691576
profileID + ".securerandom.algorithm", allInfo);
1577+
setProperty("jdkSecureRandomStrongAlgorithms",
1578+
profileID + ".securerandom.strongAlgorithms", allInfo);
15701579
setProperty("jdkFipsMode",
15711580
profileID + ".fips.mode", allInfo);
15721581

@@ -1912,6 +1921,7 @@ private static boolean isPropertyAppendable(String property) {
19121921
case "jdkTlsDisabledAlgorithms":
19131922
case "jdkTlsDisabledNamedCurves":
19141923
case "jdkTlsLegacyAlgorithms":
1924+
case "jdkSecureRandomStrongAlgorithms":
19151925
return true;
19161926
default:
19171927
return false;

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

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

351351
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.provider = OpenJCEPlusFIPS
352352
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.algorithm = SHA512DRBG
353+
RestrictedSecurity.OpenJCEPlusFIPS.FIPS140-3.securerandom.strongAlgorithms = SHA512DRBG:OpenJCEPlusFIPS
353354

354355
# Strongly enforced restricted security mode profile for FIPS 140-3.
355356
#

0 commit comments

Comments
 (0)