Skip to content

Commit 930b1f3

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 4547500 commit 930b1f3

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

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
@@ -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)