1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
5.6 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>QUnit for Cryptographic Provider Class 'crypto.js' HMAC test</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="qunit.js"></script>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
<script src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script>
<script src="../ext/cryptojs-312-core-fix.js"></script>
<!-- script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.js" -->
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/x64-core.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/hmac.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/md5.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha256.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha224.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha512.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha384.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/ripemd160.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha224.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha384.js"></script>
<script src="../crypto-1.1.js"></script>
<script src="../ext/jsbn.js"></script>
<script src="../ext/base64.js"></script>
<script src="../base64x-1.1.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
// openssl dgst -sha1 -hmac pass aaa.txt
var HMACSHA1AAAPASS = "3839089182c6a0443adaa168460c466fdd822a24";
// openssl dgst -sha224 -hmac pass aaa.txt
var HMACSHA224AAAPASS = "2a03bb43a8494be72687dfd78f3be5f384477ef4fb76180188c4e808";
// openssl dgst -sha256 -hmac pass aaa.txt
var HMACSHA256AAAPASS = "5737da4a87c0bda19ddb8898f87fb11b4680ca56f061580c046011cafc41e2ee";
// openssl dgst -sha384 -hmac pass aaa.txt
var HMACSHA384AAAPASS = "221bc1de17da49fe1aaaed4dca81cb271aa792cd4775e3c89b55f4b62ada0d0e5e585acbcbc7523d742c8e86455c4fd8";
// openssl dgst -sha512 -hmac pass aaa.txt
var HMACSHA512AAAPASS = "4ff71cce35012ba0054de832b69c29f0b29d965e6e31cf70a3cc118dd34082a54a7a9f0d9469877576892d142be8e0f48ce997fa159492bc36c1caf9b454f48f";
// openssl dgst -md5 -hmac pass aaa.txt
var HMACMD5AAAPASS = "a705d13b50d78edfee5bd1f2fa37cdd5";
// openssl dgst -ripemd160 -hmac pass aaa.txt
var HMACRIPEMD160AAAPASS = "61ff05af52b509f60dc2fdd61d378dab745fa7eb";
test("HMAC HmacSHA1(aaa,pass)", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacSHA1", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACSHA1AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacSHA224(aaa,pass) - fix with patched CryptoJS core.js", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacSHA224", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACSHA224AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacSHA256(aaa,pass)", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacSHA256", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACSHA256AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacSHA384(aaa,pass) - fixed with patched CryptoJS core.js", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacSHA384", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACSHA384AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacSHA512(aaa,pass)", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacSHA512", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACSHA512AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacMD5(aaa,pass)", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacMD5", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACMD5AAAPASS, "hmac(aaa,pass)");
});
test("HMAC HmacRIPEMD160(aaa,pass)", function() {
expect(1);
var mac1 = new KJUR.crypto.Mac({"alg": "HmacRIPEMD160", "prov": "cryptojs", "pass": "pass"});
mac1.updateString("aaa");
equal(mac1.doFinal(), HMACRIPEMD160AAAPASS, "hmac(aaa,pass)");
});
test("Crypto-JS HmacSHA224 bug test", function() {
expect(1);
var hash1 = CryptoJS.HmacSHA224("aaa", "pass");
var hmac2 = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA224, "pass");
hmac2.update("aaa");
var hash2 = hmac2.finalize();
equal(hash1.toString(CryptoJS.enc.Hex), hash2.toString(CryptoJS.enc.Hex), "224");
});
test("Crypto-JS HmacSHA384 bug test", function() {
expect(1);
var hash1 = CryptoJS.HmacSHA384("aaa", "pass");
var hmac2 = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA384, "pass");
hmac2.update("aaa");
var hash2 = hmac2.finalize();
equal(hash1.toString(CryptoJS.enc.Hex), hash2.toString(CryptoJS.enc.Hex), "384");
});
});
-->
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<p>
<a href="../">TOP</a> |
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-crypto.html">crypto</a> |
<a href="qunit-do-crypto-mac.html">crypto-mac</a> |
<a href="qunit-do-crypto-mac2.html">crypto-mac2</a> |
</p>
</body>
</html>