Skip to content

Commit

Permalink
u
Browse files Browse the repository at this point in the history
  • Loading branch information
JinhangZhang committed Aug 26, 2024
1 parent 24ab95d commit 9965922
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 32 deletions.
28 changes: 14 additions & 14 deletions test/jdk/javax/net/ssl/DTLS/CipherSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ public static void main(String[] args) throws Exception {
cipherSuite = args[0];

CipherSuite testCase = new CipherSuite();
// try {
// testCase.runTest(testCase);
// } catch (javax.net.ssl.SSLHandshakeException sslhe) {
// if (Utils.isFIPS()
// && !SecurityUtils.TLS_CIPHERSUITES.containsKey(cipherSuite)) {
// if ("No appropriate protocol (protocol is disabled or cipher suites are inappropriate)".equals(sslhe.getMessage())) {
// System.out.println("Expected exception msg: <No appropriate protocol (protocol is disabled or cipher suites are inappropriate)> is caught");
// return;
// }
// }
// } catch (Exception e) {
// e.printStackTrace();
// return;
// }
try {
testCase.runTest(testCase);
} catch (javax.net.ssl.SSLHandshakeException sslhe) {
if (Utils.isFIPS()
&& !SecurityUtils.TLS_CIPHERSUITES.containsKey(cipherSuite)) {
if ("No appropriate protocol (protocol is disabled or cipher suites are inappropriate)".equals(sslhe.getMessage())) {
System.out.println("Expected exception msg: <No appropriate protocol (protocol is disabled or cipher suites are inappropriate)> is caught");
return;
}
}
} catch (Exception e) {
e.printStackTrace();
return;
}
testCase.runTest(testCase);
}

Expand Down
10 changes: 5 additions & 5 deletions test/jdk/javax/net/ssl/FIPSFlag/FIPSFlagTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
* @test
* @summary Test flags used for FIPS 140-2 and FIPS 140-3
* @run main/othervm
* TestFIPS false
* @run main/othervm
* -Dsemeru.fips=true
* TestFIPS true 140-2
* @run main/othervm
* -Dsemeru.fips=true
* -Dsemeru.customprofile=OpenJCEPlusFIPS.FIPS140-3
* TestFIPS true 140-3
* @run main/othervm
* -Dsemeru.fips=true
* -Dsemeru.customprofile=OpenJCEPlusFIPS
* TestFIPS true 140-3
* @run main/othervm
* -Dsemeru.fips=true
* TestFIPS true 140-2
* @run main/othervm
* TestFIPS false
*/
47 changes: 34 additions & 13 deletions test/jdk/javax/net/ssl/FIPSFlag/TestFIPS.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,53 @@ public class TestFIPS {

public static void main(String[] args) throws Exception {

// System.setProperty("semeru.customprofile", "OpenJCEPlusFIPS.FIPS140-3-Weakly-Enforced");

for (Provider.Service service : Security.getProvider("SUN").getServices()) {
System.out.println(" Service: " + service.getType() + " Algorithm: " + service.getAlgorithm() + " Class: " + service.getClassName());
System.out.println("Service: " + service.getType() + " Algorithm: " + service.getAlgorithm() + " Class: " + service.getClassName());
}

// System.out.println("com.ibm.fips.mode: " + System.getProperty("com.ibm.fips.mode"));
// System.out.println("<Customprofile> is: " + System.getProperty("semeru.customprofile"));

if (SEMERU_FIPS == null) {
if (args.length == 1 && args[0].equals("false")) {
if (args[0].equals("false")) {
System.out.println("PASS");
} else {
throw new FIPSException("FIPS is not enabled");
throw new FIPSException("FIPS mode should be opened before using.");
}
return;
}

if (SEMERU_FIPS.equals(args[0])) {
System.out.println("Customprofile is: " + PROFILE);
if (PROFILE.equals(args[1])) {
System.out.println("PASS");
if (PROFILE == null) {
if (SEMERU_FIPS.equals(args[0])) {
if (args[0].equals("true")) {
if (System.getProperty("com.ibm.fips.mode").equals("140-2") && args[1].equals("140-2")) {
System.out.println("PASS");
} else {
throw new FIPSException("If there is no custom profile specified, the FIPS 140-2 should be used as default.");
}
} else {
throw new FIPSException("FIPS mode is not opened.");
}
} else {
throw new FIPSException("FIPS profile does not match");
throw new FIPSException("FIPS mode and expected mode do not match.");
}
return;
}

if (PROFILE.contains("OpenJCEPlusFIPS")) {
if (SEMERU_FIPS.equals(args[0])) {
if (args[0].equals("true")) {
if (System.getProperty("com.ibm.fips.mode").equals("140-3") && args[1].equals("140-3")) {
System.out.println("PASS");
} else {
throw new FIPSException("FIPS profile and fips mode do not match.");
}
} else {
throw new FIPSException("FIPS mode is not opened.");
}
}
} else {
throw new FIPSException("FIPS profile is not supported in FIPS 140-3 mode.");
}

System.out.println(1/0);
}

public static class FIPSException extends Exception {
Expand Down

0 comments on commit 9965922

Please sign in to comment.