Bugzilla bug: 328233 Fix for using SunJCE for all platformas that do not
use IBM JDK. sr=Alexei.Volkov git-svn-id: svn://10.0.0.236/trunk@191034 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -48,8 +48,19 @@ import javax.crypto.*;
|
||||
import javax.crypto.spec.*;
|
||||
import org.mozilla.jss.crypto.SecretKeyFacade;
|
||||
|
||||
/**
|
||||
* HMAC is a hash function based message authentication code.
|
||||
* HMACTest compares the HMAC created by Mozilla, IBM and Sun JCE.
|
||||
*
|
||||
* @author Sandeep.Konchady@Sun.COM
|
||||
* @version 1.0
|
||||
*/
|
||||
public class HMACTest {
|
||||
|
||||
/**
|
||||
* Initialize and compare hashes generated by Mozilla-JSS
|
||||
* and platform JDK vendor JCE.
|
||||
*/
|
||||
public static void doHMAC(SecretKeyFacade sk, String alg)
|
||||
throws Exception {
|
||||
|
||||
@@ -66,7 +77,7 @@ public class HMACTest {
|
||||
String javaVendorName = System.getProperty("java.vendor");
|
||||
if ( javaVendorName.equals("IBM Corporation") ) {
|
||||
macJCE = Mac.getInstance(alg, "IBMJCE");
|
||||
} else if ( javaVendorName.equals("Sun Microsystems Inc.") ) {
|
||||
} else {
|
||||
macJCE = Mac.getInstance(alg, "SunJCE");
|
||||
}
|
||||
macJCE.init(sk);
|
||||
@@ -75,14 +86,18 @@ public class HMACTest {
|
||||
|
||||
//Check to see if HMACs are equal
|
||||
if ( java.util.Arrays.equals(resultJSS, resultSunJCE) ) {
|
||||
System.out.println(javaVendorName.substring(0,3) +
|
||||
" and Mozilla give same " + alg);
|
||||
System.out.println(javaVendorName +
|
||||
" JCE and Mozilla-JSS give same " + alg);
|
||||
} else {
|
||||
throw new Exception("ERROR: " + javaVendorName.substring(0,3) +
|
||||
" and Mozilla give different "+ alg );
|
||||
throw new Exception("ERROR: " + javaVendorName +
|
||||
" JCE and Mozilla-JSS give different "+ alg );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Main test method.
|
||||
* @params args[]
|
||||
*/
|
||||
public static void main(String []argv) {
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user