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.
374 lines
28 KiB
374 lines
28 KiB
<!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 'asn1cms.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://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-min.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.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/x64-core.js"></script> |
|
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/sha512.js"></script> |
|
|
|
<script src="../ext/jsbn.js"></script> |
|
<script src="../ext/jsbn2.js"></script> |
|
<script src="../ext/rsa.js"></script> |
|
<script src="../ext/rsa2.js"></script> |
|
<script src="../ext/base64.js"></script> |
|
<script src="../base64x-1.1.js"></script> |
|
<script src="../asn1hex-1.1.js"></script> |
|
<script src="../rsapem-1.1.js"></script> |
|
<script src="../rsasign-1.2.js"></script> |
|
<script src="../crypto-1.1.js"></script> |
|
<script src="../keyutil-1.0.js"></script> |
|
<script src="../asn1-1.0.js"></script> |
|
<script src="../asn1x509-1.0.js"></script> |
|
<script src="../asn1cms-1.0.js"></script> |
|
<script src="../asn1cades-1.0.js"></script> |
|
<script src="../x509-1.1.js"></script> |
|
|
|
<script type="text/javascript"> |
|
<!-- |
|
$(document).ready(function(){ |
|
|
|
// _test/z4.* RSA 2048bit |
|
var sZ4_PRVP8PPEM = |
|
"-----BEGIN PRIVATE KEY-----\n" + |
|
"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQDfdOqotHd55SYO\n" + |
|
"0dLz2oXengw/tZ+q3ZmOPeVmMuOMIYO/Cv1wk2U0OK4pug4OBSJPhl09Zs6IwB8N\n" + |
|
"wPOU7EDTgMOcQUYB/6QNCI1J7Zm2oLtuchzz4pIb+o4ZAhVprLhRyvqi8OTKQ7kf\n" + |
|
"Gfs5Tuwmn1M/0fQkfzMxADpjOKNgf0uy6lN6utjdTrPKKFUQNdc6/Ty8EeTnQEwU\n" + |
|
"lsT2LAXCfEKxTn5RlRljDztS7Sfgs8VL0FPy1Qi8B+dFcgRYKFrcpsVaZ1lBmXKs\n" + |
|
"XDRu5QR/Rg3f9DRq4GR1sNH8RLY9uApMl2SNz+sR4zRPG85R/se5Q06Gu0BUQ3UP\n" + |
|
"m67ETVZLAgMBAAECggEADjU54mYvHpICXHjc5+JiFqiH8NkUgOG8LL4kwt3DeBp9\n" + |
|
"bP0+5hSJH8vmzwJkeGG9L79EWG4b/bfxgYdeNX7cFFagmWPRFrlxbd64VRYFawZH\n" + |
|
"RJt+2cbzMVI6DL8EK4bu5Ux5qTiV44Jw19hoD9nDzCTfPzSTSGrKD3iLPdnREYaI\n" + |
|
"GDVxcjBv3Tx6rrv3Z2lhHHKhEHb0RRjATcjAVKV9NZhMajJ4l9pqJ3A4IQrCBl95\n" + |
|
"ux6Xm1oXP0i6aR78cjchsCpcMXdP3WMsvHgTlsZT0RZLFHrvkiNHlPiil4G2/eHk\n" + |
|
"wvT//CrcbO6SmI/zCtMmypuHJqcr+Xb7GPJoa64WoQKBgQDwrfelf3Rdfo9kaK/b\n" + |
|
"rBmbu1++qWpYVPTedQy84DK2p3GE7YfKyI+fhbnw5ol3W1jjfvZC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yGXpg3Eg2h3iLvUtwcNny0hRKstc73Jl9xR3qXfXKJH0ThTl\n" + |
|
"q0gq\n" + |
|
"-----END CERTIFICATE-----\n"; |
|
|
|
// ======= TEST =============================================================== |
|
|
|
test("attr ContentType tSTInfo", function() { |
|
expect(2); |
|
|
|
var o = new KJUR.asn1.cms.ContentType({"oid": "1.2.840.113549.1.9.16.1.4"}); |
|
equal(o.getEncodedHex(), "301a06092a864886f70d010903310d060b2a864886f70d0109100104", "tstInfo by oid"); |
|
|
|
var o2 = new KJUR.asn1.cms.ContentType({"name": "tstinfo"}); |
|
equal(o2.getEncodedHex(), "301a06092a864886f70d010903310d060b2a864886f70d0109100104", "tstInfo by name"); |
|
}); |
|
|
|
test("attr MessageDigest 01020304abcd", function() { |
|
var o = new KJUR.asn1.cms.MessageDigest({"hex": "01020304abcd"}); |
|
equal(o.getEncodedHex(), "301506092a864886f70d0109043108040601020304abcd", "tstInfo"); |
|
}); |
|
|
|
test("attr SigningTime 131231235959Z", function() { |
|
expect(2); |
|
|
|
var o1 = new KJUR.asn1.cms.SigningTime({"str": "131231235959Z"}); |
|
equal(o1.getEncodedHex(), "301c06092a864886f70d010905310f170d3133313233313233353935395a", "{str:1312...}"); |
|
|
|
var o2 = new KJUR.asn1.cms.SigningTime({}); |
|
equal(o2.getEncodedHex().substr(0, 34), |
|
"301c06092a864886f70d010905310f170d3133313233313233353935395a".substr(0, 34), "{}"); |
|
}); |
|
|
|
test("attr SigningCertificate z4self", function() { |
|
var o = new KJUR.asn1.cms.SigningCertificate({array: [sZ4_CERPEM]}); |
|
equal(o.getEncodedHex(), "304a060b2a864886f70d010910020c313b30393037041476c19d787741bdaf76cab1c42d166cb536aa83f8301f301a310b3009060355040613025553310b3009060355040a0c025a34020101", ""); |
|
}); |
|
|
|
test("attr SigningCertificateV2 z4self", function() { |
|
var o = new KJUR.asn1.cms.SigningCertificateV2({array: [sZ4_CERPEM], hashAlg: 'sha512'}); |
|
equal(o.getEncodedHex(), "308185060b2a864886f70d010910022f317630743072300d06096086480165030402030500044026b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c5301f301a310b3009060355040613025553310b3009060355040a0c025a34020101", ""); |
|
}); |
|
|
|
test("IssuerAndSerialNumber /C=US/O=T1 3", function() { |
|
expect(2); |
|
|
|
var o = new KJUR.asn1.cms.IssuerAndSerialNumber({"issuer": {"str": "/C=US/O=T1"}, |
|
"serial": {"int": 3}}); |
|
equal(o.getEncodedHex(), "301f301a310b3009060355040613025553310b3009060355040a0c025431020103", "by issuer and serial"); |
|
|
|
var o2 = new KJUR.asn1.cms.IssuerAndSerialNumber({cert: sZ4_CERPEM}); |
|
equal(o2.getEncodedHex(), "301f301a310b3009060355040613025553310b3009060355040a0c025a34020101", "by cert"); |
|
}); |
|
|
|
test("AttributeList/1 sorted", function() { |
|
var a1 = new KJUR.asn1.cms.ContentType({"oid": "1.2.840.113549.1.9.16.1.4"}); |
|
var a2 = new KJUR.asn1.cms.MessageDigest({"hex": "0102030405060708090001020304050607080900"}); |
|
|
|
expect(3); |
|
|
|
var o1 = new KJUR.asn1.cms.AttributeList(); |
|
o1.add(a1); |
|
o1.add(a2); |
|
equal(o1.getEncodedHex(), "3141301a06092a864886f70d010903310d060b2a864886f70d0109100104302306092a864886f70d010904311604140102030405060708090001020304050607080900", "[a1,a2], sortFlag = true"); |
|
|
|
var o2 = new KJUR.asn1.cms.AttributeList(); |
|
o2.add(a2); |
|
o2.add(a1); |
|
equal(o2.getEncodedHex(), "3141301a06092a864886f70d010903310d060b2a864886f70d0109100104302306092a864886f70d010904311604140102030405060708090001020304050607080900", "[a2,a1], sortFlag = true"); |
|
|
|
var o3 = new KJUR.asn1.cms.AttributeList(); |
|
o3.sortFlag = false; |
|
o3.add(a2); |
|
o3.add(a1); |
|
equal(o3.getEncodedHex(), "3141302306092a864886f70d010904311604140102030405060708090001020304050607080900301a06092a864886f70d010903310d060b2a864886f70d0109100104", "[a2,a1], sortFlag = false"); |
|
}); |
|
|
|
test("SignerInfo/1", function() { |
|
var o = new KJUR.asn1.cms.SignerInfo(); |
|
o.dSignerIdentifier = |
|
new KJUR.asn1.cms.IssuerAndSerialNumber({issuer: {str: '/C=US/O=T1'}, |
|
serial: {int: 1}}); |
|
o.dDigestAlgorithm = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'sha1'}); |
|
o.dSignedAttrs.add(new KJUR.asn1.cms.ContentType({oid: '1.2.840.113549.1.7.1'})); // data |
|
o.dSignedAttrs.add(new KJUR.asn1.cms.MessageDigest({hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'})); |
|
o.dSigAlg = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'SHA1withRSA'}); |
|
o.dSig = new KJUR.asn1.DEROctetString({hex: 'b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8'}); |
|
|
|
equal(o.getEncodedHex(), "3081a1020101301f301a310b3009060355040613025553310b3009060355040a0c025431020101300906052b0e03021a0500a03f301806092a864886f70d010903310b06092a864886f70d010701302306092a864886f70d01090431160414a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0300d06092a864886f70d01010505000420b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8", "si1"); |
|
}); |
|
|
|
test("SignerInfo/2 sign(sZ4PRV), setSignerIdentifier(sZ4CER)", function() { |
|
var o = new KJUR.asn1.cms.SignerInfo(); |
|
o.setSignerIdentifier(sZ4_CERPEM); |
|
o.dDigestAlgorithm = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'sha1'}); |
|
o.dSignedAttrs.add(new KJUR.asn1.cms.ContentType({oid: '1.2.840.113549.1.7.1'})); // data |
|
o.dSignedAttrs.add(new KJUR.asn1.cms.MessageDigest({hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'})); |
|
o.sign(sZ4_PRVP8PPEM, "SHA1withRSA"); |
|
equal(o.getEncodedHex(), "30820183020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300906052b0e03021a0500a03f301806092a864886f70d010903310b06092a864886f70d010701302306092a864886f70d01090431160414a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0300d06092a864886f70d010105050004820100dddd5f91e66958996fa1783907bbe97dcb1b1592a4513b0fd6714875dce9957641c4c73cc8d87b9243c83b8f0499fa8392d43721eece8c7aa12e991db721268c290b3fbe930934ecf9c512db5084d55605e6e46c0beb88e784d3bbb60fc7ebaa16e2accdc9d8bef1a1df7c59d7efe2abb0fad8578019f51bea27e205207d42d96c21d19eb276b1744ea751e8357053c6b84452ff97fa4b74b8d3b923edfb2d5a1a5f5ba3e2ecdc63d82f95f416b70e85f2d72acffaea5e16782fa2e202649ecc6c3cc9517b6352500c366a76d71fdbfc9e0195bbef142557d1e211d75a5362d0409002acb576dee3e9f26336a3ebcbfe2642a0fd65c9a22b826fca791b253bdf", "si2"); |
|
}); |
|
|
|
test("EncapsulatedContentInfo", function() { |
|
expect(5); |
|
|
|
var o1 = new KJUR.asn1.cms.EncapsulatedContentInfo(); |
|
o1.setContentValueHex('616161'); |
|
equal(o1.getEncodedHex(), "301206092a864886f70d010701a0050403616161", "setContentValueHex(616161)"); |
|
|
|
var o2 = new KJUR.asn1.cms.EncapsulatedContentInfo(); |
|
o2.setContentValueStr('aaa'); |
|
equal(o2.getEncodedHex(), "301206092a864886f70d010701a0050403616161", "setContentValueStr(aaa)"); |
|
|
|
var o3 = new KJUR.asn1.cms.EncapsulatedContentInfo(); |
|
o3.setContentValueStr('aaa'); |
|
o3.isDetached = true; |
|
equal(o3.getEncodedHex(), "300b06092a864886f70d010701", "setContentValueStr(aaa) isDetached"); |
|
|
|
var o4 = new KJUR.asn1.cms.EncapsulatedContentInfo(); |
|
o4.setContentType('tstinfo'); |
|
o4.setContentValueHex('3006020101020102'); |
|
equal(o4.getEncodedHex(), "3019060b2a864886f70d0109100104a00a04083006020101020102", |
|
"setContentValueHex(3006020101020102) tstInfo"); |
|
|
|
var o5 = new KJUR.asn1.cms.EncapsulatedContentInfo(); |
|
o5.setContentValue({str: 'aaa'}); |
|
equal(o5.getEncodedHex(), "301206092a864886f70d010701a0050403616161", "setContentValue({str:aaa})"); |
|
}); |
|
|
|
test("ContentInfo/1", function() { |
|
var nA = KJUR.asn1; |
|
var seq = new nA.DERSequence({array: [new nA.DERInteger({int: 1}), |
|
new nA.DERInteger({int: 2})]}); |
|
var o = new KJUR.asn1.cms.ContentInfo({type: 'signed-data', obj: seq}); |
|
equal(o.getEncodedHex(), "301506092a864886f70d010702a0083006020101020102"); |
|
}); |
|
|
|
test("SignedData/1", function() { |
|
var o = new KJUR.asn1.cms.SignedData(); |
|
o.dEncapContentInfo.setContentValueHex('616161'); |
|
o.digestAlgNameList = ['sha1']; |
|
o.signerInfoList[0].dSignerIdentifier = |
|
new KJUR.asn1.cms.IssuerAndSerialNumber({issuer: {str: '/C=US/O=T1'}, |
|
serial: {int: 1}}); |
|
o.signerInfoList[0].dDigestAlgorithm = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'sha1'}); |
|
o.signerInfoList[0].dSignedAttrs.add(new KJUR.asn1.cms.ContentType({oid: '1.2.840.113549.1.7.1'})); // data |
|
o.signerInfoList[0].dSignedAttrs.add(new KJUR.asn1.cms.MessageDigest({hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'})); |
|
o.signerInfoList[0].dSigAlg = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'SHA1withRSA'}); |
|
o.signerInfoList[0].dSig = new KJUR.asn1.DEROctetString({hex: 'b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8'}); |
|
|
|
equal(o.getEncodedHex(), "3081cb020101310b300906052b0e03021a0500301206092a864886f70d010701a00504036161613181a43081a1020101301f301a310b3009060355040613025553310b3009060355040a0c025431020101300906052b0e03021a0500a03f301806092a864886f70d010903310b06092a864886f70d010701302306092a864886f70d01090431160414a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0300d06092a864886f70d01010505000420b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8", "sd1"); |
|
}); |
|
|
|
test("SignedData/2 getContentInfoEncodedHex", function() { |
|
var o = new KJUR.asn1.cms.SignedData(); |
|
o.dEncapContentInfo.setContentValueHex('616161'); |
|
o.digestAlgNameList = ['sha1']; |
|
o.signerInfoList[0].dSignerIdentifier = |
|
new KJUR.asn1.cms.IssuerAndSerialNumber({issuer: {str: '/C=US/O=T1'}, |
|
serial: {int: 1}}); |
|
o.signerInfoList[0].dDigestAlgorithm = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'sha1'}); |
|
o.signerInfoList[0].dSignedAttrs.add(new KJUR.asn1.cms.ContentType({oid: '1.2.840.113549.1.7.1'})); // data |
|
o.signerInfoList[0].dSignedAttrs.add(new KJUR.asn1.cms.MessageDigest({hex: 'a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0'})); |
|
o.signerInfoList[0].dSigAlg = new KJUR.asn1.x509.AlgorithmIdentifier({name: 'SHA1withRSA'}); |
|
o.signerInfoList[0].dSig = new KJUR.asn1.DEROctetString({hex: 'b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8'}); |
|
|
|
equal(o.getContentInfoEncodedHex(), "3081dc06092a864886f70d010702a081ce3081cb020101310b300906052b0e03021a0500301206092a864886f70d010701a00504036161613181a43081a1020101301f301a310b3009060355040613025553310b3009060355040a0c025431020101300906052b0e03021a0500a03f301806092a864886f70d010903310b06092a864886f70d010701302306092a864886f70d01090431160414a1a2a3a4a5a6a7a8a9a0a1a2a3a4a5a6a7a8a9a0300d06092a864886f70d01010505000420b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8b1b2b3b4b5b6b7b8", "sd1"); |
|
}); |
|
|
|
test("SignedData total test", function() { |
|
var nC = KJUR.asn1.cms; |
|
var sd = new nC.SignedData(); |
|
|
|
sd.dEncapContentInfo.setContentValue({str: "jsrsasign"}); |
|
|
|
sd.signerInfoList[0].setForContentAndHash({sdObj: sd, |
|
eciObj: sd.dEncapContentInfo, |
|
hashAlg: 'sha256'}); |
|
sd.signerInfoList[0].dSignedAttrs.add(new nC.SigningTime({str: '131231235959Z'})); |
|
//sd.signerInfoList[0].dSignedAttrs.add(new nC.SigningTime()); |
|
|
|
sd.signerInfoList[0].setSignerIdentifier(sZ4_CERPEM); |
|
sd.signerInfoList[0].sign(sZ4_PRVP8PPEM, "SHA256withRSA"); |
|
|
|
equal(sd.getContentInfoEncodedHex(), "308201fa06092a864886f70d010702a08201eb308201e7020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676e318201b5308201b1020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a069301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4300d06092a864886f70d01010b0500048201002e102927a557ecef796fc36b5d858207e93927343361fe5136ce34e645347765ac5de316190ad57bc96bfdff34d7829c7cb6280470a32c3a3965149aed9f1032f9d4f92cecb5038c19b6f0b0f894e730e138cf2f5a7ce1f239535b829977ce1ad4b2fcf226953edecaabf6a5b7fcd179a5e6bd1b44c1f101341a4ac38f7d2d086c2d00cc3c6ad7fb07525cf7cb766420e5f628c36ddaefb708701666a301bc8f1b9c24ca0e50bf4626648d15b2c9eee1b87453f15ca27f3e0580095947a58bcc3ff685b7c4c2cedb3aefe77a87d8ed57eab22a082220e909088cfb18f951c65a9cd39213f9a7e3a81b13b6137f0283da99e0302a9c27238099e31cb5656e3200", ""); |
|
}); |
|
|
|
test("SignedData total test/2 addCertificateByPEM", function() { |
|
var nC = KJUR.asn1.cms; |
|
var sd = new nC.SignedData(); |
|
|
|
sd.dEncapContentInfo.setContentValue({str: "jsrsasign"}); |
|
sd.addCertificatesByPEM(sZ4_CERPEM); |
|
|
|
sd.signerInfoList[0].setForContentAndHash({sdObj: sd, |
|
eciObj: sd.dEncapContentInfo, |
|
hashAlg: 'sha256'}); |
|
sd.signerInfoList[0].dSignedAttrs.add(new nC.SigningTime({str: '131231235959Z'})); |
|
//sd.signerInfoList[0].dSignedAttrs.add(new nC.SigningTime()); |
|
|
|
sd.signerInfoList[0].setSignerIdentifier(sZ4_CERPEM); |
|
sd.signerInfoList[0].sign(sZ4_PRVP8PPEM, "SHA256withRSA"); |
|
|
|
equal(sd.getContentInfoEncodedHex(), "3082050106092a864886f70d010702a08204f2308204ee020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676ea0820303308202ff308201e7a003020102020101300d06092a864886f70d0101050500301a310b3009060355040613025553310b3009060355040a0c025a34301e170d3133303832383138323833345a170d3233303832383138323833345a301a310b3009060355040613025553310b3009060355040a0c025a3430820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a350304e301d0603551d0e041604140764f4c4c9056eff423fdd05a1953c96ed6a13cd301f0603551d230418301680140764f4c4c9056eff423fdd05a1953c96ed6a13cd300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100c7c6a27dcbc6a54c7eda81531665f89cfd16eb76f1f0caaf883ab8034e8ab2a34c3e219e810a7f6f8efe62ba1aaee05a2b3960c016940a656d032c1244432ffbff4fbda64d833e12b55f374ea2f952ae446df86704a469d45e7cc00970c16ced3e5ab93e85c8c49104512b56d6dab927011204246f464bea5284ff41abfd0198db0c7a974d7016b4cf76b90747f3172090a14957e914eac51c3587542de45d34a5fb29ed28d7548bd871ec0768d0126eda359f986b4b3d5563d84b6dad758af2f53785a859b9b300be8159a6ec0b60ff31e9d24f6fd7ea14cac865e9837120da1de22ef52dc1c367cb48512acb5cef7265f71477a977d72891f44e14e5ab482a318201b5308201b1020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a069301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4300d06092a864886f70d01010b0500048201002e102927a557ecef796fc36b5d858207e93927343361fe5136ce34e645347765ac5de316190ad57bc96bfdff34d7829c7cb6280470a32c3a3965149aed9f1032f9d4f92cecb5038c19b6f0b0f894e730e138cf2f5a7ce1f239535b829977ce1ad4b2fcf226953edecaabf6a5b7fcd179a5e6bd1b44c1f101341a4ac38f7d2d086c2d00cc3c6ad7fb07525cf7cb766420e5f628c36ddaefb708701666a301bc8f1b9c24ca0e50bf4626648d15b2c9eee1b87453f15ca27f3e0580095947a58bcc3ff685b7c4c2cedb3aefe77a87d8ed57eab22a082220e909088cfb18f951c65a9cd39213f9a7e3a81b13b6137f0283da99e0302a9c27238099e31cb5656e3200", ""); |
|
}); |
|
|
|
test("CMSUtil.newSignedData/1", function() { |
|
var sd = KJUR.asn1.cms.CMSUtil.newSignedData( |
|
{ |
|
content: {str: "jsrsasign"}, |
|
signerInfos: [{ |
|
hashAlg: 'sha256', |
|
sAttr: { |
|
SigningTime: {str: '131231235959Z'} |
|
}, |
|
signerCert: sZ4_CERPEM, |
|
sigAlg: 'SHA256withRSA', |
|
signerPrvKey: sZ4_PRVP8PPEM |
|
}] |
|
} |
|
); |
|
|
|
equal(sd.getContentInfoEncodedHex(), "308201fa06092a864886f70d010702a08201eb308201e7020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676e318201b5308201b1020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a069301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4300d06092a864886f70d01010b0500048201002e102927a557ecef796fc36b5d858207e93927343361fe5136ce34e645347765ac5de316190ad57bc96bfdff34d7829c7cb6280470a32c3a3965149aed9f1032f9d4f92cecb5038c19b6f0b0f894e730e138cf2f5a7ce1f239535b829977ce1ad4b2fcf226953edecaabf6a5b7fcd179a5e6bd1b44c1f101341a4ac38f7d2d086c2d00cc3c6ad7fb07525cf7cb766420e5f628c36ddaefb708701666a301bc8f1b9c24ca0e50bf4626648d15b2c9eee1b87453f15ca27f3e0580095947a58bcc3ff685b7c4c2cedb3aefe77a87d8ed57eab22a082220e909088cfb18f951c65a9cd39213f9a7e3a81b13b6137f0283da99e0302a9c27238099e31cb5656e3200", ""); |
|
}); |
|
|
|
test("CMSUtil.newSignedData/2 certificate added", function() { |
|
var sd = KJUR.asn1.cms.CMSUtil.newSignedData( |
|
{ |
|
content: {str: "jsrsasign"}, |
|
certs: [sZ4_CERPEM], |
|
signerInfos: [{ |
|
hashAlg: 'sha256', |
|
sAttr: { |
|
SigningTime: {str: '131231235959Z'} |
|
}, |
|
signerCert: sZ4_CERPEM, |
|
sigAlg: 'SHA256withRSA', |
|
signerPrvKey: sZ4_PRVP8PPEM |
|
}] |
|
} |
|
); |
|
|
|
equal(sd.getContentInfoEncodedHex(), "3082050106092a864886f70d010702a08204f2308204ee020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676ea0820303308202ff308201e7a003020102020101300d06092a864886f70d0101050500301a310b3009060355040613025553310b3009060355040a0c025a34301e170d3133303832383138323833345a170d3233303832383138323833345a301a310b3009060355040613025553310b3009060355040a0c025a3430820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a350304e301d0603551d0e041604140764f4c4c9056eff423fdd05a1953c96ed6a13cd301f0603551d230418301680140764f4c4c9056eff423fdd05a1953c96ed6a13cd300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100c7c6a27dcbc6a54c7eda81531665f89cfd16eb76f1f0caaf883ab8034e8ab2a34c3e219e810a7f6f8efe62ba1aaee05a2b3960c016940a656d032c1244432ffbff4fbda64d833e12b55f374ea2f952ae446df86704a469d45e7cc00970c16ced3e5ab93e85c8c49104512b56d6dab927011204246f464bea5284ff41abfd0198db0c7a974d7016b4cf76b90747f3172090a14957e914eac51c3587542de45d34a5fb29ed28d7548bd871ec0768d0126eda359f986b4b3d5563d84b6dad758af2f53785a859b9b300be8159a6ec0b60ff31e9d24f6fd7ea14cac865e9837120da1de22ef52dc1c367cb48512acb5cef7265f71477a977d72891f44e14e5ab482a318201b5308201b1020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a069301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd4300d06092a864886f70d01010b0500048201002e102927a557ecef796fc36b5d858207e93927343361fe5136ce34e645347765ac5de316190ad57bc96bfdff34d7829c7cb6280470a32c3a3965149aed9f1032f9d4f92cecb5038c19b6f0b0f894e730e138cf2f5a7ce1f239535b829977ce1ad4b2fcf226953edecaabf6a5b7fcd179a5e6bd1b44c1f101341a4ac38f7d2d086c2d00cc3c6ad7fb07525cf7cb766420e5f628c36ddaefb708701666a301bc8f1b9c24ca0e50bf4626648d15b2c9eee1b87453f15ca27f3e0580095947a58bcc3ff685b7c4c2cedb3aefe77a87d8ed57eab22a082220e909088cfb18f951c65a9cd39213f9a7e3a81b13b6137f0283da99e0302a9c27238099e31cb5656e3200", ""); |
|
}); |
|
|
|
test("CMSUtil.newSignedData/3 2+signcertv2,sigpol added", function() { |
|
var sd = KJUR.asn1.cms.CMSUtil.newSignedData( |
|
{ |
|
content: {str: "jsrsasign"}, |
|
certs: [sZ4_CERPEM], |
|
signerInfos: [{ |
|
hashAlg: 'sha256', |
|
sAttr: { |
|
SigningTime: {str: '131231235959Z'}, |
|
SigningCertificateV2: {array: [sZ4_CERPEM]}, |
|
SignaturePolicyIdentifier: { |
|
oid: '1.2.3.4.5', |
|
hash: {alg: 'sha1', hash: 'b1b2b3b4b5b6b7b8'} |
|
}, |
|
}, |
|
signerCert: sZ4_CERPEM, |
|
sigAlg: 'SHA256withRSA', |
|
signerPrvKey: sZ4_PRVP8PPEM |
|
}] |
|
} |
|
); |
|
|
|
equal(sd.getContentInfoEncodedHex(), "3082058a06092a864886f70d010702a082057b30820577020101310f300d06096086480165030402010500301806092a864886f70d010701a00b04096a737273617369676ea0820303308202ff308201e7a003020102020101300d06092a864886f70d0101050500301a310b3009060355040613025553310b3009060355040a0c025a34301e170d3133303832383138323833345a170d3233303832383138323833345a301a310b3009060355040613025553310b3009060355040a0c025a3430820122300d06092a864886f70d01010105000382010f003082010a0282010100df74eaa8b47779e5260ed1d2f3da85de9e0c3fb59faadd998e3de56632e38c2183bf0afd7093653438ae29ba0e0e05224f865d3d66ce88c01f0dc0f394ec40d380c39c414601ffa40d088d49ed99b6a0bb6e721cf3e2921bfa8e19021569acb851cafaa2f0e4ca43b91f19fb394eec269f533fd1f4247f3331003a6338a3607f4bb2ea537abad8dd4eb3ca28551035d73afd3cbc11e4e7404c1496c4f62c05c27c42b14e7e519519630f3b52ed27e0b3c54bd053f2d508bc07e745720458285adca6c55a6759419972ac5c346ee5047f460ddff4346ae06475b0d1fc44b63db80a4c97648dcfeb11e3344f1bce51fec7b9434e86bb405443750f9baec44d564b0203010001a350304e301d0603551d0e041604140764f4c4c9056eff423fdd05a1953c96ed6a13cd301f0603551d230418301680140764f4c4c9056eff423fdd05a1953c96ed6a13cd300c0603551d13040530030101ff300d06092a864886f70d01010505000382010100c7c6a27dcbc6a54c7eda81531665f89cfd16eb76f1f0caaf883ab8034e8ab2a34c3e219e810a7f6f8efe62ba1aaee05a2b3960c016940a656d032c1244432ffbff4fbda64d833e12b55f374ea2f952ae446df86704a469d45e7cc00970c16ced3e5ab93e85c8c49104512b56d6dab927011204246f464bea5284ff41abfd0198db0c7a974d7016b4cf76b90747f3172090a14957e914eac51c3587542de45d34a5fb29ed28d7548bd871ec0768d0126eda359f986b4b3d5563d84b6dad758af2f53785a859b9b300be8159a6ec0b60ff31e9d24f6fd7ea14cac865e9837120da1de22ef52dc1c367cb48512acb5cef7265f71477a977d72891f44e14e5ab482a3182023e3082023a020101301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06096086480165030402010500a081f1301806092a864886f70d010903310b06092a864886f70d010701301c06092a864886f70d010905310f170d3133313233313233353935395a302e060b2a864886f70d010910020f311f301d06042a0304053015300906052b0e03021a05000408b1b2b3b4b5b6b7b8302f06092a864886f70d0109043122042084c24dd1d9f56eb3a07ae4a23445add4facbaed78c89475296ab7954284d9cd43056060b2a864886f70d010910022f3147304530430420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442301f301a310b3009060355040613025553310b3009060355040a0c025a34020101300d06092a864886f70d01010b0500048201001498c043e60fcde56f9c8d922e8872e901db4bf3042ed6e830118343fb77f646366ba4f58d5db71da17bfc9dc329fcb5648e012c137d8782c2aad21deabbaa08b0f49139e157e658e33a3a5439bfce5e30a7eac30c133559a3c5295984369f593953b61637591aa10da7d1f4edca9c7f54227e96805a6c6df1bf22cfd090e8e7f43b5fb38573a33dcb0cfbfe43c150d8628ea2c3f60ddc658b8f952079dcfdcc727ba27187d4300f1c2fc66cbf516ab304c70df4ddfb2369e92971f4058ecb930ec914d35abf34c1f05b473f3b50e6d2cd2919b8e477a2d8251de97bd39a1676364015d0aadf9f74b526fccef42f69cd84a547f4b550e8eb890f9296d671146c", ""); |
|
}); |
|
|
|
}); |
|
--> |
|
</script> |
|
|
|
</head> |
|
<body> |
|
<div id="qunit"></div> |
|
<div id="qunit-fixture">test markup</div> |
|
<div> |
|
QUnit TEST |
|
<a href="qunit-do-asn1.html">asn1</a> | |
|
<a href="qunit-do-asn1x509.html">asn1x509</a> | |
|
<a href="qunit-do-asn1cms.html">asn1cms</a> | |
|
<a href="qunit-do-asn1tsp.html">asn1tsp</a> | |
|
<a href="../api/index.html">APIDOCS</a> | |
|
</div> |
|
</body> |
|
</html> |
|
|
|
|