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.
196 lines
10 KiB
196 lines
10 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
"http://www.w3.org/TR/html4/loose.dtd"> |
|
<html> |
|
<head> |
|
<title>QUnit for KEYUTIL private key reader 'keyutil.js'</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://code.jquery.com/qunit/qunit-1.11.0.js"></script> |
|
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.11.0.css" type="text/css" media="screen"/> |
|
|
|
<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/prng4.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/rng.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/base64.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/rsa.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/rsa2.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/sha1.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../asn1hex-1.1.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../rsapem-1.1.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../rsasign-1.2.js"></script> |
|
|
|
<script src="http://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../asn1-1.0.js"></script> |
|
|
|
<!-- jsrsasign keyutil external codes --> |
|
<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/x64-core.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/cipher-core.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/aes.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/tripledes.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/md5.js"></script> |
|
<!-- for PKCS5 PBKDF2 --> |
|
<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/hmac.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/pbkdf2.js"></script> |
|
|
|
<script src="../keyutil-1.0.js"></script> |
|
<script src="../dsa-modified-1.0.js"></script> |
|
|
|
<script src="../x509-1.1.js"></script> |
|
<script src="../crypto-1.1.js"></script> |
|
|
|
<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/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="../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(){ |
|
|
|
// key _work_dsa/d1 |
|
var p = new BigInteger("9ed327a12407c8d2dc9a6b9359fbc48f2a317504f33b48661c4b03778f55b818af219285bbcdfa60f63f96f5c3c06738d72432a36f46d6490a0fe70238517671e7abdb430c4ffb74a17fb6d0ceceee28fddb49273bcd165a520e4a9717b4d27ef06f3417df6a9ea2da35058f119ae76ac8095a2c45ee576c3dfe8253f3449a4f", 16); |
|
var q = new BigInteger("832124c3188298f8d6dd1ad84121c2ef33a5d52b", 16); |
|
var g = new BigInteger("711ac4053baf502aa0a09abcb7af72885495e1efb0de129d93c7bb16f0e4b80a1a10d0409ed52bcd0df0b5511f6e08f74715517e9406edd45d78f0ef15d92b27ef398ea7bf9365fa13591322149fa84635187da277f15cbc8c9a28423feb233221e5d1ad36d926d2e1e0c770f34dc04a616f55685222a9b1cf4f8ecf87c19b7e", 16); |
|
var y = new BigInteger("8cafd9654ce51818e154613bd0b14ee974fbdffc5a19802c4301302bc854d5e17daf0d6745a4aaa8e46ff96b57c89371fa72cca12a2248821645d1ff75869a2549ad7fd110ceefea5616d00be5941036e1a2d87bbcf0bfbe6c3b1e18ba0d3b3af6d34bacf613270a0b5f67c78668e4ba5b3ec0aa28e762ea1f9f2e0167e0523b", 16); |
|
var x = new BigInteger("73b3538660ceac98a3bf48e53f88b4e124657c21", 16); |
|
|
|
// _work_dsa/d1.pub.p8.pem DSA 1024bit |
|
var d1PubP8PEM = "" + |
|
"-----BEGIN PUBLIC KEY-----\n" + |
|
"MIIBtzCCASsGByqGSM44BAEwggEeAoGBAJ7TJ6EkB8jS3Jprk1n7xI8qMXUE8ztI\n" + |
|
"ZhxLA3ePVbgYryGShbvN+mD2P5b1w8BnONckMqNvRtZJCg/nAjhRdnHnq9tDDE/7\n" + |
|
"dKF/ttDOzu4o/dtJJzvNFlpSDkqXF7TSfvBvNBffap6i2jUFjxGa52rICVosRe5X\n" + |
|
"bD3+glPzRJpPAhUAgyEkwxiCmPjW3RrYQSHC7zOl1SsCgYBxGsQFO69QKqCgmry3\n" + |
|
"r3KIVJXh77DeEp2Tx7sW8OS4ChoQ0ECe1SvNDfC1UR9uCPdHFVF+lAbt1F148O8V\n" + |
|
"2Ssn7zmOp7+TZfoTWRMiFJ+oRjUYfaJ38Vy8jJooQj/rIzIh5dGtNtkm0uHgx3Dz\n" + |
|
"TcBKYW9VaFIiqbHPT47Ph8GbfgOBhQACgYEAjK/ZZUzlGBjhVGE70LFO6XT73/xa\n" + |
|
"GYAsQwEwK8hU1eF9rw1nRaSqqORv+WtXyJNx+nLMoSoiSIIWRdH/dYaaJUmtf9EQ\n" + |
|
"zu/qVhbQC+WUEDbhoth7vPC/vmw7Hhi6DTs69tNLrPYTJwoLX2fHhmjkuls+wKoo\n" + |
|
"52LqH58uAWfgUjs=\n" + |
|
"-----END PUBLIC KEY-----\n"; |
|
|
|
// _work_dsa/d1.self.cer DSA 1024bit |
|
var d1CerPEM = "" + |
|
"-----BEGIN CERTIFICATE-----\n" + |
|
"MIICxDCCAoKgAwIBAgIJAP2Mxo43IyYSMAsGCWCGSAFlAwQDAjAaMQswCQYDVQQG\n" + |
|
"EwJVUzELMAkGA1UECgwCRDEwHhcNMTMxMDAyMTUwNDQ0WhcNMjMwOTMwMTUwNDQ0\n" + |
|
"WjAaMQswCQYDVQQGEwJVUzELMAkGA1UECgwCRDEwggG3MIIBKwYHKoZIzjgEATCC\n" + |
|
"AR4CgYEAntMnoSQHyNLcmmuTWfvEjyoxdQTzO0hmHEsDd49VuBivIZKFu836YPY/\n" + |
|
"lvXDwGc41yQyo29G1kkKD+cCOFF2ceer20MMT/t0oX+20M7O7ij920knO80WWlIO\n" + |
|
"SpcXtNJ+8G80F99qnqLaNQWPEZrnasgJWixF7ldsPf6CU/NEmk8CFQCDISTDGIKY\n" + |
|
"+NbdGthBIcLvM6XVKwKBgHEaxAU7r1AqoKCavLevcohUleHvsN4SnZPHuxbw5LgK\n" + |
|
"GhDQQJ7VK80N8LVRH24I90cVUX6UBu3UXXjw7xXZKyfvOY6nv5Nl+hNZEyIUn6hG\n" + |
|
"NRh9onfxXLyMmihCP+sjMiHl0a022SbS4eDHcPNNwEphb1VoUiKpsc9Pjs+HwZt+\n" + |
|
"A4GFAAKBgQCMr9llTOUYGOFUYTvQsU7pdPvf/FoZgCxDATAryFTV4X2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C/\n" + |
|
"vmw7Hhi6DTs69tNLrPYTJwoLX2fHhmjkuls+wKoo52LqH58uAWfgUjsCFHOzU4Zg\n" + |
|
"zqyYo79I5T+ItOEkZXwh\n" + |
|
"-----END DSA PRIVATE KEY-----\n"; |
|
|
|
// _work_dsa/d1.prv.p5e.pem DSA 1024bit |
|
var d1PrvP5EPEM = "" + |
|
"-----BEGIN DSA PRIVATE KEY-----\n" + |
|
"Proc-Type: 4,ENCRYPTED\n" + |
|
"DEK-Info: DES-EDE3-CBC,0A4241238121CC53\n" + |
|
"\n" + |
|
"SREBGTs1GdPEyT0O4MQIPfZZ59Wj8dcvqyEv+IlHzztZbqUiBfGYidu5ybhhaq8W\n" + |
|
"FvDLUTyUPhWqjnTPI0P73t/nMFhZEEB/PWP4SCCXcsd+8ygIEVQfXl9CcFfFxsiP\n" + |
|
"UhRBaZrU/yQ/IynKSboA/RfysHyfJTn3GcJLmMDhs7x4yZr+E8FIfk15qXCkzEsH\n" + |
|
"yFkhDi0D23RfttXie5HiQE0e2XsB127aCkYfQ5nMesrGTVtQb+8cuodtejmGtFtT\n" + |
|
"kslgs45yRNUznxxMi/61sm6pkH///ow0w5DN74UQsqpJj4CYhhNQY4r/QnK8SvlL\n" + |
|
"+KFXazkFwWNZbXiyxF7zdaCsb5bglvfmJspSDGUIcxPzwMG1GQBA3IqOegjmgU/5\n" + |
|
"LMElak/HMFFjT+jUUvxVSJIWK7f4+lWypwPkmmZib9dx8XHPpUr/vXBwPLE40fRG\n" + |
|
"9enP7lSZRWjmW9alWIn6dpjG5HsQwH4eMxdD1fqLR7BR+nx+z47wqmAXPIzOL7PW\n" + |
|
"N4nVxc1+juzITbT6HZB5gkHJG/5l/YFDsACK8aLHp+lgM/Onyg3cMDKSbaXERPZb\n" + |
|
"q0MrwzdrLyCc6x9HYz2QDA==\n" + |
|
"-----END DSA PRIVATE KEY-----\n"; |
|
var d1PrvP5EPass = "passwd"; |
|
|
|
// ======= TEST =================================================================================== |
|
|
|
test("KEYUTIL.getKeyFromPublicPKCS8PEM d1(DSA 1024bit)", function() { |
|
var key = KEYUTIL.getKeyFromPublicPKCS8PEM(d1PubP8PEM); |
|
expect(5); |
|
ok(key instanceof KJUR.crypto.DSA, "isDSA"); |
|
equal(p.compareTo(key.p), 0, "p"); |
|
equal(q.compareTo(key.q), 0, "q"); |
|
equal(g.compareTo(key.g), 0, "g"); |
|
equal(y.compareTo(key.y), 0, "y"); |
|
}); |
|
|
|
test("X509.getPublicKeyFromCertPEM d1(DSA 1024bit)", function() { |
|
var key = X509.getPublicKeyFromCertPEM(d1CerPEM); |
|
expect(5); |
|
ok(key instanceof KJUR.crypto.DSA, "isDSA"); |
|
equal(p.compareTo(key.p), 0, "p"); |
|
equal(q.compareTo(key.q), 0, "q"); |
|
equal(g.compareTo(key.g), 0, "g"); |
|
equal(y.compareTo(key.y), 0, "y"); |
|
}); |
|
|
|
test("KEYUTIL.getKey(d1.prv.p5p.pem(DSA 1024bit))", function() { |
|
var key = KEYUTIL.getKey(d1PrvP5PPEM); |
|
expect(7); |
|
ok(key instanceof KJUR.crypto.DSA, "isDSA"); |
|
equal(p.compareTo(key.p), 0, "p"); |
|
equal(q.compareTo(key.q), 0, "q"); |
|
equal(g.compareTo(key.g), 0, "g"); |
|
equal(y.compareTo(key.y), 0, "y"); |
|
equal(x.toString(16), key.x.toString(16), "x_s"); |
|
equal(x.compareTo(key.x), 0, "x"); |
|
}); |
|
|
|
test("KEYUTIL.getKey(d1.prv.p5e.pem(DSA 1024bit))", function() { |
|
var key = KEYUTIL.getKey(d1PrvP5EPEM, d1PrvP5EPass); |
|
expect(7); |
|
ok(key instanceof KJUR.crypto.DSA, "isDSA"); |
|
equal(p.compareTo(key.p), 0, "p"); |
|
equal(q.compareTo(key.q), 0, "q"); |
|
equal(g.compareTo(key.g), 0, "g"); |
|
equal(y.compareTo(key.y), 0, "y"); |
|
equal(x.toString(16), key.x.toString(16), "x_s"); |
|
equal(x.compareTo(key.x), 0, "x"); |
|
}); |
|
|
|
}); |
|
--> |
|
</script> |
|
|
|
</head> |
|
<body> |
|
<div id="qunit"></div> |
|
<div id="qunit-fixture">test markup</div> |
|
QUnit for |
|
<a href="qunit-do-keyutil.html">keyutil</a> | |
|
<a href="qunit-do-keyutil-eprv.html">keyutil-eprv</a> | |
|
<a href="qunit-do-keyutil-pub.html">keyutil-pub</a> | |
|
</body> |
|
</html> |
|
|
|
|