forked from kjur/jsrsasign
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qunit-do-asn1x509-newcert-veri.html
executable file
·138 lines (127 loc) · 4.74 KB
/
qunit-do-asn1x509-newcert-veri.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<title>QUnit for ASN1 Encoder Class 'asn1x509.js' X509Util.newCert verifySignature 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="../ext/cj/cryptojs-312-core-fix.js"></script>
<script src="../ext/cj/x64-core.js"></script>
<script src="../ext/cj/cipher-core_min.js"></script>
<script src="../ext/cj/aes_min.js"></script>
<script src="../ext/cj/tripledes_min.js"></script>
<script src="../ext/cj/enc-base64_min.js"></script>
<script src="../ext/cj/md5_min.js"></script>
<script src="../ext/cj/sha1_min.js"></script>
<script src="../ext/cj/sha256_min.js"></script>
<script src="../ext/cj/sha224_min.js"></script>
<script src="../ext/cj/sha512_min.js"></script>
<script src="../ext/cj/sha384_min.js"></script>
<script src="../ext/cj/ripemd160_min.js"></script>
<script src="../ext/cj/hmac_min.js"></script>
<script src="../ext/cj/pbkdf2_min.js"></script>
<script src="../ext/yahoo.js"></script>
<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/prng4.js"></script>
<script src="../ext/rng.js"></script>
<script src="../ext/base64.js"></script>
<script src="../ext/rsa.js"></script>
<script src="../ext/rsa2.js"></script>
<script src="../ext/ec.js"></script>
<script src="../ext/ec-patch.js"></script>
<script src="../src/base64x-1.1.js"></script>
<script src="../src/asn1hex-1.1.js"></script>
<script src="../src/rsapem-1.1.js"></script>
<script src="../src/rsasign-1.2.js"></script>
<script src="../src/crypto-1.1.js"></script>
<script src="../src/asn1-1.0.js"></script>
<script src="../src/ecdsa-modified-1.0.js"></script>
<script src="../src/ecparam-1.0.js"></script>
<script src="../src/asn1x509-1.0.js"></script>
<script src="../src/x509-1.1.js"></script>
<script src="../src/keyutil-1.0.js"></script>
<script type="text/javascript">
<!--
// *** DATA *********************
var certTmpl = {
serial: {int: 4},
sigalg: {name: 'SHA1withRSA'},
issuer: {str: '/C=US/O=a'},
notbefore: {str: '130504235959Z'},
notafter: {str: '140504235959Z'},
subject: {str: '/C=US/O=b'},
sbjpubkey: null,
ext: [
{basicConstraints: {cA: true, critical: true}},
{keyUsage: {bin: '11'}},
{cRLDistributionPoints: {uri: 'http://aaa.com/a.crl'}},
{extKeyUsage: {array: [{name: 'clientAuth'}]}},
],
cakey: null
};
var kpRSA = KEYUTIL.generateKeypair("RSA", 1024);
var kpEC = KEYUTIL.generateKeypair("EC", "secp256k1");
// *** TEST *********************
$(document).ready(function(){
test("newCertPEM SHA1withRSA signature value verify", function() {
var tmpl = JSON.parse(JSON.stringify(certTmpl));
tmpl.sigalg.name = "SHA1withRSA";
tmpl.sbjpubkey = kpRSA.pubKeyObj;
tmpl.cakey = kpRSA.prvKeyObj;
var certPEM = KJUR.asn1.x509.X509Util.newCertPEM(tmpl);
var hCert = pemtohex(certPEM);
var x = new X509();
x.readCertHex(hCert);
equal(x.verifySignature(kpRSA.pubKeyObj), true, "VALID");
});
test("newCertPEM SHA256withRSA signature value verify", function() {
var tmpl = JSON.parse(JSON.stringify(certTmpl));
tmpl.sigalg.name = "SHA256withRSA";
tmpl.sbjpubkey = kpRSA.pubKeyObj;
tmpl.cakey = kpRSA.prvKeyObj;
var certPEM = KJUR.asn1.x509.X509Util.newCertPEM(tmpl);
var hCert = pemtohex(certPEM);
var x = new X509();
x.readCertHex(hCert);
equal(x.verifySignature(kpRSA.pubKeyObj), true, "VALID");
});
test("newCertPEM SHA1withECDSA signature value verify", function() {
var tmpl = JSON.parse(JSON.stringify(certTmpl));
tmpl.sigalg.name = "SHA1withECDSA";
tmpl.sbjpubkey = kpEC.pubKeyObj;
tmpl.cakey = kpEC.prvKeyObj;
var certPEM = KJUR.asn1.x509.X509Util.newCertPEM(tmpl);
var hCert = pemtohex(certPEM);
var x = new X509();
x.readCertHex(hCert);
equal(x.verifySignature(kpEC.pubKeyObj), true, "VALID");
});
test("newCertPEM SHA256withECDSA signature value verify", function() {
var tmpl = JSON.parse(JSON.stringify(certTmpl));
tmpl.sigalg.name = "SHA256withECDSA";
tmpl.sbjpubkey = kpEC.pubKeyObj;
tmpl.cakey = kpEC.prvKeyObj;
var certPEM = KJUR.asn1.x509.X509Util.newCertPEM(tmpl);
var hCert = pemtohex(certPEM);
var x = new X509();
x.readCertHex(hCert);
equal(x.verifySignature(kpEC.pubKeyObj), true, "VALID");
});
});
-->
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
<a href="index.html">TEST INDEX</a> |
<a href="qunit-do-x509-hex2dn.html">x509-hex2dn</a> |
<a href="qunit-do-asn1x509.html">asn1x509</a> |
<a href="qunit-do-asn1x509-newcrt.html">asn1x509-newcrt</a> |
<a href="qunit-do-asn1x509-multirdn.html">asn1x509-multirdn</a> |
<a href="qunit-do-asn1csr.html">asn1csr</a> |
</body>
</html>