mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Bugzilla bug: 328233 Fix for using SunJCE for all platformas that do not
use IBM JDK. sr=Alexei.Volkov
This commit is contained in:
parent
2fe3283659
commit
701ae3b6eb
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user