< prev index next >
test/jdk/java/security/MessageDigest/TestSameValue.java
Print this page
rev 59383 : [mq]: final
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -58,11 +58,10 @@
String[] algorithmArr = { "SHA", "Sha", "MD5", "md5", "SHA-224",
"SHA-256", "SHA-384", "SHA-512", "SHA3-224", "SHA3-256",
"SHA3-384", "SHA3-512" };
for (String algorithm : algorithmArr) {
- try {
md = MessageDigest.getInstance(algorithm);
for (UpdateDigestMethod updateMethod : UpdateDigestMethod
.values()) {
byte[] output = updateMethod.updateDigest(data, md);
@@ -74,39 +73,17 @@
"Test failed at algorithm/provider/numUpdate:"
+ algorithm + "/" + md.getProvider()
+ "/" + updateMethod);
}
}
- } catch (NoSuchAlgorithmException nae) {
- if (algorithm.startsWith("SHA3") && !isSHA3supported()) {
- continue;
- } else {
- throw nae;
- }
- }
}
out.println("All "
+ algorithmArr.length * UpdateDigestMethod.values().length
+ " tests Passed");
}
- // SHA-3 hash algorithms are only supported by "SUN" provider
- // and "OracleUcrypto" provider on Solaris 12.0 or later
- // This method checks if system supports SHA-3
- private boolean isSHA3supported() {
- if (Security.getProvider("SUN") != null) {
- return true;
- }
- if (Security.getProvider("OracleUcrypto") != null
- && "SunOS".equals(System.getProperty("os.name"))
- && System.getProperty("os.version").compareTo("5.12") >= 0) {
- return true;
- }
- return false;
- }
-
private static enum UpdateDigestMethod {
/*
* update the data one by one using method update(byte input) then do
* digest (giving the output buffer, offset, and the number of bytes to
< prev index next >