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.
216 lines
13 KiB
216 lines
13 KiB
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
|
"http://www.w3.org/TR/html4/loose.dtd"> |
|
<html> |
|
<head> |
|
<title>QUnit for X.509 Certificate 'x509.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://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 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/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="../ext/base64.js"></script> |
|
|
|
<script language="JavaScript" type="text/javascript" src="../base64x-1.1.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../crypto-1.1.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 language="JavaScript" type="text/javascript" src="../x509-1.1.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../ext/yahoo.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../asn1-1.0.js"></script> |
|
<script language="JavaScript" type="text/javascript" src="../asn1x509-1.0.js"></script> |
|
|
|
<script type="text/javascript"> |
|
$(document).ready(function(){ |
|
|
|
var certGithubPEM = "-----BEGIN CERTIFICATE-----\r\n" + |
|
"MIIF4DCCBMigAwIBAgIQDACTENIG2+M3VTWAEY3chzANBgkqhkiG9w0BAQsFADB1\r\n" + |
|
"MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r\n" + |
|
"d3cuZGlnaWNlcnQuY29tMTQwMgYDVQQDEytEaWdpQ2VydCBTSEEyIEV4dGVuZGVk\r\n" + |
|
"IFZhbGlkYXRpb24gU2VydmVyIENBMB4XDTE0MDQwODAwMDAwMFoXDTE2MDQxMjEy\r\n" + |
|
"MDAwMFowgfAxHTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRMwEQYLKwYB\r\n" + |
|
"BAGCNzwCAQMTAlVTMRkwFwYLKwYBBAGCNzwCAQITCERlbGF3YXJlMRAwDgYDVQQF\r\n" + |
|
"Ewc1MTU3NTUwMRcwFQYDVQQJEw41NDggNHRoIFN0cmVldDEOMAwGA1UEERMFOTQx\r\n" + |
|
"MDcxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1T\r\n" + |
|
"YW4gRnJhbmNpc2NvMRUwEwYDVQQKEwxHaXRIdWIsIEluYy4xEzARBgNVBAMTCmdp\r\n" + |
|
"dGh1Yi5j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BQcwAYYYaHR0cDovL29jc3AuZGlnaWNlcnQuY29tMFIGCCsGAQUFBzAChkZodHRw\r\n" + |
|
"Oi8vY2FjZXJ0cy5kaWdpY2VydC5jb20vRGlnaUNlcnRTSEEyRXh0ZW5kZWRWYWxp\r\n" + |
|
"ZGF0aW9uU2VydmVyQ0EuY3J0MAwGA1UdEwEB/wQCMAAwDQYJKoZIhvcNAQELBQAD\r\n" + |
|
"ggEBAG/nbcuC8++QhwnXDxUiLIz+06scipbbXRJd0XjAMbD/RciJ9wiYUhcfTEsg\r\n" + |
|
"ZGpt21DXEL5+q/4vgNipSlhBaYFyGQiDm5IQTmIte0ZwQ26jUxMf4pOmI1v3kj43\r\n" + |
|
"FHU7uUskQS6lPUgND5nqHkKXxv6V2qtHmssrA9YNQMEK93ga2rWDpK21mUkgLviT\r\n" + |
|
"PB5sPdE7IzprOCp+Ynpf3RcFddAkXb6NqJoQRPrStMrv19C1dqUmJRwIQdhkkqev\r\n" + |
|
"ff6IQDlhC8BIMKmCNK33cEYDfDWROtW7JNgBvBTwww8jO1gyug8SbGZ6bZ3k8OV8\r\n" + |
|
"XX4C2NesiZcLYbc2n7B9O+63M2k=\r\n" + |
|
"-----END CERTIFICATE-----\r\n"; |
|
|
|
// _gitpg/jsrsasign/test/eckey/k1.self.cer |
|
var k1CertPEM = "" + |
|
"-----BEGIN CERTIFICATE-----\n" + |
|
"MIIBfDCCASGgAwIBAgIJAKbxELQvSUDNMAoGCCqGSM49BAMCMBoxCzAJBgNVBAYT\n" + |
|
"AlVTMQswCQYDVQQKDAJLMTAeFw0xMzA3MTQwMjE3MTdaFw0yMzA3MTIwMjE3MTda\n" + |
|
"MBoxCzAJBgNVBAYTAlVTMQswCQYDVQQKDAJLMTBZMBMGByqGSM49AgEGCCqGSM49\n" + |
|
"AwEHA0IABKAVMqPAkABT3mD77+/MpYeTMBWY0wi0Hm9ONk44jCcRvvQyxZkUjJQU\n" + |
|
"PU/0bCy3Pj5qQdfu8jwEfqEeYGZ95CWjUDBOMB0GA1UdDgQWBBTIR74yfMz/Y4hw\n" + |
|
"dXSW4r42bESo/DAfBgNVHSMEGDAWgBTIR74yfMz/Y4hwdXSW4r42bESo/DAMBgNV\n" + |
|
"HRMEBTADAQH/MAoGCCqGSM49BAMCA0kAMEYCIQDfAcS/WKBrP6JBgksQVpp4jdq4\n" + |
|
"C53Yu4F5NkaMgthAHgIhANGRdWAP1QdW9l6tiglQwdqJs4T0e8+NYv+RcAb3VYwn\n" + |
|
"-----END CERTIFICATE-----\n"; |
|
var k1CertHex = X509.pemToHex(k1CertPEM); |
|
|
|
test("getV3ExtInfoListOfCertHex test1", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
var a = X509.getV3ExtInfoListOfCertHex(hCert); |
|
equal(a.length, 9, "num ext=9"); |
|
equal(a[0].posTLV, 1484, "AKID TLV index"); |
|
equal(a[0].oid, "2.5.29.35", "AKID oid"); |
|
equal(a[0].critical, false, "AKID critical"); |
|
equal(a[0].posV, 1502, "AKID value index"); |
|
equal(a[1].oid, "2.5.29.14", "SKID oid"); |
|
equal(a[1].critical, false, "SKID critical"); |
|
equal(a[2].oid, "2.5.29.17", "SAN oid"); |
|
equal(a[2].critical, false, "SAN critical"); |
|
equal(a[3].oid, "2.5.29.15", "KeyUsage oid"); |
|
equal(a[3].critical, true, "KeyUsage critical"); |
|
equal(a[3].posV, 1714, "KeyUsage posV"); |
|
equal(ASN1HEX.getHexOfTLV_AtObj(hCert, a[3].posV), "030205a0", "KeyUsage value 030205a0"); |
|
equal(a[4].oid, "2.5.29.37", "ExtKeyUsage oid"); |
|
equal(a[4].critical, false, "ExtKeyUsage critical"); |
|
equal(a[5].oid, "2.5.29.31", "CDP oid"); |
|
equal(a[5].critical, false, "CDP critical"); |
|
equal(a[6].oid, "2.5.29.32", "CertPolicy oid"); |
|
equal(a[6].critical, false, "CertPolicy critical"); |
|
equal(a[7].oid, "1.3.6.1.5.5.7.1.1", "AIA oid"); |
|
equal(a[7].critical, false, "AIA critical"); |
|
equal(a[8].oid, "2.5.29.19", "basicConstraints oid"); |
|
equal(a[8].critical, true, "basicConstraints critical"); |
|
equal(ASN1HEX.getHexOfTLV_AtObj(hCert, a[8].posV), "3000", "basicConst value 3000"); |
|
}); |
|
|
|
test("getPosOfTLV_V3ExtValue test1", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
equal(X509.getPosOfTLV_V3ExtValue(hCert, "keyUsage"), 1714, "by keyUsage"); |
|
equal(X509.getPosOfTLV_V3ExtValue(hCert, "2.5.29.15"), 1714, "by 2.5.29.15(=keyUsage)"); |
|
equal(X509.getPosOfTLV_V3ExtValue(hCert, "policyConstraints"), -1, |
|
"by policyConstraints -> -1, no such extension"); |
|
equal(X509.getPosOfTLV_V3ExtValue(hCert, "0.0.0.0"), -1, |
|
"by 0.0.0.0 -> -1, no such extension"); |
|
}); |
|
|
|
test("getHexOfV_V3ExtValue test1", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
equal(X509.getHexOfV_V3ExtValue(hCert, "keyUsage"), "05a0", "by keyUsage"); |
|
equal(X509.getHexOfV_V3ExtValue(hCert, "2.5.29.15"), "05a0", "by 2.5.29.15(=keyUsage)"); |
|
equal(X509.getHexOfV_V3ExtValue(hCert, "policyConstraints"), null, |
|
"by policyConstraints -> null, no such extention"); |
|
equal(X509.getHexOfV_V3ExtValue(hCert, "0.0.0.0"), null, |
|
"by 0.0.0.0 -> null, no such extension"); |
|
}); |
|
|
|
test("getHexOfTLV_V3ExtValue test1", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
equal(X509.getHexOfTLV_V3ExtValue(hCert, "keyUsage"), "030205a0", "by keyUsage"); |
|
equal(X509.getHexOfTLV_V3ExtValue(hCert, "2.5.29.15"), "030205a0", "by 2.5.29.15(=keyUsage)"); |
|
equal(X509.getHexOfTLV_V3ExtValue(hCert, "policyConstraints"), null, |
|
"by policyConstraints -> null, no such extension"); |
|
equal(X509.getHexOfTLV_V3ExtValue(hCert, "0.0.0.0"), null, |
|
"by 0.0.0.0 -> null, no such extension"); |
|
}); |
|
|
|
test("getExtKeyUsageBin", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
equal(X509.getExtKeyUsageBin(hCert), "101", "101"); |
|
}); |
|
|
|
test("getExtKeyUsageString", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
equal(X509.getExtKeyUsageString(hCert), "digitalSignature,keyEncipherment", "digitalSignature,keyEncipherment"); |
|
}); |
|
|
|
test("getExtAIAInfo", function() { |
|
var hCert = X509.pemToHex(certGithubPEM); |
|
var info = X509.getExtAIAInfo(hCert); |
|
equal(info.ocsp.length, 1, "number item of ocsp = 1"); |
|
equal(info.ocsp[0], "http://ocsp.digicert.com", "ocsp=http://ocsp.digicert.com"); |
|
equal(info.caissuer.length, 1, "number item of caIssuer = 1"); |
|
equal(info.caissuer[0], "http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt", "caIssuer=http://cacerts.digicert.com/DigiCertSHA2ExtendedValidationServerCA.crt"); |
|
}); |
|
|
|
test("getExtBasicConstraints k1 {cA:true}", function() { |
|
var r = X509.getExtBasicConstraints(k1CertHex); |
|
equal(typeof r, "object"); |
|
equal(r.cA, true); |
|
equal(r.pathLen === undefined, true); |
|
}); |
|
|
|
// test/z1.der1-p3 basicConstraints={ca:true, pathlen:3} |
|
test("getExtBasicConstraints z1.der1-p3 {cA:true,pathLen:3}", function() { |
|
var r = X509.getExtBasicConstraints("3082017630820120a003020102020107300d06092a864886f70d01010b05003019310b3009060355040613025553310a3008060355040a0c0154301e170d3136303431333134313832365a170d3236303431333134313832365a3019310b3009060355040613025553310a3008060355040a0c0154305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a3533051301d0603551d0e04160414c5473ee200c8e7ad7003dff5420b8cddf4c20e15301f0603551d23041830168014c5473ee200c8e7ad7003dff5420b8cddf4c20e15300f0603551d13040830060101ff020103300d06092a864886f70d01010b0500034100862bf6d5f0c366dd1c71af10df93e2e9e0b7210b6912d1774e27107203f2dc257f9b132285bc1ce8d32d8ffc69470cd6c52ec76b7d68708eca3bbd49556f3005"); |
|
equal(typeof r, "object"); |
|
equal(r.cA, true); |
|
equal(r.pathLen, 3); |
|
}); |
|
|
|
// test/z1.der2-no basicConstraints has empty value (for EE) |
|
test("getExtBasicConstraints z1.der2-emp {}", function() { |
|
var r = X509.getExtBasicConstraints("308201703082011aa003020102020107300d06092a864886f70d01010b05003019310b3009060355040613025553310a3008060355040a0c0154301e170d3136303431333134313934345a170d3236303431333134313934345a3019310b3009060355040613025553310a3008060355040a0c0154305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a34d304b301d0603551d0e04160414c5473ee200c8e7ad7003dff5420b8cddf4c20e15301f0603551d23041830168014c5473ee200c8e7ad7003dff5420b8cddf4c20e1530090603551d1304023000300d06092a864886f70d01010b050003410039de7f9c2975d1d309edd707609c3052c6adeda0b440c55e86410d303abd3363e4d66a1858c5c7f747fee590c38cf68a9ae39ce394175e36d12308490d3b94f2"); |
|
equal(typeof r, "object"); |
|
equal(r.cA === undefined, true); |
|
equal(r.pathLen === undefined, true); |
|
}); |
|
|
|
// test/z1.der3-no (no basic constraints) |
|
test("getExtBasicConstraints z1.der3-no (no basic constraints)", function() { |
|
var r = X509.getExtBasicConstraints("308201653082010fa003020102020107300d06092a864886f70d01010b05003019310b3009060355040613025553310a3008060355040a0c0154301e170d3136303431333135313332335a170d3236303431333135313332335a3019310b3009060355040613025553310a3008060355040a0c0154305c300d06092a864886f70d0101010500034b003048024100e8664dd2b40529121568f3b39bc97a62e7ba3c09babdc4f0dcd8df90eb790b9bb645a2b70e3112747b4d3c41b51424895115fef88f79d43eae5b1a4e3518fd590203010001a3423040301d0603551d0e04160414c5473ee200c8e7ad7003dff5420b8cddf4c20e15301f0603551d23041830168014c5473ee200c8e7ad7003dff5420b8cddf4c20e15300d06092a864886f70d01010b050003410016f823db6f65546958157ec08c20e736b0243fb6fa2fba6b74ac036f0115786c070d80d94b428f2f9d174169fb19e00fadfa5dbfbd19f27e2782adbd7bec644b"); |
|
equal(r, null); |
|
}); |
|
|
|
}); |
|
</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-x509.html">x509</a> | |
|
<a href="qunit-do-x509-ext.html">x509-ext</a> | |
|
<a href="qunit-do-x509-key.html">x509-key</a> | |
|
<a href="qunit-do-x509-kid.html">x509-kid</a> | |
|
</p> |
|
|
|
</body> |
|
<center><p>© 2015-2016 Kenji Urushima</p></center> |
|
</html> |
|
|
|
|