forked from rachanon/stdbWeb
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.
110 lines
6.6 KiB
110 lines
6.6 KiB
9 years ago
|
<!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' for ECDSA 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="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/core.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/ripemd160.js"></script>
|
||
|
<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/sha512.js"></script>
|
||
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha384.js"></script>
|
||
|
<script src="../crypto-1.1.js"></script>
|
||
|
<!-- for rsapem -->
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/jsbn.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/jsbn2.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/base64.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/prng4.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/rng.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/ec.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/ec-patch.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../asn1hex-1.1.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../asn1-1.0.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../crypto-1.1.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ecdsa-modified-1.0.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ecparam-1.0.js"></script>
|
||
|
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
<!--
|
||
|
$(document).ready(function(){
|
||
|
|
||
|
// ======= TEST ===============================================================
|
||
|
|
||
|
test("ECDSA signing test1", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA256withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initSign({'ecprvhex': '11b5737cf9d93f17c0cb1a84655d3995a02824097effa5edd8ee26381eb5d6c3', 'eccurvename': 'secp256r1'});
|
||
|
sig.updateString("aaa");
|
||
|
var sigValueHex = sig.sign();
|
||
|
equal(sigValueHex.substr(0, 2), "30", "sign aaa SHA256withECDSA secp256r1");
|
||
|
});
|
||
|
|
||
|
test("ECDSA verify test1", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA256withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initVerifyByPublicKey({'ecpubhex': '04a01532a3c0900053de60fbefefcca58793301598d308b41e6f4e364e388c2711bef432c599148c94143d4ff46c2cb73e3e6a41d7eef23c047ea11e60667de425', 'eccurvename': 'secp256r1'});
|
||
|
sig.updateString("aaa");
|
||
|
var result = sig.verify('3045022100f729843c8bb5f285380ef5e4d708608d7449dadfa50129112668e972d30f210b0220051c589f0ebdad7a41370e9d9ce405734e854788387f21997028312a305ddae8'); // k1.sig.aaa.1
|
||
|
equal(result, true, "verify aaa SHA256withECDSA secp256r1 k1.sig.aaa.1");
|
||
|
});
|
||
|
|
||
|
test("ECDSA verify test2", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA256withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initVerifyByPublicKey({'ecpubhex': '04a01532a3c0900053de60fbefefcca58793301598d308b41e6f4e364e388c2711bef432c599148c94143d4ff46c2cb73e3e6a41d7eef23c047ea11e60667de425', 'eccurvename': 'secp256r1'});
|
||
|
sig.updateString("aaa");
|
||
|
var result = sig.verify('304502202241c432b03179b65f63ac66ed9273531a7f5c00feab5e55a7921c81a8f74275022100a51a260c76a33718e77b0459b239cc709209a7da7ba9a7311059413546598ec0'); // k1.sig.aaa.2
|
||
|
equal(result, true, "verify aaa SHA256withECDSA secp256r1 k1.sig.aaa.2");
|
||
|
});
|
||
|
|
||
|
test("ECDSA verify test3", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA256withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initVerifyByPublicKey({'ecpubhex': '0422353f380062b2bde67712091386faa369ec5ef1a244d06c459fe3de1fb0a5d8ad23a3878be75e375546f14ca6e42755fee04bd78c0343ac8038f5a218e1fbc5', 'eccurvename': 'secp256k1'});
|
||
|
sig.updateString("aaa");
|
||
|
var result = sig.verify('30450220350cc4ac81e68fce3cd134ab1cf4ae0e853a297be0f5f0508b0abc3681ba3364022100a601afe06571a95554f722f4fd0114a3335e9e3c155b390aba53dffbb3eedfec'); // k4.sig.aaa.1
|
||
|
equal(result, true, "verify aaa SHA256withECDSA secp256k1 k4.sig.aaa.1");
|
||
|
});
|
||
|
|
||
|
test("ECDSA verify test4", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA256withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initVerifyByPublicKey({'ecpubhex': '04543526abdfc47394a3f2645b0d48651a9f3a4d46d8740be322915107f050250c730ca40b37e1dc85e082b4bb181b8847bd6d0fa278bae5eb1c05474c9a4e2beec28c970be49c1949f09e96979a277a514830e32a5b9de1ec68ab99f492dd300a', 'eccurvename': 'secp384r1'});
|
||
|
sig.updateString("aaa");
|
||
|
var result = sig.verify('306502303725858ae53a59a71b0d48553d5c3b0d450a4a76c1da2fd5b508cdb598607a418d7bc622006afe0655e894c2ac6b2b03023100dfffc7d84c02d0e3625a19c9305a1a8caa01fab7da4c4f847086774d5a9205f3de2fe041c76aca429c0229d3c74769b0'); // k6.sig.aaa.1
|
||
|
equal(result, true, "verify aaa SHA256withECDSA secp384r1 k6.sig.aaa.1");
|
||
|
});
|
||
|
|
||
|
test("SHA1withECDSA verify test1", function() {
|
||
|
var sig = new KJUR.crypto.Signature({"alg": "SHA1withECDSA", "prov": "cryptojs/jsrsa"});
|
||
|
sig.initVerifyByPublicKey({'ecpubhex': '04a01532a3c0900053de60fbefefcca58793301598d308b41e6f4e364e388c2711bef432c599148c94143d4ff46c2cb73e3e6a41d7eef23c047ea11e60667de425', 'eccurvename': 'secp256r1'});
|
||
|
sig.updateString("aaa");
|
||
|
var result = sig.verify('3046022100deb7e5b5b0740d59befeabea276355627357ca7de573c3812ba38381794fd38e0221009ea6a40e79a3a25e957980c0aaf13ea3fc600c40e22a446dfcaba8443f6402ce'); // k1.sig.aaa.3
|
||
|
equal(result, true, "verify aaa SHA1withECDSA secp256r1 k1.sig.aaa.3");
|
||
|
});
|
||
|
|
||
|
|
||
|
});
|
||
|
-->
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="qunit"></div>
|
||
|
<div id="qunit-fixture">test markup</div>
|
||
|
|
||
|
<p>
|
||
|
ECC related QUnit test pages:
|
||
|
<a href="qunit-do-crypto.html">crypto.js</a> |
|
||
|
<a href="qunit-do-crypto-ecdsa.html">crypto.js Signature class for ECDSA</a> |
|
||
|
<a href="qunit-do-ecdsamod.html">ecdsa-modified.js</a> |
|
||
|
<a href="qunit-do-ecparam.html">ecparam.js</a> |
|
||
|
</p>
|
||
|
|
||
|
</body>
|
||
|
</html>
|