jdk/test/sun/security/pkcs11/fips/CipherTest.java
changeset 7039 6464c8e62a18
parent 6856 533f4ad71f88
child 8991 7df5283fd3b8
equal deleted inserted replaced
7038:fd9c0e3b34eb 7039:6464c8e62a18
   115 
   115 
   116         boolean isEnabled() {
   116         boolean isEnabled() {
   117             // ignore SCSV
   117             // ignore SCSV
   118             if (cipherSuite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
   118             if (cipherSuite.equals("TLS_EMPTY_RENEGOTIATION_INFO_SCSV")) {
   119                 return false;
   119                 return false;
       
   120             }
       
   121 
       
   122             // ignore exportable cipher suite for TLSv1.1
       
   123             if (protocol.equals("TLSv1.1")) {
       
   124                 if(cipherSuite.indexOf("_EXPORT_") != -1) {
       
   125                     return false;
       
   126                 }
   120             }
   127             }
   121 
   128 
   122             return true;
   129             return true;
   123         }
   130         }
   124 
   131 
   147         String[] clientAuths = {null};
   154         String[] clientAuths = {null};
   148         tests = new ArrayList<TestParameters>(
   155         tests = new ArrayList<TestParameters>(
   149             cipherSuites.length * protocols.length * clientAuths.length);
   156             cipherSuites.length * protocols.length * clientAuths.length);
   150         for (int i = 0; i < cipherSuites.length; i++) {
   157         for (int i = 0; i < cipherSuites.length; i++) {
   151             String cipherSuite = cipherSuites[i];
   158             String cipherSuite = cipherSuites[i];
   152             if (peerFactory.isSupported(cipherSuite) == false) {
   159 
   153                 continue;
       
   154             }
       
   155             // skip kerberos cipher suites
       
   156             if (cipherSuite.startsWith("TLS_KRB5")) {
       
   157                 continue;
       
   158             }
       
   159             for (int j = 0; j < protocols.length; j++) {
   160             for (int j = 0; j < protocols.length; j++) {
   160                 String protocol = protocols[j];
   161                 String protocol = protocols[j];
   161                 if (protocol.equals("SSLv2Hello")) {
   162 
       
   163                 if (!peerFactory.isSupported(cipherSuite, protocol)) {
   162                     continue;
   164                     continue;
   163                 }
   165                 }
       
   166 
   164                 for (int k = 0; k < clientAuths.length; k++) {
   167                 for (int k = 0; k < clientAuths.length; k++) {
   165                     String clientAuth = clientAuths[k];
   168                     String clientAuth = clientAuths[k];
   166                     if ((clientAuth != null) &&
   169                     if ((clientAuth != null) &&
   167                             (cipherSuite.indexOf("DH_anon") != -1)) {
   170                             (cipherSuite.indexOf("DH_anon") != -1)) {
   168                         // no client with anonymous ciphersuites
   171                         // no client with anonymous ciphersuites
   291         ks.load(in, passwd);
   294         ks.load(in, passwd);
   292         in.close();
   295         in.close();
   293         return ks;
   296         return ks;
   294     }
   297     }
   295 
   298 
   296     public static void main(PeerFactory peerFactory, KeyStore keyStore, String[] args)
   299     public static void main(PeerFactory peerFactory, KeyStore keyStore,
   297             throws Exception {
   300             String[] args) throws Exception {
       
   301 
   298         long time = System.currentTimeMillis();
   302         long time = System.currentTimeMillis();
   299         String relPath;
   303         String relPath;
   300         if ((args.length > 0) && args[0].equals("sh")) {
   304         if ((args != null) && (args.length > 0) && args[0].equals("sh")) {
   301             relPath = pathToStoresSH;
   305             relPath = pathToStoresSH;
   302         } else {
   306         } else {
   303             relPath = pathToStores;
   307             relPath = pathToStores;
   304         }
   308         }
   305         PATH = new File(System.getProperty("test.src", "."), relPath);
   309         PATH = new File(System.getProperty("test.src", "."), relPath);
   343 
   347 
   344         abstract Client newClient(CipherTest cipherTest) throws Exception;
   348         abstract Client newClient(CipherTest cipherTest) throws Exception;
   345 
   349 
   346         abstract Server newServer(CipherTest cipherTest) throws Exception;
   350         abstract Server newServer(CipherTest cipherTest) throws Exception;
   347 
   351 
   348         boolean isSupported(String cipherSuite) {
   352         boolean isSupported(String cipherSuite, String protocol) {
       
   353             // skip kerberos cipher suites
       
   354             if (cipherSuite.startsWith("TLS_KRB5")) {
       
   355                 System.out.println("Skipping unsupported test for " +
       
   356                                     cipherSuite + " of " + protocol);
       
   357                 return false;
       
   358             }
       
   359 
       
   360             // skip SSLv2Hello protocol
       
   361             if (protocol.equals("SSLv2Hello")) {
       
   362                 System.out.println("Skipping unsupported test for " +
       
   363                                     cipherSuite + " of " + protocol);
       
   364                 return false;
       
   365             }
       
   366 
       
   367             // ignore exportable cipher suite for TLSv1.1
       
   368             if (protocol.equals("TLSv1.1")) {
       
   369                 if (cipherSuite.indexOf("_EXPORT_WITH") != -1) {
       
   370                     System.out.println("Skipping obsoleted test for " +
       
   371                                         cipherSuite + " of " + protocol);
       
   372                     return false;
       
   373                 }
       
   374             }
       
   375 
   349             return true;
   376             return true;
   350         }
   377         }
   351     }
   378     }
   352 
   379 
   353 }
   380 }