diff --git a/mozilla/security/jss/org/mozilla/jss/tests/HMACTest.java b/mozilla/security/jss/org/mozilla/jss/tests/HMACTest.java index b91ebb489a8..d56fcf50f5f 100755 --- a/mozilla/security/jss/org/mozilla/jss/tests/HMACTest.java +++ b/mozilla/security/jss/org/mozilla/jss/tests/HMACTest.java @@ -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 {