1
0
Fork 0
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.
 
 
 
 

182 lines
6.7 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 'asn1.js' ASN1Util.newObject</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" />
<!-- getPEM -->
<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://yui.yahooapis.com/2.9.0/build/yahoo/yahoo-min.js"></script>
<script src="../ext/jsbn.js"></script>
<script src="../ext/jsbn2.js"></script>
<script src="../ext/base64.js"></script>
<script src="../base64x-1.1.js"></script>
<script src="../asn1-1.0.js"></script>
<script src="../asn1x509-1.0.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function(){
// ======= TEST ===============================================================
test("boolean test", function() {
equal(KJUR.asn1.ASN1Util.newObject({'bool': {}}).getEncodedHex(), "0101ff", "boolean test1");
});
test("int 3", function() {
equal(KJUR.asn1.ASN1Util.newObject({'int': {'int': 3}}).getEncodedHex(), "020103", "test1");
});
test("int 3", function() {
equal(KJUR.asn1.ASN1Util.newObject({'int': 3}).getEncodedHex(), "020103", "test1");
});
test("bitstr test unused:0 1a2b", function() {
equal(KJUR.asn1.ASN1Util.newObject({'bitstr': {'hex': '001a2b'}}).getEncodedHex(), "0303001a2b", "test1");
});
test("bitstr test unused:0 1a2b", function() {
equal(KJUR.asn1.ASN1Util.newObject({'bitstr': '001a2b'}).getEncodedHex(), "0303001a2b", "test1");
});
test("octstr test 1a2b", function() {
equal(KJUR.asn1.ASN1Util.newObject({'octstr': {'hex': '1a2b'}}).getEncodedHex(), "04021a2b", "test1");
});
test("octstr test abc", function() {
equal(KJUR.asn1.ASN1Util.newObject({'octstr': 'abc'}).getEncodedHex(), "0403616263", "test1");
});
test("null test", function() {
equal(KJUR.asn1.ASN1Util.newObject({'null': {}}).getEncodedHex(), "0500", "test1");
});
test("oid test 2.5.4.5", function() {
equal(KJUR.asn1.ASN1Util.newObject({'oid': {'oid': '2.5.4.5'}}).getEncodedHex(), "0603550405", "test1");
});
test("oid test 2.5.4.5", function() {
equal(KJUR.asn1.ASN1Util.newObject({'oid': '2.5.4.5'}).getEncodedHex(), "0603550405", "test1");
});
test("oid test keyUsage", function() {
equal(KJUR.asn1.ASN1Util.newObject({'oid': 'keyUsage'}).getEncodedHex(), "0603551d0f", "test1");
});
test("oid test countryName", function() {
equal(KJUR.asn1.ASN1Util.newObject({'oid': 'countryName'}).getEncodedHex(), "0603550406", "test1");
});
test("utf8str test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'utf8str': {'str': 'aaa'}}).getEncodedHex(), "0c03616161", "test1");
});
test("utf8str test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'utf8str': 'aaa'}).getEncodedHex(), "0c03616161", "test1");
});
test("numstr test 123", function() {
equal(KJUR.asn1.ASN1Util.newObject({'numstr': {'str': '123'}}).getEncodedHex(), "1203313233", "test1");
});
test("numstr test 123", function() {
equal(KJUR.asn1.ASN1Util.newObject({'numstr': '123'}).getEncodedHex(), "1203313233", "test1");
});
test("prnstr test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'prnstr': {'str': 'aaa'}}).getEncodedHex(), "1303616161", "test1");
});
test("prnstr test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'prnstr': 'aaa'}).getEncodedHex(), "1303616161", "test1");
});
test("telstr test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'telstr': {'str': 'aaa'}}).getEncodedHex(), "1403616161", "test1");
});
test("telstr test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'telstr': 'aaa'}).getEncodedHex(), "1403616161", "test1");
});
test("ia5str test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'ia5str': {'str': 'aaa'}}).getEncodedHex(), "1603616161", "test1");
});
test("ia5str test aaa", function() {
equal(KJUR.asn1.ASN1Util.newObject({'ia5str': 'aaa'}).getEncodedHex(), "1603616161", "test1");
});
test("utctime test 491231235959Z", function() {
equal(KJUR.asn1.ASN1Util.newObject({'utctime': {'str': '491231235959Z'}}).getEncodedHex(), "170d3439313233313233353935395a", "test1");
});
test("utctime test 491231235959Z", function() {
equal(KJUR.asn1.ASN1Util.newObject({'utctime': '491231235959Z'}).getEncodedHex(), "170d3439313233313233353935395a", "test1");
});
test("gentime test 20131231235959Z", function() {
equal(KJUR.asn1.ASN1Util.newObject({'gentime': {'str': '20131231235959Z'}}).getEncodedHex(), "180f32303133313233313233353935395a", "test1");
});
test("gentime test 20131231235959Z", function() {
equal(KJUR.asn1.ASN1Util.newObject({'gentime': '20131231235959Z'}).getEncodedHex(), "180f32303133313233313233353935395a", "test1");
});
test("seq test [int 3]", function() {
equal(KJUR.asn1.ASN1Util.newObject({'seq': [{'int': 3}]}).getEncodedHex(), "3003020103", "test1");
});
test("seq test [int 3, int 4]", function() {
equal(KJUR.asn1.ASN1Util.newObject({'seq': [{'int': 3}, {'int': 4}]}).getEncodedHex(), "3006020103020104", "test1");
});
test("set test [int 3]", function() {
equal(KJUR.asn1.ASN1Util.newObject({'set': [{'int': 3}]}).getEncodedHex(), "3103020103", "test1");
});
test("set test [int 3, int 4]", function() {
equal(KJUR.asn1.ASN1Util.newObject({'set': [{'int': 3}, {'int': 4}]}).getEncodedHex(), "3106020103020104", "test1");
});
test("tag test seq [int 3, int 4] implicit", function() {
equal(KJUR.asn1.ASN1Util.newObject({'tag': {'tag': 'a1', 'explicit': false, 'obj': {'seq': [{'int': 3}, {'int': 4}]}}}).getEncodedHex(), "a106020103020104", "test1");
});
test("tag test seq [int 3, int 4] explicit", function() {
equal(KJUR.asn1.ASN1Util.newObject({'tag': {'tag': 'a1', 'explicit': true, 'obj': {'seq': [{'int': 3}, {'int': 4}]}}}).getEncodedHex(), "a1083006020103020104", "test1");
});
test("tag test seq [int 3, int 4] explicit", function() {
equal(KJUR.asn1.ASN1Util.newObject({'tag': ['a1', true, {'seq': [{'int': 3}, {'int': 4}]}]}).getEncodedHex(), "a1083006020103020104", "test1");
});
test("tag test RFC 3161 TSP Accuracy 500ms", function() {
equal(KJUR.asn1.ASN1Util.newObject(
{seq: [{tag: {tag: '80', explicit: false, obj: {int: 500}}}]}).getEncodedHex(),
"3004800201f4", "test1");
});
test("jsonToASN1HEX test1", function() {
var result = KJUR.asn1.ASN1Util.jsonToASN1HEX({seq: [{int: 4}, {int: 5}]});
equal(result, "3006020104020105", "seq int int");
});
});
-->
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture">test markup</div>
</body>
</html>