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.
136 lines
7.9 KiB
136 lines
7.9 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 RSAKey signing add-on 'rsa-sign.js of RSAPSS signature'</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 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/rsa.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/rsa2.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../ext/base64.js"></script>
|
||
|
|
||
|
<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/sha1.js"></script>
|
||
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha256.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 language="JavaScript" type="text/javascript" src="../asn1hex-1.1.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../crypto-1.1.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../pkcs5pkey-1.0.js"></script>
|
||
|
<script language="JavaScript" type="text/javascript" src="../base64x-1.1.js"></script>
|
||
|
|
||
|
<script>
|
||
|
$(document).ready(function(){
|
||
|
|
||
|
// _work_pss/kp1.prv.pem
|
||
|
var sKp1PrvPEM = "" +
|
||
|
"-----BEGIN RSA PRIVATE KEY-----\n" +
|
||
|
"MIIEpQIBAAKCAQEArwrxcCYEd97QIzTK6NJukvJjL2TsJMM0TGtznkM60/LxiWpA\n" +
|
||
|
"LrG6nyVUE3hlZviSeQz59x8Wg7rELKNVckBj4nOMUUfdJCGJHVPRShL+4gK7R1Zs\n" +
|
||
|
"ctgzqOCrEvmbMZxs+Lql29L9UoKHJPOaLLHJHJGnGB2uXmZ5cYvg2c5JMhAgzocb\n" +
|
||
|
"HzBW9M24D5ZtDGPabub+pLptieS/Cpb39kFL2IF4o+nLPgGvNtw0NKzG4deljZYJ\n" +
|
||
|
"q7FFDC0lvxOIG2Jhr3F+2oU7o7zr0vn3lrbKYK8Ppo+9mKTf5r+l+nwCWm14hNpa\n" +
|
||
|
"PZM5M8UKCfPWSsMH01OZ5x/4/KdWkteyyUwYtwIDAQABAoIBAQCt/C2RcGhekXzG\n" +
|
||
|
"kbHiC0/XBdAqiqDhxZlVIDSyqVZu13rXQGH9R7EcgKj6FWCNIiPM6GYJCMCDPP/C\n" +
|
||
|
"8rJ6tp/RtVJSdCDNyfuUx/wuKYVpNpfZx4BSAq4OfQnt+WYVwMrbzAIR5rze51jX\n" +
|
||
|
"FL85D5m7qNaydMYdlLO/de6P76f3dkTBkg6aloyCcQ3G5q6PnAWS5U8rBEKfNqYK\n" +
|
||
|
"cNj9t6TGVgVW88/aemygfvpmNHo9Gq8i2URKoWpGnHhGMYx4r3FYLitZWGJrZbEj\n" +
|
||
|
"E+ChTzrt8uTnjsO/+aFHNpEDFUXJbQKYx+gd47Fx5n6KGQZoXvyAtjgcQxh0Hhdg\n" +
|
||
|
"NMrGc0dJAoGBAOHaQAL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|
||
|
// _work_pss/kp1.pub.pem
|
||
|
var sKp1PubPEM = "" +
|
||
|
"-----BEGIN PUBLIC KEY-----\n" +
|
||
|
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArwrxcCYEd97QIzTK6NJu\n" +
|
||
|
"kvJjL2TsJMM0TGtznkM60/LxiWpALrG6nyVUE3hlZviSeQz59x8Wg7rELKNVckBj\n" +
|
||
|
"4nOMUUfdJCGJHVPRShL+4gK7R1ZsctgzqOCrEvmbMZxs+Lql29L9UoKHJPOaLLHJ\n" +
|
||
|
"HJGnGB2uXmZ5cYvg2c5JMhAgzocbHzBW9M24D5ZtDGPabub+pLptieS/Cpb39kFL\n" +
|
||
|
"2IF4o+nLPgGvNtw0NKzG4deljZYJq7FFDC0lvxOIG2Jhr3F+2oU7o7zr0vn3lrbK\n" +
|
||
|
"YK8Ppo+9mKTf5r+l+nwCWm14hNpaPZM5M8UKCfPWSsMH01OZ5x/4/KdWkteyyUwY\n" +
|
||
|
"twIDAQAB\n" +
|
||
|
"-----END PUBLIC KEY-----\n";
|
||
|
|
||
|
// _work_pss/kp1.sig.aaa.-1.1
|
||
|
var sKp1SigAAA1 = "4c392f5428c5d76a1dd0eb665954bf8600024d5759506f223f77cbbf0fded92b0d1679658caaf7870ea82fd24b55008b19dd78fdf76f6cd857fb96d665f07f8cf08c84251d98e8719021c46e37e65c7389cc443292ff0111d6bd88c8a47b10a6faed5c95159c5a3642064064ca0b3d2c560222afa9f0c184096584893bd3d6e888ee6d3fe56fa772ed9bda7663520ebc66f33505cd0622138b26f1790dee99635f9094bcb424b31568c4d0a9475118d0a0a7a80359c3022fcf75069e7213c47d79e5542b84fca9123161c5fa9c757b019bac03f4c62839c3bd31923a7d46ae47299ab0c51e0124ee37c5d52afff0be2c37ad6d8196ba54bc28fb80cc979ab05f";
|
||
|
|
||
|
// _work_pss/kp1.sig.aaa.-1.2
|
||
|
var sKp1SigAAA2 = "18b6b70deeb89dca5a8542feaaa08547de49d957afd98b6a2d3a083db340d2b3d2277c475a401275c02c38590529c609167fb953c397b4cd31a0cc5048d0b9403156173e7bba668033267a4fbfd355bff6570defd1c6bc192c4a4e244fc8045093cb0519e409ea1399e9c0367a9136a3423a804f625af95a0715c08d35ffab217581da2cc76fbc1d0075e07f7dec9a9400ac3ef7fea28e876b7d0ffe13441bed228e4f0c72d90361485d1b322c285ce11f2555a52936ed405bb546f58280cb41071e7b7a656009b68d925fdba0c5a77fc6991cee117a8c4511fc0d55930262ba7a2e3cff1ea01aff8c4e763f5bbf31a6d9e6a508cc6bb46b17b7671510a2fb23";
|
||
|
|
||
|
// _work_pss/kp1.sig.aaa.-2.3
|
||
|
var sKp1SigAAA3 = "03fe7741e637140571e468ae84e76583ce040f7179fae7f378225f9eace7e4599c95f0393003be84c7d6fc263bacfa97ac07784482335e64a4c4d5fbc58697a3d0fa005230508a9f40ea8d5f6791694e07627ea47c0b4a3f6b9055e2add8b7eab99052ee40f1bcde65e2b1237f63afafcc9b69d86993ce7e4a5827df3462d79b55647da5781a6dda37b6763a2eca986ef5a7d71ed341a7cc99ce9b22b7b3e06ea0d1020914f8742a18453c410b91753b8ad2e50c6d2b5aa8affd30f61b4d4eb396a0fc0393e9dba5eb8ec78e543ecc2b4739d09a8b6879263b32a0c5f39c1eba40ea7a1991c4b03926245cf4c3d9b5076831f9aebd34745432e6e15fceb80276";
|
||
|
|
||
|
// _work_pss/kp1.sig.aaa.-2.4
|
||
|
var sKp1SigAAA4 = "455cda85ae69b91d29b82c27ec3cd8d335d443153558fd6a28599b5da5957aa5e96fe5c93e0700ab2efaaef8a1665e3eee68fb4ecd8a1f51c5434fa375464c6b4c4eb9184bc6ec8d2dbb5d75982ba7b6b5ca79041baadaa29f4329f47d4fbecafcd14c2794e32ccd4340fb7efec9c57bb0a5a6dbba331fdfa82f51fbe0bf47ff97892902f53b4906cc9ff438dbacf4c834251f2b8f95cdc066097d5ea4ffac3ff4c5f19c72863850fa1be5f48c94100eb20e4cee4265d21629413250a46e1ee14a4f4a576fbc9bb76ec0625f0941d7aa903fe392cf5fbb5ceaf3769dd432dd73c67df61f04471b1b79bab178c7db70ccecaa8900618874f314484b20e367517b";
|
||
|
|
||
|
//=========================================================================
|
||
|
module("Verifier Test");
|
||
|
|
||
|
test("RSAPSS kp1.sig.aaa.-1.1 verify test", function() {
|
||
|
var pubKey = PKCS5PKEY.getRSAKeyFromPublicPKCS8PEM(sKp1PubPEM);
|
||
|
var result = pubKey.verifyPSS("aaa", sKp1SigAAA1, "sha1", -1);
|
||
|
equal(result, true, 'kp1.sig');
|
||
|
});
|
||
|
|
||
|
test("RSAPSS kp1.sig.aaa.-1.2 verify test", function() {
|
||
|
var pubKey = PKCS5PKEY.getRSAKeyFromPublicPKCS8PEM(sKp1PubPEM);
|
||
|
var result = pubKey.verifyPSS("aaa", sKp1SigAAA2, "sha1", -1);
|
||
|
equal(result, true, 'kp1.sig');
|
||
|
});
|
||
|
|
||
|
test("RSAPSS kp1.sig.aaa.-2.3 verify test", function() {
|
||
|
var pubKey = PKCS5PKEY.getRSAKeyFromPublicPKCS8PEM(sKp1PubPEM);
|
||
|
var result = pubKey.verifyPSS("aaa", sKp1SigAAA3, "sha1", -2);
|
||
|
equal(result, true, 'kp1.sig');
|
||
|
});
|
||
|
|
||
|
test("RSAPSS kp1.sig.aaa.-2.4 verify test", function() {
|
||
|
var pubKey = PKCS5PKEY.getRSAKeyFromPublicPKCS8PEM(sKp1PubPEM);
|
||
|
var result = pubKey.verifyPSS("aaa", sKp1SigAAA4, "sha1", -2);
|
||
|
equal(result, true, 'kp1.sig');
|
||
|
});
|
||
|
|
||
|
test("RSAPSS kp1 sign and verify", function() {
|
||
|
var prvKey = new RSAKey();
|
||
|
prvKey.readPrivateKeyFromPEMString(sKp1PrvPEM);
|
||
|
var hSigValue = prvKey.signPSS("aaa", "sha1", -2);
|
||
|
|
||
|
var pubKey = PKCS5PKEY.getRSAKeyFromPublicPKCS8PEM(sKp1PubPEM);
|
||
|
var result = pubKey.verifyPSS("aaa", hSigValue, "sha1", -2);
|
||
|
equal(result, true, 'kp1.sig');
|
||
|
});
|
||
|
|
||
|
});
|
||
|
</script>
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="qunit"></div>
|
||
|
<div id="qunit-fixture">test markup</div>
|
||
|
</body>
|
||
|
</html>
|
||
|
|
||
|
|
||
|
|