diff --git a/test/jdk/javax/net/ssl/DTLS/CipherSuite.java b/test/jdk/javax/net/ssl/DTLS/CipherSuite.java index 6de67e0b1e5..669e15a459d 100644 --- a/test/jdk/javax/net/ssl/DTLS/CipherSuite.java +++ b/test/jdk/javax/net/ssl/DTLS/CipherSuite.java @@ -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: 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: is caught"); + return; + } + } + } catch (Exception e) { + e.printStackTrace(); + return; + } testCase.runTest(testCase); } diff --git a/test/jdk/javax/net/ssl/FIPSFlag/FIPSFlagTests.java b/test/jdk/javax/net/ssl/FIPSFlag/FIPSFlagTests.java index 0038d53a4fb..666a409a068 100644 --- a/test/jdk/javax/net/ssl/FIPSFlag/FIPSFlagTests.java +++ b/test/jdk/javax/net/ssl/FIPSFlag/FIPSFlagTests.java @@ -25,6 +25,11 @@ * @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 @@ -32,9 +37,4 @@ * -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 */ \ No newline at end of file diff --git a/test/jdk/javax/net/ssl/FIPSFlag/TestFIPS.java b/test/jdk/javax/net/ssl/FIPSFlag/TestFIPS.java index 4e623a9ec2a..ec1886bc1a9 100644 --- a/test/jdk/javax/net/ssl/FIPSFlag/TestFIPS.java +++ b/test/jdk/javax/net/ssl/FIPSFlag/TestFIPS.java @@ -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(" 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 {