< prev index next >

test/jdk/java/security/MessageDigest/TestDigestIOStream.java

Print this page
rev 59107 : imported patch security


  99                                     "testDigestOff failed at:" + algorithm + "/"
 100                                             + length + "/" + readModel);
 101                         }
 102                     }
 103                 }
 104             } catch (NoSuchAlgorithmException nae) {
 105                 if (algorithm.startsWith("SHA3") && !isSHA3supported()) {
 106                     continue;
 107                 } else {
 108                     throw nae;
 109                 }
 110             }
 111         }
 112         int testNumber = ALGORITHM_ARRAY.length * ReadModel.values().length
 113                 * DATA_LEN_ARRAY.length * 2
 114                 + ALGORITHM_ARRAY.length * DATA_LEN_ARRAY.length * 2;
 115         out.println("All " + testNumber + " Tests Passed");
 116     }
 117 
 118     // SHA-3 hash algorithms are only supported by "SUN" provider
 119     // and "OracleUcrypto" provider on Solaris 12.0 or later
 120     // This method checks if system supports SHA-3
 121     private boolean isSHA3supported() {
 122         if (Security.getProvider("SUN") != null) {
 123             return true;
 124         }
 125         if (Security.getProvider("OracleUcrypto") != null
 126                 && "SunOS".equals(System.getProperty("os.name"))
 127                 && System.getProperty("os.version").compareTo("5.12") >= 0) {
 128             return true;
 129         }
 130         return false;
 131     }
 132 
 133     /**
 134      * Test DigestInputStream and DigestOutputStream digest function when digest
 135      * set on and off
 136      *
 137      * @param algo
 138      *            Message Digest algorithm
 139      * @param readModel
 140      *            which read method used(READ, BUFFER_READ, MIX_READ)
 141      * @param on
 142      *            digest switch(on and off)
 143      * @param dataLength
 144      *            plain test data length.
 145      * @exception Exception
 146      *                throw unexpected exception
 147      */




  99                                     "testDigestOff failed at:" + algorithm + "/"
 100                                             + length + "/" + readModel);
 101                         }
 102                     }
 103                 }
 104             } catch (NoSuchAlgorithmException nae) {
 105                 if (algorithm.startsWith("SHA3") && !isSHA3supported()) {
 106                     continue;
 107                 } else {
 108                     throw nae;
 109                 }
 110             }
 111         }
 112         int testNumber = ALGORITHM_ARRAY.length * ReadModel.values().length
 113                 * DATA_LEN_ARRAY.length * 2
 114                 + ALGORITHM_ARRAY.length * DATA_LEN_ARRAY.length * 2;
 115         out.println("All " + testNumber + " Tests Passed");
 116     }
 117 
 118     // SHA-3 hash algorithms are only supported by "SUN" provider

 119     // This method checks if system supports SHA-3
 120     private boolean isSHA3supported() {
 121         if (Security.getProvider("SUN") != null) {





 122             return true;
 123         }
 124         return false;
 125     }
 126 
 127     /**
 128      * Test DigestInputStream and DigestOutputStream digest function when digest
 129      * set on and off
 130      *
 131      * @param algo
 132      *            Message Digest algorithm
 133      * @param readModel
 134      *            which read method used(READ, BUFFER_READ, MIX_READ)
 135      * @param on
 136      *            digest switch(on and off)
 137      * @param dataLength
 138      *            plain test data length.
 139      * @exception Exception
 140      *                throw unexpected exception
 141      */


< prev index next >