diff --git a/ChangeLog.txt b/ChangeLog.txt index 9dc18873..30718283 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,8 +1,21 @@ ChangeLog for jsrsasign +DERBitString, KeyUsage and tsp PKIFailureInfo critical bug fix +* Changes from 10.5.21 to 10.5.22 (2022-May-24) + - src/asn1.js + - DERBitString critical bugfix + - src/asn1tsp.js + - PKIFailureInfo critical bugfix + - src/asn1x509.js + - KeyUsage critical bugfix + - src/base64.x + - namearraytobinstr critical bugfix + - test/qunit-do-{asn1,asn1tsp,asn1x509,base64x}.html + - add and fix some test cases for above + DERBitString, KeyUsage and tsp PKIFailureInfo fix -* Changes from 10.5.20 to 10.5.21 (2022-May-23) +* Changes from 10.5.20 to 10.5.21 (2022-May-23) *RELEASE RESIGNED* - src/asn1x509.js - KeyUsage bugfix, refactoring - src/asn1tsp.js diff --git a/api/files.html b/api/files.html index ad064e34..c2bc008e 100644 --- a/api/files.html +++ b/api/files.html @@ -529,7 +529,7 @@

asn1-1.0.js

Version:
-
jsrsasign 10.5.21 asn1 1.0.25 (2022-May-23)
+
jsrsasign 10.5.22 asn1 1.0.26 (2022-May-24)
@@ -643,7 +643,7 @@

asn1tsp-1.0.js

Version:
-
jsrsasign 10.5.21 asn1tsp 2.0.8 (2022-May-23)
+
jsrsasign 10.5.22 asn1tsp 2.0.9 (2022-May-24)
@@ -662,7 +662,7 @@

asn1x509-1.0.js

Version:
-
jsrsasign 10.5.21 asn1x509 2.1.15 (2022-May-23)
+
jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24)
@@ -681,7 +681,7 @@

base64x-1.1.js

Version:
-
jsrsasign 10.5.21 base64x 1.1.27 (2022-May-23)
+
jsrsasign 10.5.22 base64x 1.1.28 (2022-May-24)
diff --git a/api/symbols/global__.html b/api/symbols/global__.html index b7a3dcfb..1266ff99 100644 --- a/api/symbols/global__.html +++ b/api/symbols/global__.html @@ -3395,8 +3395,8 @@

db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
-namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1100000001'
-namearraytobinstr(['c', 'b'], db) &rarr: '100001000'
+namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011' +namearraytobinstr(['c', 'b'], db) &rarr: '000100001' diff --git a/api/symbols/src/asn1-1.0.js.html b/api/symbols/src/asn1-1.0.js.html index 8b82600e..b3a9cb62 100644 --- a/api/symbols/src/asn1-1.0.js.html +++ b/api/symbols/src/asn1-1.0.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
  1 /* asn1-1.0.25.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* asn1-1.0.26.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * asn1.js - ASN.1 DER encoder classes
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name asn1-1.0.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.5.21 asn1 1.0.25 (2022-May-23)
+ 19  * @version jsrsasign 10.5.22 asn1 1.0.26 (2022-May-24)
  20  * @since jsrsasign 2.1
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -981,867 +981,868 @@
 974  * NOTE1: 'params' can be omitted.<br/>
 975  * NOTE2: 'obj' parameter have been supported since
 976  * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).<br/>
-977  * @example
-978  * // default constructor
-979  * o = new KJUR.asn1.DERBitString();
-980  * // initialize with binary string
-981  * o = new KJUR.asn1.DERBitString({bin: "1011"});
-982  * // initialize with boolean array
-983  * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
-984  * // initialize with hexadecimal string (04 is unused bits)
-985  * o = new KJUR.asn1.DERBitString({hex: "04bac0"});
-986  * // initialize with ASN1Util.newObject argument for encapsulated
-987  * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
-988  * // above generates a ASN.1 data like this:
-989  * // BIT STRING, encapsulates {
-990  * //   SEQUENCE {
-991  * //     INTEGER 3
-992  * //     PrintableString 'aaa'
-993  * //     }
-994  * //   } 
-995  */
-996 KJUR.asn1.DERBitString = function(params) {
-997     if (params !== undefined && typeof params.obj !== "undefined") {
-998 	var o = KJUR.asn1.ASN1Util.newObject(params.obj);
-999 	params.hex = "00" + o.tohex();
-1000     }
-1001     KJUR.asn1.DERBitString.superclass.constructor.call(this);
-1002     this.hT = "03";
-1003 
-1004     /**
-1005      * set ASN.1 value(V) by a hexadecimal string including unused bits
-1006      * @name setHexValueIncludingUnusedBits
-1007      * @memberOf KJUR.asn1.DERBitString#
-1008      * @function
-1009      * @param {String} newHexStringIncludingUnusedBits
-1010      */
-1011     this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
-1012         this.hTLV = null;
-1013         this.isModified = true;
-1014         this.hV = newHexStringIncludingUnusedBits;
-1015     };
-1016 
-1017     /**
-1018      * set ASN.1 value(V) by unused bit and hexadecimal string of value
-1019      * @name setUnusedBitsAndHexValue
-1020      * @memberOf KJUR.asn1.DERBitString#
-1021      * @function
-1022      * @param {Integer} unusedBits
-1023      * @param {String} hValue
-1024      */
-1025     this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
-1026         if (unusedBits < 0 || 7 < unusedBits) {
-1027             throw "unused bits shall be from 0 to 7: u = " + unusedBits;
-1028         }
-1029         var hUnusedBits = "0" + unusedBits;
-1030         this.hTLV = null;
-1031         this.isModified = true;
-1032         this.hV = hUnusedBits + hValue;
-1033     };
-1034 
-1035     /**
-1036      * set ASN.1 DER BitString by binary string<br/>
-1037      * @name setByBinaryString
-1038      * @memberOf KJUR.asn1.DERBitString#
-1039      * @function
-1040      * @param {String} binaryString binary value string (i.e. '10111')
-1041      * @description
-1042      * Its unused bits will be calculated automatically by length of 
-1043      * 'binaryValue'. <br/>
-1044      * NOTE: Leading zeros '0' will be ignored.
-1045      * @example
-1046      * o = new KJUR.asn1.DERBitString();
-1047      * o.setByBinaryString("1011");
-1048      * o.setByBinaryString("001"); // leading zeros ignored
-1049      */
-1050     this.setByBinaryString = function(binaryString) {
-1051         binaryString = binaryString.replace(/^0+/, '');
-1052         var unusedBits = 8 - binaryString.length % 8;
-1053         if (unusedBits == 8) unusedBits = 0;
-1054 	
-1055 	binaryString += "0000000".substr(0, unusedBits);
-1056 
-1057         var h = '';
-1058         for (var i = 0; i < binaryString.length - 1; i += 8) {
-1059             var b = binaryString.substr(i, 8);
-1060             var x = parseInt(b, 2).toString(16);
-1061             if (x.length == 1) x = '0' + x;
-1062             h += x;  
-1063         }
-1064         this.hTLV = null;
-1065         this.isModified = true;
-1066         this.hV = '0' + unusedBits + h;
-1067     };
-1068 
-1069     /**
-1070      * set ASN.1 TLV value(V) by an array of boolean<br/>
-1071      * @name setByBooleanArray
-1072      * @memberOf KJUR.asn1.DERBitString#
-1073      * @function
-1074      * @param {array} booleanArray array of boolean (ex. [true, false, true])
-1075      * @description
-1076      * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
-1077      * @example
-1078      * o = new KJUR.asn1.DERBitString();
-1079      * o.setByBooleanArray([false, true, false, true, true]);
-1080      */
-1081     this.setByBooleanArray = function(booleanArray) {
-1082         var s = '';
-1083         for (var i = 0; i < booleanArray.length; i++) {
-1084             if (booleanArray[i] == true) {
-1085                 s += '1';
-1086             } else {
-1087                 s += '0';
-1088             }
-1089         }
-1090         this.setByBinaryString(s);
-1091     };
-1092 
-1093     /**
-1094      * generate an array of falses with specified length<br/>
-1095      * @name newFalseArray
-1096      * @memberOf KJUR.asn1.DERBitString
-1097      * @function
-1098      * @param {Integer} nLength length of array to generate
-1099      * @return {array} array of boolean falses
-1100      * @description
-1101      * This static method may be useful to initialize boolean array.
-1102      * @example
-1103      * o = new KJUR.asn1.DERBitString();
-1104      * o.newFalseArray(3) → [false, false, false]
-1105      */
-1106     this.newFalseArray = function(nLength) {
-1107         var a = new Array(nLength);
-1108         for (var i = 0; i < nLength; i++) {
-1109             a[i] = false;
-1110         }
-1111         return a;
-1112     };
-1113 
-1114     this.getFreshValueHex = function() {
-1115         return this.hV;
-1116     };
-1117 
-1118     if (typeof params != "undefined") {
-1119         if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
-1120             this.setHexValueIncludingUnusedBits(params);
-1121         } else if (typeof params['hex'] != "undefined") {
-1122             this.setHexValueIncludingUnusedBits(params['hex']);
-1123         } else if (typeof params['bin'] != "undefined") {
-1124             this.setByBinaryString(params['bin']);
-1125         } else if (typeof params['array'] != "undefined") {
-1126             this.setByBooleanArray(params['array']);
-1127         }
-1128     }
-1129 };
-1130 extendClass(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
-1131 
-1132 // ********************************************************************
-1133 /**
-1134  * class for ASN.1 DER OctetString<br/>
-1135  * @name KJUR.asn1.DEROctetString
-1136  * @class class for ASN.1 DER OctetString
-1137  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1138  * @extends KJUR.asn1.DERAbstractString
-1139  * @description
-1140  * This class provides ASN.1 OctetString simple type.<br/>
-1141  * Supported "params" attributes are:
-1142  * <ul>
-1143  * <li>str - to set a string as a value</li>
-1144  * <li>hex - to set a hexadecimal string as a value</li>
-1145  * <li>obj - to set a encapsulated ASN.1 value by JSON object 
-1146  * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
-1147  * </ul>
-1148  * NOTE: A parameter 'obj' have been supported 
-1149  * for "OCTET STRING, encapsulates" structure.
-1150  * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
-1151  * @see KJUR.asn1.DERAbstractString - superclass
-1152  * @example
-1153  * // default constructor
-1154  * o = new KJUR.asn1.DEROctetString();
-1155  * // initialize with string
-1156  * o = new KJUR.asn1.DEROctetString({str: "aaa"});
-1157  * // initialize with hexadecimal string
-1158  * o = new KJUR.asn1.DEROctetString({hex: "616161"});
-1159  * // initialize with ASN1Util.newObject argument 
-1160  * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
-1161  * // above generates a ASN.1 data like this:
-1162  * // OCTET STRING, encapsulates {
-1163  * //   SEQUENCE {
-1164  * //     INTEGER 3
-1165  * //     PrintableString 'aaa'
-1166  * //     }
-1167  * //   } 
-1168  */
-1169 KJUR.asn1.DEROctetString = function(params) {
-1170     if (params !== undefined && typeof params.obj !== "undefined") {
-1171 	var o = KJUR.asn1.ASN1Util.newObject(params.obj);
-1172 	params.hex = o.tohex();
-1173     }
-1174     KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
-1175     this.hT = "04";
-1176 };
-1177 extendClass(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
-1178 
-1179 // ********************************************************************
-1180 /**
-1181  * class for ASN.1 DER Null
-1182  * @name KJUR.asn1.DERNull
-1183  * @class class for ASN.1 DER Null
-1184  * @extends KJUR.asn1.ASN1Object
-1185  * @description
-1186  * @see KJUR.asn1.ASN1Object - superclass
-1187  */
-1188 KJUR.asn1.DERNull = function() {
-1189     KJUR.asn1.DERNull.superclass.constructor.call(this);
-1190     this.hT = "05";
-1191     this.hTLV = "0500";
-1192 };
-1193 extendClass(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
-1194 
-1195 // ********************************************************************
-1196 /**
-1197  * class for ASN.1 DER ObjectIdentifier
-1198  * @name KJUR.asn1.DERObjectIdentifier
-1199  * @class class for ASN.1 DER ObjectIdentifier
-1200  * @param {Object} JSON object or string of parameters (ex. {'oid': '2.5.4.5'})
-1201  * @extends KJUR.asn1.ASN1Object
-1202  * @see oidtohex
-1203  * 
-1204  * @description
-1205  * <br/>
-1206  * As for argument 'params' for constructor, you can specify one of
-1207  * following properties:
-1208  * <ul>
-1209  * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
-1210  * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-1211  * </ul>
-1212  * NOTE: 'params' can be omitted.
-1213  * @example
-1214  * new DERObjectIdentifier({"name": "sha1"})
-1215  * new DERObjectIdentifier({"oid": "1.2.3.4"})
-1216  * new DERObjectIdentifier({"hex": "2d..."})
-1217  * new DERObjectIdentifier("1.2.3.4")
-1218  * new DERObjectIdentifier("SHA1withRSA")
-1219  */
-1220 KJUR.asn1.DERObjectIdentifier = function(params) {
-1221     KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
-1222     this.hT = "06";
-1223 
-1224     /**
-1225      * set value by a hexadecimal string
-1226      * @name setValueHex
-1227      * @memberOf KJUR.asn1.DERObjectIdentifier#
-1228      * @function
-1229      * @param {String} newHexString hexadecimal value of OID bytes
-1230      */
-1231     this.setValueHex = function(newHexString) {
-1232         this.hTLV = null;
-1233         this.isModified = true;
-1234         this.s = null;
-1235         this.hV = newHexString;
-1236     };
-1237 
-1238     /**
-1239      * set value by a OID string<br/>
-1240      * @name setValueOidString
-1241      * @memberOf KJUR.asn1.DERObjectIdentifier#
-1242      * @function
-1243      * @param {String} oidString OID string (ex. 2.5.4.13)
-1244      * @example
-1245      * o = new KJUR.asn1.DERObjectIdentifier();
-1246      * o.setValueOidString("2.5.4.13");
-1247      */
-1248     this.setValueOidString = function(oidString) {
-1249 	var h = oidtohex(oidString);
-1250 	if (h == null)
-1251             throw new Error("malformed oid string: " + oidString);
-1252         this.hTLV = null;
-1253         this.isModified = true;
-1254         this.s = null;
-1255         this.hV = h;
-1256     };
-1257 
-1258     /**
-1259      * set value by a OID name
-1260      * @name setValueName
-1261      * @memberOf KJUR.asn1.DERObjectIdentifier#
-1262      * @function
-1263      * @param {String} oidName OID name (ex. 'serverAuth')
-1264      * @since 1.0.1
-1265      * @description
-1266      * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
-1267      * Otherwise raise error.
-1268      * @example
-1269      * o = new KJUR.asn1.DERObjectIdentifier();
-1270      * o.setValueName("serverAuth");
-1271      */
-1272     this.setValueName = function(oidName) {
-1273 	var oid = KJUR.asn1.x509.OID.name2oid(oidName);
-1274 	if (oid !== '') {
-1275             this.setValueOidString(oid);
-1276         } else {
-1277             throw new Error("DERObjectIdentifier oidName undefined: " + oidName);
-1278         }
-1279     };
-1280 
-1281     this.setValueNameOrOid = function(nameOrOid) {
-1282 	if (nameOrOid.match(/^[0-2].[0-9.]+$/)) {
-1283 	    this.setValueOidString(nameOrOid);
-1284 	} else {
-1285 	    this.setValueName(nameOrOid);
-1286 	}
-1287     }
-1288 
-1289     this.getFreshValueHex = function() {
-1290         return this.hV;
-1291     };
-1292 
-1293     this.setByParam = function(params) {
-1294         if (typeof params === "string") {
-1295 	    this.setValueNameOrOid(params);
-1296         } else if (params.oid !== undefined) {
-1297 	    this.setValueNameOrOid(params.oid);
-1298         } else if (params.name !== undefined) {
-1299             this.setValueNameOrOid(params.name);
-1300         } else if (params.hex !== undefined) {
-1301             this.setValueHex(params.hex);
-1302         }
-1303     };
-1304 
-1305     if (params !== undefined) this.setByParam(params);
-1306 };
-1307 extendClass(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
-1308 
-1309 // ********************************************************************
-1310 /**
-1311  * class for ASN.1 DER Enumerated
-1312  * @name KJUR.asn1.DEREnumerated
-1313  * @class class for ASN.1 DER Enumerated
-1314  * @extends KJUR.asn1.ASN1Object
-1315  * @description
-1316  * <br/>
-1317  * As for argument 'params' for constructor, you can specify one of
-1318  * following properties:
-1319  * <ul>
-1320  * <li>int - specify initial ASN.1 value(V) by integer value</li>
-1321  * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-1322  * </ul>
-1323  * NOTE: 'params' can be omitted.
-1324  * @example
-1325  * new KJUR.asn1.DEREnumerated(123);
-1326  * new KJUR.asn1.DEREnumerated({int: 123});
-1327  * new KJUR.asn1.DEREnumerated({hex: '1fad'});
-1328  */
-1329 KJUR.asn1.DEREnumerated = function(params) {
-1330     KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
-1331     this.hT = "0a";
-1332 
-1333     /**
-1334      * set value by Tom Wu's BigInteger object
-1335      * @name setByBigInteger
-1336      * @memberOf KJUR.asn1.DEREnumerated#
-1337      * @function
-1338      * @param {BigInteger} bigIntegerValue to set
-1339      */
-1340     this.setByBigInteger = function(bigIntegerValue) {
-1341         this.hTLV = null;
-1342         this.isModified = true;
-1343         this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
-1344     };
-1345 
-1346     /**
-1347      * set value by integer value
-1348      * @name setByInteger
-1349      * @memberOf KJUR.asn1.DEREnumerated#
-1350      * @function
-1351      * @param {Integer} integer value to set
-1352      */
-1353     this.setByInteger = function(intValue) {
-1354         var bi = new BigInteger(String(intValue), 10);
-1355         this.setByBigInteger(bi);
-1356     };
-1357 
-1358     /**
-1359      * set value by integer value
-1360      * @name setValueHex
-1361      * @memberOf KJUR.asn1.DEREnumerated#
-1362      * @function
-1363      * @param {String} hexadecimal string of integer value
-1364      * @description
-1365      * <br/>
-1366      * NOTE: Value shall be represented by minimum octet length of
-1367      * two's complement representation.
-1368      */
-1369     this.setValueHex = function(newHexString) {
-1370         this.hV = newHexString;
-1371     };
-1372 
-1373     this.getFreshValueHex = function() {
-1374         return this.hV;
-1375     };
-1376 
-1377     if (typeof params != "undefined") {
-1378         if (typeof params['int'] != "undefined") {
-1379             this.setByInteger(params['int']);
-1380         } else if (typeof params == "number") {
-1381             this.setByInteger(params);
-1382         } else if (typeof params['hex'] != "undefined") {
-1383             this.setValueHex(params['hex']);
-1384         }
-1385     }
-1386 };
-1387 extendClass(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
-1388 
-1389 // ********************************************************************
-1390 /**
-1391  * class for ASN.1 DER UTF8String
-1392  * @name KJUR.asn1.DERUTF8String
-1393  * @class class for ASN.1 DER UTF8String
-1394  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1395  * @extends KJUR.asn1.DERAbstractString
-1396  * @description
-1397  * @see KJUR.asn1.DERAbstractString - superclass
-1398  */
-1399 KJUR.asn1.DERUTF8String = function(params) {
-1400     KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
-1401     this.hT = "0c";
-1402 };
-1403 extendClass(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
-1404 
-1405 // ********************************************************************
-1406 /**
-1407  * class for ASN.1 DER NumericString
-1408  * @name KJUR.asn1.DERNumericString
-1409  * @class class for ASN.1 DER NumericString
-1410  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1411  * @extends KJUR.asn1.DERAbstractString
-1412  * @description
-1413  * @see KJUR.asn1.DERAbstractString - superclass
-1414  */
-1415 KJUR.asn1.DERNumericString = function(params) {
-1416     KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
-1417     this.hT = "12";
-1418 };
-1419 extendClass(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
-1420 
-1421 // ********************************************************************
-1422 /**
-1423  * class for ASN.1 DER PrintableString
-1424  * @name KJUR.asn1.DERPrintableString
-1425  * @class class for ASN.1 DER PrintableString
-1426  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1427  * @extends KJUR.asn1.DERAbstractString
-1428  * @description
-1429  * @see KJUR.asn1.DERAbstractString - superclass
-1430  */
-1431 KJUR.asn1.DERPrintableString = function(params) {
-1432     KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
-1433     this.hT = "13";
-1434 };
-1435 extendClass(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
-1436 
-1437 // ********************************************************************
-1438 /**
-1439  * class for ASN.1 DER TeletexString
-1440  * @name KJUR.asn1.DERTeletexString
-1441  * @class class for ASN.1 DER TeletexString
-1442  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1443  * @extends KJUR.asn1.DERAbstractString
-1444  * @description
-1445  * @see KJUR.asn1.DERAbstractString - superclass
-1446  */
-1447 KJUR.asn1.DERTeletexString = function(params) {
-1448     KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
-1449     this.hT = "14";
-1450 };
-1451 extendClass(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
-1452 
-1453 // ********************************************************************
-1454 /**
-1455  * class for ASN.1 DER IA5String
-1456  * @name KJUR.asn1.DERIA5String
-1457  * @class class for ASN.1 DER IA5String
-1458  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1459  * @extends KJUR.asn1.DERAbstractString
-1460  * @description
-1461  * @see KJUR.asn1.DERAbstractString - superclass
-1462  */
-1463 KJUR.asn1.DERIA5String = function(params) {
-1464     KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
-1465     this.hT = "16";
-1466 };
-1467 extendClass(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
-1468 
-1469 // ********************************************************************
-1470 /**
-1471  * class for ASN.1 DER VisibleString
-1472  * @name KJUR.asn1.DERVisibleString
-1473  * @class class for ASN.1 DER VisibleString
-1474  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1475  * @extends KJUR.asn1.DERAbstractString
-1476  * @since jsrsasign 8.0.23 asn1 1.0.15
-1477  * @description
-1478  * @see KJUR.asn1.DERAbstractString - superclass
-1479  */
-1480 KJUR.asn1.DERVisibleString = function(params) {
-1481     KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
-1482     this.hT = "1a";
-1483 };
-1484 extendClass(KJUR.asn1.DERVisibleString, KJUR.asn1.DERAbstractString);
-1485 
-1486 // ********************************************************************
-1487 /**
-1488  * class for ASN.1 DER BMPString
-1489  * @name KJUR.asn1.DERBMPString
-1490  * @class class for ASN.1 DER BMPString
-1491  * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1492  * @extends KJUR.asn1.DERAbstractString
-1493  * @since jsrsasign 8.0.23 asn1 1.0.15
-1494  * @description
-1495  * @see KJUR.asn1.DERAbstractString - superclass
-1496  */
-1497 KJUR.asn1.DERBMPString = function(params) {
-1498     KJUR.asn1.DERBMPString.superclass.constructor.call(this, params);
-1499     this.hT = "1e";
-1500 };
-1501 extendClass(KJUR.asn1.DERBMPString, KJUR.asn1.DERAbstractString);
-1502 
-1503 // ********************************************************************
-1504 /**
-1505  * class for ASN.1 DER UTCTime
-1506  * @name KJUR.asn1.DERUTCTime
-1507  * @class class for ASN.1 DER UTCTime
-1508  * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
-1509  * @extends KJUR.asn1.DERAbstractTime
-1510  * @see KJUR.asn1.DERGeneralizedTime
-1511  * @see KJUR.asn1.x509.Time
-1512  *
-1513  * @description
-1514  * <br/>
-1515  * As for argument 'params' for constructor, you can specify one of
-1516  * following properties:
-1517  * <ul>
-1518  * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
-1519  * <li>date - specify Date object.</li>
-1520  * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
-1521  * </ul>
-1522  * NOTE1: 'params' can be omitted.
-1523  * NOTE2: 'millis' property is supported from jsrsasign 10.4.1 asn1 1.0.22.
-1524  *
-1525  * <h4>EXAMPLES</h4>
-1526  * @example
-1527  * new DERUTCTime("20151231235959Z")
-1528  * new DERUTCTime("20151231235959.123Z")
-1529  * new DERUTCTime(new Date())
-1530  * new DERUTCTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
-1531  * new DERUTCTime({str: "20151231235959.123Z"})
-1532  * new DERUTCTime({date: new Date()})
-1533  * new DERUTCTime({date: new Date(), millis: true})
-1534  * new DERUTCTime({millis: true})
-1535  */
-1536 KJUR.asn1.DERUTCTime = function(params) {
-1537     KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
-1538     this.hT = "17";
-1539     this.params = undefined;
-1540 
-1541     this.getFreshValueHex = function() {
-1542 	var params = this.params;
-1543 
-1544 	if (this.params == undefined) params = { date: new Date() };
-1545 
-1546 	if (typeof params == "string") {
-1547 	    if (params.match(/^[0-9]{12}Z$/) ||
-1548 		params.match(/^[0-9]{12}\.[0-9]+Z$/)) {
-1549 		this.hV = stohex(params);
-1550 	    } else {
-1551 		throw new Error("malformed string for UTCTime: " + params);
-1552 	    }
-1553 	} else if (params.str != undefined) {
-1554 	    this.hV = stohex(params.str);
-1555 	} else if (params.date == undefined && params.millis == true) {
-1556 	    var date = new Date();
-1557 	    this.hV = stohex(this.formatDate(date, 'utc', true));
-1558 	} else if (params.date != undefined &&
-1559 		   params.date instanceof Date) {
-1560 	    var withMillis = (params.millis === true);
-1561 	    this.hV = stohex(this.formatDate(params.date, 'utc', withMillis));
-1562 	} else if (params instanceof Date) {
-1563 	    this.hV = stohex(this.formatDate(params, 'utc'));
-1564 	}
-1565 
-1566 	if (this.hV == undefined) {
-1567 	    throw new Error("parameter not specified properly for UTCTime");
-1568 	}
-1569 	return this.hV;
-1570     };
-1571 
-1572     if (params != undefined) this.setByParam(params);
-1573 };
-1574 extendClass(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
-1575 
-1576 // ********************************************************************
-1577 /**
-1578  * class for ASN.1 DER GeneralizedTime
-1579  * @name KJUR.asn1.DERGeneralizedTime
-1580  * @class class for ASN.1 DER GeneralizedTime
-1581  * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
-1582  * @property {Boolean} withMillis flag to show milliseconds or not
-1583  * @extends KJUR.asn1.DERAbstractTime
-1584  * @see KJUR.asn1.DERUTCTime
-1585  * @see KJUR.asn1.x509.Time
-1586  *
-1587  * @description
-1588  * <br/>
-1589  * As for argument 'params' for constructor, you can specify one of
-1590  * following properties:
-1591  * <ul>
-1592  * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
-1593  * <li>date - specify Date object.</li>
-1594  * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
-1595  * </ul>
-1596  * NOTE1: 'params' can be omitted.
-1597  * NOTE2: 'millis' property is supported from asn1 1.0.6.
-1598  *
-1599  * <h4>EXAMPLES</h4>
-1600  * @example
-1601  * new DERGeneralizedTime("20151231235959Z")
-1602  * new DERGeneralizedTime("20151231235959.123Z")
-1603  * new DERGeneralizedTime(new Date())
-1604  * new DERGeneralizedTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
-1605  * new DERGeneralizedTime({str: "20151231235959.123Z"})
-1606  * new DERGeneralizedTime({date: new Date()})
-1607  * new DERGeneralizedTime({date: new Date(), millis: true})
-1608  * new DERGeneralizedTime({millis: true})
-1609  */
-1610 KJUR.asn1.DERGeneralizedTime = function(params) {
-1611     KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
-1612     this.hT = "18";
-1613     this.params = params;
-1614 
-1615     this.getFreshValueHex = function() {
-1616 	var params = this.params;
-1617 
-1618 	if (this.params == undefined) params = { date: new Date() };
-1619 
-1620 	if (typeof params == "string") {
-1621 	    if (params.match(/^[0-9]{14}Z$/) ||
-1622 		params.match(/^[0-9]{14}\.[0-9]+Z$/)) {
-1623 		this.hV = stohex(params);
-1624 	    } else {
-1625 		throw new Error("malformed string for GeneralizedTime: " + params);
-1626 	    }
-1627 	} else if (params.str != undefined) {
-1628 	    this.hV = stohex(params.str);
-1629 	} else if (params.date == undefined && params.millis == true) {
-1630 	    var date = new Date();
-1631 	    this.hV = stohex(this.formatDate(date, 'gen', true));
-1632 	} else if (params.date != undefined &&
-1633 		   params.date instanceof Date) {
-1634 	    var withMillis = (params.millis === true);
-1635 	    this.hV = stohex(this.formatDate(params.date, 'gen', withMillis));
-1636 	} else if (params instanceof Date) {
-1637 	    this.hV = stohex(this.formatDate(params, 'gen'));
-1638 	}
-1639 
-1640 	if (this.hV == undefined) {
-1641 	    throw new Error("parameter not specified properly for GeneralizedTime");
-1642 	}
-1643 	return this.hV;
-1644     };
-1645 
-1646     if (params != undefined) this.setByParam(params);
-1647 };
-1648 extendClass(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
-1649 
-1650 // ********************************************************************
-1651 /**
-1652  * class for ASN.1 DER Sequence
-1653  * @name KJUR.asn1.DERSequence
-1654  * @class class for ASN.1 DER Sequence
-1655  * @extends KJUR.asn1.DERAbstractStructured
-1656  * @description
-1657  * <br/>
-1658  * As for argument 'params' for constructor, you can specify one of
-1659  * following properties:
-1660  * <ul>
-1661  * <li>array - specify array of ASN1Object to set elements of content</li>
-1662  * </ul>
-1663  * NOTE: 'params' can be omitted.
-1664  */
-1665 KJUR.asn1.DERSequence = function(params) {
-1666     KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
-1667     this.hT = "30";
-1668     this.getFreshValueHex = function() {
-1669         var h = '';
-1670         for (var i = 0; i < this.asn1Array.length; i++) {
-1671             var asn1Obj = this.asn1Array[i];
-1672             h += asn1Obj.tohex();
-1673         }
-1674         this.hV = h;
-1675         return this.hV;
-1676     };
-1677 };
-1678 extendClass(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
-1679 
-1680 // ********************************************************************
-1681 /**
-1682  * class for ASN.1 DER Set
-1683  * @name KJUR.asn1.DERSet
-1684  * @class class for ASN.1 DER Set
-1685  * @extends KJUR.asn1.DERAbstractStructured
-1686  * @description
-1687  * <br/>
-1688  * As for argument 'params' for constructor, you can specify one of
-1689  * following properties:
-1690  * <ul>
-1691  * <li>array - specify array of ASN1Object to set elements of content</li>
-1692  * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
-1693  * </ul>
-1694  * NOTE1: 'params' can be omitted.<br/>
-1695  * NOTE2: sortflag is supported since 1.0.5.
-1696  */
-1697 KJUR.asn1.DERSet = function(params) {
-1698     KJUR.asn1.DERSet.superclass.constructor.call(this, params);
-1699     this.hT = "31";
-1700     this.sortFlag = true; // item shall be sorted only in ASN.1 DER
-1701     this.getFreshValueHex = function() {
-1702         var a = new Array();
-1703         for (var i = 0; i < this.asn1Array.length; i++) {
-1704             var asn1Obj = this.asn1Array[i];
-1705             a.push(asn1Obj.tohex());
-1706         }
-1707         if (this.sortFlag == true) a.sort();
-1708         this.hV = a.join('');
-1709         return this.hV;
-1710     };
-1711 
-1712     if (typeof params != "undefined") {
-1713         if (typeof params.sortflag != "undefined" &&
-1714             params.sortflag == false)
-1715             this.sortFlag = false;
-1716     }
-1717 };
-1718 extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
-1719 
-1720 // ********************************************************************
-1721 /**
-1722  * class for ASN.1 DER TaggedObject
-1723  * @name KJUR.asn1.DERTaggedObject
-1724  * @class class for ASN.1 DER TaggedObject
-1725  * @extends KJUR.asn1.ASN1Object
-1726  *
-1727  * @description
-1728  * <br/>
-1729  * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
-1730  * For example, if you find '[1]' tag in a ASN.1 dump, 
-1731  * 'tagNoHex' will be 'a1'.
-1732  * <br/>
-1733  * As for optional argument 'params' for constructor, you can specify *ANY* of
-1734  * following properties:
-1735  * <ul>
-1736  * <li>tag - specify tag (default is 'a0' which means [0])</li>
-1737  * <li>explicit - specify true if this is explicit tag otherwise false 
-1738  *     (default is 'true').</li>
-1739  * <li>obj - specify ASN1Object which is tagged</li>
-1740  * <li>tage - specify tag with explicit</li>
-1741  * <li>tagi - specify tag with implicit</li>
-1742  * </ul>
-1743  *
-1744  * @example
-1745  * new KJUR.asn1.DERTaggedObject({
-1746  *  tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
-1747  * }) 
-1748  * new KJUR.asn1.DERTaggedObject({
-1749  *  tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit
-1750  * }) 
-1751  * new KJUR.asn1.DERTaggedObject({
-1752  *  tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
-1753  * }) 
-1754  *
-1755  * // to hexadecimal
-1756  * d1 = new KJUR.asn1.DERUTF8String({str':'a'})
-1757  * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
-1758  * hex = d2.tohex();
-1759  */
-1760 KJUR.asn1.DERTaggedObject = function(params) {
-1761     KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
-1762 
-1763     var _KJUR_asn1 = KJUR.asn1,
-1764 	_ASN1HEX = ASN1HEX,
-1765 	_getV = _ASN1HEX.getV,
-1766 	_isASN1HEX = _ASN1HEX.isASN1HEX,
-1767 	_newObject = _KJUR_asn1.ASN1Util.newObject;
-1768 
-1769     this.hT = "a0";
-1770     this.hV = '';
-1771     this.isExplicit = true;
-1772     this.asn1Object = null;
-1773     this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true};
-1774 
-1775     /**
-1776      * set value by an ASN1Object
-1777      * @name setString
-1778      * @memberOf KJUR.asn1.DERTaggedObject#
-1779      * @function
-1780      * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
-1781      * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
-1782      * @param {ASN1Object} asn1Object ASN.1 to encapsulate
-1783      * @deprecated since jsrsasign 10.5.4 please use setByParam instead
-1784      */
-1785     this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
-1786 	this.params = {tag: tagNoHex,
-1787 		       explicit: isExplicitFlag,
-1788 		       obj: asn1Object};
-1789     };
-1790 
-1791     this.getFreshValueHex = function() {
-1792 	var params = this.params;
-1793 
-1794 	if (params.explicit == undefined) params.explicit = true;
-1795 
-1796 	if (params.tage != undefined) {
-1797 	    params.tag = params.tage;
-1798 	    params.explicit = true;
-1799 	}
-1800 	if (params.tagi != undefined) {
-1801 	    params.tag = params.tagi;
-1802 	    params.explicit = false;
-1803 	}
-1804 
-1805 	if (params.str != undefined) {
-1806 	    this.hV = utf8tohex(params.str);
-1807 	} else if (params.hex != undefined) {
-1808 	    this.hV = params.hex;
-1809 	} else if (params.obj != undefined) {
-1810 	    var hV1;
-1811 	    if (params.obj instanceof _KJUR_asn1.ASN1Object) {
-1812 		hV1 = params.obj.tohex();
-1813 	    } else if (typeof params.obj == "object") {
-1814 		hV1 = _newObject(params.obj).tohex();
-1815 	    }
-1816 	    if (params.explicit) {
-1817 		this.hV = hV1;
-1818 	    } else {
-1819 		this.hV = _getV(hV1, 0);
-1820 	    }
-1821 	} else {
-1822 	    throw new Error("str, hex nor obj not specified");
-1823 	}
-1824 
-1825 	if (params.tag == undefined) params.tag = "a0";
-1826 	this.hT = params.tag;
-1827         this.hTLV = null;
-1828         this.isModified = true;
-1829 
-1830         return this.hV;
-1831     };
-1832 
-1833     this.setByParam = function(params) {
-1834 	this.params = params;
-1835     };
-1836 
-1837     if (params !== undefined) this.setByParam(params);
-1838 };
-1839 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
-1840 
\ No newline at end of file +977 * +978 * @example +979 * // default constructor +980 * o = new KJUR.asn1.DERBitString(); +981 * // initialize with binary string +982 * o = new KJUR.asn1.DERBitString({bin: "1011"}); +983 * // initialize with boolean array +984 * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]}); +985 * // initialize with hexadecimal string (04 is unused bits) +986 * o = new KJUR.asn1.DERBitString({hex: "04bac0"}); +987 * // initialize with ASN1Util.newObject argument for encapsulated +988 * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}}); +989 * // above generates a ASN.1 data like this: +990 * // BIT STRING, encapsulates { +991 * // SEQUENCE { +992 * // INTEGER 3 +993 * // PrintableString 'aaa' +994 * // } +995 * // } +996 */
+997 KJUR.asn1.DERBitString = function(params) { +998 if (params !== undefined && typeof params.obj !== "undefined") { +999 var o = KJUR.asn1.ASN1Util.newObject(params.obj); +1000 params.hex = "00" + o.tohex(); +1001 } +1002 KJUR.asn1.DERBitString.superclass.constructor.call(this); +1003 this.hT = "03"; +1004 +1005 /** +1006 * set ASN.1 value(V) by a hexadecimal string including unused bits +1007 * @name setHexValueIncludingUnusedBits +1008 * @memberOf KJUR.asn1.DERBitString# +1009 * @function +1010 * @param {String} newHexStringIncludingUnusedBits +1011 */ +1012 this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) { +1013 this.hTLV = null; +1014 this.isModified = true; +1015 this.hV = newHexStringIncludingUnusedBits; +1016 }; +1017 +1018 /** +1019 * set ASN.1 value(V) by unused bit and hexadecimal string of value +1020 * @name setUnusedBitsAndHexValue +1021 * @memberOf KJUR.asn1.DERBitString# +1022 * @function +1023 * @param {Integer} unusedBits +1024 * @param {String} hValue +1025 */ +1026 this.setUnusedBitsAndHexValue = function(unusedBits, hValue) { +1027 if (unusedBits < 0 || 7 < unusedBits) { +1028 throw "unused bits shall be from 0 to 7: u = " + unusedBits; +1029 } +1030 var hUnusedBits = "0" + unusedBits; +1031 this.hTLV = null; +1032 this.isModified = true; +1033 this.hV = hUnusedBits + hValue; +1034 }; +1035 +1036 /** +1037 * set ASN.1 DER BitString by binary string<br/> +1038 * @name setByBinaryString +1039 * @memberOf KJUR.asn1.DERBitString# +1040 * @function +1041 * @param {String} binaryString binary value string (i.e. '10111') +1042 * @description +1043 * Its unused bits will be calculated automatically by length of +1044 * 'binaryValue'. <br/> +1045 * NOTE: Leading zeros '0' will be ignored. +1046 * @example +1047 * o = new KJUR.asn1.DERBitString(); +1048 * o.setByBinaryString("1011"); +1049 * o.setByBinaryString("001"); // leading zeros ignored +1050 */ +1051 this.setByBinaryString = function(binaryString) { +1052 binaryString = binaryString.replace(/0+$/, ''); +1053 var unusedBits = 8 - binaryString.length % 8; +1054 if (unusedBits == 8) unusedBits = 0; +1055 +1056 binaryString += "0000000".substr(0, unusedBits); +1057 +1058 var h = ''; +1059 for (var i = 0; i < binaryString.length - 1; i += 8) { +1060 var b = binaryString.substr(i, 8); +1061 var x = parseInt(b, 2).toString(16); +1062 if (x.length == 1) x = '0' + x; +1063 h += x; +1064 } +1065 this.hTLV = null; +1066 this.isModified = true; +1067 this.hV = '0' + unusedBits + h; +1068 }; +1069 +1070 /** +1071 * set ASN.1 TLV value(V) by an array of boolean<br/> +1072 * @name setByBooleanArray +1073 * @memberOf KJUR.asn1.DERBitString# +1074 * @function +1075 * @param {array} booleanArray array of boolean (ex. [true, false, true]) +1076 * @description +1077 * NOTE: Trailing falses will be ignored in the ASN.1 DER Object. +1078 * @example +1079 * o = new KJUR.asn1.DERBitString(); +1080 * o.setByBooleanArray([false, true, false, true, true]); +1081 */ +1082 this.setByBooleanArray = function(booleanArray) { +1083 var s = ''; +1084 for (var i = 0; i < booleanArray.length; i++) { +1085 if (booleanArray[i] == true) { +1086 s += '1'; +1087 } else { +1088 s += '0'; +1089 } +1090 } +1091 this.setByBinaryString(s); +1092 }; +1093 +1094 /** +1095 * generate an array of falses with specified length<br/> +1096 * @name newFalseArray +1097 * @memberOf KJUR.asn1.DERBitString +1098 * @function +1099 * @param {Integer} nLength length of array to generate +1100 * @return {array} array of boolean falses +1101 * @description +1102 * This static method may be useful to initialize boolean array. +1103 * @example +1104 * o = new KJUR.asn1.DERBitString(); +1105 * o.newFalseArray(3) → [false, false, false] +1106 */ +1107 this.newFalseArray = function(nLength) { +1108 var a = new Array(nLength); +1109 for (var i = 0; i < nLength; i++) { +1110 a[i] = false; +1111 } +1112 return a; +1113 }; +1114 +1115 this.getFreshValueHex = function() { +1116 return this.hV; +1117 }; +1118 +1119 if (typeof params != "undefined") { +1120 if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) { +1121 this.setHexValueIncludingUnusedBits(params); +1122 } else if (typeof params['hex'] != "undefined") { +1123 this.setHexValueIncludingUnusedBits(params['hex']); +1124 } else if (typeof params['bin'] != "undefined") { +1125 this.setByBinaryString(params['bin']); +1126 } else if (typeof params['array'] != "undefined") { +1127 this.setByBooleanArray(params['array']); +1128 } +1129 } +1130 }; +1131 extendClass(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object); +1132 +1133 // ******************************************************************** +1134 /** +1135 * class for ASN.1 DER OctetString<br/> +1136 * @name KJUR.asn1.DEROctetString +1137 * @class class for ASN.1 DER OctetString +1138 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1139 * @extends KJUR.asn1.DERAbstractString +1140 * @description +1141 * This class provides ASN.1 OctetString simple type.<br/> +1142 * Supported "params" attributes are: +1143 * <ul> +1144 * <li>str - to set a string as a value</li> +1145 * <li>hex - to set a hexadecimal string as a value</li> +1146 * <li>obj - to set a encapsulated ASN.1 value by JSON object +1147 * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li> +1148 * </ul> +1149 * NOTE: A parameter 'obj' have been supported +1150 * for "OCTET STRING, encapsulates" structure. +1151 * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25). +1152 * @see KJUR.asn1.DERAbstractString - superclass +1153 * @example +1154 * // default constructor +1155 * o = new KJUR.asn1.DEROctetString(); +1156 * // initialize with string +1157 * o = new KJUR.asn1.DEROctetString({str: "aaa"}); +1158 * // initialize with hexadecimal string +1159 * o = new KJUR.asn1.DEROctetString({hex: "616161"}); +1160 * // initialize with ASN1Util.newObject argument +1161 * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}}); +1162 * // above generates a ASN.1 data like this: +1163 * // OCTET STRING, encapsulates { +1164 * // SEQUENCE { +1165 * // INTEGER 3 +1166 * // PrintableString 'aaa' +1167 * // } +1168 * // } +1169 */ +1170 KJUR.asn1.DEROctetString = function(params) { +1171 if (params !== undefined && typeof params.obj !== "undefined") { +1172 var o = KJUR.asn1.ASN1Util.newObject(params.obj); +1173 params.hex = o.tohex(); +1174 } +1175 KJUR.asn1.DEROctetString.superclass.constructor.call(this, params); +1176 this.hT = "04"; +1177 }; +1178 extendClass(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString); +1179 +1180 // ******************************************************************** +1181 /** +1182 * class for ASN.1 DER Null +1183 * @name KJUR.asn1.DERNull +1184 * @class class for ASN.1 DER Null +1185 * @extends KJUR.asn1.ASN1Object +1186 * @description +1187 * @see KJUR.asn1.ASN1Object - superclass +1188 */ +1189 KJUR.asn1.DERNull = function() { +1190 KJUR.asn1.DERNull.superclass.constructor.call(this); +1191 this.hT = "05"; +1192 this.hTLV = "0500"; +1193 }; +1194 extendClass(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object); +1195 +1196 // ******************************************************************** +1197 /** +1198 * class for ASN.1 DER ObjectIdentifier +1199 * @name KJUR.asn1.DERObjectIdentifier +1200 * @class class for ASN.1 DER ObjectIdentifier +1201 * @param {Object} JSON object or string of parameters (ex. {'oid': '2.5.4.5'}) +1202 * @extends KJUR.asn1.ASN1Object +1203 * @see oidtohex +1204 * +1205 * @description +1206 * <br/> +1207 * As for argument 'params' for constructor, you can specify one of +1208 * following properties: +1209 * <ul> +1210 * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li> +1211 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li> +1212 * </ul> +1213 * NOTE: 'params' can be omitted. +1214 * @example +1215 * new DERObjectIdentifier({"name": "sha1"}) +1216 * new DERObjectIdentifier({"oid": "1.2.3.4"}) +1217 * new DERObjectIdentifier({"hex": "2d..."}) +1218 * new DERObjectIdentifier("1.2.3.4") +1219 * new DERObjectIdentifier("SHA1withRSA") +1220 */ +1221 KJUR.asn1.DERObjectIdentifier = function(params) { +1222 KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this); +1223 this.hT = "06"; +1224 +1225 /** +1226 * set value by a hexadecimal string +1227 * @name setValueHex +1228 * @memberOf KJUR.asn1.DERObjectIdentifier# +1229 * @function +1230 * @param {String} newHexString hexadecimal value of OID bytes +1231 */ +1232 this.setValueHex = function(newHexString) { +1233 this.hTLV = null; +1234 this.isModified = true; +1235 this.s = null; +1236 this.hV = newHexString; +1237 }; +1238 +1239 /** +1240 * set value by a OID string<br/> +1241 * @name setValueOidString +1242 * @memberOf KJUR.asn1.DERObjectIdentifier# +1243 * @function +1244 * @param {String} oidString OID string (ex. 2.5.4.13) +1245 * @example +1246 * o = new KJUR.asn1.DERObjectIdentifier(); +1247 * o.setValueOidString("2.5.4.13"); +1248 */ +1249 this.setValueOidString = function(oidString) { +1250 var h = oidtohex(oidString); +1251 if (h == null) +1252 throw new Error("malformed oid string: " + oidString); +1253 this.hTLV = null; +1254 this.isModified = true; +1255 this.s = null; +1256 this.hV = h; +1257 }; +1258 +1259 /** +1260 * set value by a OID name +1261 * @name setValueName +1262 * @memberOf KJUR.asn1.DERObjectIdentifier# +1263 * @function +1264 * @param {String} oidName OID name (ex. 'serverAuth') +1265 * @since 1.0.1 +1266 * @description +1267 * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'. +1268 * Otherwise raise error. +1269 * @example +1270 * o = new KJUR.asn1.DERObjectIdentifier(); +1271 * o.setValueName("serverAuth"); +1272 */ +1273 this.setValueName = function(oidName) { +1274 var oid = KJUR.asn1.x509.OID.name2oid(oidName); +1275 if (oid !== '') { +1276 this.setValueOidString(oid); +1277 } else { +1278 throw new Error("DERObjectIdentifier oidName undefined: " + oidName); +1279 } +1280 }; +1281 +1282 this.setValueNameOrOid = function(nameOrOid) { +1283 if (nameOrOid.match(/^[0-2].[0-9.]+$/)) { +1284 this.setValueOidString(nameOrOid); +1285 } else { +1286 this.setValueName(nameOrOid); +1287 } +1288 } +1289 +1290 this.getFreshValueHex = function() { +1291 return this.hV; +1292 }; +1293 +1294 this.setByParam = function(params) { +1295 if (typeof params === "string") { +1296 this.setValueNameOrOid(params); +1297 } else if (params.oid !== undefined) { +1298 this.setValueNameOrOid(params.oid); +1299 } else if (params.name !== undefined) { +1300 this.setValueNameOrOid(params.name); +1301 } else if (params.hex !== undefined) { +1302 this.setValueHex(params.hex); +1303 } +1304 }; +1305 +1306 if (params !== undefined) this.setByParam(params); +1307 }; +1308 extendClass(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object); +1309 +1310 // ******************************************************************** +1311 /** +1312 * class for ASN.1 DER Enumerated +1313 * @name KJUR.asn1.DEREnumerated +1314 * @class class for ASN.1 DER Enumerated +1315 * @extends KJUR.asn1.ASN1Object +1316 * @description +1317 * <br/> +1318 * As for argument 'params' for constructor, you can specify one of +1319 * following properties: +1320 * <ul> +1321 * <li>int - specify initial ASN.1 value(V) by integer value</li> +1322 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li> +1323 * </ul> +1324 * NOTE: 'params' can be omitted. +1325 * @example +1326 * new KJUR.asn1.DEREnumerated(123); +1327 * new KJUR.asn1.DEREnumerated({int: 123}); +1328 * new KJUR.asn1.DEREnumerated({hex: '1fad'}); +1329 */ +1330 KJUR.asn1.DEREnumerated = function(params) { +1331 KJUR.asn1.DEREnumerated.superclass.constructor.call(this); +1332 this.hT = "0a"; +1333 +1334 /** +1335 * set value by Tom Wu's BigInteger object +1336 * @name setByBigInteger +1337 * @memberOf KJUR.asn1.DEREnumerated# +1338 * @function +1339 * @param {BigInteger} bigIntegerValue to set +1340 */ +1341 this.setByBigInteger = function(bigIntegerValue) { +1342 this.hTLV = null; +1343 this.isModified = true; +1344 this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue); +1345 }; +1346 +1347 /** +1348 * set value by integer value +1349 * @name setByInteger +1350 * @memberOf KJUR.asn1.DEREnumerated# +1351 * @function +1352 * @param {Integer} integer value to set +1353 */ +1354 this.setByInteger = function(intValue) { +1355 var bi = new BigInteger(String(intValue), 10); +1356 this.setByBigInteger(bi); +1357 }; +1358 +1359 /** +1360 * set value by integer value +1361 * @name setValueHex +1362 * @memberOf KJUR.asn1.DEREnumerated# +1363 * @function +1364 * @param {String} hexadecimal string of integer value +1365 * @description +1366 * <br/> +1367 * NOTE: Value shall be represented by minimum octet length of +1368 * two's complement representation. +1369 */ +1370 this.setValueHex = function(newHexString) { +1371 this.hV = newHexString; +1372 }; +1373 +1374 this.getFreshValueHex = function() { +1375 return this.hV; +1376 }; +1377 +1378 if (typeof params != "undefined") { +1379 if (typeof params['int'] != "undefined") { +1380 this.setByInteger(params['int']); +1381 } else if (typeof params == "number") { +1382 this.setByInteger(params); +1383 } else if (typeof params['hex'] != "undefined") { +1384 this.setValueHex(params['hex']); +1385 } +1386 } +1387 }; +1388 extendClass(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object); +1389 +1390 // ******************************************************************** +1391 /** +1392 * class for ASN.1 DER UTF8String +1393 * @name KJUR.asn1.DERUTF8String +1394 * @class class for ASN.1 DER UTF8String +1395 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1396 * @extends KJUR.asn1.DERAbstractString +1397 * @description +1398 * @see KJUR.asn1.DERAbstractString - superclass +1399 */ +1400 KJUR.asn1.DERUTF8String = function(params) { +1401 KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params); +1402 this.hT = "0c"; +1403 }; +1404 extendClass(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString); +1405 +1406 // ******************************************************************** +1407 /** +1408 * class for ASN.1 DER NumericString +1409 * @name KJUR.asn1.DERNumericString +1410 * @class class for ASN.1 DER NumericString +1411 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1412 * @extends KJUR.asn1.DERAbstractString +1413 * @description +1414 * @see KJUR.asn1.DERAbstractString - superclass +1415 */ +1416 KJUR.asn1.DERNumericString = function(params) { +1417 KJUR.asn1.DERNumericString.superclass.constructor.call(this, params); +1418 this.hT = "12"; +1419 }; +1420 extendClass(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString); +1421 +1422 // ******************************************************************** +1423 /** +1424 * class for ASN.1 DER PrintableString +1425 * @name KJUR.asn1.DERPrintableString +1426 * @class class for ASN.1 DER PrintableString +1427 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1428 * @extends KJUR.asn1.DERAbstractString +1429 * @description +1430 * @see KJUR.asn1.DERAbstractString - superclass +1431 */ +1432 KJUR.asn1.DERPrintableString = function(params) { +1433 KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params); +1434 this.hT = "13"; +1435 }; +1436 extendClass(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString); +1437 +1438 // ******************************************************************** +1439 /** +1440 * class for ASN.1 DER TeletexString +1441 * @name KJUR.asn1.DERTeletexString +1442 * @class class for ASN.1 DER TeletexString +1443 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1444 * @extends KJUR.asn1.DERAbstractString +1445 * @description +1446 * @see KJUR.asn1.DERAbstractString - superclass +1447 */ +1448 KJUR.asn1.DERTeletexString = function(params) { +1449 KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params); +1450 this.hT = "14"; +1451 }; +1452 extendClass(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString); +1453 +1454 // ******************************************************************** +1455 /** +1456 * class for ASN.1 DER IA5String +1457 * @name KJUR.asn1.DERIA5String +1458 * @class class for ASN.1 DER IA5String +1459 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1460 * @extends KJUR.asn1.DERAbstractString +1461 * @description +1462 * @see KJUR.asn1.DERAbstractString - superclass +1463 */ +1464 KJUR.asn1.DERIA5String = function(params) { +1465 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params); +1466 this.hT = "16"; +1467 }; +1468 extendClass(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString); +1469 +1470 // ******************************************************************** +1471 /** +1472 * class for ASN.1 DER VisibleString +1473 * @name KJUR.asn1.DERVisibleString +1474 * @class class for ASN.1 DER VisibleString +1475 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1476 * @extends KJUR.asn1.DERAbstractString +1477 * @since jsrsasign 8.0.23 asn1 1.0.15 +1478 * @description +1479 * @see KJUR.asn1.DERAbstractString - superclass +1480 */ +1481 KJUR.asn1.DERVisibleString = function(params) { +1482 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params); +1483 this.hT = "1a"; +1484 }; +1485 extendClass(KJUR.asn1.DERVisibleString, KJUR.asn1.DERAbstractString); +1486 +1487 // ******************************************************************** +1488 /** +1489 * class for ASN.1 DER BMPString +1490 * @name KJUR.asn1.DERBMPString +1491 * @class class for ASN.1 DER BMPString +1492 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'}) +1493 * @extends KJUR.asn1.DERAbstractString +1494 * @since jsrsasign 8.0.23 asn1 1.0.15 +1495 * @description +1496 * @see KJUR.asn1.DERAbstractString - superclass +1497 */ +1498 KJUR.asn1.DERBMPString = function(params) { +1499 KJUR.asn1.DERBMPString.superclass.constructor.call(this, params); +1500 this.hT = "1e"; +1501 }; +1502 extendClass(KJUR.asn1.DERBMPString, KJUR.asn1.DERAbstractString); +1503 +1504 // ******************************************************************** +1505 /** +1506 * class for ASN.1 DER UTCTime +1507 * @name KJUR.asn1.DERUTCTime +1508 * @class class for ASN.1 DER UTCTime +1509 * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'}) +1510 * @extends KJUR.asn1.DERAbstractTime +1511 * @see KJUR.asn1.DERGeneralizedTime +1512 * @see KJUR.asn1.x509.Time +1513 * +1514 * @description +1515 * <br/> +1516 * As for argument 'params' for constructor, you can specify one of +1517 * following properties: +1518 * <ul> +1519 * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li> +1520 * <li>date - specify Date object.</li> +1521 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li> +1522 * </ul> +1523 * NOTE1: 'params' can be omitted. +1524 * NOTE2: 'millis' property is supported from jsrsasign 10.4.1 asn1 1.0.22. +1525 * +1526 * <h4>EXAMPLES</h4> +1527 * @example +1528 * new DERUTCTime("20151231235959Z") +1529 * new DERUTCTime("20151231235959.123Z") +1530 * new DERUTCTime(new Date()) +1531 * new DERUTCTime(new Date(Date.UTC(2015,11,31,23,59,59,123))) +1532 * new DERUTCTime({str: "20151231235959.123Z"}) +1533 * new DERUTCTime({date: new Date()}) +1534 * new DERUTCTime({date: new Date(), millis: true}) +1535 * new DERUTCTime({millis: true}) +1536 */ +1537 KJUR.asn1.DERUTCTime = function(params) { +1538 KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params); +1539 this.hT = "17"; +1540 this.params = undefined; +1541 +1542 this.getFreshValueHex = function() { +1543 var params = this.params; +1544 +1545 if (this.params == undefined) params = { date: new Date() }; +1546 +1547 if (typeof params == "string") { +1548 if (params.match(/^[0-9]{12}Z$/) || +1549 params.match(/^[0-9]{12}\.[0-9]+Z$/)) { +1550 this.hV = stohex(params); +1551 } else { +1552 throw new Error("malformed string for UTCTime: " + params); +1553 } +1554 } else if (params.str != undefined) { +1555 this.hV = stohex(params.str); +1556 } else if (params.date == undefined && params.millis == true) { +1557 var date = new Date(); +1558 this.hV = stohex(this.formatDate(date, 'utc', true)); +1559 } else if (params.date != undefined && +1560 params.date instanceof Date) { +1561 var withMillis = (params.millis === true); +1562 this.hV = stohex(this.formatDate(params.date, 'utc', withMillis)); +1563 } else if (params instanceof Date) { +1564 this.hV = stohex(this.formatDate(params, 'utc')); +1565 } +1566 +1567 if (this.hV == undefined) { +1568 throw new Error("parameter not specified properly for UTCTime"); +1569 } +1570 return this.hV; +1571 }; +1572 +1573 if (params != undefined) this.setByParam(params); +1574 }; +1575 extendClass(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime); +1576 +1577 // ******************************************************************** +1578 /** +1579 * class for ASN.1 DER GeneralizedTime +1580 * @name KJUR.asn1.DERGeneralizedTime +1581 * @class class for ASN.1 DER GeneralizedTime +1582 * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'}) +1583 * @property {Boolean} withMillis flag to show milliseconds or not +1584 * @extends KJUR.asn1.DERAbstractTime +1585 * @see KJUR.asn1.DERUTCTime +1586 * @see KJUR.asn1.x509.Time +1587 * +1588 * @description +1589 * <br/> +1590 * As for argument 'params' for constructor, you can specify one of +1591 * following properties: +1592 * <ul> +1593 * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li> +1594 * <li>date - specify Date object.</li> +1595 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li> +1596 * </ul> +1597 * NOTE1: 'params' can be omitted. +1598 * NOTE2: 'millis' property is supported from asn1 1.0.6. +1599 * +1600 * <h4>EXAMPLES</h4> +1601 * @example +1602 * new DERGeneralizedTime("20151231235959Z") +1603 * new DERGeneralizedTime("20151231235959.123Z") +1604 * new DERGeneralizedTime(new Date()) +1605 * new DERGeneralizedTime(new Date(Date.UTC(2015,11,31,23,59,59,123))) +1606 * new DERGeneralizedTime({str: "20151231235959.123Z"}) +1607 * new DERGeneralizedTime({date: new Date()}) +1608 * new DERGeneralizedTime({date: new Date(), millis: true}) +1609 * new DERGeneralizedTime({millis: true}) +1610 */ +1611 KJUR.asn1.DERGeneralizedTime = function(params) { +1612 KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params); +1613 this.hT = "18"; +1614 this.params = params; +1615 +1616 this.getFreshValueHex = function() { +1617 var params = this.params; +1618 +1619 if (this.params == undefined) params = { date: new Date() }; +1620 +1621 if (typeof params == "string") { +1622 if (params.match(/^[0-9]{14}Z$/) || +1623 params.match(/^[0-9]{14}\.[0-9]+Z$/)) { +1624 this.hV = stohex(params); +1625 } else { +1626 throw new Error("malformed string for GeneralizedTime: " + params); +1627 } +1628 } else if (params.str != undefined) { +1629 this.hV = stohex(params.str); +1630 } else if (params.date == undefined && params.millis == true) { +1631 var date = new Date(); +1632 this.hV = stohex(this.formatDate(date, 'gen', true)); +1633 } else if (params.date != undefined && +1634 params.date instanceof Date) { +1635 var withMillis = (params.millis === true); +1636 this.hV = stohex(this.formatDate(params.date, 'gen', withMillis)); +1637 } else if (params instanceof Date) { +1638 this.hV = stohex(this.formatDate(params, 'gen')); +1639 } +1640 +1641 if (this.hV == undefined) { +1642 throw new Error("parameter not specified properly for GeneralizedTime"); +1643 } +1644 return this.hV; +1645 }; +1646 +1647 if (params != undefined) this.setByParam(params); +1648 }; +1649 extendClass(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime); +1650 +1651 // ******************************************************************** +1652 /** +1653 * class for ASN.1 DER Sequence +1654 * @name KJUR.asn1.DERSequence +1655 * @class class for ASN.1 DER Sequence +1656 * @extends KJUR.asn1.DERAbstractStructured +1657 * @description +1658 * <br/> +1659 * As for argument 'params' for constructor, you can specify one of +1660 * following properties: +1661 * <ul> +1662 * <li>array - specify array of ASN1Object to set elements of content</li> +1663 * </ul> +1664 * NOTE: 'params' can be omitted. +1665 */ +1666 KJUR.asn1.DERSequence = function(params) { +1667 KJUR.asn1.DERSequence.superclass.constructor.call(this, params); +1668 this.hT = "30"; +1669 this.getFreshValueHex = function() { +1670 var h = ''; +1671 for (var i = 0; i < this.asn1Array.length; i++) { +1672 var asn1Obj = this.asn1Array[i]; +1673 h += asn1Obj.tohex(); +1674 } +1675 this.hV = h; +1676 return this.hV; +1677 }; +1678 }; +1679 extendClass(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured); +1680 +1681 // ******************************************************************** +1682 /** +1683 * class for ASN.1 DER Set +1684 * @name KJUR.asn1.DERSet +1685 * @class class for ASN.1 DER Set +1686 * @extends KJUR.asn1.DERAbstractStructured +1687 * @description +1688 * <br/> +1689 * As for argument 'params' for constructor, you can specify one of +1690 * following properties: +1691 * <ul> +1692 * <li>array - specify array of ASN1Object to set elements of content</li> +1693 * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li> +1694 * </ul> +1695 * NOTE1: 'params' can be omitted.<br/> +1696 * NOTE2: sortflag is supported since 1.0.5. +1697 */ +1698 KJUR.asn1.DERSet = function(params) { +1699 KJUR.asn1.DERSet.superclass.constructor.call(this, params); +1700 this.hT = "31"; +1701 this.sortFlag = true; // item shall be sorted only in ASN.1 DER +1702 this.getFreshValueHex = function() { +1703 var a = new Array(); +1704 for (var i = 0; i < this.asn1Array.length; i++) { +1705 var asn1Obj = this.asn1Array[i]; +1706 a.push(asn1Obj.tohex()); +1707 } +1708 if (this.sortFlag == true) a.sort(); +1709 this.hV = a.join(''); +1710 return this.hV; +1711 }; +1712 +1713 if (typeof params != "undefined") { +1714 if (typeof params.sortflag != "undefined" && +1715 params.sortflag == false) +1716 this.sortFlag = false; +1717 } +1718 }; +1719 extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured); +1720 +1721 // ******************************************************************** +1722 /** +1723 * class for ASN.1 DER TaggedObject +1724 * @name KJUR.asn1.DERTaggedObject +1725 * @class class for ASN.1 DER TaggedObject +1726 * @extends KJUR.asn1.ASN1Object +1727 * +1728 * @description +1729 * <br/> +1730 * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object. +1731 * For example, if you find '[1]' tag in a ASN.1 dump, +1732 * 'tagNoHex' will be 'a1'. +1733 * <br/> +1734 * As for optional argument 'params' for constructor, you can specify *ANY* of +1735 * following properties: +1736 * <ul> +1737 * <li>tag - specify tag (default is 'a0' which means [0])</li> +1738 * <li>explicit - specify true if this is explicit tag otherwise false +1739 * (default is 'true').</li> +1740 * <li>obj - specify ASN1Object which is tagged</li> +1741 * <li>tage - specify tag with explicit</li> +1742 * <li>tagi - specify tag with implicit</li> +1743 * </ul> +1744 * +1745 * @example +1746 * new KJUR.asn1.DERTaggedObject({ +1747 * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit +1748 * }) +1749 * new KJUR.asn1.DERTaggedObject({ +1750 * tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit +1751 * }) +1752 * new KJUR.asn1.DERTaggedObject({ +1753 * tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit +1754 * }) +1755 * +1756 * // to hexadecimal +1757 * d1 = new KJUR.asn1.DERUTF8String({str':'a'}) +1758 * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1}); +1759 * hex = d2.tohex(); +1760 */ +1761 KJUR.asn1.DERTaggedObject = function(params) { +1762 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this); +1763 +1764 var _KJUR_asn1 = KJUR.asn1, +1765 _ASN1HEX = ASN1HEX, +1766 _getV = _ASN1HEX.getV, +1767 _isASN1HEX = _ASN1HEX.isASN1HEX, +1768 _newObject = _KJUR_asn1.ASN1Util.newObject; +1769 +1770 this.hT = "a0"; +1771 this.hV = ''; +1772 this.isExplicit = true; +1773 this.asn1Object = null; +1774 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true}; +1775 +1776 /** +1777 * set value by an ASN1Object +1778 * @name setString +1779 * @memberOf KJUR.asn1.DERTaggedObject# +1780 * @function +1781 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag +1782 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag +1783 * @param {ASN1Object} asn1Object ASN.1 to encapsulate +1784 * @deprecated since jsrsasign 10.5.4 please use setByParam instead +1785 */ +1786 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) { +1787 this.params = {tag: tagNoHex, +1788 explicit: isExplicitFlag, +1789 obj: asn1Object}; +1790 }; +1791 +1792 this.getFreshValueHex = function() { +1793 var params = this.params; +1794 +1795 if (params.explicit == undefined) params.explicit = true; +1796 +1797 if (params.tage != undefined) { +1798 params.tag = params.tage; +1799 params.explicit = true; +1800 } +1801 if (params.tagi != undefined) { +1802 params.tag = params.tagi; +1803 params.explicit = false; +1804 } +1805 +1806 if (params.str != undefined) { +1807 this.hV = utf8tohex(params.str); +1808 } else if (params.hex != undefined) { +1809 this.hV = params.hex; +1810 } else if (params.obj != undefined) { +1811 var hV1; +1812 if (params.obj instanceof _KJUR_asn1.ASN1Object) { +1813 hV1 = params.obj.tohex(); +1814 } else if (typeof params.obj == "object") { +1815 hV1 = _newObject(params.obj).tohex(); +1816 } +1817 if (params.explicit) { +1818 this.hV = hV1; +1819 } else { +1820 this.hV = _getV(hV1, 0); +1821 } +1822 } else { +1823 throw new Error("str, hex nor obj not specified"); +1824 } +1825 +1826 if (params.tag == undefined) params.tag = "a0"; +1827 this.hT = params.tag; +1828 this.hTLV = null; +1829 this.isModified = true; +1830 +1831 return this.hV; +1832 }; +1833 +1834 this.setByParam = function(params) { +1835 this.params = params; +1836 }; +1837 +1838 if (params !== undefined) this.setByParam(params); +1839 }; +1840 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object); +1841
\ No newline at end of file diff --git a/api/symbols/src/asn1tsp-1.0.js.html b/api/symbols/src/asn1tsp-1.0.js.html index dca4b8db..129486ff 100644 --- a/api/symbols/src/asn1tsp-1.0.js.html +++ b/api/symbols/src/asn1tsp-1.0.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
  1 /* asn1tsp-2.0.8.js (c) 2014-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* asn1tsp-2.0.9.js (c) 2014-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * asn1tsp.js - ASN.1 DER encoder classes for RFC 3161 Time Stamp Protocol
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name asn1tsp-1.0.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.5.21 asn1tsp 2.0.8 (2022-May-23)
+ 19  * @version jsrsasign 10.5.22 asn1tsp 2.0.9 (2022-May-24)
  20  * @since jsrsasign 4.5.1
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -867,764 +867,768 @@
 860 	if (typeof params == "number" && 
 861 	    0 <= params && params <= 25) {
 862 	    d |= 1 << params;
-863 	} else if (typeof params == "string" &&
-864 		   _nameValue[params] != undefined) {
-865 	    return namearraytobinstr([params], _nameValue);
-866 	} else if (typeof params == "object" &&
-867 		   params.length != undefined) {
-868 	    return namearraytobinstr(params, _nameValue);
-869 	} else {
-870 	    throw new _Error("wrong params");
-871 	}
-872 
-873 	return d.toString(2);
-874     };
-875 
-876     this.tohex = function() {
-877 	var params = this.params;
-878 
-879 	var binValue = this.getBinValue();
-880 	return (new _DERBitString({"bin": binValue})).tohex();
-881     };
-882     this.getEncodedHex = function() { return this.tohex(); };
-883 
-884     if (params != undefined) this.setByParam(params);
-885 };
-886 extendClass(KJUR.asn1.tsp.PKIFailureInfo, KJUR.asn1.ASN1Object);
+863 	    var s = d.toString(2);
+864 	    var r = "";
+865 	    for (var i = s.length - 1; i >= 0; i--) r += s[i];
+866 	    return r;
+867 	} else if (typeof params == "string" &&
+868 		   _nameValue[params] != undefined) {
+869 	    return namearraytobinstr([params], _nameValue);
+870 	} else if (typeof params == "object" &&
+871 		   params.length != undefined) {
+872 	    return namearraytobinstr(params, _nameValue);
+873 	} else {
+874 	    throw new _Error("wrong params");
+875 	}
+876 
+877 	return 
+878     };
+879 
+880     this.tohex = function() {
+881 	var params = this.params;
+882 
+883 	var binValue = this.getBinValue();
+884 	return (new _DERBitString({"bin": binValue})).tohex();
+885     };
+886     this.getEncodedHex = function() { return this.tohex(); };
 887 
-888 // --- END OF RFC 2510 CMP -------------------------------------------
-889 
-890 /**
-891  * abstract class for TimeStampToken generator (DEPRECATED)<br/>
-892  * @name KJUR.asn1.tsp.AbstractTSAAdapter
-893  * @class abstract class for TimeStampToken generator
-894  * @param {Array} params associative array of parameters
-895  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
-896  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
-897  *
-898  * @description
-899  * This is abstract class for TimeStampToken generator.
-900  */
-901 KJUR.asn1.tsp.AbstractTSAAdapter = function(params) {
-902     this.getTSTHex = function(msgHex, hashAlg) {
-903         throw "not implemented yet";
-904     };
-905 };
-906 
-907 /**
-908  * class for simple TimeStampToken generator (DEPRECATED)<br/>
-909  * @name KJUR.asn1.tsp.SimpleTSAAdapter
-910  * @class class for simple TimeStampToken generator
-911  * @extends KJUR.asn1.tsp.AbstractTSAAdapter
-912  * @param {Array} params associative array of parameters
-913  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
-914  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
-915  *
-916  * @description
-917  * This is a simple TimeStampToken generator class.
-918  */
-919 KJUR.asn1.tsp.SimpleTSAAdapter = function(params) {
-920     var _KJUR = KJUR,
-921 	_KJUR_asn1 = _KJUR.asn1,
-922 	_KJUR_asn1_tsp = _KJUR_asn1.tsp,
-923 	_hashHex = _KJUR.crypto.Util.hashHex;
-924 
-925     _KJUR_asn1_tsp.SimpleTSAAdapter.superclass.constructor.call(this);
-926     this.params = null;
-927     this.serial = 0;
+888     if (params != undefined) this.setByParam(params);
+889 };
+890 extendClass(KJUR.asn1.tsp.PKIFailureInfo, KJUR.asn1.ASN1Object);
+891 
+892 // --- END OF RFC 2510 CMP -------------------------------------------
+893 
+894 /**
+895  * abstract class for TimeStampToken generator (DEPRECATED)<br/>
+896  * @name KJUR.asn1.tsp.AbstractTSAAdapter
+897  * @class abstract class for TimeStampToken generator
+898  * @param {Array} params associative array of parameters
+899  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
+900  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
+901  *
+902  * @description
+903  * This is abstract class for TimeStampToken generator.
+904  */
+905 KJUR.asn1.tsp.AbstractTSAAdapter = function(params) {
+906     this.getTSTHex = function(msgHex, hashAlg) {
+907         throw "not implemented yet";
+908     };
+909 };
+910 
+911 /**
+912  * class for simple TimeStampToken generator (DEPRECATED)<br/>
+913  * @name KJUR.asn1.tsp.SimpleTSAAdapter
+914  * @class class for simple TimeStampToken generator
+915  * @extends KJUR.asn1.tsp.AbstractTSAAdapter
+916  * @param {Array} params associative array of parameters
+917  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
+918  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
+919  *
+920  * @description
+921  * This is a simple TimeStampToken generator class.
+922  */
+923 KJUR.asn1.tsp.SimpleTSAAdapter = function(params) {
+924     var _KJUR = KJUR,
+925 	_KJUR_asn1 = _KJUR.asn1,
+926 	_KJUR_asn1_tsp = _KJUR_asn1.tsp,
+927 	_hashHex = _KJUR.crypto.Util.hashHex;
 928 
-929     this.getTSTHex = function(msgHex, hashAlg) {
-930         // messageImprint
-931         var hashHex = _hashHex(msgHex, hashAlg);
-932         this.params.econtent.content.messageImprint =
-933             {alg: hashAlg, hash: hashHex};
-934 
-935         // serial
-936         this.params.econtent.content.serial =
-937 	    {'int': this.serial++};
+929     _KJUR_asn1_tsp.SimpleTSAAdapter.superclass.constructor.call(this);
+930     this.params = null;
+931     this.serial = 0;
+932 
+933     this.getTSTHex = function(msgHex, hashAlg) {
+934         // messageImprint
+935         var hashHex = _hashHex(msgHex, hashAlg);
+936         this.params.econtent.content.messageImprint =
+937             {alg: hashAlg, hash: hashHex};
 938 
-939         // nonce
-940         var nonceValue = Math.floor(Math.random() * 1000000000);
-941         this.params.econtent.content.nonce =
-942 	    {'int': nonceValue};
-943 
-944         var obj = 
-945             new _KJUR_asn1_tsp.TimeStampToken(this.params);
-946         return obj.getContentInfoEncodedHex();
-947     };
-948 
-949     if (params !== undefined) this.params = params;
-950 };
-951 extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,
-952             KJUR.asn1.tsp.AbstractTSAAdapter);
-953 
-954 /**
-955  * class for fixed TimeStampToken generator (DEPRECATED)<br/>
-956  * @name KJUR.asn1.tsp.FixedTSAAdapter
-957  * @class class for fixed TimeStampToken generator
-958  * @extends KJUR.asn1.tsp.AbstractTSAAdapter
-959  * @param {Array} params associative array of parameters
-960  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
-961  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
-962  *
-963  * @description
-964  * This class generates fixed TimeStampToken except messageImprint
-965  * for testing purpose.
-966  * General TSA generates TimeStampToken which varies following
-967  * fields:
-968  * <ul>
-969  * <li>genTime</li>
-970  * <li>serialNumber</li>
-971  * <li>nonce</li>
-972  * </ul>
-973  * Those values are provided by initial parameters.
-974  */
-975 KJUR.asn1.tsp.FixedTSAAdapter = function(params) {
-976     var _KJUR = KJUR,
-977 	_KJUR_asn1 = _KJUR.asn1,
-978 	_KJUR_asn1_tsp = _KJUR_asn1.tsp,
-979 	_hashHex = _KJUR.crypto.Util.hashHex;
-980 
-981     _KJUR_asn1_tsp.FixedTSAAdapter.superclass.constructor.call(this);
-982     this.params = null;
-983 
-984     this.getTSTHex = function(msgHex, hashAlg) {
-985         // fixed serialNumber
-986         // fixed nonce        
-987         var hashHex = _hashHex(msgHex, hashAlg);
-988         this.params.econtent.content.messageImprint =
-989             {alg: hashAlg, hash: hashHex};
-990         var obj = new _KJUR_asn1_tsp.TimeStampToken(this.params);
-991         return obj.getContentInfoEncodedHex();
-992     };
-993 
-994     if (params !== undefined) this.params = params;
-995 };
-996 extendClass(KJUR.asn1.tsp.FixedTSAAdapter,
-997             KJUR.asn1.tsp.AbstractTSAAdapter);
-998 
-999 // --- TSP utilities -------------------------------------------------
-1000 
-1001 /**
-1002  * TSP utiliteis class
-1003  * @name KJUR.asn1.tsp.TSPUtil
-1004  * @class TSP utilities class
-1005  */
-1006 KJUR.asn1.tsp.TSPUtil = new function() {
-1007 };
-1008 /**
-1009  * generate TimeStampToken ASN.1 object specified by JSON parameters (DEPRECATED)<br/>
-1010  * @name newTimeStampToken
-1011  * @memberOf KJUR.asn1.tsp.TSPUtil
-1012  * @function
-1013  * @param {Array} param JSON parameter to generate TimeStampToken
-1014  * @return {KJUR.asn1.cms.SignedData} object just generated
-1015  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0. Please use TimeStampToken class
-1016  * @see KJUR.asn1.tsp.TimeStampToken
-1017  *
-1018  * @description
-1019  * @example
-1020  */
-1021 KJUR.asn1.tsp.TSPUtil.newTimeStampToken = function(params) {
-1022     return new KJUR.asn1.tsp.TimeStampToken(params);
-1023 };
-1024 
-1025 /**
-1026  * parse hexadecimal string of TimeStampReq
-1027  * @name parseTimeStampReq
-1028  * @memberOf KJUR.asn1.tsp.TSPUtil
-1029  * @function
-1030  * @param {String} hexadecimal string of TimeStampReq
-1031  * @return {Array} JSON object of parsed parameters
-1032  * @see KJUR.asn1.tsp.TSPParser#getTimeStampReq
-1033  * @deprecated since jsrsasign 10.5.18 asn1tsp 2.0.6. Please use TSPParser.getTimeStampReq instead.
-1034  *
-1035  * @description
-1036  * This method parses a hexadecimal string of TimeStampReq
-1037  * and returns parsed their fields:
+939         // serial
+940         this.params.econtent.content.serial =
+941 	    {'int': this.serial++};
+942 
+943         // nonce
+944         var nonceValue = Math.floor(Math.random() * 1000000000);
+945         this.params.econtent.content.nonce =
+946 	    {'int': nonceValue};
+947 
+948         var obj = 
+949             new _KJUR_asn1_tsp.TimeStampToken(this.params);
+950         return obj.getContentInfoEncodedHex();
+951     };
+952 
+953     if (params !== undefined) this.params = params;
+954 };
+955 extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,
+956             KJUR.asn1.tsp.AbstractTSAAdapter);
+957 
+958 /**
+959  * class for fixed TimeStampToken generator (DEPRECATED)<br/>
+960  * @name KJUR.asn1.tsp.FixedTSAAdapter
+961  * @class class for fixed TimeStampToken generator
+962  * @extends KJUR.asn1.tsp.AbstractTSAAdapter
+963  * @param {Array} params associative array of parameters
+964  * @since jsrsasign 4.7.0 asn1tsp 1.0.1
+965  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0
+966  *
+967  * @description
+968  * This class generates fixed TimeStampToken except messageImprint
+969  * for testing purpose.
+970  * General TSA generates TimeStampToken which varies following
+971  * fields:
+972  * <ul>
+973  * <li>genTime</li>
+974  * <li>serialNumber</li>
+975  * <li>nonce</li>
+976  * </ul>
+977  * Those values are provided by initial parameters.
+978  */
+979 KJUR.asn1.tsp.FixedTSAAdapter = function(params) {
+980     var _KJUR = KJUR,
+981 	_KJUR_asn1 = _KJUR.asn1,
+982 	_KJUR_asn1_tsp = _KJUR_asn1.tsp,
+983 	_hashHex = _KJUR.crypto.Util.hashHex;
+984 
+985     _KJUR_asn1_tsp.FixedTSAAdapter.superclass.constructor.call(this);
+986     this.params = null;
+987 
+988     this.getTSTHex = function(msgHex, hashAlg) {
+989         // fixed serialNumber
+990         // fixed nonce        
+991         var hashHex = _hashHex(msgHex, hashAlg);
+992         this.params.econtent.content.messageImprint =
+993             {alg: hashAlg, hash: hashHex};
+994         var obj = new _KJUR_asn1_tsp.TimeStampToken(this.params);
+995         return obj.getContentInfoEncodedHex();
+996     };
+997 
+998     if (params !== undefined) this.params = params;
+999 };
+1000 extendClass(KJUR.asn1.tsp.FixedTSAAdapter,
+1001             KJUR.asn1.tsp.AbstractTSAAdapter);
+1002 
+1003 // --- TSP utilities -------------------------------------------------
+1004 
+1005 /**
+1006  * TSP utiliteis class
+1007  * @name KJUR.asn1.tsp.TSPUtil
+1008  * @class TSP utilities class
+1009  */
+1010 KJUR.asn1.tsp.TSPUtil = new function() {
+1011 };
+1012 /**
+1013  * generate TimeStampToken ASN.1 object specified by JSON parameters (DEPRECATED)<br/>
+1014  * @name newTimeStampToken
+1015  * @memberOf KJUR.asn1.tsp.TSPUtil
+1016  * @function
+1017  * @param {Array} param JSON parameter to generate TimeStampToken
+1018  * @return {KJUR.asn1.cms.SignedData} object just generated
+1019  * @deprecated since jsrsasign 10.0.0 asn1tsp 2.0.0. Please use TimeStampToken class
+1020  * @see KJUR.asn1.tsp.TimeStampToken
+1021  *
+1022  * @description
+1023  * @example
+1024  */
+1025 KJUR.asn1.tsp.TSPUtil.newTimeStampToken = function(params) {
+1026     return new KJUR.asn1.tsp.TimeStampToken(params);
+1027 };
+1028 
+1029 /**
+1030  * parse hexadecimal string of TimeStampReq
+1031  * @name parseTimeStampReq
+1032  * @memberOf KJUR.asn1.tsp.TSPUtil
+1033  * @function
+1034  * @param {String} hexadecimal string of TimeStampReq
+1035  * @return {Array} JSON object of parsed parameters
+1036  * @see KJUR.asn1.tsp.TSPParser#getTimeStampReq
+1037  * @deprecated since jsrsasign 10.5.18 asn1tsp 2.0.6. Please use TSPParser.getTimeStampReq instead.
 1038  *
-1039  * @example
-1040  * var json = KJUR.asn1.tsp.TSPUtil.parseTimeStampReq("302602...");
-1041  * // resulted DUMP of above 'json':
-1042  * {
-1043  *  messageImprint: {
-1044  *       alg: 'sha256',          // MessageImprint hashAlg
-1045  *       hash: 'a1a2a3a4...'},   // MessageImprint hashValue
-1046  *  policy: '1.2.3.4.5',             // tsaPolicy (OPTION)
-1047  *  nonce: '9abcf318...',            // nonce (OPTION)
-1048  *  certreq: true}                   // certReq (OPTION)
-1049  */
-1050 KJUR.asn1.tsp.TSPUtil.parseTimeStampReq = function(reqHex) {
-1051     var parser = new KJUR.asn1.tsp.TSPParser();
-1052     return parser.getTimeStampReq(reqHex);
-1053 };
-1054 
-1055 /**
-1056  * parse hexadecimal string of MessageImprint
-1057  * @name parseMessageImprint
-1058  * @memberOf KJUR.asn1.tsp.TSPUtil
-1059  * @function
-1060  * @param {String} hexadecimal string of MessageImprint
-1061  * @return {Array} JSON object of parsed parameters
-1062  * @see KJUR.asn1.tsp.TSPParser#getMessageImprint
-1063  * @deprecated since jsrsasign 10.5.18 asn1tsp 2.0.6. Please use TSPParser.getMessageImprint instead.
-1064  *
-1065  * @description
-1066  * This method parses a hexadecimal string of MessageImprint
-1067  * and returns parsed their fields:
+1039  * @description
+1040  * This method parses a hexadecimal string of TimeStampReq
+1041  * and returns parsed their fields:
+1042  *
+1043  * @example
+1044  * var json = KJUR.asn1.tsp.TSPUtil.parseTimeStampReq("302602...");
+1045  * // resulted DUMP of above 'json':
+1046  * {
+1047  *  messageImprint: {
+1048  *       alg: 'sha256',          // MessageImprint hashAlg
+1049  *       hash: 'a1a2a3a4...'},   // MessageImprint hashValue
+1050  *  policy: '1.2.3.4.5',             // tsaPolicy (OPTION)
+1051  *  nonce: '9abcf318...',            // nonce (OPTION)
+1052  *  certreq: true}                   // certReq (OPTION)
+1053  */
+1054 KJUR.asn1.tsp.TSPUtil.parseTimeStampReq = function(reqHex) {
+1055     var parser = new KJUR.asn1.tsp.TSPParser();
+1056     return parser.getTimeStampReq(reqHex);
+1057 };
+1058 
+1059 /**
+1060  * parse hexadecimal string of MessageImprint
+1061  * @name parseMessageImprint
+1062  * @memberOf KJUR.asn1.tsp.TSPUtil
+1063  * @function
+1064  * @param {String} hexadecimal string of MessageImprint
+1065  * @return {Array} JSON object of parsed parameters
+1066  * @see KJUR.asn1.tsp.TSPParser#getMessageImprint
+1067  * @deprecated since jsrsasign 10.5.18 asn1tsp 2.0.6. Please use TSPParser.getMessageImprint instead.
 1068  *
-1069  * @example
-1070  * KJUR.asn1.tsp.TSPUtil.parseMessageImprint("302602...") →
-1071  * { alg:  'sha256', hash: 'a1a2a3a4...'}
-1072  */
-1073 KJUR.asn1.tsp.TSPUtil.parseMessageImprint = function(miHex) {
-1074     var parser = new KJUR.asn1.tsp.TSPParser();
-1075     return parser.getMessageImprint(miHex);
-1076 /*
-1077     var _ASN1HEX = ASN1HEX;
-1078     var _getChildIdx = _ASN1HEX.getChildIdx;
-1079     var _getV = _ASN1HEX.getV;
-1080     var _getIdxbyList = _ASN1HEX.getIdxbyList;
-1081     var json = {};
-1082 
-1083     if (miHex.substr(0, 2) != "30")
-1084         throw "head of messageImprint hex shall be '30'";
-1085 
-1086     var idxList = _getChildIdx(miHex, 0);
-1087     var hashAlgOidIdx = _getIdxbyList(miHex, 0, [0, 0]);
-1088     var hashAlgHex = _getV(miHex, hashAlgOidIdx);
-1089     var hashAlgOid = _ASN1HEX.hextooidstr(hashAlgHex);
-1090     var hashAlgName = KJUR.asn1.x509.OID.oid2name(hashAlgOid);
-1091     if (hashAlgName == '')
-1092         throw "hashAlg name undefined: " + hashAlgOid;
-1093     var hashAlg = hashAlgName;
-1094     var hashValueIdx = _getIdxbyList(miHex, 0, [1]);
-1095 
-1096     json.alg = hashAlg;
-1097     json.hash = _getV(miHex, hashValueIdx); 
-1098 
-1099     return json;
-1100 */
-1101 };
+1069  * @description
+1070  * This method parses a hexadecimal string of MessageImprint
+1071  * and returns parsed their fields:
+1072  *
+1073  * @example
+1074  * KJUR.asn1.tsp.TSPUtil.parseMessageImprint("302602...") →
+1075  * { alg:  'sha256', hash: 'a1a2a3a4...'}
+1076  */
+1077 KJUR.asn1.tsp.TSPUtil.parseMessageImprint = function(miHex) {
+1078     var parser = new KJUR.asn1.tsp.TSPParser();
+1079     return parser.getMessageImprint(miHex);
+1080 /*
+1081     var _ASN1HEX = ASN1HEX;
+1082     var _getChildIdx = _ASN1HEX.getChildIdx;
+1083     var _getV = _ASN1HEX.getV;
+1084     var _getIdxbyList = _ASN1HEX.getIdxbyList;
+1085     var json = {};
+1086 
+1087     if (miHex.substr(0, 2) != "30")
+1088         throw "head of messageImprint hex shall be '30'";
+1089 
+1090     var idxList = _getChildIdx(miHex, 0);
+1091     var hashAlgOidIdx = _getIdxbyList(miHex, 0, [0, 0]);
+1092     var hashAlgHex = _getV(miHex, hashAlgOidIdx);
+1093     var hashAlgOid = _ASN1HEX.hextooidstr(hashAlgHex);
+1094     var hashAlgName = KJUR.asn1.x509.OID.oid2name(hashAlgOid);
+1095     if (hashAlgName == '')
+1096         throw "hashAlg name undefined: " + hashAlgOid;
+1097     var hashAlg = hashAlgName;
+1098     var hashValueIdx = _getIdxbyList(miHex, 0, [1]);
+1099 
+1100     json.alg = hashAlg;
+1101     json.hash = _getV(miHex, hashValueIdx); 
 1102 
-1103 /**
-1104  * class for parsing RFC 3161 TimeStamp protocol data<br/>
-1105  * @name KJUR.asn1.tsp.TSPParser
-1106  * @class RFC 3161 TimeStamp protocol parser class
-1107  * @since jsrsasign 10.1.0 asn1tsp 2.0.1
-1108  *
-1109  * @description
-1110  * This is an ASN.1 parser for 
-1111  * <a href="https://tools.ietf.org/html/rfc3161">RFC 3161</a>.
-1112  */
-1113 KJUR.asn1.tsp.TSPParser = function() {
-1114     var _Error = Error,
-1115 	_X509 = X509,
-1116 	_x509obj = new _X509(),
-1117 	_ASN1HEX = ASN1HEX,
-1118 	_getV = _ASN1HEX.getV,
-1119 	_getTLV = _ASN1HEX.getTLV,
-1120 	_getIdxbyList = _ASN1HEX.getIdxbyList,
-1121 	_getTLVbyListEx = _ASN1HEX.getTLVbyListEx,
-1122 	_getChildIdx = _ASN1HEX.getChildIdx;
-1123     var _aSTATUSSTR = [
-1124 	"granted", "grantedWithMods", "rejection", "waiting",
-1125 	"revocationWarning", "revocationNotification" ];
-1126     var _pFAILUREINFO = {
-1127 	0: "badAlg", 2: "badRequest", 5: "badDataFormat",
-1128 	14: "timeNotAvailable", 15: "unacceptedPolicy",
-1129 	16: "unacceptedExtension", 17: "addInfoNotAvailable",
-1130 	25: "systemFailure"
-1131     };
-1132     
-1133     /**
-1134      * parse ASN.1 TimeStampResp<br/>
-1135      * @name getResponse
-1136      * @memberOf KJUR.asn1.tsp.TSPParser#
-1137      * @function
-1138      * @param {String} h hexadecimal string of ASN.1 TimeStampResp
-1139      * @return {Array} JSON object of TimeStampResp parameter
-1140      * @see KJUR.asn1.tsp.TimeStampResp
-1141      * @see KJUR.asn1.tsp.TimeStampToken
-1142      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
-1143      *
-1144      * @description
-1145      * This method parses ASN.1 TimeStampRsp defined in RFC 3161.
-1146      * <pre>
-1147      * TimeStampResp ::= SEQUENCE {
-1148      *   status          PKIStatusInfo,
-1149      *   timeStampToken  TimeStampToken  OPTIONAL }
-1150      * </pre>
-1151      * When "h" is a TSP error response,
-1152      * returned parameter contains "statusinfo" only.
-1153      *
-1154      * @example
-1155      * parser = new KJUR.asn1.tsp.TSPParser();
-1156      * parser.getResponse("30...") →
-1157      * { 
-1158      *   statusinfo: 'granted',
-1159      *   ... // almost the same as CMS SignedData parameters
-1160      *   econtent: {
-1161      *     type: "tstinfo",
-1162      *     content: { // TSTInfo parameter
-1163      *       policy: '1.2.3.4.5',
-1164      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
-1165      *       serial: {'int': 3},
-1166      *       genTime: {str: '20131231235959.123Z'},
-1167      *       accuracy: {millis: 500},
-1168      *       ordering: true,
-1169      *       nonce: {int: 3}
-1170      *     }
-1171      *   },
-1172      *   ...
-1173      * }
-1174      */
-1175     this.getResponse = function(h) {
-1176 	var aIdx = _getChildIdx(h, 0);
-1177 	
-1178 	if (aIdx.length == 1) {
-1179 	    return this.getPKIStatusInfo(_getTLV(h, aIdx[0]));
-1180 	} else if (aIdx.length > 1) {
-1181 	    var pPKIStatusInfo = this.getPKIStatusInfo(_getTLV(h, aIdx[0]));
-1182 	    var hTST = _getTLV(h, aIdx[1]);
-1183 	    var pResult = this.getToken(hTST);
-1184 	    pResult.statusinfo = pPKIStatusInfo;
-1185 	    return pResult;
-1186 	}
-1187     };
-1188 
-1189     /**
-1190      * parse ASN.1 TimeStampToken<br/>
-1191      * @name getToken
-1192      * @memberOf KJUR.asn1.tsp.TSPParser#
-1193      * @function
-1194      * @param {String} h hexadecimal string of ASN.1 TimeStampToken
-1195      * @return {Array} JSON object of TimeStampToken parameter
-1196      * @see KJUR.asn1.tsp.TimeStampToken
-1197      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
-1198      * @see KJUR.asn1.tsp.TSPParser#setTSTInfo
-1199      *
-1200      * @description
-1201      * This method parses ASN.1 TimeStampRsp defined in RFC 3161.
-1202      * This method will parse "h" as CMS SigneData by
-1203      * {@link KJUR.asn1.cms.CMSParser#getCMSSignedData}, then
-1204      * parse and modify "econtent.content" parameter by
-1205      * {@link KJUR.asn1.tsp.TSPParser#setTSTInfo} method.
-1206      *
-1207      * @example
-1208      * parser = new KJUR.asn1.tsp.TSPParser();
-1209      * parser.getToken("30...") →
-1210      * { 
-1211      *   ... // almost the same as CMS SignedData parameters
-1212      *   econtent: {
-1213      *     type: "tstinfo",
-1214      *     content: { // TSTInfo parameter
-1215      *       policy: '1.2.3.4.5',
-1216      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
-1217      *       serial: {'int': 3},
-1218      *       genTime: {str: '20131231235959.123Z'},
-1219      *       accuracy: {millis: 500},
-1220      *       ordering: true,
-1221      *       nonce: {int: 3}
-1222      *     }
-1223      *   },
-1224      *   ...
-1225      * }
-1226      */
-1227     this.getToken = function(h) {
-1228 	var _CMSParser = new KJUR.asn1.cms.CMSParser;
-1229 	var p = _CMSParser.getCMSSignedData(h);
-1230 	this.setTSTInfo(p);
-1231 	return p;
-1232     };
-1233 
-1234     /**
-1235      * set ASN.1 TSTInfo parameter to CMS SignedData parameter<br/>
-1236      * @name setTSTInfo
-1237      * @memberOf KJUR.asn1.tsp.TSPParser#
-1238      * @function
-1239      * @param {Array} pCMSSignedData JSON object of CMS SignedData parameter
-1240      * @see KJUR.asn1.tsp.TimeStampToken
-1241      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
-1242      *
-1243      * @description
-1244      * This method modifies "econtent.content" of CMS SignedData parameter
-1245      * to parsed TSTInfo.
-1246      * <pre>
-1247      *
-1248      * @example
-1249      * parser = new KJUR.asn1.tsp.TSPParser();
-1250      * pCMSSignedData = { 
-1251      *   ... // almost the same as CMS SignedData parameters
-1252      *   econtent: {
-1253      *     type: "tstinfo",
-1254      *     content: { hex: "30..." }
-1255      *   },
-1256      *   ...
-1257      * };
-1258      * parser.setTSTInfo(pCMSSignedData);
-1259      * pCMSSignedData → { 
-1260      *   ... // almost the same as CMS SignedData parameters
-1261      *   econtent: {
-1262      *     type: "tstinfo",
-1263      *     content: { // TSTInfo parameter
-1264      *       policy: '1.2.3.4.5',
-1265      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
-1266      *       serial: {int: 3},
-1267      *       genTime: {str: '20131231235959.123Z'},
-1268      *       accuracy: {millis: 500},
-1269      *       ordering: true,
-1270      *       nonce: {int: 3}
-1271      *     }
-1272      *   },
-1273      *   ...
-1274      * };
-1275      */
-1276     this.setTSTInfo = function(pCMSSignedData) {
-1277 	var pEContent = pCMSSignedData.econtent;
-1278 	if (pEContent.type == "tstinfo") {
-1279 	    var hContent = pEContent.content.hex;
-1280 	    var pTSTInfo = this.getTSTInfo(hContent);
-1281 	    //pTSTInfo.hex_ = hContent;
-1282 	    pEContent.content = pTSTInfo;
-1283 	}
-1284     };
-1285 
-1286     /**
-1287      * parse ASN.1 TSTInfo<br/>
-1288      * @name getTSTInfo
-1289      * @memberOf KJUR.asn1.tsp.TSPParser#
-1290      * @function
-1291      * @param {String} h hexadecimal string of ASN.1 TSTInfo
-1292      * @return {Array} JSON object of TSTInfo parameter
-1293      * @see KJUR.asn1.tsp.TSTInfo
-1294      *
-1295      * @description
-1296      * This method parses ASN.1 TSTInfo defined in RFC 3161.
-1297      * <pre>
-1298      * TSTInfo ::= SEQUENCE  {
-1299      *    version          INTEGER  { v1(1) },
-1300      *    policy           TSAPolicyId,
-1301      *    messageImprint   MessageImprint,
-1302      *    serialNumber     INTEGER,
-1303      *    genTime          GeneralizedTime,
-1304      *    accuracy         Accuracy                 OPTIONAL,
-1305      *    ordering         BOOLEAN             DEFAULT FALSE,
-1306      *    nonce            INTEGER                  OPTIONAL,
-1307      *    tsa              [0] GeneralName          OPTIONAL,
-1308      *    extensions       [1] IMPLICIT Extensions  OPTIONAL }
-1309      * </pre>
-1310      *
-1311      * @example
-1312      * parser = new KJUR.asn1.tsp.TSPParser();
-1313      * parser.getTSTInfo("30...") →
-1314      * {
-1315      *   policy: '1.2.3.4.5',
-1316      *   messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
-1317      *   serial: {'int': 3},
-1318      *   genTime: {str: '20131231235959.123Z'},
-1319      *   accuracy: {millis: 500},
-1320      *   ordering: true,
-1321      *   nonce: {int: 3}
-1322      * }
-1323      */
-1324     this.getTSTInfo = function(h) {
-1325 	var pResult = {};
-1326 	var aIdx = _getChildIdx(h, 0);
-1327 
-1328 	var hPolicy = _getV(h, aIdx[1]);
-1329 	pResult.policy = hextooid(hPolicy);
-1330 
-1331 	var hMessageImprint = _getTLV(h, aIdx[2]);
-1332 	pResult.messageImprint = this.getMessageImprint(hMessageImprint);
-1333 
-1334 	var hSerial = _getV(h, aIdx[3]);
-1335 	pResult.serial = {hex: hSerial};
-1336 
-1337 	var hGenTime = _getV(h, aIdx[4]);
-1338 	pResult.genTime = {str: hextoutf8(hGenTime)};
-1339 
-1340 	var offset = 0;
-1341 
-1342 	if (aIdx.length > 5 && h.substr(aIdx[5], 2) == "30") {
-1343 	    var hAccuracy = _getTLV(h, aIdx[5]);
-1344 	    pResult.accuracy = this.getAccuracy(hAccuracy);
-1345 	    offset++;
-1346 	}
-1347 
-1348 	if (aIdx.length > 5 + offset && 
-1349 	    h.substr(aIdx[5 + offset], 2) == "01") {
-1350 	    var hOrdering = _getV(h, aIdx[5 + offset]);
-1351 	    if (hOrdering == "ff") pResult.ordering = true;
-1352 	    offset++;
-1353 	}
-1354 
-1355 	if (aIdx.length > 5 + offset &&
-1356 	    h.substr(aIdx[5 + offset], 2) == "02") {
-1357 	    var hNonce = _getV(h, aIdx[5 + offset]);
-1358 	    pResult.nonce = {hex: hNonce};
-1359 	    offset++;
-1360 	}
-1361 
-1362 	if (aIdx.length > 5 + offset &&
-1363 	    h.substr(aIdx[5 + offset], 2) == "a0") {
-1364 	    var hGeneralNames = _getTLV(h, aIdx[5 + offset]);
-1365 	    hGeneralNames = "30" + hGeneralNames.substr(2);
-1366 	    pGeneralNames = _x509obj.getGeneralNames(hGeneralNames);
-1367 	    var pName = pGeneralNames[0].dn;
-1368 	    pResult.tsa = pName;
-1369 	    offset++;
-1370 	}
-1371 
-1372 	if (aIdx.length > 5 + offset &&
-1373 	    h.substr(aIdx[5 + offset], 2) == "a1") {
-1374 	    var hExt = _getTLV(h, aIdx[5 + offset]);
-1375 	    hExt = "30" + hExt.substr(2);
-1376 	    var aExt = _x509obj.getExtParamArray(hExt);
-1377 	    pResult.ext = aExt;
-1378 	    offset++;
-1379 	}
-1380 
-1381 	return pResult;
-1382     };
-1383 
-1384     /**
-1385      * parse ASN.1 Accuracy<br/>
-1386      * @name getAccuracy
-1387      * @memberOf KJUR.asn1.tsp.TSPParser#
-1388      * @function
-1389      * @param {String} h hexadecimal string of ASN.1 Accuracy
-1390      * @return {Array} JSON object of Accuracy parameter
-1391      * @see KJUR.asn1.tsp.Accuracy
-1392      *
-1393      * @description
-1394      * This method parses ASN.1 Accuracy defined in RFC 3161.
-1395      * <pre>
-1396      * Accuracy ::= SEQUENCE {
-1397      *    seconds        INTEGER              OPTIONAL,
-1398      *    millis     [0] INTEGER  (1..999)    OPTIONAL,
-1399      *    micros     [1] INTEGER  (1..999)    OPTIONAL  }
-1400      * </pre>
-1401      *
-1402      * @example
-1403      * parser = new KJUR.asn1.tsp.TSPParser();
-1404      * parser.getAccuracy("30...") → {millis: 500}
-1405      */
-1406     this.getAccuracy = function(h) {
-1407 	var pResult = {};
-1408 
-1409 	var aIdx = _getChildIdx(h, 0);
-1410 
-1411 	for (var i = 0; i < aIdx.length; i++) {
-1412 	    var tag = h.substr(aIdx[i], 2);
-1413 	    var hV = _getV(h, aIdx[i]);
-1414 	    var iV = parseInt(hV, 16);
-1415 
-1416 	    if (tag == "02") {
-1417 		pResult.seconds = iV;
-1418 	    } else if (tag == "80") {
-1419 		pResult.millis = iV;
-1420 	    } else if (tag == "81") {
-1421 		pResult.micros = iV;
-1422 	    }
-1423 	}
-1424 
-1425 	return pResult;
-1426     };
-1427 
-1428     /**
-1429      * parse ASN.1 MessageImprint<br/>
-1430      * @name getMessageImprint
-1431      * @memberOf KJUR.asn1.tsp.TSPParser#
-1432      * @function
-1433      * @param {String} h hexadecimal string of ASN.1 MessageImprint
-1434      * @return {Array} JSON object of MessageImprint parameter
-1435      * @see KJUR.asn1.tsp.MessageImprint
-1436      *
-1437      * @description
-1438      * This method parses ASN.1 MessageImprint defined in RFC 3161.
-1439      *
-1440      * @example
-1441      * parser = new KJUR.asn1.tsp.TSPParser();
-1442      * parser.getMessageImprint("30...") → 
-1443      * { alg: "sha256", hash: "12ab..." }
-1444      */
-1445     this.getMessageImprint = function(h) {
-1446 	if (h.substr(0, 2) != "30")
-1447             throw new Error("head of messageImprint hex shall be x30");
-1448 
-1449 	var json = {};
-1450 	var idxList = _getChildIdx(h, 0);
-1451 	var hashAlgOidIdx = _getIdxbyList(h, 0, [0, 0]);
-1452 	var hashAlgHex = _getV(h, hashAlgOidIdx);
-1453 	var hashAlgOid = _ASN1HEX.hextooidstr(hashAlgHex);
-1454 	var hashAlgName = KJUR.asn1.x509.OID.oid2name(hashAlgOid);
-1455 	if (hashAlgName == '')
-1456             throw new Error("hashAlg name undefined: " + hashAlgOid);
-1457 	var hashAlg = hashAlgName;
-1458 	var hashValueIdx = _getIdxbyList(h, 0, [1]);
-1459 	
-1460 	json.alg = hashAlg;
-1461 	json.hash = _getV(h, hashValueIdx); 
-1462 
-1463 	return json;
-1464     };
-1465 
-1466     /**
-1467      * parse ASN.1 PKIStatusInfo<br/>
-1468      * @name getPKIStatusInfo
-1469      * @memberOf KJUR.asn1.tsp.TSPParser#
-1470      * @function
-1471      * @param {String} h hexadecimal string of ASN.1 PKIStatusInfo
-1472      * @return {Array} JSON object of PKIStatusInfo parameter
-1473      * @see KJUR.asn1.tsp.PKIStatusInfo
-1474      *
-1475      * @description
-1476      * This method parses ASN.1 PKIStatusInfo defined in RFC 3161.
-1477      *
-1478      * @example
-1479      * parser = new KJUR.asn1.tsp.TSPParser();
-1480      * parser.getPKIStatusInfo("30...") → 
-1481      * { status: "rejection",
-1482      *   statusstr: ["unsupported algorithm"],
-1483      *   failinfo: "badAlg" }
-1484      */
-1485     this.getPKIStatusInfo = function(h) {
-1486 	var pResult = {};
-1487 	var aIdx = _getChildIdx(h, 0);
-1488 	var offset = 0;
-1489 
-1490 	try {
-1491 	    var hStatus = _getV(h, aIdx[0]);
-1492 	    var iStatus = parseInt(hStatus, 16);
-1493 	    pResult.status = _aSTATUSSTR[iStatus];
-1494 	} catch(ex) {};
-1495 
-1496 	if (aIdx.length > 1 && h.substr(aIdx[1], 2) == "30") {
-1497 	    var hPKIFreeText = _getTLV(h, aIdx[1]);
-1498 	    pResult.statusstr = 
-1499 		this.getPKIFreeText(hPKIFreeText);
-1500 	    offset++;
-1501 	}
-1502 
-1503 	if (aIdx.length > offset &&
-1504 	    h.substr(aIdx[1 + offset], 2) == "03") {
-1505 	    var hPKIFailureInfo = _getTLV(h, aIdx[1 + offset]);
-1506 	    pResult.failinfo = 
-1507 		this.getPKIFailureInfo(hPKIFailureInfo);
-1508 	}
-1509 
-1510 	return pResult;
-1511     };
-1512 
-1513     /**
-1514      * parse ASN.1 PKIFreeText<br/>
-1515      * @name getPKIFreeText
-1516      * @memberOf KJUR.asn1.tsp.TSPParser#
-1517      * @function
-1518      * @param {String} h hexadecimal string of ASN.1 PKIFreeText
-1519      * @return {Array} array of string
-1520      * @since jsrsasign 10.1.3 asn1tsp 2.0.3
-1521      * @see KJUR.asn1.tsp.PKIFreeText
-1522      *
-1523      * @description
-1524      * This method parses ASN.1 PKIFreeText defined in RFC 3161.
-1525      *
-1526      * @example
-1527      * parser = new KJUR.asn1.tsp.TSPParser();
-1528      * parser.getPKIFreeText("300a0c036161610c03616161") → 
-1529      * ["aaa", "aaa"]
-1530      */
-1531     this.getPKIFreeText = function(h) {
-1532 	var aResult = [];
-1533 	var aIdx = _getChildIdx(h, 0);
-1534 	for (var i = 0; i < aIdx.length; i++) {
-1535 	    aResult.push(_ASN1HEX.getString(h, aIdx[i]));
-1536 	}
-1537 	return aResult;
-1538     };
-1539 
-1540     /**
-1541      * parse ASN.1 PKIFailureInfo<br/>
-1542      * @name getPKIFailureInfo
-1543      * @memberOf KJUR.asn1.tsp.TSPParser#
-1544      * @function
-1545      * @param {String} h hexadecimal string of ASN.1 PKIFailureInfo
-1546      * @return {Object} failureInfo string or number
-1547      * @since jsrsasign 10.1.3 asn1tsp 2.0.3
-1548      * @see KJUR.asn1.tsp.PKIFailureInfo
-1549      *
-1550      * @description
-1551      * This method parses ASN.1 PKIFailureInfo defined in RFC 3161.
-1552      *
-1553      * @example
-1554      * parser = new KJUR.asn1.tsp.TSPParser();
-1555      * parser.getPKIFailureInfo("03020700") → "badAlg"
-1556      * parser.getPKIFailureInfo("03020780") → 1
-1557      * parser.getPKIFailureInfo("030203c8") → "systemFailure"
-1558      */
-1559     this.getPKIFailureInfo = function(h) {
-1560 	var n = _ASN1HEX.getInt(h, 0);
-1561 	if (_pFAILUREINFO[n] != undefined) {
-1562 	    return _pFAILUREINFO[n];
-1563 	} else {
-1564 	    return n;
-1565 	}
-1566     };
-1567 
-1568     /**
-1569      * parse hexadecimal string of TimeStampReq<br/>
-1570      * @name getTimeStampReq
-1571      * @memberOf KJUR.asn1.tsp.TSPParser#
-1572      * @function
-1573      * @param {String} h hexadecimal string of TimeStampReq
-1574      * @return {Array} JSON object of parsed parameters
-1575      * @since jsrsasign 10.5.18 asn1tsp 2.0.6
-1576      * @see KJUR.asn1.tsp.TimeStampReq
-1577      * @see KJUR.asn1.tsp.TSPUtil.parseTimeStampReq
-1578      *
-1579      * @description
-1580      * This method parses a hexadecimal string of TimeStampReq
-1581      * and returns parsed their fields:
+1103     return json;
+1104 */
+1105 };
+1106 
+1107 /**
+1108  * class for parsing RFC 3161 TimeStamp protocol data<br/>
+1109  * @name KJUR.asn1.tsp.TSPParser
+1110  * @class RFC 3161 TimeStamp protocol parser class
+1111  * @since jsrsasign 10.1.0 asn1tsp 2.0.1
+1112  *
+1113  * @description
+1114  * This is an ASN.1 parser for 
+1115  * <a href="https://tools.ietf.org/html/rfc3161">RFC 3161</a>.
+1116  */
+1117 KJUR.asn1.tsp.TSPParser = function() {
+1118     var _Error = Error,
+1119 	_X509 = X509,
+1120 	_x509obj = new _X509(),
+1121 	_ASN1HEX = ASN1HEX,
+1122 	_getV = _ASN1HEX.getV,
+1123 	_getTLV = _ASN1HEX.getTLV,
+1124 	_getIdxbyList = _ASN1HEX.getIdxbyList,
+1125 	_getTLVbyListEx = _ASN1HEX.getTLVbyListEx,
+1126 	_getChildIdx = _ASN1HEX.getChildIdx;
+1127     var _aSTATUSSTR = [
+1128 	"granted", "grantedWithMods", "rejection", "waiting",
+1129 	"revocationWarning", "revocationNotification" ];
+1130     var _pFAILUREINFO = {
+1131 	0: "badAlg", 2: "badRequest", 5: "badDataFormat",
+1132 	14: "timeNotAvailable", 15: "unacceptedPolicy",
+1133 	16: "unacceptedExtension", 17: "addInfoNotAvailable",
+1134 	25: "systemFailure"
+1135     };
+1136     
+1137     /**
+1138      * parse ASN.1 TimeStampResp<br/>
+1139      * @name getResponse
+1140      * @memberOf KJUR.asn1.tsp.TSPParser#
+1141      * @function
+1142      * @param {String} h hexadecimal string of ASN.1 TimeStampResp
+1143      * @return {Array} JSON object of TimeStampResp parameter
+1144      * @see KJUR.asn1.tsp.TimeStampResp
+1145      * @see KJUR.asn1.tsp.TimeStampToken
+1146      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
+1147      *
+1148      * @description
+1149      * This method parses ASN.1 TimeStampRsp defined in RFC 3161.
+1150      * <pre>
+1151      * TimeStampResp ::= SEQUENCE {
+1152      *   status          PKIStatusInfo,
+1153      *   timeStampToken  TimeStampToken  OPTIONAL }
+1154      * </pre>
+1155      * When "h" is a TSP error response,
+1156      * returned parameter contains "statusinfo" only.
+1157      *
+1158      * @example
+1159      * parser = new KJUR.asn1.tsp.TSPParser();
+1160      * parser.getResponse("30...") →
+1161      * { 
+1162      *   statusinfo: 'granted',
+1163      *   ... // almost the same as CMS SignedData parameters
+1164      *   econtent: {
+1165      *     type: "tstinfo",
+1166      *     content: { // TSTInfo parameter
+1167      *       policy: '1.2.3.4.5',
+1168      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
+1169      *       serial: {'int': 3},
+1170      *       genTime: {str: '20131231235959.123Z'},
+1171      *       accuracy: {millis: 500},
+1172      *       ordering: true,
+1173      *       nonce: {int: 3}
+1174      *     }
+1175      *   },
+1176      *   ...
+1177      * }
+1178      */
+1179     this.getResponse = function(h) {
+1180 	var aIdx = _getChildIdx(h, 0);
+1181 	
+1182 	if (aIdx.length == 1) {
+1183 	    return this.getPKIStatusInfo(_getTLV(h, aIdx[0]));
+1184 	} else if (aIdx.length > 1) {
+1185 	    var pPKIStatusInfo = this.getPKIStatusInfo(_getTLV(h, aIdx[0]));
+1186 	    var hTST = _getTLV(h, aIdx[1]);
+1187 	    var pResult = this.getToken(hTST);
+1188 	    pResult.statusinfo = pPKIStatusInfo;
+1189 	    return pResult;
+1190 	}
+1191     };
+1192 
+1193     /**
+1194      * parse ASN.1 TimeStampToken<br/>
+1195      * @name getToken
+1196      * @memberOf KJUR.asn1.tsp.TSPParser#
+1197      * @function
+1198      * @param {String} h hexadecimal string of ASN.1 TimeStampToken
+1199      * @return {Array} JSON object of TimeStampToken parameter
+1200      * @see KJUR.asn1.tsp.TimeStampToken
+1201      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
+1202      * @see KJUR.asn1.tsp.TSPParser#setTSTInfo
+1203      *
+1204      * @description
+1205      * This method parses ASN.1 TimeStampRsp defined in RFC 3161.
+1206      * This method will parse "h" as CMS SigneData by
+1207      * {@link KJUR.asn1.cms.CMSParser#getCMSSignedData}, then
+1208      * parse and modify "econtent.content" parameter by
+1209      * {@link KJUR.asn1.tsp.TSPParser#setTSTInfo} method.
+1210      *
+1211      * @example
+1212      * parser = new KJUR.asn1.tsp.TSPParser();
+1213      * parser.getToken("30...") →
+1214      * { 
+1215      *   ... // almost the same as CMS SignedData parameters
+1216      *   econtent: {
+1217      *     type: "tstinfo",
+1218      *     content: { // TSTInfo parameter
+1219      *       policy: '1.2.3.4.5',
+1220      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
+1221      *       serial: {'int': 3},
+1222      *       genTime: {str: '20131231235959.123Z'},
+1223      *       accuracy: {millis: 500},
+1224      *       ordering: true,
+1225      *       nonce: {int: 3}
+1226      *     }
+1227      *   },
+1228      *   ...
+1229      * }
+1230      */
+1231     this.getToken = function(h) {
+1232 	var _CMSParser = new KJUR.asn1.cms.CMSParser;
+1233 	var p = _CMSParser.getCMSSignedData(h);
+1234 	this.setTSTInfo(p);
+1235 	return p;
+1236     };
+1237 
+1238     /**
+1239      * set ASN.1 TSTInfo parameter to CMS SignedData parameter<br/>
+1240      * @name setTSTInfo
+1241      * @memberOf KJUR.asn1.tsp.TSPParser#
+1242      * @function
+1243      * @param {Array} pCMSSignedData JSON object of CMS SignedData parameter
+1244      * @see KJUR.asn1.tsp.TimeStampToken
+1245      * @see KJUR.asn1.cms.CMSParser#getCMSSignedData
+1246      *
+1247      * @description
+1248      * This method modifies "econtent.content" of CMS SignedData parameter
+1249      * to parsed TSTInfo.
+1250      * <pre>
+1251      *
+1252      * @example
+1253      * parser = new KJUR.asn1.tsp.TSPParser();
+1254      * pCMSSignedData = { 
+1255      *   ... // almost the same as CMS SignedData parameters
+1256      *   econtent: {
+1257      *     type: "tstinfo",
+1258      *     content: { hex: "30..." }
+1259      *   },
+1260      *   ...
+1261      * };
+1262      * parser.setTSTInfo(pCMSSignedData);
+1263      * pCMSSignedData → { 
+1264      *   ... // almost the same as CMS SignedData parameters
+1265      *   econtent: {
+1266      *     type: "tstinfo",
+1267      *     content: { // TSTInfo parameter
+1268      *       policy: '1.2.3.4.5',
+1269      *       messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
+1270      *       serial: {int: 3},
+1271      *       genTime: {str: '20131231235959.123Z'},
+1272      *       accuracy: {millis: 500},
+1273      *       ordering: true,
+1274      *       nonce: {int: 3}
+1275      *     }
+1276      *   },
+1277      *   ...
+1278      * };
+1279      */
+1280     this.setTSTInfo = function(pCMSSignedData) {
+1281 	var pEContent = pCMSSignedData.econtent;
+1282 	if (pEContent.type == "tstinfo") {
+1283 	    var hContent = pEContent.content.hex;
+1284 	    var pTSTInfo = this.getTSTInfo(hContent);
+1285 	    //pTSTInfo.hex_ = hContent;
+1286 	    pEContent.content = pTSTInfo;
+1287 	}
+1288     };
+1289 
+1290     /**
+1291      * parse ASN.1 TSTInfo<br/>
+1292      * @name getTSTInfo
+1293      * @memberOf KJUR.asn1.tsp.TSPParser#
+1294      * @function
+1295      * @param {String} h hexadecimal string of ASN.1 TSTInfo
+1296      * @return {Array} JSON object of TSTInfo parameter
+1297      * @see KJUR.asn1.tsp.TSTInfo
+1298      *
+1299      * @description
+1300      * This method parses ASN.1 TSTInfo defined in RFC 3161.
+1301      * <pre>
+1302      * TSTInfo ::= SEQUENCE  {
+1303      *    version          INTEGER  { v1(1) },
+1304      *    policy           TSAPolicyId,
+1305      *    messageImprint   MessageImprint,
+1306      *    serialNumber     INTEGER,
+1307      *    genTime          GeneralizedTime,
+1308      *    accuracy         Accuracy                 OPTIONAL,
+1309      *    ordering         BOOLEAN             DEFAULT FALSE,
+1310      *    nonce            INTEGER                  OPTIONAL,
+1311      *    tsa              [0] GeneralName          OPTIONAL,
+1312      *    extensions       [1] IMPLICIT Extensions  OPTIONAL }
+1313      * </pre>
+1314      *
+1315      * @example
+1316      * parser = new KJUR.asn1.tsp.TSPParser();
+1317      * parser.getTSTInfo("30...") →
+1318      * {
+1319      *   policy: '1.2.3.4.5',
+1320      *   messageImprint: {alg: 'sha256', hash: 'a1a2a3a4...'},
+1321      *   serial: {'int': 3},
+1322      *   genTime: {str: '20131231235959.123Z'},
+1323      *   accuracy: {millis: 500},
+1324      *   ordering: true,
+1325      *   nonce: {int: 3}
+1326      * }
+1327      */
+1328     this.getTSTInfo = function(h) {
+1329 	var pResult = {};
+1330 	var aIdx = _getChildIdx(h, 0);
+1331 
+1332 	var hPolicy = _getV(h, aIdx[1]);
+1333 	pResult.policy = hextooid(hPolicy);
+1334 
+1335 	var hMessageImprint = _getTLV(h, aIdx[2]);
+1336 	pResult.messageImprint = this.getMessageImprint(hMessageImprint);
+1337 
+1338 	var hSerial = _getV(h, aIdx[3]);
+1339 	pResult.serial = {hex: hSerial};
+1340 
+1341 	var hGenTime = _getV(h, aIdx[4]);
+1342 	pResult.genTime = {str: hextoutf8(hGenTime)};
+1343 
+1344 	var offset = 0;
+1345 
+1346 	if (aIdx.length > 5 && h.substr(aIdx[5], 2) == "30") {
+1347 	    var hAccuracy = _getTLV(h, aIdx[5]);
+1348 	    pResult.accuracy = this.getAccuracy(hAccuracy);
+1349 	    offset++;
+1350 	}
+1351 
+1352 	if (aIdx.length > 5 + offset && 
+1353 	    h.substr(aIdx[5 + offset], 2) == "01") {
+1354 	    var hOrdering = _getV(h, aIdx[5 + offset]);
+1355 	    if (hOrdering == "ff") pResult.ordering = true;
+1356 	    offset++;
+1357 	}
+1358 
+1359 	if (aIdx.length > 5 + offset &&
+1360 	    h.substr(aIdx[5 + offset], 2) == "02") {
+1361 	    var hNonce = _getV(h, aIdx[5 + offset]);
+1362 	    pResult.nonce = {hex: hNonce};
+1363 	    offset++;
+1364 	}
+1365 
+1366 	if (aIdx.length > 5 + offset &&
+1367 	    h.substr(aIdx[5 + offset], 2) == "a0") {
+1368 	    var hGeneralNames = _getTLV(h, aIdx[5 + offset]);
+1369 	    hGeneralNames = "30" + hGeneralNames.substr(2);
+1370 	    pGeneralNames = _x509obj.getGeneralNames(hGeneralNames);
+1371 	    var pName = pGeneralNames[0].dn;
+1372 	    pResult.tsa = pName;
+1373 	    offset++;
+1374 	}
+1375 
+1376 	if (aIdx.length > 5 + offset &&
+1377 	    h.substr(aIdx[5 + offset], 2) == "a1") {
+1378 	    var hExt = _getTLV(h, aIdx[5 + offset]);
+1379 	    hExt = "30" + hExt.substr(2);
+1380 	    var aExt = _x509obj.getExtParamArray(hExt);
+1381 	    pResult.ext = aExt;
+1382 	    offset++;
+1383 	}
+1384 
+1385 	return pResult;
+1386     };
+1387 
+1388     /**
+1389      * parse ASN.1 Accuracy<br/>
+1390      * @name getAccuracy
+1391      * @memberOf KJUR.asn1.tsp.TSPParser#
+1392      * @function
+1393      * @param {String} h hexadecimal string of ASN.1 Accuracy
+1394      * @return {Array} JSON object of Accuracy parameter
+1395      * @see KJUR.asn1.tsp.Accuracy
+1396      *
+1397      * @description
+1398      * This method parses ASN.1 Accuracy defined in RFC 3161.
+1399      * <pre>
+1400      * Accuracy ::= SEQUENCE {
+1401      *    seconds        INTEGER              OPTIONAL,
+1402      *    millis     [0] INTEGER  (1..999)    OPTIONAL,
+1403      *    micros     [1] INTEGER  (1..999)    OPTIONAL  }
+1404      * </pre>
+1405      *
+1406      * @example
+1407      * parser = new KJUR.asn1.tsp.TSPParser();
+1408      * parser.getAccuracy("30...") → {millis: 500}
+1409      */
+1410     this.getAccuracy = function(h) {
+1411 	var pResult = {};
+1412 
+1413 	var aIdx = _getChildIdx(h, 0);
+1414 
+1415 	for (var i = 0; i < aIdx.length; i++) {
+1416 	    var tag = h.substr(aIdx[i], 2);
+1417 	    var hV = _getV(h, aIdx[i]);
+1418 	    var iV = parseInt(hV, 16);
+1419 
+1420 	    if (tag == "02") {
+1421 		pResult.seconds = iV;
+1422 	    } else if (tag == "80") {
+1423 		pResult.millis = iV;
+1424 	    } else if (tag == "81") {
+1425 		pResult.micros = iV;
+1426 	    }
+1427 	}
+1428 
+1429 	return pResult;
+1430     };
+1431 
+1432     /**
+1433      * parse ASN.1 MessageImprint<br/>
+1434      * @name getMessageImprint
+1435      * @memberOf KJUR.asn1.tsp.TSPParser#
+1436      * @function
+1437      * @param {String} h hexadecimal string of ASN.1 MessageImprint
+1438      * @return {Array} JSON object of MessageImprint parameter
+1439      * @see KJUR.asn1.tsp.MessageImprint
+1440      *
+1441      * @description
+1442      * This method parses ASN.1 MessageImprint defined in RFC 3161.
+1443      *
+1444      * @example
+1445      * parser = new KJUR.asn1.tsp.TSPParser();
+1446      * parser.getMessageImprint("30...") → 
+1447      * { alg: "sha256", hash: "12ab..." }
+1448      */
+1449     this.getMessageImprint = function(h) {
+1450 	if (h.substr(0, 2) != "30")
+1451             throw new Error("head of messageImprint hex shall be x30");
+1452 
+1453 	var json = {};
+1454 	var idxList = _getChildIdx(h, 0);
+1455 	var hashAlgOidIdx = _getIdxbyList(h, 0, [0, 0]);
+1456 	var hashAlgHex = _getV(h, hashAlgOidIdx);
+1457 	var hashAlgOid = _ASN1HEX.hextooidstr(hashAlgHex);
+1458 	var hashAlgName = KJUR.asn1.x509.OID.oid2name(hashAlgOid);
+1459 	if (hashAlgName == '')
+1460             throw new Error("hashAlg name undefined: " + hashAlgOid);
+1461 	var hashAlg = hashAlgName;
+1462 	var hashValueIdx = _getIdxbyList(h, 0, [1]);
+1463 	
+1464 	json.alg = hashAlg;
+1465 	json.hash = _getV(h, hashValueIdx); 
+1466 
+1467 	return json;
+1468     };
+1469 
+1470     /**
+1471      * parse ASN.1 PKIStatusInfo<br/>
+1472      * @name getPKIStatusInfo
+1473      * @memberOf KJUR.asn1.tsp.TSPParser#
+1474      * @function
+1475      * @param {String} h hexadecimal string of ASN.1 PKIStatusInfo
+1476      * @return {Array} JSON object of PKIStatusInfo parameter
+1477      * @see KJUR.asn1.tsp.PKIStatusInfo
+1478      *
+1479      * @description
+1480      * This method parses ASN.1 PKIStatusInfo defined in RFC 3161.
+1481      *
+1482      * @example
+1483      * parser = new KJUR.asn1.tsp.TSPParser();
+1484      * parser.getPKIStatusInfo("30...") → 
+1485      * { status: "rejection",
+1486      *   statusstr: ["unsupported algorithm"],
+1487      *   failinfo: "badAlg" }
+1488      */
+1489     this.getPKIStatusInfo = function(h) {
+1490 	var pResult = {};
+1491 	var aIdx = _getChildIdx(h, 0);
+1492 	var offset = 0;
+1493 
+1494 	try {
+1495 	    var hStatus = _getV(h, aIdx[0]);
+1496 	    var iStatus = parseInt(hStatus, 16);
+1497 	    pResult.status = _aSTATUSSTR[iStatus];
+1498 	} catch(ex) {};
+1499 
+1500 	if (aIdx.length > 1 && h.substr(aIdx[1], 2) == "30") {
+1501 	    var hPKIFreeText = _getTLV(h, aIdx[1]);
+1502 	    pResult.statusstr = 
+1503 		this.getPKIFreeText(hPKIFreeText);
+1504 	    offset++;
+1505 	}
+1506 
+1507 	if (aIdx.length > offset &&
+1508 	    h.substr(aIdx[1 + offset], 2) == "03") {
+1509 	    var hPKIFailureInfo = _getTLV(h, aIdx[1 + offset]);
+1510 	    pResult.failinfo = 
+1511 		this.getPKIFailureInfo(hPKIFailureInfo);
+1512 	}
+1513 
+1514 	return pResult;
+1515     };
+1516 
+1517     /**
+1518      * parse ASN.1 PKIFreeText<br/>
+1519      * @name getPKIFreeText
+1520      * @memberOf KJUR.asn1.tsp.TSPParser#
+1521      * @function
+1522      * @param {String} h hexadecimal string of ASN.1 PKIFreeText
+1523      * @return {Array} array of string
+1524      * @since jsrsasign 10.1.3 asn1tsp 2.0.3
+1525      * @see KJUR.asn1.tsp.PKIFreeText
+1526      *
+1527      * @description
+1528      * This method parses ASN.1 PKIFreeText defined in RFC 3161.
+1529      *
+1530      * @example
+1531      * parser = new KJUR.asn1.tsp.TSPParser();
+1532      * parser.getPKIFreeText("300a0c036161610c03616161") → 
+1533      * ["aaa", "aaa"]
+1534      */
+1535     this.getPKIFreeText = function(h) {
+1536 	var aResult = [];
+1537 	var aIdx = _getChildIdx(h, 0);
+1538 	for (var i = 0; i < aIdx.length; i++) {
+1539 	    aResult.push(_ASN1HEX.getString(h, aIdx[i]));
+1540 	}
+1541 	return aResult;
+1542     };
+1543 
+1544     /**
+1545      * parse ASN.1 PKIFailureInfo<br/>
+1546      * @name getPKIFailureInfo
+1547      * @memberOf KJUR.asn1.tsp.TSPParser#
+1548      * @function
+1549      * @param {String} h hexadecimal string of ASN.1 PKIFailureInfo
+1550      * @return {Object} failureInfo string or number
+1551      * @since jsrsasign 10.1.3 asn1tsp 2.0.3
+1552      * @see KJUR.asn1.tsp.PKIFailureInfo
+1553      *
+1554      * @description
+1555      * This method parses ASN.1 PKIFailureInfo defined in RFC 3161.
+1556      *
+1557      * @example
+1558      * parser = new KJUR.asn1.tsp.TSPParser();
+1559      * parser.getPKIFailureInfo("03020700") → "badAlg"
+1560      * parser.getPKIFailureInfo("03020780") → 1
+1561      * parser.getPKIFailureInfo("030203c8") → "systemFailure"
+1562      */
+1563     this.getPKIFailureInfo = function(h) {
+1564 	var n = _ASN1HEX.getInt(h, 0);
+1565 	if (_pFAILUREINFO[n] != undefined) {
+1566 	    return _pFAILUREINFO[n];
+1567 	} else {
+1568 	    return n;
+1569 	}
+1570     };
+1571 
+1572     /**
+1573      * parse hexadecimal string of TimeStampReq<br/>
+1574      * @name getTimeStampReq
+1575      * @memberOf KJUR.asn1.tsp.TSPParser#
+1576      * @function
+1577      * @param {String} h hexadecimal string of TimeStampReq
+1578      * @return {Array} JSON object of parsed parameters
+1579      * @since jsrsasign 10.5.18 asn1tsp 2.0.6
+1580      * @see KJUR.asn1.tsp.TimeStampReq
+1581      * @see KJUR.asn1.tsp.TSPUtil.parseTimeStampReq
 1582      *
-1583      * @example
-1584      * var parser = new KJUR.asn1.tsp.TSPParser();
-1585      * parser.getTimeStampReq("302602...") →
-1586      * { messageImprint: {
-1587      *       alg: 'sha256',          // MessageImprint hashAlg
-1588      *       hash: 'a1a2a3a4...'},   // MessageImprint hashValue
-1589      *   policy: '1.2.3.4.5',         // tsaPolicy (OPTION)
-1590      *   nonce: '9abcf318...',        // nonce (OPTION)
-1591      *   certreq: true }              // certReq (OPTION)
-1592      */
-1593     this.getTimeStampReq = function(h) {
-1594 	var json = {};
-1595 	json.certreq = false;
-1596 
-1597 	var idxList = _getChildIdx(h, 0);
-1598 
-1599 	if (idxList.length < 2)
-1600             throw new Error("TimeStampReq must have at least 2 items");
-1601 
-1602 	var miHex = _getTLV(h, idxList[1]);
-1603 	json.messageImprint = KJUR.asn1.tsp.TSPUtil.parseMessageImprint(miHex); 
-1604 
-1605 	for (var i = 2; i < idxList.length; i++) {
-1606             var idx = idxList[i];
-1607             var tag = h.substr(idx, 2);
-1608             if (tag == "06") { // case OID
-1609 		var policyHex = _getV(h, idx);
-1610 		json.policy = _ASN1HEX.hextooidstr(policyHex);
-1611             }
-1612             if (tag == "02") { // case INTEGER
-1613 		json.nonce = _getV(h, idx);
-1614             }
-1615             if (tag == "01") { // case BOOLEAN
-1616 		json.certreq = true;
-1617             }
-1618 	}
-1619 
-1620 	return json;
-1621     };
-1622 };
-1623 
\ No newline at end of file +1583 * @description +1584 * This method parses a hexadecimal string of TimeStampReq +1585 * and returns parsed their fields: +1586 * +1587 * @example +1588 * var parser = new KJUR.asn1.tsp.TSPParser(); +1589 * parser.getTimeStampReq("302602...") → +1590 * { messageImprint: { +1591 * alg: 'sha256', // MessageImprint hashAlg +1592 * hash: 'a1a2a3a4...'}, // MessageImprint hashValue +1593 * policy: '1.2.3.4.5', // tsaPolicy (OPTION) +1594 * nonce: '9abcf318...', // nonce (OPTION) +1595 * certreq: true } // certReq (OPTION) +1596 */
+1597 this.getTimeStampReq = function(h) { +1598 var json = {}; +1599 json.certreq = false; +1600 +1601 var idxList = _getChildIdx(h, 0); +1602 +1603 if (idxList.length < 2) +1604 throw new Error("TimeStampReq must have at least 2 items"); +1605 +1606 var miHex = _getTLV(h, idxList[1]); +1607 json.messageImprint = KJUR.asn1.tsp.TSPUtil.parseMessageImprint(miHex); +1608 +1609 for (var i = 2; i < idxList.length; i++) { +1610 var idx = idxList[i]; +1611 var tag = h.substr(idx, 2); +1612 if (tag == "06") { // case OID +1613 var policyHex = _getV(h, idx); +1614 json.policy = _ASN1HEX.hextooidstr(policyHex); +1615 } +1616 if (tag == "02") { // case INTEGER +1617 json.nonce = _getV(h, idx); +1618 } +1619 if (tag == "01") { // case BOOLEAN +1620 json.certreq = true; +1621 } +1622 } +1623 +1624 return json; +1625 }; +1626 }; +1627
\ No newline at end of file diff --git a/api/symbols/src/asn1x509-1.0.js.html b/api/symbols/src/asn1x509-1.0.js.html index a98dfaae..a18ad3d2 100644 --- a/api/symbols/src/asn1x509-1.0.js.html +++ b/api/symbols/src/asn1x509-1.0.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
  1 /* asn1x509-2.1.15.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* asn1x509-2.1.16.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * asn1x509.js - ASN.1 DER encoder classes for X.509 certificate
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name asn1x509-1.0.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.5.21 asn1x509 2.1.15 (2022-May-23)
+ 19  * @version jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24)
  20  * @since jsrsasign 2.1
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -645,4149 +645,4120 @@
 638     this.oid = "2.5.29.15";
 639     if (params !== undefined) this.params = params;
 640 };
-641 KJUR.asn1.x509.KeyUsage_bak = function(params) {
-642     KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this, params);
-643     var _KEYUSAGE_NAME = X509.KEYUSAGE_NAME;
-644 
-645     this.getExtnValueHex = function() {
-646         return this.asn1ExtnValue.tohex();
-647     };
-648 
-649     this.oid = "2.5.29.15";
-650     if (params !== undefined) {
-651         if (params.bin !== undefined) {
-652             this.asn1ExtnValue = new KJUR.asn1.DERBitString(params);
-653         }
-654 	if (params.names !== undefined &&
-655 	    params.names.length !== undefined) {
-656 	    var names = params.names;
-657 	    var s = "000000000";
-658 	    for (var i = 0; i < names.length; i++) {
-659 		for (var j = 0; j < _KEYUSAGE_NAME.length; j++) {
-660 		    if (names[i] === _KEYUSAGE_NAME[j]) {
-661 			s = s.substring(0, j) + '1' + 
-662 			    s.substring(j + 1, s.length);
-663 		    }
-664 		}
-665 	    }
-666             this.asn1ExtnValue = new KJUR.asn1.DERBitString({bin: s});
-667 	}
-668     }
-669 };
-670 extendClass(KJUR.asn1.x509.KeyUsage, KJUR.asn1.x509.Extension);
-671 
-672 /**
-673  * BasicConstraints ASN.1 structure class
-674  * @name KJUR.asn1.x509.BasicConstraints
-675  * @class BasicConstraints ASN.1 structure class
-676  * @param {Array} params JSON object for parameters (ex. {cA:true,critical:true})
-677  * @extends KJUR.asn1.x509.Extension
-678  * @see {@link X509#getExtBasicConstraints}
-679  * @description
-680  * This class represents 
-681  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.9">
-682  * BasicConstraints extension defined in RFC 5280 4.2.1.9</a>.
-683  * <pre>
-684  *  id-ce-basicConstraints OBJECT IDENTIFIER ::=  { id-ce 19 }
-685  *  BasicConstraints ::= SEQUENCE {
-686  *       cA                      BOOLEAN DEFAULT FALSE,
-687  *       pathLenConstraint       INTEGER (0..MAX) OPTIONAL }
-688  * </pre>
-689  * Its constructor can have following parameters:
-690  * <ul>
-691  * <li>{Boolean}cA - cA flag</li>
-692  * <li>{Integer}pathLen - pathLen field value</li>
-693  * <li>{Boolean}critical - critical flag</li>
-694  * </ul>
-695  * @example
-696  * new KJUR.asn1.x509.BasicConstraints({
-697  *   cA: true,
-698  *   pathLen: 3,
-699  *   critical: true
-700  * })
-701  */
-702 KJUR.asn1.x509.BasicConstraints = function(params) {
-703     KJUR.asn1.x509.BasicConstraints.superclass.constructor.call(this, params);
-704     var _KJUR_asn1 = KJUR.asn1,
-705 	_DERBoolean = _KJUR_asn1.DERBoolean,
-706 	_DERInteger = _KJUR_asn1.DERInteger,
-707 	_DERSequence = _KJUR_asn1.DERSequence;
-708 
-709     var cA = false;
-710     var pathLen = -1;
-711 
-712     this.getExtnValueHex = function() {
-713         var asn1Array = new Array();
-714         if (this.cA) asn1Array.push(new _DERBoolean());
-715         if (this.pathLen > -1)
-716             asn1Array.push(new _DERInteger({'int': this.pathLen}));
-717         var asn1Seq = new _DERSequence({'array': asn1Array});
-718         this.asn1ExtnValue = asn1Seq;
-719         return this.asn1ExtnValue.tohex();
-720     };
-721 
-722     this.oid = "2.5.29.19";
-723     this.cA = false;
-724     this.pathLen = -1;
-725     if (params !== undefined) {
-726         if (params.cA !== undefined) {
-727             this.cA = params.cA;
-728         }
-729         if (params.pathLen !== undefined) {
-730             this.pathLen = params.pathLen;
-731         }
-732     }
-733 };
-734 extendClass(KJUR.asn1.x509.BasicConstraints, KJUR.asn1.x509.Extension);
-735 
-736 /**
-737  * CRLDistributionPoints ASN.1 structure class
-738  * @name KJUR.asn1.x509.CRLDistributionPoints
-739  * @class CRLDistributionPoints ASN.1 structure class
-740  * @param {Array} params associative array of parameters (ex. {'uri': 'http://a.com/', 'critical': true})
-741  * @extends KJUR.asn1.x509.Extension
-742  * @see {@link X509#getExtCRLDistributionPoints}
-743  * @see {@link KJUR.asn1.x509.DistributionPoint}
-744  * @see {@link KJUR.asn1.x509.GeneralNames}
-745  * @description
-746  * This class represents 
-747  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
-748  * CRLDistributionPoints extension defined in RFC 5280 4.2.1.13</a>.
-749  * <pre>
-750  * id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::=  { id-ce 31 }
-751  * CRLDistributionPoints ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint
-752  * DistributionPoint ::= SEQUENCE {
-753  *      distributionPoint       [0]     DistributionPointName OPTIONAL,
-754  *      reasons                 [1]     ReasonFlags OPTIONAL,
-755  *      cRLIssuer               [2]     GeneralNames OPTIONAL }
-756  * DistributionPointName ::= CHOICE {
-757  *      fullName                [0]     GeneralNames,
-758  *      nameRelativeToCRLIssuer [1]     RelativeDistinguishedName }
-759  * </pre>
-760  * Constructor can have following parameter:
-761  * <ul>
-762  * <li>{Array}array - array of {@link KJUR.asn1.x509.DistributionPoint} parameter</li>
-763  * <li>{Boolean}critical - critical flag</li>
-764  * </ul>
-765  * @example
-766  * new KJUR.asn1.x509.CRLDistributionPoints({
-767  *   array: [{fulluri: "http://aaa.com/"}, {fulluri: "ldap://aaa.com/"}],
-768  *   critical: true
-769  * })
-770  */
-771 KJUR.asn1.x509.CRLDistributionPoints = function(params) {
-772     KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this, params);
-773     var _KJUR = KJUR,
-774 	_KJUR_asn1 = _KJUR.asn1,
-775 	_KJUR_asn1_x509 = _KJUR_asn1.x509;
-776 
-777     this.getExtnValueHex = function() {
-778         return this.asn1ExtnValue.tohex();
-779     };
+641 extendClass(KJUR.asn1.x509.KeyUsage, KJUR.asn1.x509.Extension);
+642 
+643 /**
+644  * BasicConstraints ASN.1 structure class
+645  * @name KJUR.asn1.x509.BasicConstraints
+646  * @class BasicConstraints ASN.1 structure class
+647  * @param {Array} params JSON object for parameters (ex. {cA:true,critical:true})
+648  * @extends KJUR.asn1.x509.Extension
+649  * @see {@link X509#getExtBasicConstraints}
+650  * @description
+651  * This class represents 
+652  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.9">
+653  * BasicConstraints extension defined in RFC 5280 4.2.1.9</a>.
+654  * <pre>
+655  *  id-ce-basicConstraints OBJECT IDENTIFIER ::=  { id-ce 19 }
+656  *  BasicConstraints ::= SEQUENCE {
+657  *       cA                      BOOLEAN DEFAULT FALSE,
+658  *       pathLenConstraint       INTEGER (0..MAX) OPTIONAL }
+659  * </pre>
+660  * Its constructor can have following parameters:
+661  * <ul>
+662  * <li>{Boolean}cA - cA flag</li>
+663  * <li>{Integer}pathLen - pathLen field value</li>
+664  * <li>{Boolean}critical - critical flag</li>
+665  * </ul>
+666  * @example
+667  * new KJUR.asn1.x509.BasicConstraints({
+668  *   cA: true,
+669  *   pathLen: 3,
+670  *   critical: true
+671  * })
+672  */
+673 KJUR.asn1.x509.BasicConstraints = function(params) {
+674     KJUR.asn1.x509.BasicConstraints.superclass.constructor.call(this, params);
+675     var _KJUR_asn1 = KJUR.asn1,
+676 	_DERBoolean = _KJUR_asn1.DERBoolean,
+677 	_DERInteger = _KJUR_asn1.DERInteger,
+678 	_DERSequence = _KJUR_asn1.DERSequence;
+679 
+680     var cA = false;
+681     var pathLen = -1;
+682 
+683     this.getExtnValueHex = function() {
+684         var asn1Array = new Array();
+685         if (this.cA) asn1Array.push(new _DERBoolean());
+686         if (this.pathLen > -1)
+687             asn1Array.push(new _DERInteger({'int': this.pathLen}));
+688         var asn1Seq = new _DERSequence({'array': asn1Array});
+689         this.asn1ExtnValue = asn1Seq;
+690         return this.asn1ExtnValue.tohex();
+691     };
+692 
+693     this.oid = "2.5.29.19";
+694     this.cA = false;
+695     this.pathLen = -1;
+696     if (params !== undefined) {
+697         if (params.cA !== undefined) {
+698             this.cA = params.cA;
+699         }
+700         if (params.pathLen !== undefined) {
+701             this.pathLen = params.pathLen;
+702         }
+703     }
+704 };
+705 extendClass(KJUR.asn1.x509.BasicConstraints, KJUR.asn1.x509.Extension);
+706 
+707 /**
+708  * CRLDistributionPoints ASN.1 structure class
+709  * @name KJUR.asn1.x509.CRLDistributionPoints
+710  * @class CRLDistributionPoints ASN.1 structure class
+711  * @param {Array} params associative array of parameters (ex. {'uri': 'http://a.com/', 'critical': true})
+712  * @extends KJUR.asn1.x509.Extension
+713  * @see {@link X509#getExtCRLDistributionPoints}
+714  * @see {@link KJUR.asn1.x509.DistributionPoint}
+715  * @see {@link KJUR.asn1.x509.GeneralNames}
+716  * @description
+717  * This class represents 
+718  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
+719  * CRLDistributionPoints extension defined in RFC 5280 4.2.1.13</a>.
+720  * <pre>
+721  * id-ce-cRLDistributionPoints OBJECT IDENTIFIER ::=  { id-ce 31 }
+722  * CRLDistributionPoints ::= SEQUENCE SIZE (1..MAX) OF DistributionPoint
+723  * DistributionPoint ::= SEQUENCE {
+724  *      distributionPoint       [0]     DistributionPointName OPTIONAL,
+725  *      reasons                 [1]     ReasonFlags OPTIONAL,
+726  *      cRLIssuer               [2]     GeneralNames OPTIONAL }
+727  * DistributionPointName ::= CHOICE {
+728  *      fullName                [0]     GeneralNames,
+729  *      nameRelativeToCRLIssuer [1]     RelativeDistinguishedName }
+730  * </pre>
+731  * Constructor can have following parameter:
+732  * <ul>
+733  * <li>{Array}array - array of {@link KJUR.asn1.x509.DistributionPoint} parameter</li>
+734  * <li>{Boolean}critical - critical flag</li>
+735  * </ul>
+736  * @example
+737  * new KJUR.asn1.x509.CRLDistributionPoints({
+738  *   array: [{fulluri: "http://aaa.com/"}, {fulluri: "ldap://aaa.com/"}],
+739  *   critical: true
+740  * })
+741  */
+742 KJUR.asn1.x509.CRLDistributionPoints = function(params) {
+743     KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this, params);
+744     var _KJUR = KJUR,
+745 	_KJUR_asn1 = _KJUR.asn1,
+746 	_KJUR_asn1_x509 = _KJUR_asn1.x509;
+747 
+748     this.getExtnValueHex = function() {
+749         return this.asn1ExtnValue.tohex();
+750     };
+751 
+752     this.setByDPArray = function(dpArray) {
+753 	var asn1Array = [];
+754 	for (var i = 0; i < dpArray.length; i++) {
+755 	    if (dpArray[i] instanceof KJUR.asn1.ASN1Object) {
+756 		asn1Array.push(dpArray[i]);
+757 	    } else {
+758 		var dp = new _KJUR_asn1_x509.DistributionPoint(dpArray[i]);
+759 		asn1Array.push(dp);
+760 	    }
+761 	}
+762         this.asn1ExtnValue = new _KJUR_asn1.DERSequence({'array': asn1Array});
+763     };
+764 
+765     this.setByOneURI = function(uri) {
+766         var dp1 = new _KJUR_asn1_x509.DistributionPoint({fulluri: uri});
+767         this.setByDPArray([dp1]);
+768     };
+769 
+770     this.oid = "2.5.29.31";
+771     if (params !== undefined) {
+772         if (params.array !== undefined) {
+773             this.setByDPArray(params.array);
+774         } else if (params.uri !== undefined) {
+775             this.setByOneURI(params.uri);
+776         }
+777     }
+778 };
+779 extendClass(KJUR.asn1.x509.CRLDistributionPoints, KJUR.asn1.x509.Extension);
 780 
-781     this.setByDPArray = function(dpArray) {
-782 	var asn1Array = [];
-783 	for (var i = 0; i < dpArray.length; i++) {
-784 	    if (dpArray[i] instanceof KJUR.asn1.ASN1Object) {
-785 		asn1Array.push(dpArray[i]);
-786 	    } else {
-787 		var dp = new _KJUR_asn1_x509.DistributionPoint(dpArray[i]);
-788 		asn1Array.push(dp);
-789 	    }
-790 	}
-791         this.asn1ExtnValue = new _KJUR_asn1.DERSequence({'array': asn1Array});
-792     };
-793 
-794     this.setByOneURI = function(uri) {
-795         var dp1 = new _KJUR_asn1_x509.DistributionPoint({fulluri: uri});
-796         this.setByDPArray([dp1]);
-797     };
-798 
-799     this.oid = "2.5.29.31";
-800     if (params !== undefined) {
-801         if (params.array !== undefined) {
-802             this.setByDPArray(params.array);
-803         } else if (params.uri !== undefined) {
-804             this.setByOneURI(params.uri);
-805         }
-806     }
-807 };
-808 extendClass(KJUR.asn1.x509.CRLDistributionPoints, KJUR.asn1.x509.Extension);
-809 
-810 /**
-811  * DistributionPoint ASN.1 structure class<br/>
-812  * @name KJUR.asn1.x509.DistributionPoint
-813  * @class DistributionPoint ASN.1 structure class
-814  * @param {Array} params JSON object of parameters (OPTIONAL)
-815  * @extends KJUR.asn1.ASN1Object
-816  * @see {@link KJUR.asn1.x509.CRLDistributionPoints}
-817  * @see {@link KJUR.asn1.x509.DistributionPointName}
-818  * @see {@link KJUR.asn1.x509.GeneralNames}
-819  * @see {@link X509#getDistributionPoint}
-820  * @description
-821  * This class represents 
-822  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
-823  * DistributionPoint defined in RFC 5280 4.2.1.13</a>.
-824  * <pre>
-825  * DistributionPoint ::= SEQUENCE {
-826  *      distributionPoint       [0]     DistributionPointName OPTIONAL,
-827  *      reasons                 [1]     ReasonFlags OPTIONAL,
-828  *      cRLIssuer               [2]     GeneralNames OPTIONAL }
-829  * </pre>
-830  * Constructor can have following parameter:
-831  * <ul>
-832  * <li>{String}fulluri - uri string for fullName uri. This has the same meaning for '{dpname: {full: [{uri: "..."]}}'.</li>
-833  * <li>{Array}dpname - JSON object for {@link KJUR.asn1.x509.DistributionPointName} parameters</li>
-834  * <li>{DistrubutionPoint}dpobj - {@link KJUR.asn1.x509.DistributionPointName} object (DEPRECATED)</li>
-835  * </ul>
-836  * <br/>
-837  * NOTE1: Parameter "fulluri" and "dpname" supported 
-838  * since jsrsasign 9.0.0 asn1x509 2.0.0.
-839  * <br/>
-840  * NOTE2: The "reasons" and "cRLIssuer" fields are currently
-841  * not supported.
-842  * @example
-843  * new KJUR.asn1.x509.DistributionPoint(
-844  *   {fulluri: "http://example.com/crl1.crl"})
-845  * new KJUR.asn1.x509.DistributionPoint(
-846  *   {dpname: {full: [{uri: "http://example.com/crl1.crl"}]}})
-847  * new KJUR.asn1.x509.DistributionPoint(
-848  *   {dpobj: new DistributionPoint(...)})
-849  */
-850 KJUR.asn1.x509.DistributionPoint = function(params) {
-851     KJUR.asn1.x509.DistributionPoint.superclass.constructor.call(this);
-852     var asn1DP = null,
-853 	_KJUR = KJUR,
-854 	_KJUR_asn1 = _KJUR.asn1,
-855 	_DistributionPointName = _KJUR_asn1.x509.DistributionPointName;
-856 
-857     this.tohex = function() {
-858         var seq = new _KJUR_asn1.DERSequence();
-859         if (this.asn1DP != null) {
-860             var o1 = new _KJUR_asn1.DERTaggedObject({'explicit': true,
-861                                                      'tag': 'a0',
-862                                                      'obj': this.asn1DP});
-863             seq.appendASN1Object(o1);
-864         }
-865         this.hTLV = seq.tohex();
-866         return this.hTLV;
-867     };
-868     this.getEncodedHex = function() { return this.tohex(); };
-869 
-870     if (params !== undefined) {
-871         if (params.dpobj !== undefined) {
-872             this.asn1DP = params.dpobj;
-873         } else if (params.dpname !== undefined) {
-874             this.asn1DP = new _DistributionPointName(params.dpname);
-875 	} else if (params.fulluri !== undefined) {
-876             this.asn1DP = new _DistributionPointName({full: [{uri: params.fulluri}]});
-877 	}
-878     }
-879 };
-880 extendClass(KJUR.asn1.x509.DistributionPoint, KJUR.asn1.ASN1Object);
-881 
-882 /**
-883  * DistributionPointName ASN.1 structure class<br/>
-884  * @name KJUR.asn1.x509.DistributionPointName
-885  * @class DistributionPointName ASN.1 structure class
-886  * @param {Array} params JSON object of parameters or GeneralNames object
-887  * @extends KJUR.asn1.ASN1Object
-888  * @see {@link KJUR.asn1.x509.CRLDistributionPoints}
-889  * @see {@link KJUR.asn1.x509.DistributionPoint}
-890  * @see {@link KJUR.asn1.x509.GeneralNames}
-891  * @see {@link X509#getDistributionPointName}
-892  * @description
-893  * This class represents 
-894  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
-895  * DistributionPointName defined in RFC 5280 4.2.1.13</a>.
-896  * <pre>
-897  * DistributionPointName ::= CHOICE {
-898  *      fullName                [0]     GeneralNames,
-899  *      nameRelativeToCRLIssuer [1]     RelativeDistinguishedName }
-900  * </pre>
-901  * Constructor can have following parameter:
-902  * <ul>
-903  * <li>{String}full - JSON object parameter of {@link KJUR.asn1.x509.GeneralNames} for 'fullName' field</li>
-904  * <li>{GeneralNames} - {@link KJUR.asn1.x509.GeneralNames} object for 'fullName'</li>
-905  * </ul>
-906  * NOTE1: 'full' parameter have been suppored since jsrsasign 9.0.0 asn1x509 2.0.0.
-907  * <br>
-908  * NOTE2: The 'nameRelativeToCRLIssuer' field is currently not supported.
-909  * @example
-910  * new KJUR.asn1.x509.DistributionPointName({full: <<GeneralNamesParameter>>})
-911  * new KJUR.asn1.x509.DistributionPointName({full: [{uri: <<CDPURI>>}]})
-912  * new KJUR.asn1.x509.DistributionPointName({full: [{dn: <<DN Parameter>>}]}
-913  * new KJUR.asn1.x509.DistributionPointName({full: [{uri: "http://example.com/root.crl"}]})
-914  * new KJUR.asn1.x509.DistributionPointName({full: [{dn {str: "/C=US/O=Test"}}]})
-915  * new KJUR.asn1.x509.DistributionPointName(new GeneralNames(...))
-916  */
-917 KJUR.asn1.x509.DistributionPointName = function(params) {
-918     KJUR.asn1.x509.DistributionPointName.superclass.constructor.call(this);
-919     var asn1Obj = null,
-920 	type = null,
-921 	tag = null,
-922 	asn1V = null,
-923 	_KJUR = KJUR,
-924 	_KJUR_asn1 = _KJUR.asn1,
-925 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject;
-926 
-927     this.tohex = function() {
-928         if (this.type != "full")
-929             throw new Error("currently type shall be 'full': " + this.type);
-930         this.asn1Obj = new _DERTaggedObject({'explicit': false,
-931                                              'tag': this.tag,
-932                                              'obj': this.asn1V});
-933         this.hTLV = this.asn1Obj.tohex();
-934         return this.hTLV;
-935     };
-936     this.getEncodedHex = function() { return this.tohex(); };
-937 
-938     if (params !== undefined) {
-939         if (_KJUR_asn1.x509.GeneralNames.prototype.isPrototypeOf(params)) {
-940             this.type = "full";
-941             this.tag = "a0";
-942             this.asn1V = params;
-943 	} else if (params.full !== undefined) {
-944             this.type = "full";
-945             this.tag = "a0";
-946             this.asn1V = new _KJUR_asn1.x509.GeneralNames(params.full);
-947         } else {
-948             throw new Error("This class supports GeneralNames only as argument");
-949         }
-950     }
-951 };
-952 extendClass(KJUR.asn1.x509.DistributionPointName, KJUR.asn1.ASN1Object);
-953 
-954 /**
-955  * CertificatePolicies ASN.1 structure class
-956  * @name KJUR.asn1.x509.CertificatePolicies
-957  * @class CertificatePolicies ASN.1 structure class
-958  * @param {Array} params associative array of parameters
-959  * @extends KJUR.asn1.x509.Extension
-960  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-961  * @see KJUR.asn1.x509.CertificatePolicies
-962  * @see KJUR.asn1.x509.PolicyInformation
-963  * @see KJUR.asn1.x509.PolicyQualifierInfo
-964  * @see KJUR.asn1.x509.UserNotice
-965  * @see KJUR.asn1.x509.NoticeReference
-966  * @see KJUR.asn1.x509.DisplayText
-967  * @description
-968  * This class represents 
-969  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-970  * CertificatePolicies extension defined in RFC 5280 4.2.1.4</a>.
-971  * <pre>
-972  * id-ce-certificatePolicies OBJECT IDENTIFIER ::=  { id-ce 32 }
-973  * CertificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
-974  * </pre>
-975  * Its constructor can have following parameters:
-976  * <ul>
-977  * <li>array - array of {@link KJUR.asn1.x509.PolicyInformation} parameter</li>
-978  * <li>critical - boolean: critical flag</li>
-979  * </ul>
-980  * NOTE: Returned JSON value format have been changed without 
-981  * backward compatibility since jsrsasign 9.0.0 asn1x509 2.0.0.
-982  * @example
-983  * e1 = new KJUR.asn1.x509.CertificatePolicies({
-984  *   array: [
-985  *     { policyoid: "1.2.3.4.5",
-986  *       array: [
-987  *         { cps: "https://example.com/repository" },
-988  *         { unotice: {
-989  *           noticeref: { // CA SHOULD NOT use this by RFC
-990  *             org: {type: "ia5", str: "Sample Org"},
-991  *             noticenum: [{int: 5}, {hex: "01af"}]
-992  *           },
-993  *           exptext: {type: "ia5", str: "Sample Policy"}
-994  *         }}
-995  *       ]
-996  *     }
-997  *   ],
-998  *   critical: true
-999  * });
-1000  */
-1001 KJUR.asn1.x509.CertificatePolicies = function(params) {
-1002     KJUR.asn1.x509.CertificatePolicies.superclass.constructor.call(this, params);
-1003     var _KJUR = KJUR,
-1004 	_KJUR_asn1 = _KJUR.asn1,
-1005 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-1006 	_DERSequence = _KJUR_asn1.DERSequence,
-1007 	_PolicyInformation = _KJUR_asn1_x509.PolicyInformation;
-1008 
-1009     this.params = null;
-1010 
-1011     this.getExtnValueHex = function() {
-1012 	var aPI = [];
-1013 	for (var i = 0; i < this.params.array.length; i++) {
-1014 	    aPI.push(new _PolicyInformation(this.params.array[i]));
-1015 	}
-1016 	var seq = new _DERSequence({array: aPI});
-1017 	this.asn1ExtnValue = seq;
-1018         return this.asn1ExtnValue.tohex();
-1019     };
-1020 
-1021     this.oid = "2.5.29.32";
-1022     if (params !== undefined) {
-1023 	this.params = params;
-1024     }
-1025 };
-1026 extendClass(KJUR.asn1.x509.CertificatePolicies, KJUR.asn1.x509.Extension);
-1027 
-1028 // ===== BEGIN CertificatePolicies related classes =====
-1029 /**
-1030  * PolicyInformation ASN.1 structure class
-1031  * @name KJUR.asn1.x509.PolicyInformation
-1032  * @class PolicyInformation ASN.1 structure class
-1033  * @param {Array} params JSON object of parameters
-1034  * @extends KJUR.asn1.ASN1Object
-1035  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-1036  * @see KJUR.asn1.x509.CertificatePolicies
-1037  * @see KJUR.asn1.x509.PolicyInformation
-1038  * @see KJUR.asn1.x509.PolicyQualifierInfo
-1039  * @see KJUR.asn1.x509.UserNotice
-1040  * @see KJUR.asn1.x509.NoticeReference
-1041  * @see KJUR.asn1.x509.DisplayText
-1042  * @description
-1043  * This class represents 
-1044  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-1045  * PolicyInformation defined in RFC 5280 4.2.1.4</a>.
-1046  * <pre>
-1047  * PolicyInformation ::= SEQUENCE {
-1048  *      policyIdentifier   CertPolicyId,
-1049  *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
-1050  *                         PolicyQualifierInfo OPTIONAL }
-1051  * CertPolicyId ::= OBJECT IDENTIFIER
-1052  * Its constructor can have following parameters:
-1053  * <ul>
-1054  * <li>{String}policyoid - policy OID (ex. "1.2.3.4.5")</li>
-1055  * <li>{Object}array - array of {@link KJUR.asn1.x509.PolicyQualifierInfo}
-1056  * parameters (OPTIONAL)</li>
-1057  * </ul>
-1058  * @example
-1059  * new KJUR.asn1.x509.PolicyInformation({
-1060  *   policyoid: "1.2.3.4.5",
-1061  *   array: [
-1062  *     { cps: "https://example.com/repository" },
-1063  *     { unotice: {
-1064  *       noticeref: { // CA SHOULD NOT use this by RFC
-1065  *         org: {type: "ia5", str: "Sample Org"},
-1066  *         noticenum: [{int: 5}, {hex: "01af"}]
-1067  *       },
-1068  *       exptext: {type: "ia5", str: "Sample Policy"}
-1069  *     }}
-1070  *   ]
-1071  * })
-1072  */
-1073 KJUR.asn1.x509.PolicyInformation = function(params) {
-1074     KJUR.asn1.x509.PolicyInformation.superclass.constructor.call(this,
-1075 								 params);
-1076     var _KJUR_asn1 = KJUR.asn1,
-1077 	_DERSequence = _KJUR_asn1.DERSequence,
-1078 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-1079 	_PolicyQualifierInfo = _KJUR_asn1.x509.PolicyQualifierInfo;
-1080 
-1081     this.params = null;
-1082 
-1083     this.tohex = function() {
-1084 	if (this.params.policyoid === undefined &&
-1085 	    this.params.array === undefined)
-1086 	    throw new Error("parameter oid and array missing");
-1087 
-1088 	// policy oid
-1089 	var a = [new _DERObjectIdentifier(this.params.policyoid)];
-1090 
-1091 	// array of ASN1Object of PolicyQualifierInfo
-1092 	if (this.params.array !== undefined) {
-1093 	    var aPQI = [];
-1094 	    for (var i = 0; i < this.params.array.length; i++) {
-1095 		aPQI.push(new _PolicyQualifierInfo(this.params.array[i]));
-1096 	    }
-1097 	    if (aPQI.length > 0) {
-1098 		a.push(new _DERSequence({array: aPQI}));
-1099 	    }
-1100 	}
-1101 
-1102 	var seq = new _DERSequence({array: a});
-1103 	return seq.tohex();
-1104     };
-1105     this.getEncodedHex = function() { return this.tohex(); };
-1106 
-1107     if (params !== undefined) {
-1108 	this.params = params;
-1109     }
-1110 };
-1111 extendClass(KJUR.asn1.x509.PolicyInformation, KJUR.asn1.ASN1Object);
-1112 
-1113 /**
-1114  * PolicyQualifierInfo ASN.1 structure class
-1115  * @name KJUR.asn1.x509.PolicyQualifierInfo
-1116  * @class PolicyQualifierInfo ASN.1 structure class
-1117  * @param {Array} params associative array of parameters
-1118  * @extends KJUR.asn1.ASN1Object
-1119  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-1120  * @description
-1121  * This class represents 
-1122  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-1123  * PolicyQualifierInfo defined in RFC 5280 4.2.1.4</a>.
-1124  * <pre>
-1125  * PolicyQualifierInfo ::= SEQUENCE {
-1126  *      policyQualifierId  PolicyQualifierId,
-1127  *      qualifier          ANY DEFINED BY policyQualifierId }
-1128  * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
-1129  * CPSuri ::= IA5String
-1130  * </pre>
-1131  * Its constructor can have one of following two parameters:
-1132  * <ul>
-1133  * <li>{String}cps - URI string for CPS</li>
-1134  * <li>{Object}unotice - {@link KJUR.asn1.x509.UserNotice} parameter</li>
-1135  * </ul>
-1136  * @example
-1137  * new PolicyQualifierInfo({
-1138  *   cps: "https://example.com/repository/cps"
-1139  * })
-1140  *
-1141  * new PolicyQualifierInfo({
-1142  *   unotice: {
-1143  *     noticeref: { // CA SHOULD NOT use this by RFC
-1144  *       org: {type: "bmp", str: "Sample Org"},
-1145  *       noticenum: [{int: 3}, {hex: "01af"}]
-1146  *     },
-1147  *     exptext: {type: "ia5", str: "Sample Policy"}
-1148  *   }
-1149  * })
-1150  */
-1151 KJUR.asn1.x509.PolicyQualifierInfo = function(params) {
-1152     KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,
-1153 								   params);
-1154     var _KJUR_asn1 = KJUR.asn1,
-1155 	_DERSequence = _KJUR_asn1.DERSequence,
-1156 	_DERIA5String = _KJUR_asn1.DERIA5String,
-1157 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-1158 	_UserNotice = _KJUR_asn1.x509.UserNotice;
-1159 
-1160     this.params = null;
-1161 
-1162     this.tohex = function() {
-1163 	if (this.params.cps !== undefined) {
-1164 	    var seq = new _DERSequence({array: [
-1165 		new _DERObjectIdentifier({oid: '1.3.6.1.5.5.7.2.1'}),
-1166 		new _DERIA5String({str: this.params.cps})
-1167 	    ]});
-1168 	    return seq.tohex();
-1169 	}
-1170 	if (this.params.unotice != undefined) {
-1171 	    var seq = new _DERSequence({array: [
-1172 		new _DERObjectIdentifier({oid: '1.3.6.1.5.5.7.2.2'}),
-1173 		new _UserNotice(this.params.unotice)
-1174 	    ]});
-1175 	    return seq.tohex();
-1176 	}
-1177     };
-1178     this.getEncodedHex = function() { return this.tohex(); };
-1179 
-1180     if (params !== undefined) {
-1181 	this.params = params;
-1182     }
-1183 };
-1184 extendClass(KJUR.asn1.x509.PolicyQualifierInfo, KJUR.asn1.ASN1Object);
-1185 
-1186 
-1187 /**
-1188  * UserNotice ASN.1 structure class
-1189  * @name KJUR.asn1.x509.UserNotice
-1190  * @class UserNotice ASN.1 structure class
-1191  * @param {Array} params associative array of parameters
-1192  * @extends KJUR.asn1.ASN1Object
-1193  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-1194  * @description
-1195  * This class represents 
-1196  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-1197  * UserNotice defined in RFC 5280 4.2.1.4</a>.
-1198  * <pre>
-1199  * UserNotice ::= SEQUENCE {
-1200  *      noticeRef        NoticeReference OPTIONAL,
-1201  *      explicitText     DisplayText OPTIONAL }
-1202  * </pre>
-1203  * Its constructor can have following two parameters:
-1204  * <ul>
-1205  * <li>{Object}noticeref - {@link KJUR.asn1.x509.NoticeReference} parameter.
-1206  * This SHALL NOT be set for conforming CA by RFC 5280. (OPTIONAL)</li>
-1207  * <li>{Object}exptext - explicitText value
-1208  * by {@link KJUR.asn1.x509.DisplayText} parameter (OPTIONAL)</li>
-1209  * </ul>
-1210  * @example
-1211  * new UserNotice({
-1212  *   noticeref: {
-1213  *     org: {type: "bmp", str: "Sample Org"},
-1214  *     noticenum: [{int: 3}, {hex: "01af"}]
-1215  *   },
-1216  *   exptext: {type: "ia5", str: "Sample Policy"}
-1217  * })
-1218  */
-1219 KJUR.asn1.x509.UserNotice = function(params) {
-1220     KJUR.asn1.x509.UserNotice.superclass.constructor.call(this, params);
-1221     var _DERSequence = KJUR.asn1.DERSequence,
-1222 	_DERInteger = KJUR.asn1.DERInteger,
-1223 	_DisplayText = KJUR.asn1.x509.DisplayText,
-1224 	_NoticeReference = KJUR.asn1.x509.NoticeReference;
-1225 
-1226     this.params = null;
-1227 
-1228     this.tohex = function() {
-1229 	var a = [];
-1230 	if (this.params.noticeref !== undefined) {
-1231 	    a.push(new _NoticeReference(this.params.noticeref));
-1232 	}
-1233 	if (this.params.exptext !== undefined) {
-1234 	    a.push(new _DisplayText(this.params.exptext));
-1235 	}
-1236 	var seq = new _DERSequence({array: a});
-1237 	return seq.tohex();
-1238     };
-1239     this.getEncodedHex = function() { return this.tohex(); };
-1240 
-1241     if (params !== undefined) {
-1242 	this.params = params;
-1243     }
-1244 };
-1245 extendClass(KJUR.asn1.x509.UserNotice, KJUR.asn1.ASN1Object);
-1246 
-1247 /**
-1248  * NoticeReference ASN.1 structure class
-1249  * @name KJUR.asn1.x509.NoticeReference
-1250  * @class NoticeReference ASN.1 structure class
-1251  * @param {Array} params associative array of parameters
-1252  * @extends KJUR.asn1.ASN1Object
-1253  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-1254  * @description
-1255  * This class represents 
-1256  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-1257  * NoticeReference defined in RFC 5280 4.2.1.4</a>.
-1258  * <pre>
-1259  * NoticeReference ::= SEQUENCE {
-1260  *      organization     DisplayText,
-1261  *      noticeNumbers    SEQUENCE OF INTEGER }
-1262  * </pre>
-1263  * Its constructor can have following two parameters:
-1264  * <ul>
-1265  * <li>{Object}org - organization by {@link KJUR.asn1.x509.DisplayText}
-1266  * parameter.</li>
-1267  * <li>{Object}noticenum - noticeNumbers value by an array of
-1268  * {@link KJUR.asn1.DERInteger} parameter</li>
-1269  * </ul>
-1270  * @example
-1271  * new NoticeReference({
-1272  *   org: {type: "bmp", str: "Sample Org"},
-1273  *   noticenum: [{int: 3}, {hex: "01af"}]
-1274  * })
-1275  */
-1276 KJUR.asn1.x509.NoticeReference = function(params) {
-1277     KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this, params);
-1278     var _DERSequence = KJUR.asn1.DERSequence,
-1279 	_DERInteger = KJUR.asn1.DERInteger,
-1280 	_DisplayText = KJUR.asn1.x509.DisplayText;
-1281 
-1282     this.params = null;
-1283 
-1284     this.tohex = function() {
-1285 	var a = [];
-1286 	if (this.params.org !== undefined) {
-1287 	    a.push(new _DisplayText(this.params.org));
-1288 	}
-1289 	if (this.params.noticenum !== undefined) {
-1290 	    var aNoticeNum = [];
-1291 	    var aNumParam = this.params.noticenum;
-1292 	    for (var i = 0; i < aNumParam.length; i++) {
-1293 		aNoticeNum.push(new _DERInteger(aNumParam[i]));
-1294 	    }
-1295 	    a.push(new _DERSequence({array: aNoticeNum}));
-1296 	}
-1297 	if (a.length == 0) throw new Error("parameter is empty");
-1298 	var seq = new _DERSequence({array: a});
-1299 	return seq.tohex();
-1300     }
-1301     this.getEncodedHex = function() { return this.tohex(); };
-1302 
-1303     if (params !== undefined) {
-1304 	this.params = params;
-1305     }
-1306 };
-1307 extendClass(KJUR.asn1.x509.NoticeReference, KJUR.asn1.ASN1Object);
-1308 
-1309 /**
-1310  * DisplayText ASN.1 structure class
-1311  * @name KJUR.asn1.x509.DisplayText
-1312  * @class DisplayText ASN.1 structure class
-1313  * @param {Array} params associative array of parameters
-1314  * @extends KJUR.asn1.DERAbstractString
-1315  * @since jsrsasign 8.0.23 asn1x509 1.1.12
-1316  * @description
-1317  * This class represents 
-1318  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
-1319  * DisplayText defined in RFC 5280 4.2.1.4</a>.
-1320  * <pre>
-1321  * -- from RFC 5280 Appendix A
-1322  * DisplayText ::= CHOICE {
-1323  *      ia5String        IA5String      (SIZE (1..200)),
-1324  *      visibleString    VisibleString  (SIZE (1..200)),
-1325  *      bmpString        BMPString      (SIZE (1..200)),
-1326  *      utf8String       UTF8String     (SIZE (1..200)) }
-1327  * </pre>
-1328  * {@link KJUR.asn1.DERAbstractString} parameters and methods
-1329  * can be used.
-1330  * Its constructor can also have following parameter:
-1331  * <ul>
-1332  * <li>{String} type - DirectoryString type of DisplayText.
-1333  * "ia5" for IA5String, "vis" for VisibleString,
-1334  * "bmp" for BMPString and "utf8" for UTF8String.
-1335  * Default is "utf8". (OPTIONAL)</li>
-1336  * </ul>
-1337  * @example
-1338  * new DisplayText({type: "bmp", str: "Sample Org"})
-1339  * new DisplayText({type: "ia5", str: "Sample Org"})
-1340  * new DisplayText({str: "Sample Org"})
-1341  */
-1342 KJUR.asn1.x509.DisplayText = function(params) {
-1343     KJUR.asn1.x509.DisplayText.superclass.constructor.call(this, params);
-1344 
-1345     this.hT = "0c"; // DEFAULT "utf8"
-1346 
-1347     if (params !== undefined) {
-1348 	if (params.type === "ia5") {
-1349 	    this.hT = "16";
-1350 	} else if (params.type === "vis") {
-1351 	    this.hT = "1a";
-1352 	} else if (params.type === "bmp") {
-1353 	    this.hT = "1e";
-1354 	}
-1355     }
-1356 };
-1357 extendClass(KJUR.asn1.x509.DisplayText, KJUR.asn1.DERAbstractString);
-1358 // ===== END CertificatePolicies related classes =====
-1359 
-1360 // =====================================================================
-1361 /**
-1362  * NameConstraints ASN.1 structure class<br/>
-1363  * @name KJUR.asn1.x509.NameConstraints
-1364  * @class NameConstraints ASN.1 structure class
-1365  * @param {Array} params associative array of parameters
-1366  * @extends KJUR.asn1.x509.Extension
-1367  * @since jsrsasign 10.5.16 asn1x509 2.1.13
-1368  * @see X509#getExtNameConstraints
-1369  * @see KJUR.asn1.x509.GeneralSubtree
-1370  * @see KJUR.asn1.x509.GeneralName
-1371 
-1372  * @description
-1373  * This class provides X.509v3 NameConstraints extension.
-1374  * defined in 
-1375  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.10">
-1376  * RFC 5280 4.2.1.10</a>.
-1377  * <pre>
-1378  * id-ce-nameConstraints OBJECT IDENTIFIER ::=  { id-ce 30 }
-1379  * NameConstraints ::= SEQUENCE {
-1380  *   permittedSubtrees  [0]  GeneralSubtrees OPTIONAL,
-1381  *   excludedSubtrees   [1]  GeneralSubtrees OPTIONAL }
-1382  * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
-1383  * GeneralSubtree ::= SEQUENCE {
-1384  *   base           GeneralName,
-1385  *   minimum   [0]  BaseDistance DEFAULT 0,
-1386  *   maximum   [1]  BaseDistance OPTIONAL }
-1387  * BaseDistance ::= INTEGER (0..MAX)
-1388  * </pre>
-1389  *
-1390  * @example
-1391  * new NameConstraints({permit: [{dns: "example.com"}], critical: true})
-1392  * new NameConstraints({exclude: [{uri: "example.com"}], critical: true})
-1393  * new NameConstraints({exclude: [{dn: "/C=JP/O=T1"}], critical: true})
-1394  * new NameConstraints({
-1395  *   critical: true,
-1396  *   permit: [{dn: "/C=JP/O=T1"}],
-1397  *   exclude: [{dn: "/C=US/O=T1", max: 2}]})
-1398  */
-1399 KJUR.asn1.x509.NameConstraints = function(params) {
-1400     KJUR.asn1.x509.NameConstraints.superclass.constructor.call(this, params);
-1401     var _KJUR = KJUR,
-1402 	_KJUR_asn1 = _KJUR.asn1,
-1403 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-1404 	_newObject = _KJUR_asn1.ASN1Util.newObject,
-1405 	_GeneralSubtree = _KJUR_asn1_x509.GeneralSubtree;
-1406 
-1407     this.params = null;
-1408 
-1409     this.getExtnValueHex = function() {
-1410 	var params = this.params;
-1411 	var aItem = [];
-1412 	if (params.permit != undefined &&
-1413 	    params.permit.length != undefined) {
-1414 	    var aPermit = [];
-1415 	    for (var i = 0; i < params.permit.length; i++) {
-1416 		aPermit.push(new _GeneralSubtree(params.permit[i]));
-1417 	    }
-1418 	    aItem.push({tag: {tagi: "a0", obj: {seq: aPermit}}});
-1419 	}
-1420 
-1421 	if (params.exclude != undefined &&
-1422 	    params.exclude.length != undefined) {
-1423 	    var aExclude = [];
-1424 	    for (var i = 0; i < params.exclude.length; i++) {
-1425 		aExclude.push(new _GeneralSubtree(params.exclude[i]));
-1426 	    }
-1427 	    aItem.push({tag: {tagi: "a1", obj: {seq: aExclude}}});
-1428 	}
-1429 
-1430 	this.asn1ExtnValue = _newObject({seq: aItem});
-1431         return this.asn1ExtnValue.tohex();
-1432     };
-1433 
-1434     this.oid = "2.5.29.30";
-1435     if (params !== undefined) this.params = params;
-1436 };
-1437 extendClass(KJUR.asn1.x509.NameConstraints, KJUR.asn1.x509.Extension);
-1438 
-1439 /**
-1440  * GeneralSubtree ASN.1 structure class<br/>
-1441  * @name KJUR.asn1.x509.GeneralSubtree
-1442  * @class GeneralSubtree ASN.1 structure class
-1443  * @since jsrsasign 10.5.16 asn1x509 2.1.13
-1444  * @see KJUR.asn1.x509.NameConstraints
-1445  * @see KJUR.asn1.x509.GeneralName
-1446  * @see X509#getExtNameConstraints
-1447  * @see X509#getGeneralSubtree
-1448  *
-1449  * @description
-1450  * This class provides a encoder for GeneralSubtree 
-1451  * defined in 
-1452  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.10">
-1453  * RFC 5280 4.2.1.10</a>. 
-1454  * This will be used for nameConstraints extension.
-1455  * <br>
-1456  * Here is definition of the ASN.1 syntax:
-1457  * <pre>
-1458  * GeneralSubtree ::= SEQUENCE {
-1459  *   base           GeneralName,
-1460  *   minimum   [0]  BaseDistance DEFAULT 0,
-1461  *   maximum   [1]  BaseDistance OPTIONAL }
-1462  * BaseDistance ::= INTEGER (0..MAX)
-1463  * </pre>
-1464  * An argument for constructor is the same as
-1465  * {@link KJUR.asn1.x509.GeneralName} except
-1466  * this has following optional members:
-1467  * <ul>
-1468  * <li>min - {Number} value for the minimum field</li>
-1469  * <li>max - {Number} value for the maximum field</li>
-1470  * </ul>
-1471  * Please note that min and max can't be specified since
-1472  * they are prohibited in RFC 5280.
-1473  *
-1474  * @example
-1475  * new GeneralSubtree({dns: "example.com"})
-1476  * new GeneralSubtree({uri: ".example.com"})
-1477  * new GeneralSubtree({dn: "/C=JP/O=Test1"})
-1478  */
-1479 KJUR.asn1.x509.GeneralSubtree = function(params) {
-1480     KJUR.asn1.x509.GeneralSubtree.superclass.constructor.call(this);
+781 /**
+782  * DistributionPoint ASN.1 structure class<br/>
+783  * @name KJUR.asn1.x509.DistributionPoint
+784  * @class DistributionPoint ASN.1 structure class
+785  * @param {Array} params JSON object of parameters (OPTIONAL)
+786  * @extends KJUR.asn1.ASN1Object
+787  * @see {@link KJUR.asn1.x509.CRLDistributionPoints}
+788  * @see {@link KJUR.asn1.x509.DistributionPointName}
+789  * @see {@link KJUR.asn1.x509.GeneralNames}
+790  * @see {@link X509#getDistributionPoint}
+791  * @description
+792  * This class represents 
+793  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
+794  * DistributionPoint defined in RFC 5280 4.2.1.13</a>.
+795  * <pre>
+796  * DistributionPoint ::= SEQUENCE {
+797  *      distributionPoint       [0]     DistributionPointName OPTIONAL,
+798  *      reasons                 [1]     ReasonFlags OPTIONAL,
+799  *      cRLIssuer               [2]     GeneralNames OPTIONAL }
+800  * </pre>
+801  * Constructor can have following parameter:
+802  * <ul>
+803  * <li>{String}fulluri - uri string for fullName uri. This has the same meaning for '{dpname: {full: [{uri: "..."]}}'.</li>
+804  * <li>{Array}dpname - JSON object for {@link KJUR.asn1.x509.DistributionPointName} parameters</li>
+805  * <li>{DistrubutionPoint}dpobj - {@link KJUR.asn1.x509.DistributionPointName} object (DEPRECATED)</li>
+806  * </ul>
+807  * <br/>
+808  * NOTE1: Parameter "fulluri" and "dpname" supported 
+809  * since jsrsasign 9.0.0 asn1x509 2.0.0.
+810  * <br/>
+811  * NOTE2: The "reasons" and "cRLIssuer" fields are currently
+812  * not supported.
+813  * @example
+814  * new KJUR.asn1.x509.DistributionPoint(
+815  *   {fulluri: "http://example.com/crl1.crl"})
+816  * new KJUR.asn1.x509.DistributionPoint(
+817  *   {dpname: {full: [{uri: "http://example.com/crl1.crl"}]}})
+818  * new KJUR.asn1.x509.DistributionPoint(
+819  *   {dpobj: new DistributionPoint(...)})
+820  */
+821 KJUR.asn1.x509.DistributionPoint = function(params) {
+822     KJUR.asn1.x509.DistributionPoint.superclass.constructor.call(this);
+823     var asn1DP = null,
+824 	_KJUR = KJUR,
+825 	_KJUR_asn1 = _KJUR.asn1,
+826 	_DistributionPointName = _KJUR_asn1.x509.DistributionPointName;
+827 
+828     this.tohex = function() {
+829         var seq = new _KJUR_asn1.DERSequence();
+830         if (this.asn1DP != null) {
+831             var o1 = new _KJUR_asn1.DERTaggedObject({'explicit': true,
+832                                                      'tag': 'a0',
+833                                                      'obj': this.asn1DP});
+834             seq.appendASN1Object(o1);
+835         }
+836         this.hTLV = seq.tohex();
+837         return this.hTLV;
+838     };
+839     this.getEncodedHex = function() { return this.tohex(); };
+840 
+841     if (params !== undefined) {
+842         if (params.dpobj !== undefined) {
+843             this.asn1DP = params.dpobj;
+844         } else if (params.dpname !== undefined) {
+845             this.asn1DP = new _DistributionPointName(params.dpname);
+846 	} else if (params.fulluri !== undefined) {
+847             this.asn1DP = new _DistributionPointName({full: [{uri: params.fulluri}]});
+848 	}
+849     }
+850 };
+851 extendClass(KJUR.asn1.x509.DistributionPoint, KJUR.asn1.ASN1Object);
+852 
+853 /**
+854  * DistributionPointName ASN.1 structure class<br/>
+855  * @name KJUR.asn1.x509.DistributionPointName
+856  * @class DistributionPointName ASN.1 structure class
+857  * @param {Array} params JSON object of parameters or GeneralNames object
+858  * @extends KJUR.asn1.ASN1Object
+859  * @see {@link KJUR.asn1.x509.CRLDistributionPoints}
+860  * @see {@link KJUR.asn1.x509.DistributionPoint}
+861  * @see {@link KJUR.asn1.x509.GeneralNames}
+862  * @see {@link X509#getDistributionPointName}
+863  * @description
+864  * This class represents 
+865  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.13">
+866  * DistributionPointName defined in RFC 5280 4.2.1.13</a>.
+867  * <pre>
+868  * DistributionPointName ::= CHOICE {
+869  *      fullName                [0]     GeneralNames,
+870  *      nameRelativeToCRLIssuer [1]     RelativeDistinguishedName }
+871  * </pre>
+872  * Constructor can have following parameter:
+873  * <ul>
+874  * <li>{String}full - JSON object parameter of {@link KJUR.asn1.x509.GeneralNames} for 'fullName' field</li>
+875  * <li>{GeneralNames} - {@link KJUR.asn1.x509.GeneralNames} object for 'fullName'</li>
+876  * </ul>
+877  * NOTE1: 'full' parameter have been suppored since jsrsasign 9.0.0 asn1x509 2.0.0.
+878  * <br>
+879  * NOTE2: The 'nameRelativeToCRLIssuer' field is currently not supported.
+880  * @example
+881  * new KJUR.asn1.x509.DistributionPointName({full: <<GeneralNamesParameter>>})
+882  * new KJUR.asn1.x509.DistributionPointName({full: [{uri: <<CDPURI>>}]})
+883  * new KJUR.asn1.x509.DistributionPointName({full: [{dn: <<DN Parameter>>}]}
+884  * new KJUR.asn1.x509.DistributionPointName({full: [{uri: "http://example.com/root.crl"}]})
+885  * new KJUR.asn1.x509.DistributionPointName({full: [{dn {str: "/C=US/O=Test"}}]})
+886  * new KJUR.asn1.x509.DistributionPointName(new GeneralNames(...))
+887  */
+888 KJUR.asn1.x509.DistributionPointName = function(params) {
+889     KJUR.asn1.x509.DistributionPointName.superclass.constructor.call(this);
+890     var asn1Obj = null,
+891 	type = null,
+892 	tag = null,
+893 	asn1V = null,
+894 	_KJUR = KJUR,
+895 	_KJUR_asn1 = _KJUR.asn1,
+896 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject;
+897 
+898     this.tohex = function() {
+899         if (this.type != "full")
+900             throw new Error("currently type shall be 'full': " + this.type);
+901         this.asn1Obj = new _DERTaggedObject({'explicit': false,
+902                                              'tag': this.tag,
+903                                              'obj': this.asn1V});
+904         this.hTLV = this.asn1Obj.tohex();
+905         return this.hTLV;
+906     };
+907     this.getEncodedHex = function() { return this.tohex(); };
+908 
+909     if (params !== undefined) {
+910         if (_KJUR_asn1.x509.GeneralNames.prototype.isPrototypeOf(params)) {
+911             this.type = "full";
+912             this.tag = "a0";
+913             this.asn1V = params;
+914 	} else if (params.full !== undefined) {
+915             this.type = "full";
+916             this.tag = "a0";
+917             this.asn1V = new _KJUR_asn1.x509.GeneralNames(params.full);
+918         } else {
+919             throw new Error("This class supports GeneralNames only as argument");
+920         }
+921     }
+922 };
+923 extendClass(KJUR.asn1.x509.DistributionPointName, KJUR.asn1.ASN1Object);
+924 
+925 /**
+926  * CertificatePolicies ASN.1 structure class
+927  * @name KJUR.asn1.x509.CertificatePolicies
+928  * @class CertificatePolicies ASN.1 structure class
+929  * @param {Array} params associative array of parameters
+930  * @extends KJUR.asn1.x509.Extension
+931  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+932  * @see KJUR.asn1.x509.CertificatePolicies
+933  * @see KJUR.asn1.x509.PolicyInformation
+934  * @see KJUR.asn1.x509.PolicyQualifierInfo
+935  * @see KJUR.asn1.x509.UserNotice
+936  * @see KJUR.asn1.x509.NoticeReference
+937  * @see KJUR.asn1.x509.DisplayText
+938  * @description
+939  * This class represents 
+940  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+941  * CertificatePolicies extension defined in RFC 5280 4.2.1.4</a>.
+942  * <pre>
+943  * id-ce-certificatePolicies OBJECT IDENTIFIER ::=  { id-ce 32 }
+944  * CertificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
+945  * </pre>
+946  * Its constructor can have following parameters:
+947  * <ul>
+948  * <li>array - array of {@link KJUR.asn1.x509.PolicyInformation} parameter</li>
+949  * <li>critical - boolean: critical flag</li>
+950  * </ul>
+951  * NOTE: Returned JSON value format have been changed without 
+952  * backward compatibility since jsrsasign 9.0.0 asn1x509 2.0.0.
+953  * @example
+954  * e1 = new KJUR.asn1.x509.CertificatePolicies({
+955  *   array: [
+956  *     { policyoid: "1.2.3.4.5",
+957  *       array: [
+958  *         { cps: "https://example.com/repository" },
+959  *         { unotice: {
+960  *           noticeref: { // CA SHOULD NOT use this by RFC
+961  *             org: {type: "ia5", str: "Sample Org"},
+962  *             noticenum: [{int: 5}, {hex: "01af"}]
+963  *           },
+964  *           exptext: {type: "ia5", str: "Sample Policy"}
+965  *         }}
+966  *       ]
+967  *     }
+968  *   ],
+969  *   critical: true
+970  * });
+971  */
+972 KJUR.asn1.x509.CertificatePolicies = function(params) {
+973     KJUR.asn1.x509.CertificatePolicies.superclass.constructor.call(this, params);
+974     var _KJUR = KJUR,
+975 	_KJUR_asn1 = _KJUR.asn1,
+976 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+977 	_DERSequence = _KJUR_asn1.DERSequence,
+978 	_PolicyInformation = _KJUR_asn1_x509.PolicyInformation;
+979 
+980     this.params = null;
+981 
+982     this.getExtnValueHex = function() {
+983 	var aPI = [];
+984 	for (var i = 0; i < this.params.array.length; i++) {
+985 	    aPI.push(new _PolicyInformation(this.params.array[i]));
+986 	}
+987 	var seq = new _DERSequence({array: aPI});
+988 	this.asn1ExtnValue = seq;
+989         return this.asn1ExtnValue.tohex();
+990     };
+991 
+992     this.oid = "2.5.29.32";
+993     if (params !== undefined) {
+994 	this.params = params;
+995     }
+996 };
+997 extendClass(KJUR.asn1.x509.CertificatePolicies, KJUR.asn1.x509.Extension);
+998 
+999 // ===== BEGIN CertificatePolicies related classes =====
+1000 /**
+1001  * PolicyInformation ASN.1 structure class
+1002  * @name KJUR.asn1.x509.PolicyInformation
+1003  * @class PolicyInformation ASN.1 structure class
+1004  * @param {Array} params JSON object of parameters
+1005  * @extends KJUR.asn1.ASN1Object
+1006  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+1007  * @see KJUR.asn1.x509.CertificatePolicies
+1008  * @see KJUR.asn1.x509.PolicyInformation
+1009  * @see KJUR.asn1.x509.PolicyQualifierInfo
+1010  * @see KJUR.asn1.x509.UserNotice
+1011  * @see KJUR.asn1.x509.NoticeReference
+1012  * @see KJUR.asn1.x509.DisplayText
+1013  * @description
+1014  * This class represents 
+1015  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+1016  * PolicyInformation defined in RFC 5280 4.2.1.4</a>.
+1017  * <pre>
+1018  * PolicyInformation ::= SEQUENCE {
+1019  *      policyIdentifier   CertPolicyId,
+1020  *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
+1021  *                         PolicyQualifierInfo OPTIONAL }
+1022  * CertPolicyId ::= OBJECT IDENTIFIER
+1023  * Its constructor can have following parameters:
+1024  * <ul>
+1025  * <li>{String}policyoid - policy OID (ex. "1.2.3.4.5")</li>
+1026  * <li>{Object}array - array of {@link KJUR.asn1.x509.PolicyQualifierInfo}
+1027  * parameters (OPTIONAL)</li>
+1028  * </ul>
+1029  * @example
+1030  * new KJUR.asn1.x509.PolicyInformation({
+1031  *   policyoid: "1.2.3.4.5",
+1032  *   array: [
+1033  *     { cps: "https://example.com/repository" },
+1034  *     { unotice: {
+1035  *       noticeref: { // CA SHOULD NOT use this by RFC
+1036  *         org: {type: "ia5", str: "Sample Org"},
+1037  *         noticenum: [{int: 5}, {hex: "01af"}]
+1038  *       },
+1039  *       exptext: {type: "ia5", str: "Sample Policy"}
+1040  *     }}
+1041  *   ]
+1042  * })
+1043  */
+1044 KJUR.asn1.x509.PolicyInformation = function(params) {
+1045     KJUR.asn1.x509.PolicyInformation.superclass.constructor.call(this,
+1046 								 params);
+1047     var _KJUR_asn1 = KJUR.asn1,
+1048 	_DERSequence = _KJUR_asn1.DERSequence,
+1049 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+1050 	_PolicyQualifierInfo = _KJUR_asn1.x509.PolicyQualifierInfo;
+1051 
+1052     this.params = null;
+1053 
+1054     this.tohex = function() {
+1055 	if (this.params.policyoid === undefined &&
+1056 	    this.params.array === undefined)
+1057 	    throw new Error("parameter oid and array missing");
+1058 
+1059 	// policy oid
+1060 	var a = [new _DERObjectIdentifier(this.params.policyoid)];
+1061 
+1062 	// array of ASN1Object of PolicyQualifierInfo
+1063 	if (this.params.array !== undefined) {
+1064 	    var aPQI = [];
+1065 	    for (var i = 0; i < this.params.array.length; i++) {
+1066 		aPQI.push(new _PolicyQualifierInfo(this.params.array[i]));
+1067 	    }
+1068 	    if (aPQI.length > 0) {
+1069 		a.push(new _DERSequence({array: aPQI}));
+1070 	    }
+1071 	}
+1072 
+1073 	var seq = new _DERSequence({array: a});
+1074 	return seq.tohex();
+1075     };
+1076     this.getEncodedHex = function() { return this.tohex(); };
+1077 
+1078     if (params !== undefined) {
+1079 	this.params = params;
+1080     }
+1081 };
+1082 extendClass(KJUR.asn1.x509.PolicyInformation, KJUR.asn1.ASN1Object);
+1083 
+1084 /**
+1085  * PolicyQualifierInfo ASN.1 structure class
+1086  * @name KJUR.asn1.x509.PolicyQualifierInfo
+1087  * @class PolicyQualifierInfo ASN.1 structure class
+1088  * @param {Array} params associative array of parameters
+1089  * @extends KJUR.asn1.ASN1Object
+1090  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+1091  * @description
+1092  * This class represents 
+1093  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+1094  * PolicyQualifierInfo defined in RFC 5280 4.2.1.4</a>.
+1095  * <pre>
+1096  * PolicyQualifierInfo ::= SEQUENCE {
+1097  *      policyQualifierId  PolicyQualifierId,
+1098  *      qualifier          ANY DEFINED BY policyQualifierId }
+1099  * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
+1100  * CPSuri ::= IA5String
+1101  * </pre>
+1102  * Its constructor can have one of following two parameters:
+1103  * <ul>
+1104  * <li>{String}cps - URI string for CPS</li>
+1105  * <li>{Object}unotice - {@link KJUR.asn1.x509.UserNotice} parameter</li>
+1106  * </ul>
+1107  * @example
+1108  * new PolicyQualifierInfo({
+1109  *   cps: "https://example.com/repository/cps"
+1110  * })
+1111  *
+1112  * new PolicyQualifierInfo({
+1113  *   unotice: {
+1114  *     noticeref: { // CA SHOULD NOT use this by RFC
+1115  *       org: {type: "bmp", str: "Sample Org"},
+1116  *       noticenum: [{int: 3}, {hex: "01af"}]
+1117  *     },
+1118  *     exptext: {type: "ia5", str: "Sample Policy"}
+1119  *   }
+1120  * })
+1121  */
+1122 KJUR.asn1.x509.PolicyQualifierInfo = function(params) {
+1123     KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,
+1124 								   params);
+1125     var _KJUR_asn1 = KJUR.asn1,
+1126 	_DERSequence = _KJUR_asn1.DERSequence,
+1127 	_DERIA5String = _KJUR_asn1.DERIA5String,
+1128 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+1129 	_UserNotice = _KJUR_asn1.x509.UserNotice;
+1130 
+1131     this.params = null;
+1132 
+1133     this.tohex = function() {
+1134 	if (this.params.cps !== undefined) {
+1135 	    var seq = new _DERSequence({array: [
+1136 		new _DERObjectIdentifier({oid: '1.3.6.1.5.5.7.2.1'}),
+1137 		new _DERIA5String({str: this.params.cps})
+1138 	    ]});
+1139 	    return seq.tohex();
+1140 	}
+1141 	if (this.params.unotice != undefined) {
+1142 	    var seq = new _DERSequence({array: [
+1143 		new _DERObjectIdentifier({oid: '1.3.6.1.5.5.7.2.2'}),
+1144 		new _UserNotice(this.params.unotice)
+1145 	    ]});
+1146 	    return seq.tohex();
+1147 	}
+1148     };
+1149     this.getEncodedHex = function() { return this.tohex(); };
+1150 
+1151     if (params !== undefined) {
+1152 	this.params = params;
+1153     }
+1154 };
+1155 extendClass(KJUR.asn1.x509.PolicyQualifierInfo, KJUR.asn1.ASN1Object);
+1156 
+1157 
+1158 /**
+1159  * UserNotice ASN.1 structure class
+1160  * @name KJUR.asn1.x509.UserNotice
+1161  * @class UserNotice ASN.1 structure class
+1162  * @param {Array} params associative array of parameters
+1163  * @extends KJUR.asn1.ASN1Object
+1164  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+1165  * @description
+1166  * This class represents 
+1167  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+1168  * UserNotice defined in RFC 5280 4.2.1.4</a>.
+1169  * <pre>
+1170  * UserNotice ::= SEQUENCE {
+1171  *      noticeRef        NoticeReference OPTIONAL,
+1172  *      explicitText     DisplayText OPTIONAL }
+1173  * </pre>
+1174  * Its constructor can have following two parameters:
+1175  * <ul>
+1176  * <li>{Object}noticeref - {@link KJUR.asn1.x509.NoticeReference} parameter.
+1177  * This SHALL NOT be set for conforming CA by RFC 5280. (OPTIONAL)</li>
+1178  * <li>{Object}exptext - explicitText value
+1179  * by {@link KJUR.asn1.x509.DisplayText} parameter (OPTIONAL)</li>
+1180  * </ul>
+1181  * @example
+1182  * new UserNotice({
+1183  *   noticeref: {
+1184  *     org: {type: "bmp", str: "Sample Org"},
+1185  *     noticenum: [{int: 3}, {hex: "01af"}]
+1186  *   },
+1187  *   exptext: {type: "ia5", str: "Sample Policy"}
+1188  * })
+1189  */
+1190 KJUR.asn1.x509.UserNotice = function(params) {
+1191     KJUR.asn1.x509.UserNotice.superclass.constructor.call(this, params);
+1192     var _DERSequence = KJUR.asn1.DERSequence,
+1193 	_DERInteger = KJUR.asn1.DERInteger,
+1194 	_DisplayText = KJUR.asn1.x509.DisplayText,
+1195 	_NoticeReference = KJUR.asn1.x509.NoticeReference;
+1196 
+1197     this.params = null;
+1198 
+1199     this.tohex = function() {
+1200 	var a = [];
+1201 	if (this.params.noticeref !== undefined) {
+1202 	    a.push(new _NoticeReference(this.params.noticeref));
+1203 	}
+1204 	if (this.params.exptext !== undefined) {
+1205 	    a.push(new _DisplayText(this.params.exptext));
+1206 	}
+1207 	var seq = new _DERSequence({array: a});
+1208 	return seq.tohex();
+1209     };
+1210     this.getEncodedHex = function() { return this.tohex(); };
+1211 
+1212     if (params !== undefined) {
+1213 	this.params = params;
+1214     }
+1215 };
+1216 extendClass(KJUR.asn1.x509.UserNotice, KJUR.asn1.ASN1Object);
+1217 
+1218 /**
+1219  * NoticeReference ASN.1 structure class
+1220  * @name KJUR.asn1.x509.NoticeReference
+1221  * @class NoticeReference ASN.1 structure class
+1222  * @param {Array} params associative array of parameters
+1223  * @extends KJUR.asn1.ASN1Object
+1224  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+1225  * @description
+1226  * This class represents 
+1227  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+1228  * NoticeReference defined in RFC 5280 4.2.1.4</a>.
+1229  * <pre>
+1230  * NoticeReference ::= SEQUENCE {
+1231  *      organization     DisplayText,
+1232  *      noticeNumbers    SEQUENCE OF INTEGER }
+1233  * </pre>
+1234  * Its constructor can have following two parameters:
+1235  * <ul>
+1236  * <li>{Object}org - organization by {@link KJUR.asn1.x509.DisplayText}
+1237  * parameter.</li>
+1238  * <li>{Object}noticenum - noticeNumbers value by an array of
+1239  * {@link KJUR.asn1.DERInteger} parameter</li>
+1240  * </ul>
+1241  * @example
+1242  * new NoticeReference({
+1243  *   org: {type: "bmp", str: "Sample Org"},
+1244  *   noticenum: [{int: 3}, {hex: "01af"}]
+1245  * })
+1246  */
+1247 KJUR.asn1.x509.NoticeReference = function(params) {
+1248     KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this, params);
+1249     var _DERSequence = KJUR.asn1.DERSequence,
+1250 	_DERInteger = KJUR.asn1.DERInteger,
+1251 	_DisplayText = KJUR.asn1.x509.DisplayText;
+1252 
+1253     this.params = null;
+1254 
+1255     this.tohex = function() {
+1256 	var a = [];
+1257 	if (this.params.org !== undefined) {
+1258 	    a.push(new _DisplayText(this.params.org));
+1259 	}
+1260 	if (this.params.noticenum !== undefined) {
+1261 	    var aNoticeNum = [];
+1262 	    var aNumParam = this.params.noticenum;
+1263 	    for (var i = 0; i < aNumParam.length; i++) {
+1264 		aNoticeNum.push(new _DERInteger(aNumParam[i]));
+1265 	    }
+1266 	    a.push(new _DERSequence({array: aNoticeNum}));
+1267 	}
+1268 	if (a.length == 0) throw new Error("parameter is empty");
+1269 	var seq = new _DERSequence({array: a});
+1270 	return seq.tohex();
+1271     }
+1272     this.getEncodedHex = function() { return this.tohex(); };
+1273 
+1274     if (params !== undefined) {
+1275 	this.params = params;
+1276     }
+1277 };
+1278 extendClass(KJUR.asn1.x509.NoticeReference, KJUR.asn1.ASN1Object);
+1279 
+1280 /**
+1281  * DisplayText ASN.1 structure class
+1282  * @name KJUR.asn1.x509.DisplayText
+1283  * @class DisplayText ASN.1 structure class
+1284  * @param {Array} params associative array of parameters
+1285  * @extends KJUR.asn1.DERAbstractString
+1286  * @since jsrsasign 8.0.23 asn1x509 1.1.12
+1287  * @description
+1288  * This class represents 
+1289  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
+1290  * DisplayText defined in RFC 5280 4.2.1.4</a>.
+1291  * <pre>
+1292  * -- from RFC 5280 Appendix A
+1293  * DisplayText ::= CHOICE {
+1294  *      ia5String        IA5String      (SIZE (1..200)),
+1295  *      visibleString    VisibleString  (SIZE (1..200)),
+1296  *      bmpString        BMPString      (SIZE (1..200)),
+1297  *      utf8String       UTF8String     (SIZE (1..200)) }
+1298  * </pre>
+1299  * {@link KJUR.asn1.DERAbstractString} parameters and methods
+1300  * can be used.
+1301  * Its constructor can also have following parameter:
+1302  * <ul>
+1303  * <li>{String} type - DirectoryString type of DisplayText.
+1304  * "ia5" for IA5String, "vis" for VisibleString,
+1305  * "bmp" for BMPString and "utf8" for UTF8String.
+1306  * Default is "utf8". (OPTIONAL)</li>
+1307  * </ul>
+1308  * @example
+1309  * new DisplayText({type: "bmp", str: "Sample Org"})
+1310  * new DisplayText({type: "ia5", str: "Sample Org"})
+1311  * new DisplayText({str: "Sample Org"})
+1312  */
+1313 KJUR.asn1.x509.DisplayText = function(params) {
+1314     KJUR.asn1.x509.DisplayText.superclass.constructor.call(this, params);
+1315 
+1316     this.hT = "0c"; // DEFAULT "utf8"
+1317 
+1318     if (params !== undefined) {
+1319 	if (params.type === "ia5") {
+1320 	    this.hT = "16";
+1321 	} else if (params.type === "vis") {
+1322 	    this.hT = "1a";
+1323 	} else if (params.type === "bmp") {
+1324 	    this.hT = "1e";
+1325 	}
+1326     }
+1327 };
+1328 extendClass(KJUR.asn1.x509.DisplayText, KJUR.asn1.DERAbstractString);
+1329 // ===== END CertificatePolicies related classes =====
+1330 
+1331 // =====================================================================
+1332 /**
+1333  * NameConstraints ASN.1 structure class<br/>
+1334  * @name KJUR.asn1.x509.NameConstraints
+1335  * @class NameConstraints ASN.1 structure class
+1336  * @param {Array} params associative array of parameters
+1337  * @extends KJUR.asn1.x509.Extension
+1338  * @since jsrsasign 10.5.16 asn1x509 2.1.13
+1339  * @see X509#getExtNameConstraints
+1340  * @see KJUR.asn1.x509.GeneralSubtree
+1341  * @see KJUR.asn1.x509.GeneralName
+1342 
+1343  * @description
+1344  * This class provides X.509v3 NameConstraints extension.
+1345  * defined in 
+1346  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.10">
+1347  * RFC 5280 4.2.1.10</a>.
+1348  * <pre>
+1349  * id-ce-nameConstraints OBJECT IDENTIFIER ::=  { id-ce 30 }
+1350  * NameConstraints ::= SEQUENCE {
+1351  *   permittedSubtrees  [0]  GeneralSubtrees OPTIONAL,
+1352  *   excludedSubtrees   [1]  GeneralSubtrees OPTIONAL }
+1353  * GeneralSubtrees ::= SEQUENCE SIZE (1..MAX) OF GeneralSubtree
+1354  * GeneralSubtree ::= SEQUENCE {
+1355  *   base           GeneralName,
+1356  *   minimum   [0]  BaseDistance DEFAULT 0,
+1357  *   maximum   [1]  BaseDistance OPTIONAL }
+1358  * BaseDistance ::= INTEGER (0..MAX)
+1359  * </pre>
+1360  *
+1361  * @example
+1362  * new NameConstraints({permit: [{dns: "example.com"}], critical: true})
+1363  * new NameConstraints({exclude: [{uri: "example.com"}], critical: true})
+1364  * new NameConstraints({exclude: [{dn: "/C=JP/O=T1"}], critical: true})
+1365  * new NameConstraints({
+1366  *   critical: true,
+1367  *   permit: [{dn: "/C=JP/O=T1"}],
+1368  *   exclude: [{dn: "/C=US/O=T1", max: 2}]})
+1369  */
+1370 KJUR.asn1.x509.NameConstraints = function(params) {
+1371     KJUR.asn1.x509.NameConstraints.superclass.constructor.call(this, params);
+1372     var _KJUR = KJUR,
+1373 	_KJUR_asn1 = _KJUR.asn1,
+1374 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+1375 	_newObject = _KJUR_asn1.ASN1Util.newObject,
+1376 	_GeneralSubtree = _KJUR_asn1_x509.GeneralSubtree;
+1377 
+1378     this.params = null;
+1379 
+1380     this.getExtnValueHex = function() {
+1381 	var params = this.params;
+1382 	var aItem = [];
+1383 	if (params.permit != undefined &&
+1384 	    params.permit.length != undefined) {
+1385 	    var aPermit = [];
+1386 	    for (var i = 0; i < params.permit.length; i++) {
+1387 		aPermit.push(new _GeneralSubtree(params.permit[i]));
+1388 	    }
+1389 	    aItem.push({tag: {tagi: "a0", obj: {seq: aPermit}}});
+1390 	}
+1391 
+1392 	if (params.exclude != undefined &&
+1393 	    params.exclude.length != undefined) {
+1394 	    var aExclude = [];
+1395 	    for (var i = 0; i < params.exclude.length; i++) {
+1396 		aExclude.push(new _GeneralSubtree(params.exclude[i]));
+1397 	    }
+1398 	    aItem.push({tag: {tagi: "a1", obj: {seq: aExclude}}});
+1399 	}
+1400 
+1401 	this.asn1ExtnValue = _newObject({seq: aItem});
+1402         return this.asn1ExtnValue.tohex();
+1403     };
+1404 
+1405     this.oid = "2.5.29.30";
+1406     if (params !== undefined) this.params = params;
+1407 };
+1408 extendClass(KJUR.asn1.x509.NameConstraints, KJUR.asn1.x509.Extension);
+1409 
+1410 /**
+1411  * GeneralSubtree ASN.1 structure class<br/>
+1412  * @name KJUR.asn1.x509.GeneralSubtree
+1413  * @class GeneralSubtree ASN.1 structure class
+1414  * @since jsrsasign 10.5.16 asn1x509 2.1.13
+1415  * @see KJUR.asn1.x509.NameConstraints
+1416  * @see KJUR.asn1.x509.GeneralName
+1417  * @see X509#getExtNameConstraints
+1418  * @see X509#getGeneralSubtree
+1419  *
+1420  * @description
+1421  * This class provides a encoder for GeneralSubtree 
+1422  * defined in 
+1423  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.10">
+1424  * RFC 5280 4.2.1.10</a>. 
+1425  * This will be used for nameConstraints extension.
+1426  * <br>
+1427  * Here is definition of the ASN.1 syntax:
+1428  * <pre>
+1429  * GeneralSubtree ::= SEQUENCE {
+1430  *   base           GeneralName,
+1431  *   minimum   [0]  BaseDistance DEFAULT 0,
+1432  *   maximum   [1]  BaseDistance OPTIONAL }
+1433  * BaseDistance ::= INTEGER (0..MAX)
+1434  * </pre>
+1435  * An argument for constructor is the same as
+1436  * {@link KJUR.asn1.x509.GeneralName} except
+1437  * this has following optional members:
+1438  * <ul>
+1439  * <li>min - {Number} value for the minimum field</li>
+1440  * <li>max - {Number} value for the maximum field</li>
+1441  * </ul>
+1442  * Please note that min and max can't be specified since
+1443  * they are prohibited in RFC 5280.
+1444  *
+1445  * @example
+1446  * new GeneralSubtree({dns: "example.com"})
+1447  * new GeneralSubtree({uri: ".example.com"})
+1448  * new GeneralSubtree({dn: "/C=JP/O=Test1"})
+1449  */
+1450 KJUR.asn1.x509.GeneralSubtree = function(params) {
+1451     KJUR.asn1.x509.GeneralSubtree.superclass.constructor.call(this);
+1452 
+1453     var _KJUR_asn1 = KJUR.asn1,
+1454 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+1455 	_GeneralName = _KJUR_asn1_x509.GeneralName,
+1456 	_newObject = _KJUR_asn1.ASN1Util.newObject;
+1457 
+1458     this.params = null;
+1459 
+1460     this.setByParam = function(params) {
+1461 	this.params = params;
+1462     };
+1463 
+1464     this.tohex = function() {
+1465 	var params = this.params;
+1466 
+1467 	var aItem = [new _GeneralName(params)];
+1468 	if (params.min != undefined)
+1469 	    aItem.push({tag: {tagi:"80", obj: {"int": params.min}}});
+1470 	if (params.max != undefined)
+1471 	    aItem.push({tag: {tagi:"81", obj: {"int": params.max}}});
+1472 
+1473 	var dSeq = _newObject({seq: aItem});
+1474 	return dSeq.tohex();
+1475     }
+1476     this.getEncodedHex = function() { return this.tohex(); };
+1477 
+1478     if (params !== undefined) this.setByParam(params);
+1479 };
+1480 extendClass(KJUR.asn1.x509.GeneralSubtree, KJUR.asn1.ASN1Object);
 1481 
-1482     var _KJUR_asn1 = KJUR.asn1,
-1483 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-1484 	_GeneralName = _KJUR_asn1_x509.GeneralName,
-1485 	_newObject = _KJUR_asn1.ASN1Util.newObject;
-1486 
-1487     this.params = null;
-1488 
-1489     this.setByParam = function(params) {
-1490 	this.params = params;
-1491     };
-1492 
-1493     this.tohex = function() {
-1494 	var params = this.params;
-1495 
-1496 	var aItem = [new _GeneralName(params)];
-1497 	if (params.min != undefined)
-1498 	    aItem.push({tag: {tagi:"80", obj: {"int": params.min}}});
-1499 	if (params.max != undefined)
-1500 	    aItem.push({tag: {tagi:"81", obj: {"int": params.max}}});
-1501 
-1502 	var dSeq = _newObject({seq: aItem});
-1503 	return dSeq.tohex();
-1504     }
-1505     this.getEncodedHex = function() { return this.tohex(); };
-1506 
-1507     if (params !== undefined) this.setByParam(params);
-1508 };
-1509 extendClass(KJUR.asn1.x509.GeneralSubtree, KJUR.asn1.ASN1Object);
-1510 
-1511 // =====================================================================
-1512 /**
-1513  * KeyUsage ASN.1 structure class
-1514  * @name KJUR.asn1.x509.ExtKeyUsage
-1515  * @class ExtKeyUsage ASN.1 structure class
-1516  * @param {Array} params associative array of parameters
-1517  * @extends KJUR.asn1.x509.Extension
-1518  * @description
-1519  * @example
-1520  * e1 = new KJUR.asn1.x509.ExtKeyUsage({
-1521  *   critical: true,
-1522  *   array: [
-1523  *     {oid: '2.5.29.37.0'},  // anyExtendedKeyUsage
-1524  *     {name: 'clientAuth'},
-1525  *     "1.2.3.4",
-1526  *     "serverAuth"
-1527  *   ]
-1528  * });
-1529  * // id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 }
-1530  * // ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
-1531  * // KeyPurposeId ::= OBJECT IDENTIFIER
-1532  */
-1533 KJUR.asn1.x509.ExtKeyUsage = function(params) {
-1534     KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this, params);
-1535     var _KJUR = KJUR,
-1536 	_KJUR_asn1 = _KJUR.asn1;
-1537 
-1538     this.setPurposeArray = function(purposeArray) {
-1539         this.asn1ExtnValue = new _KJUR_asn1.DERSequence();
-1540         for (var i = 0; i < purposeArray.length; i++) {
-1541             var o = new _KJUR_asn1.DERObjectIdentifier(purposeArray[i]);
-1542             this.asn1ExtnValue.appendASN1Object(o);
-1543         }
-1544     };
-1545 
-1546     this.getExtnValueHex = function() {
-1547         return this.asn1ExtnValue.tohex();
-1548     };
-1549 
-1550     this.oid = "2.5.29.37";
-1551     if (params !== undefined) {
-1552         if (params.array !== undefined) {
-1553             this.setPurposeArray(params.array);
-1554         }
-1555     }
-1556 };
-1557 extendClass(KJUR.asn1.x509.ExtKeyUsage, KJUR.asn1.x509.Extension);
-1558 
-1559 /**
-1560  * AuthorityKeyIdentifier ASN.1 structure class
-1561  * @name KJUR.asn1.x509.AuthorityKeyIdentifier
-1562  * @class AuthorityKeyIdentifier ASN.1 structure class
-1563  * @param {Array} params associative array of parameters (ex. {kid: {hex: '89ab...'}, critical: true})
-1564  * @extends KJUR.asn1.x509.Extension
-1565  * @since asn1x509 1.0.8
-1566  * @description
-1567  * This class represents ASN.1 structure for <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.1">AuthorityKeyIdentifier in RFC 5280</a>.
-1568  * Constructor of this class may have following parameters.: 
-1569  * <ul>
-1570  * <li>kid - When key object (RSA, KJUR.crypto.ECDSA/DSA) or PEM string of issuing authority public key or issuer certificate is specified, key identifier will be automatically calculated by the method specified in RFC 5280. When a hexadecimal string is specifed, kid will be set explicitly by it.</li>
-1571  * <li>isscert - When PEM string of authority certificate is specified, both authorityCertIssuer and authorityCertSerialNumber will be set by the certificate.</li>
-1572  * <li>issuer - {@link KJUR.asn1.x509.X500Name} parameter to specify issuer name explicitly.</li>
-1573  * <li>sn - hexadecimal string to specify serial number explicitly.</li>
-1574  * <li>critical - boolean to specify criticality of this extension
-1575  * however conforming CA must mark this extension as non-critical in RFC 5280.</li>
-1576  * </ul>
-1577  * 
-1578  * <pre>
-1579  * d-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 35 }
-1580  * AuthorityKeyIdentifier ::= SEQUENCE {
-1581  *    keyIdentifier             [0] KeyIdentifier           OPTIONAL,
-1582  *    authorityCertIssuer       [1] GeneralNames            OPTIONAL,
-1583  *    authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL  }
-1584  * KeyIdentifier ::= OCTET STRING
-1585  * </pre>
-1586  *
-1587  * @example
-1588  * // 1. kid by key object
-1589  * keyobj = KEYUTIL.getKey("-----BEGIN PUBLIC KEY...");
-1590  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: keyobj});
-1591  * // 2. kid by PEM string of authority certificate or public key
-1592  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: "-----BEGIN..."});
-1593  * // 3. specify kid explicitly
-1594  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: "8ab1d3..."});
-1595  * });
-1596  * // 4. issuer and serial number by auhtority PEM certificate
-1597  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({isscert: "-----BEGIN..."});
-1598  * // 5. issuer and serial number explicitly
-1599  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({
-1600  *   issuer: {ldapstr: "O=test,C=US"},
-1601  *   sn: {hex: "1ac7..."}});
-1602  * // 6. combination
-1603  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({
-1604  *   kid: "-----BEGIN CERTIFICATE...",
-1605  *   isscert: "-----BEGIN CERTIFICATE..."});
-1606  */
-1607 KJUR.asn1.x509.AuthorityKeyIdentifier = function(params) {
-1608     KJUR.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this, params);
-1609     var _KJUR = KJUR,
-1610 	_KJUR_asn1 = _KJUR.asn1,
-1611 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
-1612 	_GeneralNames = _KJUR_asn1.x509.GeneralNames,
-1613 	_isKey = _KJUR.crypto.Util.isKey;
-1614 
-1615     this.asn1KID = null;
-1616     this.asn1CertIssuer = null; // X500Name hTLV
-1617     this.asn1CertSN = null;
-1618 
-1619     this.getExtnValueHex = function() {
-1620         var a = new Array();
-1621         if (this.asn1KID)
-1622             a.push(new _DERTaggedObject({'explicit': false,
-1623                                          'tag': '80',
-1624                                          'obj': this.asn1KID}));
-1625 
-1626         if (this.asn1CertIssuer)
-1627             a.push(new _DERTaggedObject({'explicit': false,
-1628                                          'tag': 'a1',
-1629                                          'obj': new _GeneralNames([{dn: this.asn1CertIssuer}])}));
-1630 
-1631         if (this.asn1CertSN)
-1632             a.push(new _DERTaggedObject({'explicit': false,
-1633                                          'tag': '82',
-1634                                          'obj': this.asn1CertSN}));
-1635 
-1636         var asn1Seq = new _KJUR_asn1.DERSequence({'array': a});
-1637         this.asn1ExtnValue = asn1Seq;
-1638         return this.asn1ExtnValue.tohex();
-1639     };
-1640 
-1641     /**
-1642      * set keyIdentifier value by DEROctetString parameter, key object or PEM file
-1643      * @name setKIDByParam
-1644      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
-1645      * @function
-1646      * @param {Array} param parameter to set key identifier
-1647      * @since asn1x509 1.0.8
-1648      * @description
-1649      * This method will set keyIdentifier by param.
-1650      * Its key identifier value can be set by following type of param argument:
-1651      * <ul>
-1652      * <li>{str: "123"} - by raw string</li>
-1653      * <li>{hex: "01af..."} - by hexadecimal value</li>
-1654      * <li>RSAKey/DSA/ECDSA - by RSAKey, KJUR.crypto.{DSA/ECDSA} public key object.
-1655      * key identifier value will be calculated by the method described in
-1656      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1657      * </li>
-1658      * <li>certificate PEM string - extract subjectPublicKeyInfo from specified PEM
-1659      * certificate and
-1660      * key identifier value will be calculated by the method described in
-1661      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1662      * <li>PKCS#1/#8 public key PEM string - pem will be converted to a key object and
-1663      * to PKCS#8 ASN.1 structure then calculate 
-1664      * a key identifier value will be calculated by the method described in
-1665      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1666      * </ul>
-1667      *
-1668      * NOTE1: Automatic key identifier calculation is supported
-1669      * since jsrsasign 8.0.16.
-1670      *
-1671      * @see KEYUTIL.getKeyID
-1672      * 
-1673      * @example
-1674      * o = new KJUR.asn1.x509.AuthorityKeyIdentifier();
-1675      * // set by hexadecimal string
-1676      * o.setKIDByParam({hex: '1ad9...'});
-1677      * // set by SubjectPublicKeyInfo of PEM certificate string
-1678      * o.setKIDByParam("-----BEGIN CERTIFICATE...");
-1679      * // set by PKCS#8 PEM public key string
-1680      * o.setKIDByParam("-----BEGIN PUBLIC KEY...");
-1681      * // set by public key object
-1682      * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
-1683      * o.setKIDByParam(pubkey);
-1684      */
-1685     this.setKIDByParam = function(param) {
-1686 	if (param.str !== undefined ||
-1687 	    param.hex !== undefined) {
-1688 	    this.asn1KID = new KJUR.asn1.DEROctetString(param);
-1689 	} else if ((typeof param === "object" &&
-1690 		    KJUR.crypto.Util.isKey(param)) ||
-1691 		   (typeof param === "string" &&
-1692 		    param.indexOf("BEGIN ") != -1)) {
-1693 
-1694 	    var keyobj = param;
-1695 	    if (typeof param === "string") {
-1696 		keyobj = KEYUTIL.getKey(param);
-1697 	    }
-1698 
-1699 	    var kid = KEYUTIL.getKeyID(keyobj);
-1700 	    this.asn1KID = new KJUR.asn1.DEROctetString({hex: kid});
-1701 	}
-1702     };
-1703 
-1704     /**
-1705      * set authorityCertIssuer value by X500Name parameter
-1706      * @name setCertIssuerByParam
-1707      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
-1708      * @function
-1709      * @param {Array} param parameter to set issuer name
-1710      * @since asn1x509 1.0.8
-1711      * @description
-1712      * This method will set authorityCertIssuer name by param.
-1713      * Issuer name can be set by following type of param argument:
-1714      * <ul>
-1715      * <li>str/ldapstr/hex/certsubject/certissuer - 
-1716      * set issuer by {@link KJUR.asn1.x509.X500Name}
-1717      * object with specified parameters.</li>
-1718      * <li>PEM CERTIFICATE STRING - extract its subject name from 
-1719      * specified issuer PEM certificate and set.
-1720      * </ul>
-1721      * NOTE1: Automatic authorityCertIssuer setting by certificate
-1722      * is supported since jsrsasign 8.0.16.
-1723      *
-1724      * @see KJUR.asn1.x509.X500Name
-1725      * @see KJUR.asn1.x509.GeneralNames
-1726      * @see X509.getSubjectHex
-1727      *
-1728      * @example
-1729      * var o = new KJUR.asn1.x509.AuthorityKeyIdentifier();
-1730      * // 1. set it by string
-1731      * o.setCertIssuerByParam({str: '/C=US/O=Test'});
-1732      * // 2. set it by issuer PEM certificate
-1733      * o.setCertIssuerByParam("-----BEGIN CERTIFICATE...");
-1734      *
-1735      */
-1736     this.setCertIssuerByParam = function(param) {
-1737 	if (param.str !== undefined ||
-1738 	    param.ldapstr !== undefined ||
-1739 	    param.hex !== undefined ||
-1740 	    param.certsubject !== undefined ||
-1741 	    param.certissuer !== undefined) {
-1742             this.asn1CertIssuer = new KJUR.asn1.x509.X500Name(param);
-1743 	} else if (typeof param === "string" &&
-1744 		   param.indexOf("BEGIN ") != -1 &&
-1745 		   param.indexOf("CERTIFICATE") != -1) {
-1746             this.asn1CertIssuer = new KJUR.asn1.x509.X500Name({certissuer: param});
-1747 	}
-1748     };
-1749 
-1750     /**
-1751      * set authorityCertSerialNumber value
-1752      * @name setCertSerialNumberByParam
-1753      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
-1754      * @function
-1755      * @param {Object} param parameter to set serial number
-1756      * @since asn1x509 1.0.8
-1757      * @description
-1758      * This method will set authorityCertSerialNumber by param.
-1759      * Serial number can be set by following type of param argument:
-1760      *
-1761      * <ul>
-1762      * <li>{int: 123} - by integer value</li>
-1763      * <li>{hex: "01af"} - by hexadecimal integer value</li>
-1764      * <li>{bigint: new BigInteger(...)} - by hexadecimal integer value</li>
-1765      * <li>PEM CERTIFICATE STRING - extract serial number from issuer certificate and
-1766      * set serial number.
-1767      * 
-1768      * NOTE1: Automatic authorityCertSerialNumber setting by certificate
-1769      * is supported since jsrsasign 8.0.16.
-1770      *
-1771      * @see X509.getSerialNumberHex
-1772      */
-1773     this.setCertSNByParam = function(param) {
-1774 	if (param.str !== undefined ||
-1775 	    param.bigint !== undefined ||
-1776 	    param.hex !== undefined) {
-1777             this.asn1CertSN = new KJUR.asn1.DERInteger(param);
-1778 	} else if (typeof param === "string" &&
-1779 		   param.indexOf("BEGIN ") != -1 &&
-1780 		   param.indexOf("CERTIFICATE")) {
-1781 
-1782             var x = new X509();
-1783             x.readCertPEM(param);
-1784 	    var sn = x.getSerialNumberHex();
-1785 	    this.asn1CertSN = new KJUR.asn1.DERInteger({hex: sn});
-1786 	}
-1787     };
-1788 
-1789     this.oid = "2.5.29.35";
-1790     if (params !== undefined) {
-1791         if (params.kid !== undefined) {
-1792             this.setKIDByParam(params.kid);
-1793         }
-1794         if (params.issuer !== undefined) {
-1795             this.setCertIssuerByParam(params.issuer);
-1796         }
-1797         if (params.sn !== undefined) {
-1798             this.setCertSNByParam(params.sn);
-1799         }
-1800 
-1801 	if (params.issuersn !== undefined &&
-1802 	    typeof params.issuersn === "string" &&
-1803 	    params.issuersn.indexOf("BEGIN ") != -1 &&
-1804 	    params.issuersn.indexOf("CERTIFICATE")) {
-1805 	    this.setCertSNByParam(params.issuersn);
-1806 	    this.setCertIssuerByParam(params.issuersn);
-1807 	}
-1808     }
-1809 };
-1810 extendClass(KJUR.asn1.x509.AuthorityKeyIdentifier, KJUR.asn1.x509.Extension);
-1811 
-1812 /**
-1813  * SubjectKeyIdentifier extension ASN.1 structure class
-1814  * @name KJUR.asn1.x509.SubjectKeyIdentifier
-1815  * @class SubjectKeyIdentifier ASN.1 structure class
-1816  * @param {Array} params associative array of parameters (ex. {kid: {hex: '89ab...'}, critical: true})
-1817  * @extends KJUR.asn1.x509.Extension
-1818  * @since asn1x509 1.1.7 jsrsasign 8.0.14
-1819  * @description
-1820  * This class represents ASN.1 structure for 
-1821  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">
-1822  * SubjectKeyIdentifier in RFC 5280</a>.
-1823  * Constructor of this class may have following parameters:
-1824  * <ul>
-1825  * <li>kid - When key object (RSA, KJUR.crypto.ECDSA/DSA) or PEM string of subject public key or certificate is specified, key identifier will be automatically calculated by the method specified in RFC 5280. When a hexadecimal string is specifed, kid will be set explicitly by it.</li>
-1826  * <li>critical - boolean to specify criticality of this extension
-1827  * however conforming CA must mark this extension as non-critical in RFC 5280.</li>
-1828  * </ul>
-1829  * <pre>
-1830  * d-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 14 }
-1831  * SubjectKeyIdentifier ::= KeyIdentifier
-1832  * KeyIdentifier ::= OCTET STRING
-1833  * </pre>
-1834  *
-1835  * @example
-1836  * // set by hexadecimal string
-1837  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: {hex: '89ab'}});
-1838  * // set by PEM public key or certificate string
-1839  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: "-----BEGIN CERTIFICATE..."});
-1840  * // set by public key object
-1841  * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
-1842  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: pubkey});
-1843  */
-1844 KJUR.asn1.x509.SubjectKeyIdentifier = function(params) {
-1845     KJUR.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this, params);
-1846     var _KJUR = KJUR,
-1847 	_KJUR_asn1 = _KJUR.asn1,
-1848 	_DEROctetString = _KJUR_asn1.DEROctetString;
-1849 
-1850     this.asn1KID = null;
-1851 
-1852     this.getExtnValueHex = function() {
-1853         this.asn1ExtnValue = this.asn1KID;
-1854         return this.asn1ExtnValue.tohex();
-1855     };
-1856 
-1857     /**
-1858      * set keyIdentifier value by DEROctetString parameter, key object or PEM file
-1859      * @name setKIDByParam
-1860      * @memberOf KJUR.asn1.x509.SubjectKeyIdentifier#
-1861      * @function
-1862      * @param {Array} param array of {@link KJUR.asn1.DERInteger} parameter
-1863      * @since asn1x509 1.1.7 jsrsasign 8.0.14
-1864      * @description
-1865      * <ul>
-1866      * <li>{str: "123"} - by raw string</li>
-1867      * <li>{hex: "01af..."} - by hexadecimal value</li>
-1868      * <li>RSAKey/DSA/ECDSA - by RSAKey, KJUR.crypto.{DSA/ECDSA} public key object.
-1869      * key identifier value will be calculated by the method described in
-1870      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1871      * </li>
-1872      * <li>certificate PEM string - extract subjectPublicKeyInfo from specified PEM
-1873      * certificate and
-1874      * key identifier value will be calculated by the method described in
-1875      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1876      * <li>PKCS#1/#8 public key PEM string - pem will be converted to a key object and
-1877      * to PKCS#8 ASN.1 structure then calculate 
-1878      * a key identifier value will be calculated by the method described in
-1879      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
-1880      * </ul>
-1881      *
-1882      * NOTE1: Automatic key identifier calculation is supported
-1883      * since jsrsasign 8.0.16.
-1884      *
-1885      * @see KEYUTIL.getKeyID
-1886      *
-1887      * @example
-1888      * o = new KJUR.asn1.x509.SubjectKeyIdentifier();
-1889      * // set by hexadecimal string
-1890      * o.setKIDByParam({hex: '1ad9...'});
-1891      * // set by SubjectPublicKeyInfo of PEM certificate string
-1892      * o.setKIDByParam("-----BEGIN CERTIFICATE...");
-1893      * // set by PKCS#8 PEM public key string
-1894      * o.setKIDByParam("-----BEGIN PUBLIC KEY...");
-1895      * // set by public key object
-1896      * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
-1897      * o.setKIDByParam(pubkey);
-1898      */
-1899     this.setKIDByParam = function(param) {
-1900 	if (param.str !== undefined ||
-1901 	    param.hex !== undefined) {
-1902 	    this.asn1KID = new _DEROctetString(param);
-1903 	} else if ((typeof param === "object" &&
-1904 		    KJUR.crypto.Util.isKey(param)) ||
-1905 		   (typeof param === "string" &&
-1906 		    param.indexOf("BEGIN") != -1)) {
-1907 
-1908 	    var keyobj = param;
-1909 	    if (typeof param === "string") {
-1910 		keyobj = KEYUTIL.getKey(param);
-1911 	    }
-1912 
-1913 	    var kid = KEYUTIL.getKeyID(keyobj);
-1914 	    this.asn1KID = new KJUR.asn1.DEROctetString({hex: kid});
-1915 	}
-1916     };
-1917 
-1918     this.oid = "2.5.29.14";
-1919     if (params !== undefined) {
-1920 	if (params.kid !== undefined) {
-1921 	    this.setKIDByParam(params.kid);
-1922 	}
-1923     }
-1924 };
-1925 extendClass(KJUR.asn1.x509.SubjectKeyIdentifier, KJUR.asn1.x509.Extension);
-1926 
-1927 /**
-1928  * AuthorityInfoAccess ASN.1 structure class
-1929  * @name KJUR.asn1.x509.AuthorityInfoAccess
-1930  * @class AuthorityInfoAccess ASN.1 structure class
-1931  * @param {Array} params JSON object of AuthorityInfoAccess parameters
-1932  * @extends KJUR.asn1.x509.Extension
-1933  * @since asn1x509 1.0.8
-1934  * @see {@link X509#getExtAuthorityInfoAccess}
-1935  * @description
-1936  * This class represents 
-1937  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.2.1">
-1938  * AuthorityInfoAccess extension defined in RFC 5280 4.2.2.1</a>.
-1939  * <pre>
-1940  * id-pe OBJECT IDENTIFIER  ::=  { id-pkix 1 }
-1941  * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
-1942  * AuthorityInfoAccessSyntax  ::=
-1943  *         SEQUENCE SIZE (1..MAX) OF AccessDescription
-1944  * AccessDescription  ::=  SEQUENCE {
-1945  *         accessMethod          OBJECT IDENTIFIER,
-1946  *         accessLocation        GeneralName  }
-1947  * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
-1948  * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
-1949  * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
-1950  * </pre>
-1951  * NOTE: Acceptable parameters have been changed since
-1952  * from jsrsasign 9.0.0 asn1x509 2.0.0.
-1953  * Parameter generated by {@link X509#getAuthorityInfoAccess}
-1954  * can be accepted as a argument of this constructor.
-1955  * @example
-1956  * e1 = new KJUR.asn1.x509.AuthorityInfoAccess({
-1957  *   array: [
-1958  *     {ocsp: 'http://ocsp.example.org'},
-1959  *     {caissuer: 'https://repository.example.org/aaa.crt'}
-1960  *   ]
-1961  * });
-1962  */
-1963 KJUR.asn1.x509.AuthorityInfoAccess = function(params) {
-1964     KJUR.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this, params);
-1965 
-1966     this.setAccessDescriptionArray = function(aParam) {
-1967         var aASN1 = new Array(),
-1968 	    _KJUR = KJUR,
-1969 	    _KJUR_asn1 = _KJUR.asn1,
-1970 	    _DERSequence = _KJUR_asn1.DERSequence,
-1971 	    _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-1972 	    _GeneralName = _KJUR_asn1.x509.GeneralName;
-1973 
-1974         for (var i = 0; i < aParam.length; i++) {
-1975 	    var adseq;
-1976 	    var adparam = aParam[i];
-1977 
-1978 	    if (adparam.ocsp !== undefined) {
-1979 		adseq = new _DERSequence({array: [
-1980 		    new _DERObjectIdentifier({oid: "1.3.6.1.5.5.7.48.1"}),
-1981 		    new _GeneralName({uri: adparam.ocsp})
-1982 		]});
-1983 	    } else if (adparam.caissuer !== undefined) {
-1984 		adseq = new _DERSequence({array: [
-1985 		    new _DERObjectIdentifier({oid: "1.3.6.1.5.5.7.48.2"}),
-1986 		    new _GeneralName({uri: adparam.caissuer})
-1987 		]});
-1988 	    } else {
-1989 		throw new Error("unknown AccessMethod parameter: " +
-1990 				JSON.stringify(adparam));
-1991 	    }
-1992 	    aASN1.push(adseq);
-1993         }
-1994         this.asn1ExtnValue = new _DERSequence({'array':aASN1});
-1995     };
-1996 
-1997     this.getExtnValueHex = function() {
-1998         return this.asn1ExtnValue.tohex();
-1999     };
-2000 
-2001     this.oid = "1.3.6.1.5.5.7.1.1";
-2002     if (params !== undefined) {
-2003         if (params.array !== undefined) {
-2004             this.setAccessDescriptionArray(params.array);
-2005         }
-2006     }
-2007 };
-2008 extendClass(KJUR.asn1.x509.AuthorityInfoAccess, KJUR.asn1.x509.Extension);
-2009 
-2010 /**
-2011  * SubjectAltName ASN.1 structure class<br/>
-2012  * @name KJUR.asn1.x509.SubjectAltName
-2013  * @class SubjectAltName ASN.1 structure class
-2014  * @param {Array} params associative array of parameters
-2015  * @extends KJUR.asn1.x509.Extension
-2016  * @since jsrsasign 6.2.3 asn1x509 1.0.19
-2017  * @see KJUR.asn1.x509.GeneralNames
-2018  * @see KJUR.asn1.x509.GeneralName
-2019  * @description
-2020  * This class provides X.509v3 SubjectAltName extension.
-2021  * <pre>
-2022  * id-ce-subjectAltName OBJECT IDENTIFIER ::=  { id-ce 17 }
-2023  * SubjectAltName ::= GeneralNames
-2024  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
-2025  * GeneralName ::= CHOICE {
-2026  *   otherName                  [0] OtherName,
-2027  *   rfc822Name                 [1] IA5String,
-2028  *   dNSName                    [2] IA5String,
-2029  *   x400Address                [3] ORAddress,
-2030  *   directoryName              [4] Name,
-2031  *   ediPartyName               [5] EDIPartyName,
-2032  *   uniformResourceIdentifier  [6] IA5String,
-2033  *   iPAddress                  [7] OCTET STRING,
-2034  *   registeredID               [8] OBJECT IDENTIFIER }
-2035  * </pre>
-2036  * @example
-2037  * e1 = new KJUR.asn1.x509.SubjectAltName({
-2038  *   critical: true,
-2039  *   array: [{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]
-2040  * });
-2041  */
-2042 KJUR.asn1.x509.SubjectAltName = function(params) {
-2043     KJUR.asn1.x509.SubjectAltName.superclass.constructor.call(this, params)
-2044 
-2045     this.setNameArray = function(paramsArray) {
-2046 	this.asn1ExtnValue = new KJUR.asn1.x509.GeneralNames(paramsArray);
-2047     };
-2048 
-2049     this.getExtnValueHex = function() {
-2050         return this.asn1ExtnValue.tohex();
-2051     };
-2052 
-2053     this.oid = "2.5.29.17";
-2054     if (params !== undefined) {
-2055         if (params.array !== undefined) {
-2056             this.setNameArray(params.array);
-2057         }
-2058     }
-2059 };
-2060 extendClass(KJUR.asn1.x509.SubjectAltName, KJUR.asn1.x509.Extension);
-2061 
-2062 /**
-2063  * IssuerAltName ASN.1 structure class<br/>
-2064  * @name KJUR.asn1.x509.IssuerAltName
-2065  * @class IssuerAltName ASN.1 structure class
-2066  * @param {Array} params associative array of parameters
-2067  * @extends KJUR.asn1.x509.Extension
-2068  * @since jsrsasign 6.2.3 asn1x509 1.0.19
-2069  * @see KJUR.asn1.x509.GeneralNames
-2070  * @see KJUR.asn1.x509.GeneralName
-2071  * @description
-2072  * This class provides X.509v3 IssuerAltName extension.
-2073  * <pre>
-2074  * id-ce-subjectAltName OBJECT IDENTIFIER ::=  { id-ce 18 }
-2075  * IssuerAltName ::= GeneralNames
-2076  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
-2077  * GeneralName ::= CHOICE {
-2078  *   otherName                  [0] OtherName,
-2079  *   rfc822Name                 [1] IA5String,
-2080  *   dNSName                    [2] IA5String,
-2081  *   x400Address                [3] ORAddress,
-2082  *   directoryName              [4] Name,
-2083  *   ediPartyName               [5] EDIPartyName,
-2084  *   uniformResourceIdentifier  [6] IA5String,
-2085  *   iPAddress                  [7] OCTET STRING,
-2086  *   registeredID               [8] OBJECT IDENTIFIER }
-2087  * </pre>
-2088  * @example
-2089  * e1 = new KJUR.asn1.x509.IssuerAltName({
-2090  *   critical: true,
-2091  *   array: [{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]
-2092  * });
-2093  */
-2094 KJUR.asn1.x509.IssuerAltName = function(params) {
-2095     KJUR.asn1.x509.IssuerAltName.superclass.constructor.call(this, params)
-2096 
-2097     this.setNameArray = function(paramsArray) {
-2098 	this.asn1ExtnValue = new KJUR.asn1.x509.GeneralNames(paramsArray);
-2099     };
-2100 
-2101     this.getExtnValueHex = function() {
-2102         return this.asn1ExtnValue.tohex();
-2103     };
-2104 
-2105     this.oid = "2.5.29.18";
-2106     if (params !== undefined) {
-2107         if (params.array !== undefined) {
-2108             this.setNameArray(params.array);
-2109         }
-2110     }
-2111 };
-2112 extendClass(KJUR.asn1.x509.IssuerAltName, KJUR.asn1.x509.Extension);
-2113 
-2114 /**
-2115  * SubjectDirectoryAttributes ASN.1 structure class<br/>
-2116  * @name KJUR.asn1.x509.SubjectDirectoryAttributes
-2117  * @class SubjectDirectoryAttributes ASN.1 structure class
-2118  * @param {Array} params associative array of parameters
-2119  * @extends KJUR.asn1.x509.Extension
-2120  * @since jsrsasign 10.1.9 asn1x509 2.1.7
-2121  * @description
-2122  * This class provides X.509v3 SubjectDirectoryAttributes extension
-2123  * defined in <a href="https://tools.ietf.org/html/rfc3739#section-3.3.2">
-2124  * RFC 3739 Qualified Certificate Profile section 3.3.2</a>.
-2125  * <pre>
-2126  * SubjectDirectoryAttributes ::= Attributes
-2127  * Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
-2128  * Attribute ::= SEQUENCE {
-2129  *   type AttributeType 
-2130  *   values SET OF AttributeValue }
-2131  * AttributeType ::= OBJECT IDENTIFIER
-2132  * AttributeValue ::= ANY DEFINED BY AttributeType
-2133  * </pre>
-2134  * @example
-2135  * e1 = new KJUR.asn1.x509.SubjectDirectoryAttributes({
-2136  *   extname: "subjectDirectoryAttributes",
-2137  *   array: [
-2138  *     { attr: "dateOfBirth", str: "19701231230000Z" },
-2139  *     { attr: "placeOfBirth", str: "Tokyo" },
-2140  *     { attr: "gender", str: "F" },
-2141  *     { attr: "countryOfCitizenship", str: "JP" },
-2142  *     { attr: "countryOfResidence", str: "JP" }
-2143  *   ]
-2144  * });
-2145  */
-2146 KJUR.asn1.x509.SubjectDirectoryAttributes = function(params) {
-2147     KJUR.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this, params);
-2148     var _KJUR_asn1 = KJUR.asn1,
-2149 	_DERSequence = _KJUR_asn1.DERSequence,
-2150 	_newObject = _KJUR_asn1.ASN1Util.newObject,
-2151 	_name2oid = _KJUR_asn1.x509.OID.name2oid;
-2152 
-2153     this.params = null;
-2154 
-2155     this.getExtnValueHex = function() {
-2156 	var a = [];
-2157 	for (var i = 0; i < this.params.array.length; i++) {
-2158 	    var pAttr = this.params.array[i];
-2159 
-2160 	    var newparam = {
-2161 		"seq": [
-2162 		    {"oid": "1.2.3.4"},
-2163 		    {"set": [{"utf8str": "DE"}]}
-2164 		]
-2165 	    };
-2166 
-2167 	    if (pAttr.attr == "dateOfBirth") {
-2168 		newparam.seq[0].oid = _name2oid(pAttr.attr);
-2169 		newparam.seq[1].set[0] = {"gentime": pAttr.str};
-2170 	    } else if (pAttr.attr == "placeOfBirth") {
-2171 		newparam.seq[0].oid = _name2oid(pAttr.attr);
-2172 		newparam.seq[1].set[0] = {"utf8str": pAttr.str};
-2173 	    } else if (pAttr.attr == "gender") {
-2174 		newparam.seq[0].oid = _name2oid(pAttr.attr);
-2175 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
-2176 	    } else if (pAttr.attr == "countryOfCitizenship") {
-2177 		newparam.seq[0].oid = _name2oid(pAttr.attr);
-2178 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
-2179 	    } else if (pAttr.attr == "countryOfResidence") {
-2180 		newparam.seq[0].oid = _name2oid(pAttr.attr);
-2181 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
-2182 	    } else {
-2183 		throw new Error("unsupported attribute: " + pAttr.attr);
-2184 	    }
-2185 	    a.push(new _newObject(newparam));
-2186 	}
-2187 	var seq = new _DERSequence({array: a});
-2188 	this.asn1ExtnValue = seq;
-2189         return this.asn1ExtnValue.tohex();
-2190     };
-2191 
-2192     this.oid = "2.5.29.9";
-2193     if (params !== undefined) {
-2194 	this.params = params;
-2195     }
-2196 };
-2197 extendClass(KJUR.asn1.x509.SubjectDirectoryAttributes, KJUR.asn1.x509.Extension);
-2198 
-2199 
-2200 /**
-2201  * priavte extension ASN.1 structure class<br/>
-2202  * @name KJUR.asn1.x509.PrivateExtension
-2203  * @class private extension ASN.1 structure class
-2204  * @param {Array} params JSON object of private extension
-2205  * @extends KJUR.asn1.x509.Extension
-2206  * @since jsrsasign 9.1.1 asn1x509 
-2207  * @see KJUR.asn1.ASN1Util.newObject
-2208  *
-2209  * @description
-2210  * This class is to represent private extension or 
-2211  * unsupported extension. 
-2212  * <pre>
-2213  * Extension  ::=  SEQUENCE  {
-2214  *      extnID      OBJECT IDENTIFIER,
-2215  *      critical    BOOLEAN DEFAULT FALSE,
-2216  *      extnValue   OCTET STRING }
-2217  * </pre>
-2218  * Following properties can be set for JSON parameter:
-2219  * <ul>
-2220  * <li>{String}extname - string of OID or predefined extension name</li>
-2221  * <li>{Boolean}critical - critical flag</li>
-2222  * <li>{Object}extn - hexadecimal string or 
-2223  * of {@link KJUR.asn1.ASN1Util.newObject} 
-2224  * JSON parameter for extnValue field</li>
-2225  * </li>
-2226  * </ul>
-2227  *
-2228  * @example
-2229  * // extn by hexadecimal
-2230  * new KJUR.asn1.x509.PrivateExtension({
-2231  *   extname: "1.2.3.4",
-2232  *   critical: true,
-2233  *   extn: "13026161" // means PrintableString "aa"
-2234  * });
-2235  *
-2236  * // extn by JSON parameter
-2237  * new KJUR.asn1.x509.PrivateExtension({
-2238  *   extname: "1.2.3.5",
-2239  *   extn: {seq: [{prnstr:"abc"},{utf8str:"def"}]}
-2240  * });
-2241  */
-2242 KJUR.asn1.x509.PrivateExtension = function(params) {
-2243     KJUR.asn1.x509.PrivateExtension.superclass.constructor.call(this, params)
-2244 
-2245     var _KJUR = KJUR,
-2246 	_isHex = _KJUR.lang.String.isHex,
-2247 	_KJUR_asn1 = _KJUR.asn1,
-2248 	_name2oid = _KJUR_asn1.x509.OID.name2oid,
-2249 	_newObject = _KJUR_asn1.ASN1Util.newObject;
-2250 
-2251     this.params = null;
-2252 
-2253     this.setByParam = function(params) {
-2254 	this.oid = _name2oid(params.extname);
-2255 	this.params = params;
-2256     };
-2257 
-2258     this.getExtnValueHex = function() {
-2259 	if (this.params.extname == undefined ||
-2260 	    this.params.extn == undefined) {
-2261 	    throw new Error("extname or extnhex not specified");
-2262 	}
-2263 
-2264 	var extn = this.params.extn;
-2265 	if (typeof extn == "string" && _isHex(extn)) {
-2266 	    return extn;
-2267 	} else if (typeof extn == "object") {
-2268 	    try {
-2269 		return _newObject(extn).tohex();
-2270 	    } catch(ex) {}
-2271 	}
-2272 	throw new Error("unsupported extn value");
-2273     };
-2274 
-2275     if (params != undefined) {
-2276 	this.setByParam(params);
-2277     }
-2278 };
-2279 extendClass(KJUR.asn1.x509.PrivateExtension, KJUR.asn1.x509.Extension);
-2280 
-2281 // === END   X.509v3 Extensions Related =======================================
-2282 
-2283 // === BEGIN CRL Related ===================================================
-2284 /**
-2285  * X.509 CRL class to sign and generate hex encoded CRL<br/>
-2286  * @name KJUR.asn1.x509.CRL
-2287  * @class X.509 CRL class to sign and generate hex encoded certificate
-2288  * @property {Array} params JSON object of parameters
-2289  * @param {Array} params JSON object of CRL parameters
-2290  * @extends KJUR.asn1.ASN1Object
-2291  * @since 1.0.3
-2292  * @see KJUR.asn1.x509.TBSCertList
-2293  * 
-2294  * @description
-2295  * This class represents CertificateList ASN.1 structur of X.509 CRL
-2296  * defined in <a href="https://tools.ietf.org/html/rfc5280#section-5.1">
-2297  * RFC 5280 5.1</a>
-2298  * <pre>
-2299  * CertificateList  ::=  SEQUENCE  {
-2300  *     tbsCertList          TBSCertList,
-2301  *     signatureAlgorithm   AlgorithmIdentifier,
-2302  *     signatureValue       BIT STRING  }
-2303  * </pre>
-2304  * NOTE: CRL class is updated without backward 
-2305  * compatibility from jsrsasign 9.1.0 asn1x509 2.1.0.
-2306  * Most of methods are removed and parameters can be set
-2307  * by JSON object.
-2308  * <br/>
-2309  * Constructor of this class can accept all
-2310  * parameters of {@link KJUR.asn1.x509.TBSCertList}.
-2311  * It also accept following parameters additionally:
-2312  * <ul>
-2313  * <li>{TBSCertList}tbsobj (OPTION) - 
-2314  * specifies {@link KJUR.asn1.x509.TBSCertList} 
-2315  * object to be signed if needed. 
-2316  * When this isn't specified, 
-2317  * this will be set from other parametes of TBSCertList.</li>
-2318  * <li>{Object}cakey (OPTION) - specifies CRL signing private key.
-2319  * Parameter "cakey" or "sighex" shall be specified. Following
-2320  * values can be specified:
-2321  *   <ul>
-2322  *   <li>PKCS#1/5 or PKCS#8 PEM string of private key</li>
-2323  *   <li>RSAKey/DSA/ECDSA key object. {@link KEYUTIL.getKey} is useful
-2324  *   to generate a key object.</li>
-2325  *   </ul>
-2326  * </li>
-2327  * <li>{String}sighex (OPTION) - hexadecimal string of signature value
-2328  * (i.e. ASN.1 value(V) of signatureValue BIT STRING without
-2329  * unused bits)</li>
-2330  * </ul>
-2331  *
-2332  * @example
-2333  * var crl = new KJUR.asn1.x509.CRL({
-2334  *  sigalg: "SHA256withRSA",
-2335  *  issuer: {str:'/C=JP/O=Test1'},
-2336  *  thisupdate: "200821235959Z",
-2337  *  nextupdate: "200828235959Z", // OPTION
-2338  *  revcert: [{sn: {hex: "12ab"}, date: "200401235959Z"}],
-2339  *  ext: [
-2340  *   {extname: "cRLNumber", num: {'int': 8}},
-2341  *   {extname: "authorityKeyIdentifier", "kid": {hex: "12ab"}}
-2342  *  ],
-2343  *  cakey: prvkey
-2344  * });
-2345  * crl.gettohex() → "30..."
-2346  * crl.getPEM() → "-----BEGIN X509 CRL..."
-2347  */
-2348 KJUR.asn1.x509.CRL = function(params) {
-2349     KJUR.asn1.x509.CRL.superclass.constructor.call(this);
-2350     var _KJUR = KJUR,
-2351 	_KJUR_asn1 = _KJUR.asn1,
-2352 	_DERSequence = _KJUR_asn1.DERSequence,
-2353 	_DERBitString = _KJUR_asn1.DERBitString,
-2354 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-2355 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
-2356 	_TBSCertList = _KJUR_asn1_x509.TBSCertList;
-2357 
-2358     this.params = undefined;
-2359 
-2360     this.setByParam = function(params) {
-2361 	this.params = params;
-2362     };
-2363 
-2364     /**
-2365      * sign CRL<br/>
-2366      * @name sign
-2367      * @memberOf KJUR.asn1.x509.CRL#
-2368      * @function
-2369      * @description
-2370      * This method signs TBSCertList with a specified 
-2371      * private key and algorithm by 
-2372      * this.params.cakey and this.params.sigalg parameter.
-2373      * @example
-2374      * crl = new KJUR.asn1.x509.CRL({..., cakey:prvkey});
-2375      * crl.sign()
-2376      */
-2377     this.sign = function() {
-2378 	var hTBSCL = (new _TBSCertList(this.params)).tohex();
-2379 	var sig = new KJUR.crypto.Signature({alg: this.params.sigalg});
-2380 	sig.init(this.params.cakey);
-2381 	sig.updateHex(hTBSCL);
-2382 	var sighex = sig.sign();
-2383 	this.params.sighex = sighex;
-2384     };
-2385 
-2386     /**
-2387      * get PEM formatted CRL string after signed<br/>
-2388      * @name getPEM
-2389      * @memberOf KJUR.asn1.x509.CRL#
-2390      * @function
-2391      * @return PEM formatted string of CRL
-2392      * @since jsrsasign 9.1.0 asn1hex 2.1.0
-2393      * @description
-2394      * This method returns a string of PEM formatted 
-2395      * CRL.
-2396      * @example
-2397      * crl = new KJUR.asn1.x509.CRL({...});
-2398      * crl.getPEM() →
-2399      * "-----BEGIN X509 CRL-----\r\n..."
-2400      */
-2401     this.getPEM = function() {
-2402 	return hextopem(this.tohex(), "X509 CRL");
-2403     };
-2404 
-2405     this.tohex = function() {
-2406 	var params = this.params;
-2407 
-2408 	if (params.tbsobj == undefined) {
-2409 	    params.tbsobj = new _TBSCertList(params);
-2410 	}
-2411 
-2412 	if (params.sighex == undefined && params.cakey != undefined) {
-2413 	    this.sign();
-2414 	}
-2415 
-2416 	if (params.sighex == undefined) {
-2417 	    throw new Error("sighex or cakey parameter not defined");
-2418 	}
-2419 	
-2420 	var a = [];
-2421 	a.push(params.tbsobj);
-2422 	a.push(new _AlgorithmIdentifier({name: params.sigalg}));
-2423 	a.push(new _DERBitString({hex: "00" + params.sighex}));
-2424 	var seq = new _DERSequence({array: a});
-2425 	return seq.tohex();
-2426     };
-2427     this.getEncodedHex = function() { return this.tohex(); };
-2428 
-2429     if (params != undefined) this.params = params;
-2430 };
-2431 extendClass(KJUR.asn1.x509.CRL, KJUR.asn1.ASN1Object);
-2432 
-2433 /**
-2434  * ASN.1 TBSCertList ASN.1 structure class for CRL<br/>
-2435  * @name KJUR.asn1.x509.TBSCertList
-2436  * @class TBSCertList ASN.1 structure class for CRL
-2437  * @property {Array} params JSON object of parameters
-2438  * @param {Array} params JSON object of TBSCertList parameters
-2439  * @extends KJUR.asn1.ASN1Object
-2440  * @since 1.0.3
-2441  *
-2442  * @description
-2443  * This class represents TBSCertList of CRL defined in
-2444  * <a href="https://tools.ietf.org/html/rfc5280#section-5.1">
-2445  * RFC 5280 5.1</a>.
-2446  * <pre>
-2447  * TBSCertList  ::=  SEQUENCE  {
-2448  *       version                 Version OPTIONAL,
-2449  *                                    -- if present, MUST be v2
-2450  *       signature               AlgorithmIdentifier,
-2451  *       issuer                  Name,
-2452  *       thisUpdate              Time,
-2453  *       nextUpdate              Time OPTIONAL,
-2454  *       revokedCertificates     SEQUENCE OF SEQUENCE  {
-2455  *            userCertificate         CertificateSerialNumber,
-2456  *            revocationDate          Time,
-2457  *            crlEntryExtensions      Extensions OPTIONAL
-2458  *                                     -- if present, version MUST be v2
-2459  *                                 }  OPTIONAL,
-2460  *       crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
-2461  * }
-2462  * </pre>
-2463  * NOTE: TBSCertList class is updated without backward 
-2464  * compatibility from jsrsasign 9.1.0 asn1x509 2.1.0.
-2465  * Most of methods are removed and parameters can be set
-2466  * by JSON object.
-2467  * <br/>
-2468  * Constructor of this class may have following parameters:
-2469  * <ul>
-2470  * <li>{Integer}version (OPTION) - version number. Omitted by default.</li>
-2471  * <li>{String}sigalg - signature algorithm name</li>
-2472  * <li>{Array}issuer - issuer parameter of {@link KJUR.asn1.x509.X500Name}</li>
-2473  * <li>{String}thisupdate - thisUpdate field value</li>
-2474  * <li>{String}nextupdate (OPTION) - thisUpdate field value</li>
-2475  * <li>{Array}revcert (OPTION) - revokedCertificates field value as array
-2476  *   Its element may have following property:
-2477  *   <ul>
-2478  *   <li>{Array}sn - serialNumber of userCertificate field specified
-2479  *   by {@link KJUR.asn1.DERInteger}</li>
-2480  *   <li>{String}date - revocationDate field specified by
-2481  *   a string of {@link KJUR.asn1.x509.Time} parameter</li>
-2482  *   <li>{Array}ext (OPTION) - array of CRL entry extension parameter</li>
-2483  *   </ul>
-2484  * </li>
-2485  * </ul>
-2486  * 
-2487  * @example
-2488  * var o = new KJUR.asn1.x509.TBSCertList({
-2489  *  sigalg: "SHA256withRSA",
-2490  *  issuer: {array: [[{type:'C',value:'JP',ds:'prn'}],
-2491  *                   [{type:'O',value:'T1',ds:'prn'}]]},
-2492  *  thisupdate: "200821235959Z",
-2493  *  nextupdate: "200828235959Z", // OPTION
-2494  *  revcert: [
-2495  *   {sn: {hex: "12ab"}, date: "200401235959Z", ext: [{extname: "cRLReason", code:1}]},
-2496  *   {sn: {hex: "12bc"}, date: "200405235959Z", ext: [{extname: "cRLReason", code:2}]}
-2497  *  ],
-2498  *  ext: [
-2499  *   {extname: "cRLNumber", num: {'int': 8}},
-2500  *   {extname: "authorityKeyIdentifier", "kid": {hex: "12ab"}}
-2501  *  ]
-2502  * });
-2503  * o.tohex() → "30..."
-2504  */
-2505 KJUR.asn1.x509.TBSCertList = function(params) {
-2506     KJUR.asn1.x509.TBSCertList.superclass.constructor.call(this);
-2507     var	_KJUR = KJUR,
-2508 	_KJUR_asn1 = _KJUR.asn1,
-2509 	_DERInteger = _KJUR_asn1.DERInteger,
-2510 	_DERSequence = _KJUR_asn1.DERSequence,
-2511 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
-2512 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-2513 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-2514 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
-2515 	_Time = _KJUR_asn1_x509.Time,
-2516 	_Extensions = _KJUR_asn1_x509.Extensions,
-2517 	_X500Name = _KJUR_asn1_x509.X500Name;
-2518     this.params = null;
-2519 
-2520     /**
-2521      * get array of ASN.1 object for extensions<br/>
-2522      * @name setByParam
-2523      * @memberOf KJUR.asn1.x509.TBSCertList#
-2524      * @function
-2525      * @param {Array} JSON object of TBSCertList parameters
-2526      * @example
-2527      * tbsc = new KJUR.asn1.x509.TBSCertificate();
-2528      * tbsc.setByParam({version:3, serial:{hex:'1234...'},...});
-2529      */
-2530     this.setByParam = function(params) {
-2531 	this.params = params;
-2532     };
-2533 
-2534     /**
-2535      * get DERSequence for revokedCertificates<br/>
-2536      * @name getRevCertSequence
-2537      * @memberOf KJUR.asn1.x509.TBSCertList#
-2538      * @function
-2539      * @return {@link KJUR.asn1.DERSequence} of revokedCertificates
-2540      */
-2541     this.getRevCertSequence = function() {
-2542 	var a = [];
-2543 	var aRevCert = this.params.revcert;
-2544 	for (var i = 0; i < aRevCert.length; i++) {
-2545 	    var aEntry = [
-2546 		new _DERInteger(aRevCert[i].sn),
-2547 		new _Time(aRevCert[i].date)
-2548 	    ];
-2549 	    if (aRevCert[i].ext != undefined) {
-2550 		aEntry.push(new _Extensions(aRevCert[i].ext));
-2551 	    }
-2552 	    a.push(new _DERSequence({array: aEntry}));
-2553 	}
-2554 	return new _DERSequence({array: a});
+1482 // =====================================================================
+1483 /**
+1484  * KeyUsage ASN.1 structure class
+1485  * @name KJUR.asn1.x509.ExtKeyUsage
+1486  * @class ExtKeyUsage ASN.1 structure class
+1487  * @param {Array} params associative array of parameters
+1488  * @extends KJUR.asn1.x509.Extension
+1489  * @description
+1490  * @example
+1491  * e1 = new KJUR.asn1.x509.ExtKeyUsage({
+1492  *   critical: true,
+1493  *   array: [
+1494  *     {oid: '2.5.29.37.0'},  // anyExtendedKeyUsage
+1495  *     {name: 'clientAuth'},
+1496  *     "1.2.3.4",
+1497  *     "serverAuth"
+1498  *   ]
+1499  * });
+1500  * // id-ce-extKeyUsage OBJECT IDENTIFIER ::= { id-ce 37 }
+1501  * // ExtKeyUsageSyntax ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId
+1502  * // KeyPurposeId ::= OBJECT IDENTIFIER
+1503  */
+1504 KJUR.asn1.x509.ExtKeyUsage = function(params) {
+1505     KJUR.asn1.x509.ExtKeyUsage.superclass.constructor.call(this, params);
+1506     var _KJUR = KJUR,
+1507 	_KJUR_asn1 = _KJUR.asn1;
+1508 
+1509     this.setPurposeArray = function(purposeArray) {
+1510         this.asn1ExtnValue = new _KJUR_asn1.DERSequence();
+1511         for (var i = 0; i < purposeArray.length; i++) {
+1512             var o = new _KJUR_asn1.DERObjectIdentifier(purposeArray[i]);
+1513             this.asn1ExtnValue.appendASN1Object(o);
+1514         }
+1515     };
+1516 
+1517     this.getExtnValueHex = function() {
+1518         return this.asn1ExtnValue.tohex();
+1519     };
+1520 
+1521     this.oid = "2.5.29.37";
+1522     if (params !== undefined) {
+1523         if (params.array !== undefined) {
+1524             this.setPurposeArray(params.array);
+1525         }
+1526     }
+1527 };
+1528 extendClass(KJUR.asn1.x509.ExtKeyUsage, KJUR.asn1.x509.Extension);
+1529 
+1530 /**
+1531  * AuthorityKeyIdentifier ASN.1 structure class
+1532  * @name KJUR.asn1.x509.AuthorityKeyIdentifier
+1533  * @class AuthorityKeyIdentifier ASN.1 structure class
+1534  * @param {Array} params associative array of parameters (ex. {kid: {hex: '89ab...'}, critical: true})
+1535  * @extends KJUR.asn1.x509.Extension
+1536  * @since asn1x509 1.0.8
+1537  * @description
+1538  * This class represents ASN.1 structure for <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.1">AuthorityKeyIdentifier in RFC 5280</a>.
+1539  * Constructor of this class may have following parameters.: 
+1540  * <ul>
+1541  * <li>kid - When key object (RSA, KJUR.crypto.ECDSA/DSA) or PEM string of issuing authority public key or issuer certificate is specified, key identifier will be automatically calculated by the method specified in RFC 5280. When a hexadecimal string is specifed, kid will be set explicitly by it.</li>
+1542  * <li>isscert - When PEM string of authority certificate is specified, both authorityCertIssuer and authorityCertSerialNumber will be set by the certificate.</li>
+1543  * <li>issuer - {@link KJUR.asn1.x509.X500Name} parameter to specify issuer name explicitly.</li>
+1544  * <li>sn - hexadecimal string to specify serial number explicitly.</li>
+1545  * <li>critical - boolean to specify criticality of this extension
+1546  * however conforming CA must mark this extension as non-critical in RFC 5280.</li>
+1547  * </ul>
+1548  * 
+1549  * <pre>
+1550  * d-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 35 }
+1551  * AuthorityKeyIdentifier ::= SEQUENCE {
+1552  *    keyIdentifier             [0] KeyIdentifier           OPTIONAL,
+1553  *    authorityCertIssuer       [1] GeneralNames            OPTIONAL,
+1554  *    authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL  }
+1555  * KeyIdentifier ::= OCTET STRING
+1556  * </pre>
+1557  *
+1558  * @example
+1559  * // 1. kid by key object
+1560  * keyobj = KEYUTIL.getKey("-----BEGIN PUBLIC KEY...");
+1561  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: keyobj});
+1562  * // 2. kid by PEM string of authority certificate or public key
+1563  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: "-----BEGIN..."});
+1564  * // 3. specify kid explicitly
+1565  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({kid: "8ab1d3..."});
+1566  * });
+1567  * // 4. issuer and serial number by auhtority PEM certificate
+1568  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({isscert: "-----BEGIN..."});
+1569  * // 5. issuer and serial number explicitly
+1570  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({
+1571  *   issuer: {ldapstr: "O=test,C=US"},
+1572  *   sn: {hex: "1ac7..."}});
+1573  * // 6. combination
+1574  * e1 = new KJUR.asn1.x509.AuthorityKeyIdentifier({
+1575  *   kid: "-----BEGIN CERTIFICATE...",
+1576  *   isscert: "-----BEGIN CERTIFICATE..."});
+1577  */
+1578 KJUR.asn1.x509.AuthorityKeyIdentifier = function(params) {
+1579     KJUR.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this, params);
+1580     var _KJUR = KJUR,
+1581 	_KJUR_asn1 = _KJUR.asn1,
+1582 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+1583 	_GeneralNames = _KJUR_asn1.x509.GeneralNames,
+1584 	_isKey = _KJUR.crypto.Util.isKey;
+1585 
+1586     this.asn1KID = null;
+1587     this.asn1CertIssuer = null; // X500Name hTLV
+1588     this.asn1CertSN = null;
+1589 
+1590     this.getExtnValueHex = function() {
+1591         var a = new Array();
+1592         if (this.asn1KID)
+1593             a.push(new _DERTaggedObject({'explicit': false,
+1594                                          'tag': '80',
+1595                                          'obj': this.asn1KID}));
+1596 
+1597         if (this.asn1CertIssuer)
+1598             a.push(new _DERTaggedObject({'explicit': false,
+1599                                          'tag': 'a1',
+1600                                          'obj': new _GeneralNames([{dn: this.asn1CertIssuer}])}));
+1601 
+1602         if (this.asn1CertSN)
+1603             a.push(new _DERTaggedObject({'explicit': false,
+1604                                          'tag': '82',
+1605                                          'obj': this.asn1CertSN}));
+1606 
+1607         var asn1Seq = new _KJUR_asn1.DERSequence({'array': a});
+1608         this.asn1ExtnValue = asn1Seq;
+1609         return this.asn1ExtnValue.tohex();
+1610     };
+1611 
+1612     /**
+1613      * set keyIdentifier value by DEROctetString parameter, key object or PEM file
+1614      * @name setKIDByParam
+1615      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
+1616      * @function
+1617      * @param {Array} param parameter to set key identifier
+1618      * @since asn1x509 1.0.8
+1619      * @description
+1620      * This method will set keyIdentifier by param.
+1621      * Its key identifier value can be set by following type of param argument:
+1622      * <ul>
+1623      * <li>{str: "123"} - by raw string</li>
+1624      * <li>{hex: "01af..."} - by hexadecimal value</li>
+1625      * <li>RSAKey/DSA/ECDSA - by RSAKey, KJUR.crypto.{DSA/ECDSA} public key object.
+1626      * key identifier value will be calculated by the method described in
+1627      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1628      * </li>
+1629      * <li>certificate PEM string - extract subjectPublicKeyInfo from specified PEM
+1630      * certificate and
+1631      * key identifier value will be calculated by the method described in
+1632      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1633      * <li>PKCS#1/#8 public key PEM string - pem will be converted to a key object and
+1634      * to PKCS#8 ASN.1 structure then calculate 
+1635      * a key identifier value will be calculated by the method described in
+1636      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1637      * </ul>
+1638      *
+1639      * NOTE1: Automatic key identifier calculation is supported
+1640      * since jsrsasign 8.0.16.
+1641      *
+1642      * @see KEYUTIL.getKeyID
+1643      * 
+1644      * @example
+1645      * o = new KJUR.asn1.x509.AuthorityKeyIdentifier();
+1646      * // set by hexadecimal string
+1647      * o.setKIDByParam({hex: '1ad9...'});
+1648      * // set by SubjectPublicKeyInfo of PEM certificate string
+1649      * o.setKIDByParam("-----BEGIN CERTIFICATE...");
+1650      * // set by PKCS#8 PEM public key string
+1651      * o.setKIDByParam("-----BEGIN PUBLIC KEY...");
+1652      * // set by public key object
+1653      * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
+1654      * o.setKIDByParam(pubkey);
+1655      */
+1656     this.setKIDByParam = function(param) {
+1657 	if (param.str !== undefined ||
+1658 	    param.hex !== undefined) {
+1659 	    this.asn1KID = new KJUR.asn1.DEROctetString(param);
+1660 	} else if ((typeof param === "object" &&
+1661 		    KJUR.crypto.Util.isKey(param)) ||
+1662 		   (typeof param === "string" &&
+1663 		    param.indexOf("BEGIN ") != -1)) {
+1664 
+1665 	    var keyobj = param;
+1666 	    if (typeof param === "string") {
+1667 		keyobj = KEYUTIL.getKey(param);
+1668 	    }
+1669 
+1670 	    var kid = KEYUTIL.getKeyID(keyobj);
+1671 	    this.asn1KID = new KJUR.asn1.DEROctetString({hex: kid});
+1672 	}
+1673     };
+1674 
+1675     /**
+1676      * set authorityCertIssuer value by X500Name parameter
+1677      * @name setCertIssuerByParam
+1678      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
+1679      * @function
+1680      * @param {Array} param parameter to set issuer name
+1681      * @since asn1x509 1.0.8
+1682      * @description
+1683      * This method will set authorityCertIssuer name by param.
+1684      * Issuer name can be set by following type of param argument:
+1685      * <ul>
+1686      * <li>str/ldapstr/hex/certsubject/certissuer - 
+1687      * set issuer by {@link KJUR.asn1.x509.X500Name}
+1688      * object with specified parameters.</li>
+1689      * <li>PEM CERTIFICATE STRING - extract its subject name from 
+1690      * specified issuer PEM certificate and set.
+1691      * </ul>
+1692      * NOTE1: Automatic authorityCertIssuer setting by certificate
+1693      * is supported since jsrsasign 8.0.16.
+1694      *
+1695      * @see KJUR.asn1.x509.X500Name
+1696      * @see KJUR.asn1.x509.GeneralNames
+1697      * @see X509.getSubjectHex
+1698      *
+1699      * @example
+1700      * var o = new KJUR.asn1.x509.AuthorityKeyIdentifier();
+1701      * // 1. set it by string
+1702      * o.setCertIssuerByParam({str: '/C=US/O=Test'});
+1703      * // 2. set it by issuer PEM certificate
+1704      * o.setCertIssuerByParam("-----BEGIN CERTIFICATE...");
+1705      *
+1706      */
+1707     this.setCertIssuerByParam = function(param) {
+1708 	if (param.str !== undefined ||
+1709 	    param.ldapstr !== undefined ||
+1710 	    param.hex !== undefined ||
+1711 	    param.certsubject !== undefined ||
+1712 	    param.certissuer !== undefined) {
+1713             this.asn1CertIssuer = new KJUR.asn1.x509.X500Name(param);
+1714 	} else if (typeof param === "string" &&
+1715 		   param.indexOf("BEGIN ") != -1 &&
+1716 		   param.indexOf("CERTIFICATE") != -1) {
+1717             this.asn1CertIssuer = new KJUR.asn1.x509.X500Name({certissuer: param});
+1718 	}
+1719     };
+1720 
+1721     /**
+1722      * set authorityCertSerialNumber value
+1723      * @name setCertSerialNumberByParam
+1724      * @memberOf KJUR.asn1.x509.AuthorityKeyIdentifier#
+1725      * @function
+1726      * @param {Object} param parameter to set serial number
+1727      * @since asn1x509 1.0.8
+1728      * @description
+1729      * This method will set authorityCertSerialNumber by param.
+1730      * Serial number can be set by following type of param argument:
+1731      *
+1732      * <ul>
+1733      * <li>{int: 123} - by integer value</li>
+1734      * <li>{hex: "01af"} - by hexadecimal integer value</li>
+1735      * <li>{bigint: new BigInteger(...)} - by hexadecimal integer value</li>
+1736      * <li>PEM CERTIFICATE STRING - extract serial number from issuer certificate and
+1737      * set serial number.
+1738      * 
+1739      * NOTE1: Automatic authorityCertSerialNumber setting by certificate
+1740      * is supported since jsrsasign 8.0.16.
+1741      *
+1742      * @see X509.getSerialNumberHex
+1743      */
+1744     this.setCertSNByParam = function(param) {
+1745 	if (param.str !== undefined ||
+1746 	    param.bigint !== undefined ||
+1747 	    param.hex !== undefined) {
+1748             this.asn1CertSN = new KJUR.asn1.DERInteger(param);
+1749 	} else if (typeof param === "string" &&
+1750 		   param.indexOf("BEGIN ") != -1 &&
+1751 		   param.indexOf("CERTIFICATE")) {
+1752 
+1753             var x = new X509();
+1754             x.readCertPEM(param);
+1755 	    var sn = x.getSerialNumberHex();
+1756 	    this.asn1CertSN = new KJUR.asn1.DERInteger({hex: sn});
+1757 	}
+1758     };
+1759 
+1760     this.oid = "2.5.29.35";
+1761     if (params !== undefined) {
+1762         if (params.kid !== undefined) {
+1763             this.setKIDByParam(params.kid);
+1764         }
+1765         if (params.issuer !== undefined) {
+1766             this.setCertIssuerByParam(params.issuer);
+1767         }
+1768         if (params.sn !== undefined) {
+1769             this.setCertSNByParam(params.sn);
+1770         }
+1771 
+1772 	if (params.issuersn !== undefined &&
+1773 	    typeof params.issuersn === "string" &&
+1774 	    params.issuersn.indexOf("BEGIN ") != -1 &&
+1775 	    params.issuersn.indexOf("CERTIFICATE")) {
+1776 	    this.setCertSNByParam(params.issuersn);
+1777 	    this.setCertIssuerByParam(params.issuersn);
+1778 	}
+1779     }
+1780 };
+1781 extendClass(KJUR.asn1.x509.AuthorityKeyIdentifier, KJUR.asn1.x509.Extension);
+1782 
+1783 /**
+1784  * SubjectKeyIdentifier extension ASN.1 structure class
+1785  * @name KJUR.asn1.x509.SubjectKeyIdentifier
+1786  * @class SubjectKeyIdentifier ASN.1 structure class
+1787  * @param {Array} params associative array of parameters (ex. {kid: {hex: '89ab...'}, critical: true})
+1788  * @extends KJUR.asn1.x509.Extension
+1789  * @since asn1x509 1.1.7 jsrsasign 8.0.14
+1790  * @description
+1791  * This class represents ASN.1 structure for 
+1792  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">
+1793  * SubjectKeyIdentifier in RFC 5280</a>.
+1794  * Constructor of this class may have following parameters:
+1795  * <ul>
+1796  * <li>kid - When key object (RSA, KJUR.crypto.ECDSA/DSA) or PEM string of subject public key or certificate is specified, key identifier will be automatically calculated by the method specified in RFC 5280. When a hexadecimal string is specifed, kid will be set explicitly by it.</li>
+1797  * <li>critical - boolean to specify criticality of this extension
+1798  * however conforming CA must mark this extension as non-critical in RFC 5280.</li>
+1799  * </ul>
+1800  * <pre>
+1801  * d-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 14 }
+1802  * SubjectKeyIdentifier ::= KeyIdentifier
+1803  * KeyIdentifier ::= OCTET STRING
+1804  * </pre>
+1805  *
+1806  * @example
+1807  * // set by hexadecimal string
+1808  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: {hex: '89ab'}});
+1809  * // set by PEM public key or certificate string
+1810  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: "-----BEGIN CERTIFICATE..."});
+1811  * // set by public key object
+1812  * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
+1813  * e = new KJUR.asn1.x509.SubjectKeyIdentifier({kid: pubkey});
+1814  */
+1815 KJUR.asn1.x509.SubjectKeyIdentifier = function(params) {
+1816     KJUR.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this, params);
+1817     var _KJUR = KJUR,
+1818 	_KJUR_asn1 = _KJUR.asn1,
+1819 	_DEROctetString = _KJUR_asn1.DEROctetString;
+1820 
+1821     this.asn1KID = null;
+1822 
+1823     this.getExtnValueHex = function() {
+1824         this.asn1ExtnValue = this.asn1KID;
+1825         return this.asn1ExtnValue.tohex();
+1826     };
+1827 
+1828     /**
+1829      * set keyIdentifier value by DEROctetString parameter, key object or PEM file
+1830      * @name setKIDByParam
+1831      * @memberOf KJUR.asn1.x509.SubjectKeyIdentifier#
+1832      * @function
+1833      * @param {Array} param array of {@link KJUR.asn1.DERInteger} parameter
+1834      * @since asn1x509 1.1.7 jsrsasign 8.0.14
+1835      * @description
+1836      * <ul>
+1837      * <li>{str: "123"} - by raw string</li>
+1838      * <li>{hex: "01af..."} - by hexadecimal value</li>
+1839      * <li>RSAKey/DSA/ECDSA - by RSAKey, KJUR.crypto.{DSA/ECDSA} public key object.
+1840      * key identifier value will be calculated by the method described in
+1841      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1842      * </li>
+1843      * <li>certificate PEM string - extract subjectPublicKeyInfo from specified PEM
+1844      * certificate and
+1845      * key identifier value will be calculated by the method described in
+1846      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1847      * <li>PKCS#1/#8 public key PEM string - pem will be converted to a key object and
+1848      * to PKCS#8 ASN.1 structure then calculate 
+1849      * a key identifier value will be calculated by the method described in
+1850      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">RFC 5280 4.2.1.2 (1)</a>.
+1851      * </ul>
+1852      *
+1853      * NOTE1: Automatic key identifier calculation is supported
+1854      * since jsrsasign 8.0.16.
+1855      *
+1856      * @see KEYUTIL.getKeyID
+1857      *
+1858      * @example
+1859      * o = new KJUR.asn1.x509.SubjectKeyIdentifier();
+1860      * // set by hexadecimal string
+1861      * o.setKIDByParam({hex: '1ad9...'});
+1862      * // set by SubjectPublicKeyInfo of PEM certificate string
+1863      * o.setKIDByParam("-----BEGIN CERTIFICATE...");
+1864      * // set by PKCS#8 PEM public key string
+1865      * o.setKIDByParam("-----BEGIN PUBLIC KEY...");
+1866      * // set by public key object
+1867      * pubkey = KEYUTIL.getKey("-----BEGIN CERTIFICATE...");
+1868      * o.setKIDByParam(pubkey);
+1869      */
+1870     this.setKIDByParam = function(param) {
+1871 	if (param.str !== undefined ||
+1872 	    param.hex !== undefined) {
+1873 	    this.asn1KID = new _DEROctetString(param);
+1874 	} else if ((typeof param === "object" &&
+1875 		    KJUR.crypto.Util.isKey(param)) ||
+1876 		   (typeof param === "string" &&
+1877 		    param.indexOf("BEGIN") != -1)) {
+1878 
+1879 	    var keyobj = param;
+1880 	    if (typeof param === "string") {
+1881 		keyobj = KEYUTIL.getKey(param);
+1882 	    }
+1883 
+1884 	    var kid = KEYUTIL.getKeyID(keyobj);
+1885 	    this.asn1KID = new KJUR.asn1.DEROctetString({hex: kid});
+1886 	}
+1887     };
+1888 
+1889     this.oid = "2.5.29.14";
+1890     if (params !== undefined) {
+1891 	if (params.kid !== undefined) {
+1892 	    this.setKIDByParam(params.kid);
+1893 	}
+1894     }
+1895 };
+1896 extendClass(KJUR.asn1.x509.SubjectKeyIdentifier, KJUR.asn1.x509.Extension);
+1897 
+1898 /**
+1899  * AuthorityInfoAccess ASN.1 structure class
+1900  * @name KJUR.asn1.x509.AuthorityInfoAccess
+1901  * @class AuthorityInfoAccess ASN.1 structure class
+1902  * @param {Array} params JSON object of AuthorityInfoAccess parameters
+1903  * @extends KJUR.asn1.x509.Extension
+1904  * @since asn1x509 1.0.8
+1905  * @see {@link X509#getExtAuthorityInfoAccess}
+1906  * @description
+1907  * This class represents 
+1908  * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.2.1">
+1909  * AuthorityInfoAccess extension defined in RFC 5280 4.2.2.1</a>.
+1910  * <pre>
+1911  * id-pe OBJECT IDENTIFIER  ::=  { id-pkix 1 }
+1912  * id-pe-authorityInfoAccess OBJECT IDENTIFIER ::= { id-pe 1 }
+1913  * AuthorityInfoAccessSyntax  ::=
+1914  *         SEQUENCE SIZE (1..MAX) OF AccessDescription
+1915  * AccessDescription  ::=  SEQUENCE {
+1916  *         accessMethod          OBJECT IDENTIFIER,
+1917  *         accessLocation        GeneralName  }
+1918  * id-ad OBJECT IDENTIFIER ::= { id-pkix 48 }
+1919  * id-ad-caIssuers OBJECT IDENTIFIER ::= { id-ad 2 }
+1920  * id-ad-ocsp OBJECT IDENTIFIER ::= { id-ad 1 }
+1921  * </pre>
+1922  * NOTE: Acceptable parameters have been changed since
+1923  * from jsrsasign 9.0.0 asn1x509 2.0.0.
+1924  * Parameter generated by {@link X509#getAuthorityInfoAccess}
+1925  * can be accepted as a argument of this constructor.
+1926  * @example
+1927  * e1 = new KJUR.asn1.x509.AuthorityInfoAccess({
+1928  *   array: [
+1929  *     {ocsp: 'http://ocsp.example.org'},
+1930  *     {caissuer: 'https://repository.example.org/aaa.crt'}
+1931  *   ]
+1932  * });
+1933  */
+1934 KJUR.asn1.x509.AuthorityInfoAccess = function(params) {
+1935     KJUR.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this, params);
+1936 
+1937     this.setAccessDescriptionArray = function(aParam) {
+1938         var aASN1 = new Array(),
+1939 	    _KJUR = KJUR,
+1940 	    _KJUR_asn1 = _KJUR.asn1,
+1941 	    _DERSequence = _KJUR_asn1.DERSequence,
+1942 	    _DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+1943 	    _GeneralName = _KJUR_asn1.x509.GeneralName;
+1944 
+1945         for (var i = 0; i < aParam.length; i++) {
+1946 	    var adseq;
+1947 	    var adparam = aParam[i];
+1948 
+1949 	    if (adparam.ocsp !== undefined) {
+1950 		adseq = new _DERSequence({array: [
+1951 		    new _DERObjectIdentifier({oid: "1.3.6.1.5.5.7.48.1"}),
+1952 		    new _GeneralName({uri: adparam.ocsp})
+1953 		]});
+1954 	    } else if (adparam.caissuer !== undefined) {
+1955 		adseq = new _DERSequence({array: [
+1956 		    new _DERObjectIdentifier({oid: "1.3.6.1.5.5.7.48.2"}),
+1957 		    new _GeneralName({uri: adparam.caissuer})
+1958 		]});
+1959 	    } else {
+1960 		throw new Error("unknown AccessMethod parameter: " +
+1961 				JSON.stringify(adparam));
+1962 	    }
+1963 	    aASN1.push(adseq);
+1964         }
+1965         this.asn1ExtnValue = new _DERSequence({'array':aASN1});
+1966     };
+1967 
+1968     this.getExtnValueHex = function() {
+1969         return this.asn1ExtnValue.tohex();
+1970     };
+1971 
+1972     this.oid = "1.3.6.1.5.5.7.1.1";
+1973     if (params !== undefined) {
+1974         if (params.array !== undefined) {
+1975             this.setAccessDescriptionArray(params.array);
+1976         }
+1977     }
+1978 };
+1979 extendClass(KJUR.asn1.x509.AuthorityInfoAccess, KJUR.asn1.x509.Extension);
+1980 
+1981 /**
+1982  * SubjectAltName ASN.1 structure class<br/>
+1983  * @name KJUR.asn1.x509.SubjectAltName
+1984  * @class SubjectAltName ASN.1 structure class
+1985  * @param {Array} params associative array of parameters
+1986  * @extends KJUR.asn1.x509.Extension
+1987  * @since jsrsasign 6.2.3 asn1x509 1.0.19
+1988  * @see KJUR.asn1.x509.GeneralNames
+1989  * @see KJUR.asn1.x509.GeneralName
+1990  * @description
+1991  * This class provides X.509v3 SubjectAltName extension.
+1992  * <pre>
+1993  * id-ce-subjectAltName OBJECT IDENTIFIER ::=  { id-ce 17 }
+1994  * SubjectAltName ::= GeneralNames
+1995  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
+1996  * GeneralName ::= CHOICE {
+1997  *   otherName                  [0] OtherName,
+1998  *   rfc822Name                 [1] IA5String,
+1999  *   dNSName                    [2] IA5String,
+2000  *   x400Address                [3] ORAddress,
+2001  *   directoryName              [4] Name,
+2002  *   ediPartyName               [5] EDIPartyName,
+2003  *   uniformResourceIdentifier  [6] IA5String,
+2004  *   iPAddress                  [7] OCTET STRING,
+2005  *   registeredID               [8] OBJECT IDENTIFIER }
+2006  * </pre>
+2007  * @example
+2008  * e1 = new KJUR.asn1.x509.SubjectAltName({
+2009  *   critical: true,
+2010  *   array: [{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]
+2011  * });
+2012  */
+2013 KJUR.asn1.x509.SubjectAltName = function(params) {
+2014     KJUR.asn1.x509.SubjectAltName.superclass.constructor.call(this, params)
+2015 
+2016     this.setNameArray = function(paramsArray) {
+2017 	this.asn1ExtnValue = new KJUR.asn1.x509.GeneralNames(paramsArray);
+2018     };
+2019 
+2020     this.getExtnValueHex = function() {
+2021         return this.asn1ExtnValue.tohex();
+2022     };
+2023 
+2024     this.oid = "2.5.29.17";
+2025     if (params !== undefined) {
+2026         if (params.array !== undefined) {
+2027             this.setNameArray(params.array);
+2028         }
+2029     }
+2030 };
+2031 extendClass(KJUR.asn1.x509.SubjectAltName, KJUR.asn1.x509.Extension);
+2032 
+2033 /**
+2034  * IssuerAltName ASN.1 structure class<br/>
+2035  * @name KJUR.asn1.x509.IssuerAltName
+2036  * @class IssuerAltName ASN.1 structure class
+2037  * @param {Array} params associative array of parameters
+2038  * @extends KJUR.asn1.x509.Extension
+2039  * @since jsrsasign 6.2.3 asn1x509 1.0.19
+2040  * @see KJUR.asn1.x509.GeneralNames
+2041  * @see KJUR.asn1.x509.GeneralName
+2042  * @description
+2043  * This class provides X.509v3 IssuerAltName extension.
+2044  * <pre>
+2045  * id-ce-subjectAltName OBJECT IDENTIFIER ::=  { id-ce 18 }
+2046  * IssuerAltName ::= GeneralNames
+2047  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
+2048  * GeneralName ::= CHOICE {
+2049  *   otherName                  [0] OtherName,
+2050  *   rfc822Name                 [1] IA5String,
+2051  *   dNSName                    [2] IA5String,
+2052  *   x400Address                [3] ORAddress,
+2053  *   directoryName              [4] Name,
+2054  *   ediPartyName               [5] EDIPartyName,
+2055  *   uniformResourceIdentifier  [6] IA5String,
+2056  *   iPAddress                  [7] OCTET STRING,
+2057  *   registeredID               [8] OBJECT IDENTIFIER }
+2058  * </pre>
+2059  * @example
+2060  * e1 = new KJUR.asn1.x509.IssuerAltName({
+2061  *   critical: true,
+2062  *   array: [{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]
+2063  * });
+2064  */
+2065 KJUR.asn1.x509.IssuerAltName = function(params) {
+2066     KJUR.asn1.x509.IssuerAltName.superclass.constructor.call(this, params)
+2067 
+2068     this.setNameArray = function(paramsArray) {
+2069 	this.asn1ExtnValue = new KJUR.asn1.x509.GeneralNames(paramsArray);
+2070     };
+2071 
+2072     this.getExtnValueHex = function() {
+2073         return this.asn1ExtnValue.tohex();
+2074     };
+2075 
+2076     this.oid = "2.5.29.18";
+2077     if (params !== undefined) {
+2078         if (params.array !== undefined) {
+2079             this.setNameArray(params.array);
+2080         }
+2081     }
+2082 };
+2083 extendClass(KJUR.asn1.x509.IssuerAltName, KJUR.asn1.x509.Extension);
+2084 
+2085 /**
+2086  * SubjectDirectoryAttributes ASN.1 structure class<br/>
+2087  * @name KJUR.asn1.x509.SubjectDirectoryAttributes
+2088  * @class SubjectDirectoryAttributes ASN.1 structure class
+2089  * @param {Array} params associative array of parameters
+2090  * @extends KJUR.asn1.x509.Extension
+2091  * @since jsrsasign 10.1.9 asn1x509 2.1.7
+2092  * @description
+2093  * This class provides X.509v3 SubjectDirectoryAttributes extension
+2094  * defined in <a href="https://tools.ietf.org/html/rfc3739#section-3.3.2">
+2095  * RFC 3739 Qualified Certificate Profile section 3.3.2</a>.
+2096  * <pre>
+2097  * SubjectDirectoryAttributes ::= Attributes
+2098  * Attributes ::= SEQUENCE SIZE (1..MAX) OF Attribute
+2099  * Attribute ::= SEQUENCE {
+2100  *   type AttributeType 
+2101  *   values SET OF AttributeValue }
+2102  * AttributeType ::= OBJECT IDENTIFIER
+2103  * AttributeValue ::= ANY DEFINED BY AttributeType
+2104  * </pre>
+2105  * @example
+2106  * e1 = new KJUR.asn1.x509.SubjectDirectoryAttributes({
+2107  *   extname: "subjectDirectoryAttributes",
+2108  *   array: [
+2109  *     { attr: "dateOfBirth", str: "19701231230000Z" },
+2110  *     { attr: "placeOfBirth", str: "Tokyo" },
+2111  *     { attr: "gender", str: "F" },
+2112  *     { attr: "countryOfCitizenship", str: "JP" },
+2113  *     { attr: "countryOfResidence", str: "JP" }
+2114  *   ]
+2115  * });
+2116  */
+2117 KJUR.asn1.x509.SubjectDirectoryAttributes = function(params) {
+2118     KJUR.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this, params);
+2119     var _KJUR_asn1 = KJUR.asn1,
+2120 	_DERSequence = _KJUR_asn1.DERSequence,
+2121 	_newObject = _KJUR_asn1.ASN1Util.newObject,
+2122 	_name2oid = _KJUR_asn1.x509.OID.name2oid;
+2123 
+2124     this.params = null;
+2125 
+2126     this.getExtnValueHex = function() {
+2127 	var a = [];
+2128 	for (var i = 0; i < this.params.array.length; i++) {
+2129 	    var pAttr = this.params.array[i];
+2130 
+2131 	    var newparam = {
+2132 		"seq": [
+2133 		    {"oid": "1.2.3.4"},
+2134 		    {"set": [{"utf8str": "DE"}]}
+2135 		]
+2136 	    };
+2137 
+2138 	    if (pAttr.attr == "dateOfBirth") {
+2139 		newparam.seq[0].oid = _name2oid(pAttr.attr);
+2140 		newparam.seq[1].set[0] = {"gentime": pAttr.str};
+2141 	    } else if (pAttr.attr == "placeOfBirth") {
+2142 		newparam.seq[0].oid = _name2oid(pAttr.attr);
+2143 		newparam.seq[1].set[0] = {"utf8str": pAttr.str};
+2144 	    } else if (pAttr.attr == "gender") {
+2145 		newparam.seq[0].oid = _name2oid(pAttr.attr);
+2146 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
+2147 	    } else if (pAttr.attr == "countryOfCitizenship") {
+2148 		newparam.seq[0].oid = _name2oid(pAttr.attr);
+2149 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
+2150 	    } else if (pAttr.attr == "countryOfResidence") {
+2151 		newparam.seq[0].oid = _name2oid(pAttr.attr);
+2152 		newparam.seq[1].set[0] = {"prnstr": pAttr.str};
+2153 	    } else {
+2154 		throw new Error("unsupported attribute: " + pAttr.attr);
+2155 	    }
+2156 	    a.push(new _newObject(newparam));
+2157 	}
+2158 	var seq = new _DERSequence({array: a});
+2159 	this.asn1ExtnValue = seq;
+2160         return this.asn1ExtnValue.tohex();
+2161     };
+2162 
+2163     this.oid = "2.5.29.9";
+2164     if (params !== undefined) {
+2165 	this.params = params;
+2166     }
+2167 };
+2168 extendClass(KJUR.asn1.x509.SubjectDirectoryAttributes, KJUR.asn1.x509.Extension);
+2169 
+2170 
+2171 /**
+2172  * priavte extension ASN.1 structure class<br/>
+2173  * @name KJUR.asn1.x509.PrivateExtension
+2174  * @class private extension ASN.1 structure class
+2175  * @param {Array} params JSON object of private extension
+2176  * @extends KJUR.asn1.x509.Extension
+2177  * @since jsrsasign 9.1.1 asn1x509 
+2178  * @see KJUR.asn1.ASN1Util.newObject
+2179  *
+2180  * @description
+2181  * This class is to represent private extension or 
+2182  * unsupported extension. 
+2183  * <pre>
+2184  * Extension  ::=  SEQUENCE  {
+2185  *      extnID      OBJECT IDENTIFIER,
+2186  *      critical    BOOLEAN DEFAULT FALSE,
+2187  *      extnValue   OCTET STRING }
+2188  * </pre>
+2189  * Following properties can be set for JSON parameter:
+2190  * <ul>
+2191  * <li>{String}extname - string of OID or predefined extension name</li>
+2192  * <li>{Boolean}critical - critical flag</li>
+2193  * <li>{Object}extn - hexadecimal string or 
+2194  * of {@link KJUR.asn1.ASN1Util.newObject} 
+2195  * JSON parameter for extnValue field</li>
+2196  * </li>
+2197  * </ul>
+2198  *
+2199  * @example
+2200  * // extn by hexadecimal
+2201  * new KJUR.asn1.x509.PrivateExtension({
+2202  *   extname: "1.2.3.4",
+2203  *   critical: true,
+2204  *   extn: "13026161" // means PrintableString "aa"
+2205  * });
+2206  *
+2207  * // extn by JSON parameter
+2208  * new KJUR.asn1.x509.PrivateExtension({
+2209  *   extname: "1.2.3.5",
+2210  *   extn: {seq: [{prnstr:"abc"},{utf8str:"def"}]}
+2211  * });
+2212  */
+2213 KJUR.asn1.x509.PrivateExtension = function(params) {
+2214     KJUR.asn1.x509.PrivateExtension.superclass.constructor.call(this, params)
+2215 
+2216     var _KJUR = KJUR,
+2217 	_isHex = _KJUR.lang.String.isHex,
+2218 	_KJUR_asn1 = _KJUR.asn1,
+2219 	_name2oid = _KJUR_asn1.x509.OID.name2oid,
+2220 	_newObject = _KJUR_asn1.ASN1Util.newObject;
+2221 
+2222     this.params = null;
+2223 
+2224     this.setByParam = function(params) {
+2225 	this.oid = _name2oid(params.extname);
+2226 	this.params = params;
+2227     };
+2228 
+2229     this.getExtnValueHex = function() {
+2230 	if (this.params.extname == undefined ||
+2231 	    this.params.extn == undefined) {
+2232 	    throw new Error("extname or extnhex not specified");
+2233 	}
+2234 
+2235 	var extn = this.params.extn;
+2236 	if (typeof extn == "string" && _isHex(extn)) {
+2237 	    return extn;
+2238 	} else if (typeof extn == "object") {
+2239 	    try {
+2240 		return _newObject(extn).tohex();
+2241 	    } catch(ex) {}
+2242 	}
+2243 	throw new Error("unsupported extn value");
+2244     };
+2245 
+2246     if (params != undefined) {
+2247 	this.setByParam(params);
+2248     }
+2249 };
+2250 extendClass(KJUR.asn1.x509.PrivateExtension, KJUR.asn1.x509.Extension);
+2251 
+2252 // === END   X.509v3 Extensions Related =======================================
+2253 
+2254 // === BEGIN CRL Related ===================================================
+2255 /**
+2256  * X.509 CRL class to sign and generate hex encoded CRL<br/>
+2257  * @name KJUR.asn1.x509.CRL
+2258  * @class X.509 CRL class to sign and generate hex encoded certificate
+2259  * @property {Array} params JSON object of parameters
+2260  * @param {Array} params JSON object of CRL parameters
+2261  * @extends KJUR.asn1.ASN1Object
+2262  * @since 1.0.3
+2263  * @see KJUR.asn1.x509.TBSCertList
+2264  * 
+2265  * @description
+2266  * This class represents CertificateList ASN.1 structur of X.509 CRL
+2267  * defined in <a href="https://tools.ietf.org/html/rfc5280#section-5.1">
+2268  * RFC 5280 5.1</a>
+2269  * <pre>
+2270  * CertificateList  ::=  SEQUENCE  {
+2271  *     tbsCertList          TBSCertList,
+2272  *     signatureAlgorithm   AlgorithmIdentifier,
+2273  *     signatureValue       BIT STRING  }
+2274  * </pre>
+2275  * NOTE: CRL class is updated without backward 
+2276  * compatibility from jsrsasign 9.1.0 asn1x509 2.1.0.
+2277  * Most of methods are removed and parameters can be set
+2278  * by JSON object.
+2279  * <br/>
+2280  * Constructor of this class can accept all
+2281  * parameters of {@link KJUR.asn1.x509.TBSCertList}.
+2282  * It also accept following parameters additionally:
+2283  * <ul>
+2284  * <li>{TBSCertList}tbsobj (OPTION) - 
+2285  * specifies {@link KJUR.asn1.x509.TBSCertList} 
+2286  * object to be signed if needed. 
+2287  * When this isn't specified, 
+2288  * this will be set from other parametes of TBSCertList.</li>
+2289  * <li>{Object}cakey (OPTION) - specifies CRL signing private key.
+2290  * Parameter "cakey" or "sighex" shall be specified. Following
+2291  * values can be specified:
+2292  *   <ul>
+2293  *   <li>PKCS#1/5 or PKCS#8 PEM string of private key</li>
+2294  *   <li>RSAKey/DSA/ECDSA key object. {@link KEYUTIL.getKey} is useful
+2295  *   to generate a key object.</li>
+2296  *   </ul>
+2297  * </li>
+2298  * <li>{String}sighex (OPTION) - hexadecimal string of signature value
+2299  * (i.e. ASN.1 value(V) of signatureValue BIT STRING without
+2300  * unused bits)</li>
+2301  * </ul>
+2302  *
+2303  * @example
+2304  * var crl = new KJUR.asn1.x509.CRL({
+2305  *  sigalg: "SHA256withRSA",
+2306  *  issuer: {str:'/C=JP/O=Test1'},
+2307  *  thisupdate: "200821235959Z",
+2308  *  nextupdate: "200828235959Z", // OPTION
+2309  *  revcert: [{sn: {hex: "12ab"}, date: "200401235959Z"}],
+2310  *  ext: [
+2311  *   {extname: "cRLNumber", num: {'int': 8}},
+2312  *   {extname: "authorityKeyIdentifier", "kid": {hex: "12ab"}}
+2313  *  ],
+2314  *  cakey: prvkey
+2315  * });
+2316  * crl.gettohex() → "30..."
+2317  * crl.getPEM() → "-----BEGIN X509 CRL..."
+2318  */
+2319 KJUR.asn1.x509.CRL = function(params) {
+2320     KJUR.asn1.x509.CRL.superclass.constructor.call(this);
+2321     var _KJUR = KJUR,
+2322 	_KJUR_asn1 = _KJUR.asn1,
+2323 	_DERSequence = _KJUR_asn1.DERSequence,
+2324 	_DERBitString = _KJUR_asn1.DERBitString,
+2325 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+2326 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
+2327 	_TBSCertList = _KJUR_asn1_x509.TBSCertList;
+2328 
+2329     this.params = undefined;
+2330 
+2331     this.setByParam = function(params) {
+2332 	this.params = params;
+2333     };
+2334 
+2335     /**
+2336      * sign CRL<br/>
+2337      * @name sign
+2338      * @memberOf KJUR.asn1.x509.CRL#
+2339      * @function
+2340      * @description
+2341      * This method signs TBSCertList with a specified 
+2342      * private key and algorithm by 
+2343      * this.params.cakey and this.params.sigalg parameter.
+2344      * @example
+2345      * crl = new KJUR.asn1.x509.CRL({..., cakey:prvkey});
+2346      * crl.sign()
+2347      */
+2348     this.sign = function() {
+2349 	var hTBSCL = (new _TBSCertList(this.params)).tohex();
+2350 	var sig = new KJUR.crypto.Signature({alg: this.params.sigalg});
+2351 	sig.init(this.params.cakey);
+2352 	sig.updateHex(hTBSCL);
+2353 	var sighex = sig.sign();
+2354 	this.params.sighex = sighex;
+2355     };
+2356 
+2357     /**
+2358      * get PEM formatted CRL string after signed<br/>
+2359      * @name getPEM
+2360      * @memberOf KJUR.asn1.x509.CRL#
+2361      * @function
+2362      * @return PEM formatted string of CRL
+2363      * @since jsrsasign 9.1.0 asn1hex 2.1.0
+2364      * @description
+2365      * This method returns a string of PEM formatted 
+2366      * CRL.
+2367      * @example
+2368      * crl = new KJUR.asn1.x509.CRL({...});
+2369      * crl.getPEM() →
+2370      * "-----BEGIN X509 CRL-----\r\n..."
+2371      */
+2372     this.getPEM = function() {
+2373 	return hextopem(this.tohex(), "X509 CRL");
+2374     };
+2375 
+2376     this.tohex = function() {
+2377 	var params = this.params;
+2378 
+2379 	if (params.tbsobj == undefined) {
+2380 	    params.tbsobj = new _TBSCertList(params);
+2381 	}
+2382 
+2383 	if (params.sighex == undefined && params.cakey != undefined) {
+2384 	    this.sign();
+2385 	}
+2386 
+2387 	if (params.sighex == undefined) {
+2388 	    throw new Error("sighex or cakey parameter not defined");
+2389 	}
+2390 	
+2391 	var a = [];
+2392 	a.push(params.tbsobj);
+2393 	a.push(new _AlgorithmIdentifier({name: params.sigalg}));
+2394 	a.push(new _DERBitString({hex: "00" + params.sighex}));
+2395 	var seq = new _DERSequence({array: a});
+2396 	return seq.tohex();
+2397     };
+2398     this.getEncodedHex = function() { return this.tohex(); };
+2399 
+2400     if (params != undefined) this.params = params;
+2401 };
+2402 extendClass(KJUR.asn1.x509.CRL, KJUR.asn1.ASN1Object);
+2403 
+2404 /**
+2405  * ASN.1 TBSCertList ASN.1 structure class for CRL<br/>
+2406  * @name KJUR.asn1.x509.TBSCertList
+2407  * @class TBSCertList ASN.1 structure class for CRL
+2408  * @property {Array} params JSON object of parameters
+2409  * @param {Array} params JSON object of TBSCertList parameters
+2410  * @extends KJUR.asn1.ASN1Object
+2411  * @since 1.0.3
+2412  *
+2413  * @description
+2414  * This class represents TBSCertList of CRL defined in
+2415  * <a href="https://tools.ietf.org/html/rfc5280#section-5.1">
+2416  * RFC 5280 5.1</a>.
+2417  * <pre>
+2418  * TBSCertList  ::=  SEQUENCE  {
+2419  *       version                 Version OPTIONAL,
+2420  *                                    -- if present, MUST be v2
+2421  *       signature               AlgorithmIdentifier,
+2422  *       issuer                  Name,
+2423  *       thisUpdate              Time,
+2424  *       nextUpdate              Time OPTIONAL,
+2425  *       revokedCertificates     SEQUENCE OF SEQUENCE  {
+2426  *            userCertificate         CertificateSerialNumber,
+2427  *            revocationDate          Time,
+2428  *            crlEntryExtensions      Extensions OPTIONAL
+2429  *                                     -- if present, version MUST be v2
+2430  *                                 }  OPTIONAL,
+2431  *       crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
+2432  * }
+2433  * </pre>
+2434  * NOTE: TBSCertList class is updated without backward 
+2435  * compatibility from jsrsasign 9.1.0 asn1x509 2.1.0.
+2436  * Most of methods are removed and parameters can be set
+2437  * by JSON object.
+2438  * <br/>
+2439  * Constructor of this class may have following parameters:
+2440  * <ul>
+2441  * <li>{Integer}version (OPTION) - version number. Omitted by default.</li>
+2442  * <li>{String}sigalg - signature algorithm name</li>
+2443  * <li>{Array}issuer - issuer parameter of {@link KJUR.asn1.x509.X500Name}</li>
+2444  * <li>{String}thisupdate - thisUpdate field value</li>
+2445  * <li>{String}nextupdate (OPTION) - thisUpdate field value</li>
+2446  * <li>{Array}revcert (OPTION) - revokedCertificates field value as array
+2447  *   Its element may have following property:
+2448  *   <ul>
+2449  *   <li>{Array}sn - serialNumber of userCertificate field specified
+2450  *   by {@link KJUR.asn1.DERInteger}</li>
+2451  *   <li>{String}date - revocationDate field specified by
+2452  *   a string of {@link KJUR.asn1.x509.Time} parameter</li>
+2453  *   <li>{Array}ext (OPTION) - array of CRL entry extension parameter</li>
+2454  *   </ul>
+2455  * </li>
+2456  * </ul>
+2457  * 
+2458  * @example
+2459  * var o = new KJUR.asn1.x509.TBSCertList({
+2460  *  sigalg: "SHA256withRSA",
+2461  *  issuer: {array: [[{type:'C',value:'JP',ds:'prn'}],
+2462  *                   [{type:'O',value:'T1',ds:'prn'}]]},
+2463  *  thisupdate: "200821235959Z",
+2464  *  nextupdate: "200828235959Z", // OPTION
+2465  *  revcert: [
+2466  *   {sn: {hex: "12ab"}, date: "200401235959Z", ext: [{extname: "cRLReason", code:1}]},
+2467  *   {sn: {hex: "12bc"}, date: "200405235959Z", ext: [{extname: "cRLReason", code:2}]}
+2468  *  ],
+2469  *  ext: [
+2470  *   {extname: "cRLNumber", num: {'int': 8}},
+2471  *   {extname: "authorityKeyIdentifier", "kid": {hex: "12ab"}}
+2472  *  ]
+2473  * });
+2474  * o.tohex() → "30..."
+2475  */
+2476 KJUR.asn1.x509.TBSCertList = function(params) {
+2477     KJUR.asn1.x509.TBSCertList.superclass.constructor.call(this);
+2478     var	_KJUR = KJUR,
+2479 	_KJUR_asn1 = _KJUR.asn1,
+2480 	_DERInteger = _KJUR_asn1.DERInteger,
+2481 	_DERSequence = _KJUR_asn1.DERSequence,
+2482 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+2483 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+2484 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+2485 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
+2486 	_Time = _KJUR_asn1_x509.Time,
+2487 	_Extensions = _KJUR_asn1_x509.Extensions,
+2488 	_X500Name = _KJUR_asn1_x509.X500Name;
+2489     this.params = null;
+2490 
+2491     /**
+2492      * get array of ASN.1 object for extensions<br/>
+2493      * @name setByParam
+2494      * @memberOf KJUR.asn1.x509.TBSCertList#
+2495      * @function
+2496      * @param {Array} JSON object of TBSCertList parameters
+2497      * @example
+2498      * tbsc = new KJUR.asn1.x509.TBSCertificate();
+2499      * tbsc.setByParam({version:3, serial:{hex:'1234...'},...});
+2500      */
+2501     this.setByParam = function(params) {
+2502 	this.params = params;
+2503     };
+2504 
+2505     /**
+2506      * get DERSequence for revokedCertificates<br/>
+2507      * @name getRevCertSequence
+2508      * @memberOf KJUR.asn1.x509.TBSCertList#
+2509      * @function
+2510      * @return {@link KJUR.asn1.DERSequence} of revokedCertificates
+2511      */
+2512     this.getRevCertSequence = function() {
+2513 	var a = [];
+2514 	var aRevCert = this.params.revcert;
+2515 	for (var i = 0; i < aRevCert.length; i++) {
+2516 	    var aEntry = [
+2517 		new _DERInteger(aRevCert[i].sn),
+2518 		new _Time(aRevCert[i].date)
+2519 	    ];
+2520 	    if (aRevCert[i].ext != undefined) {
+2521 		aEntry.push(new _Extensions(aRevCert[i].ext));
+2522 	    }
+2523 	    a.push(new _DERSequence({array: aEntry}));
+2524 	}
+2525 	return new _DERSequence({array: a});
+2526     };
+2527 
+2528     this.tohex = function() {
+2529 	var a = [];
+2530 	var params = this.params;
+2531 
+2532 	if (params.version != undefined) {
+2533 	    var version = params.version - 1; 
+2534 	    var obj = new _DERInteger({'int': version});
+2535 	    a.push(obj);
+2536 	}
+2537 
+2538 	a.push(new _AlgorithmIdentifier({name: params.sigalg}));
+2539 	a.push(new _X500Name(params.issuer));
+2540 	a.push(new _Time(params.thisupdate));
+2541 	if (params.nextupdate != undefined) 
+2542 	    a.push(new _Time(params.nextupdate))
+2543 	if (params.revcert != undefined) {
+2544 	    a.push(this.getRevCertSequence());
+2545 	}
+2546 	if (params.ext != undefined) {
+2547 	    var dExt = new _Extensions(params.ext);
+2548 	    a.push(new _DERTaggedObject({tag:'a0',
+2549 					 explicit:true,
+2550 					 obj:dExt}));
+2551 	}
+2552 
+2553 	var seq = new _DERSequence({array: a});
+2554 	return seq.tohex();
 2555     };
-2556 
-2557     this.tohex = function() {
-2558 	var a = [];
-2559 	var params = this.params;
-2560 
-2561 	if (params.version != undefined) {
-2562 	    var version = params.version - 1; 
-2563 	    var obj = new _DERInteger({'int': version});
-2564 	    a.push(obj);
-2565 	}
-2566 
-2567 	a.push(new _AlgorithmIdentifier({name: params.sigalg}));
-2568 	a.push(new _X500Name(params.issuer));
-2569 	a.push(new _Time(params.thisupdate));
-2570 	if (params.nextupdate != undefined) 
-2571 	    a.push(new _Time(params.nextupdate))
-2572 	if (params.revcert != undefined) {
-2573 	    a.push(this.getRevCertSequence());
-2574 	}
-2575 	if (params.ext != undefined) {
-2576 	    var dExt = new _Extensions(params.ext);
-2577 	    a.push(new _DERTaggedObject({tag:'a0',
-2578 					 explicit:true,
-2579 					 obj:dExt}));
-2580 	}
-2581 
-2582 	var seq = new _DERSequence({array: a});
-2583 	return seq.tohex();
-2584     };
-2585     this.getEncodedHex = function() { return this.tohex(); };
-2586 
-2587     if (params !== undefined) this.setByParam(params);
-2588 };
-2589 extendClass(KJUR.asn1.x509.TBSCertList, KJUR.asn1.ASN1Object);
-2590 
-2591 /**
-2592  * ASN.1 CRLEntry structure class for CRL (DEPRECATED)<br/>
-2593  * @name KJUR.asn1.x509.CRLEntry
-2594  * @class ASN.1 CRLEntry structure class for CRL
-2595  * @param {Array} params JSON object for CRL entry parameter
-2596  * @extends KJUR.asn1.ASN1Object
-2597  * @since 1.0.3
-2598  * @see KJUR.asn1.x509.TBSCertList
-2599  * @deprecated since jsrsasign 9.1.0 asn1x509 2.1.0
-2600  * @description
-2601  * This class is to represent revokedCertificate in TBSCertList.
-2602  * However this is no more used by TBSCertList since
-2603  * jsrsasign 9.1.0. So this class have been deprecated in 
-2604  * jsrsasign 9.1.0.
-2605  * <pre>
-2606  * revokedCertificates     SEQUENCE OF SEQUENCE  {
-2607  *     userCertificate         CertificateSerialNumber,
-2608  *     revocationDate          Time,
-2609  *     crlEntryExtensions      Extensions OPTIONAL
-2610  *                             -- if present, version MUST be v2 }
-2611  * </pre>
-2612  * @example
-2613  * var e = new KJUR.asn1.x509.CRLEntry({'time': {'str': '130514235959Z'}, 'sn': {'int': 234}});
-2614  */
-2615 KJUR.asn1.x509.CRLEntry = function(params) {
-2616     KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);
-2617     var sn = null,
-2618 	time = null,
-2619 	_KJUR = KJUR,
-2620 	_KJUR_asn1 = _KJUR.asn1;
-2621 
-2622     /**
-2623      * set DERInteger parameter for serial number of revoked certificate
-2624      * @name setCertSerial
-2625      * @memberOf KJUR.asn1.x509.CRLEntry
-2626      * @function
-2627      * @param {Array} intParam DERInteger parameter for certificate serial number
-2628      * @description
-2629      * @example
-2630      * entry.setCertSerial({'int': 3});
-2631      */
-2632     this.setCertSerial = function(intParam) {
-2633         this.sn = new _KJUR_asn1.DERInteger(intParam);
-2634     };
-2635 
-2636     /**
-2637      * set Time parameter for revocation date
-2638      * @name setRevocationDate
-2639      * @memberOf KJUR.asn1.x509.CRLEntry
-2640      * @function
-2641      * @param {Array} timeParam Time parameter for revocation date
-2642      * @description
-2643      * @example
-2644      * entry.setRevocationDate({'str': '130508235959Z'});
-2645      */
-2646     this.setRevocationDate = function(timeParam) {
-2647         this.time = new _KJUR_asn1.x509.Time(timeParam);
-2648     };
-2649 
-2650     this.tohex = function() {
-2651         var o = new _KJUR_asn1.DERSequence({"array": [this.sn, this.time]});
-2652         this.TLV = o.tohex();
-2653         return this.TLV;
-2654     };
-2655     this.getEncodedHex = function() { return this.tohex(); };
-2656 
-2657     if (params !== undefined) {
-2658         if (params.time !== undefined) {
-2659             this.setRevocationDate(params.time);
-2660         }
-2661         if (params.sn !== undefined) {
-2662             this.setCertSerial(params.sn);
-2663         }
-2664     }
-2665 };
-2666 extendClass(KJUR.asn1.x509.CRLEntry, KJUR.asn1.ASN1Object);
-2667 
-2668 /**
-2669  * CRLNumber CRL extension ASN.1 structure class<br/>
-2670  * @name KJUR.asn1.x509.CRLNumber
-2671  * @class CRLNumber CRL extension ASN.1 structure class
-2672  * @extends KJUR.asn1.x509.Extension
-2673  * @since jsrsasign 9.1.0 asn1x509 2.1.0
-2674  * @see KJUR.asn1.x509.TBSCertList
-2675  * @see KJUR.asn1.x509.Extensions
-2676  * @description
-2677  * This class represents ASN.1 structure for
-2678  * CRLNumber CRL extension defined in
-2679  * <a href="https://tools.ietf.org/html/rfc5280#section-5.2.3">
-2680  * RFC 5280 5.2.3</a>.
-2681  * <pre>
-2682  * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
-2683  * CRLNumber ::= INTEGER (0..MAX)
-2684  * </pre>
-2685  * Constructor of this class may have following parameters:
-2686  * <ul>
-2687  * <li>{String}extname - name "cRLNumber". It is ignored in this class but
-2688  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
-2689  * <li>{Object}num - CRLNumber value to specify
-2690  * {@link KJUR.asn1.DERInteger} parameter.</li>
-2691  * <li>{Boolean}critical - critical flag. Generally false and not specified
-2692  * in this class.(OPTION)</li>
-2693  * </ul>
-2694  *
-2695  * @example
-2696  * new KJUR.asn1.x509.CRLNumber({extname:'cRLNumber',
-2697  *                               num:{'int':147}})
-2698  */
-2699 KJUR.asn1.x509.CRLNumber = function(params) {
-2700     KJUR.asn1.x509.CRLNumber.superclass.constructor.call(this, params);
-2701     this.params = undefined;
-2702 
-2703     this.getExtnValueHex = function() {
-2704         this.asn1ExtnValue = new KJUR.asn1.DERInteger(this.params.num);
-2705         return this.asn1ExtnValue.tohex();
-2706     };
-2707 
-2708     this.oid = "2.5.29.20";
-2709     if (params != undefined) this.params = params;
-2710 };
-2711 extendClass(KJUR.asn1.x509.CRLNumber, KJUR.asn1.x509.Extension);
-2712 
-2713 /**
-2714  * CRLReason CRL entry extension ASN.1 structure class<br/>
-2715  * @name KJUR.asn1.x509.CRLReason
-2716  * @class CRLReason CRL entry extension ASN.1 structure class
-2717  * @extends KJUR.asn1.x509.Extension
-2718  * @since jsrsasign 9.1.0 asn1x509 2.1.0
-2719  * @see KJUR.asn1.x509.TBSCertList
-2720  * @see KJUR.asn1.x509.Extensions
-2721  * @description
-2722  * This class represents ASN.1 structure for
-2723  * CRLReason CRL entry extension defined in
-2724  * <a href="https://tools.ietf.org/html/rfc5280#section-5.3.1">
-2725  * RFC 5280 5.3.1</a>
-2726  * <pre>
-2727  * id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 }
-2728  * -- reasonCode ::= { CRLReason }
-2729  * CRLReason ::= ENUMERATED {
-2730  *      unspecified             (0),
-2731  *      keyCompromise           (1),
-2732  *      cACompromise            (2),
-2733  *      affiliationChanged      (3),
-2734  *      superseded              (4),
-2735  *      cessationOfOperation    (5),
-2736  *      certificateHold         (6),
-2737  *      removeFromCRL           (8),
-2738  *      privilegeWithdrawn      (9),
-2739  *      aACompromise           (10) }
-2740  * </pre>
-2741  * Constructor of this class may have following parameters:
-2742  * <ul>
-2743  * <li>{String}extname - name "cRLReason". It is ignored in this class but
-2744  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
-2745  * <li>{Integer}code - reasonCode value</li>
-2746  * <li>{Boolean}critical - critical flag. Generally false and not specified
-2747  * in this class.(OPTION)</li>
-2748  * </ul>
-2749  *
-2750  * @example
-2751  * new KJUR.asn1.x509.CRLReason({extname:'cRLReason',code:4})
-2752  */
-2753 KJUR.asn1.x509.CRLReason = function(params) {
-2754     KJUR.asn1.x509.CRLReason.superclass.constructor.call(this, params);
-2755     this.params = undefined;
-2756 
-2757     this.getExtnValueHex = function() {
-2758         this.asn1ExtnValue = new KJUR.asn1.DEREnumerated(this.params.code);
-2759         return this.asn1ExtnValue.tohex();
-2760     };
-2761 
-2762     this.oid = "2.5.29.21";
-2763     if (params != undefined) this.params = params;
-2764 };
-2765 extendClass(KJUR.asn1.x509.CRLReason, KJUR.asn1.x509.Extension);
-2766 
-2767 // === END   CRL Related ===================================================
-2768 
-2769 // === BEGIN OCSP Related ===================================================
-2770 /**
-2771  * Nonce OCSP extension ASN.1 structure class<br/>
-2772  * @name KJUR.asn1.x509.OCSPNonce
-2773  * @class Nonce OCSP extension ASN.1 structure class
-2774  * @extends KJUR.asn1.x509.Extension
-2775  * @since jsrsasign 9.1.6 asn1x509 2.1.2
-2776  * @param {Array} params JSON object for Nonce extension
-2777  * @see KJUR.asn1.ocsp.ResponseData
-2778  * @see KJUR.asn1.x509.Extensions
-2779  * @see X509#getExtOCSPNonce
-2780  * @description
-2781  * This class represents
-2782  * Nonce OCSP extension value defined in
-2783  * <a href="https://tools.ietf.org/html/rfc6960#section-4.4.1">
-2784  * RFC 6960 4.4.1</a> as JSON object.
-2785  * <pre>
-2786  * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
-2787  * id-pkix-ocsp-nonce     OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
-2788  * Nonce ::= OCTET STRING
-2789  * </pre>
-2790  * Constructor of this class may have following parameters:
-2791  * <ul>
-2792  * <li>{String}extname - name "ocspNonce". It is ignored in this class but
-2793  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
-2794  * <li>{String}hex - hexadecimal string of nonce value</li>
-2795  * <li>{Number}int - integer of nonce value. "hex" or "int" needs to be
-2796  * specified.</li>
-2797  * <li>{Boolean}critical - critical flag. Generally false and not specified
-2798  * in this class.(OPTION)</li>
-2799  * </ul>
-2800  *
-2801  * @example
-2802  * new KJUR.asn1.x509.OCSPNonce({extname:'ocspNonce',
-2803  *                               hex: '12ab...'})
-2804  */
-2805 KJUR.asn1.x509.OCSPNonce = function(params) {
-2806     KJUR.asn1.x509.OCSPNonce.superclass.constructor.call(this, params);
-2807     this.params = undefined;
-2808 
-2809     this.getExtnValueHex = function() {
-2810         this.asn1ExtnValue = new KJUR.asn1.DEROctetString(this.params);
-2811         return this.asn1ExtnValue.tohex();
-2812     };
-2813 
-2814     this.oid = "1.3.6.1.5.5.7.48.1.2";
-2815     if (params != undefined) this.params = params;
-2816 };
-2817 extendClass(KJUR.asn1.x509.OCSPNonce, KJUR.asn1.x509.Extension);
-2818 
-2819 /**
-2820  * OCSPNoCheck certificate ASN.1 structure class<br/>
-2821  * @name KJUR.asn1.x509.OCSPNoCheck
-2822  * @class OCSPNoCheck extension ASN.1 structure class
-2823  * @extends KJUR.asn1.x509.Extension
-2824  * @since jsrsasign 9.1.6 asn1x509 2.1.2
-2825  * @param {Array} params JSON object for OCSPNoCheck extension
-2826  * @see KJUR.asn1.x509.Extensions
-2827  * @see X509#getExtOCSPNoCheck
-2828  * @description
-2829  * This class represents
-2830  * OCSPNoCheck extension value defined in
-2831  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.2.2.1">
-2832  * RFC 6960 4.2.2.2.1</a> as JSON object.
-2833  * <pre>
-2834  * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
-2835  * </pre>
-2836  * Constructor of this class may have following parameters:
-2837  * <ul>
-2838  * <li>{String}extname - name "ocspNoCheck". It is ignored in this class but
-2839  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
-2840  * <li>{Boolean}critical - critical flag. Generally false and not specified
-2841  * in this class.(OPTION)</li>
-2842  * </ul>
-2843  *
-2844  * @example
-2845  * new KJUR.asn1.x509.OCSPNonce({extname:'ocspNoCheck'})
-2846  */
-2847 KJUR.asn1.x509.OCSPNoCheck = function(params) {
-2848     KJUR.asn1.x509.OCSPNoCheck.superclass.constructor.call(this, params);
-2849     this.params = undefined;
-2850 
-2851     this.getExtnValueHex = function() {
-2852         this.asn1ExtnValue = new KJUR.asn1.DERNull();
-2853         return this.asn1ExtnValue.tohex();
-2854     };
-2855 
-2856     this.oid = "1.3.6.1.5.5.7.48.1.5";
-2857     if (params != undefined) this.params = params;
-2858 };
-2859 extendClass(KJUR.asn1.x509.OCSPNoCheck, KJUR.asn1.x509.Extension);
-2860 
-2861 // === END   OCSP Related ===================================================
-2862 
-2863 // === BEGIN Other X.509v3 Extensions========================================
-2864 
-2865 /**
-2866  * AdobeTimeStamp X.509v3 extension ASN.1 encoder class<br/>
-2867  * @name KJUR.asn1.x509.AdobeTimeStamp
-2868  * @class AdobeTimeStamp X.509v3 extension ASN.1 encoder class
-2869  * @extends KJUR.asn1.x509.Extension
-2870  * @since jsrsasign 10.0.1 asn1x509 2.1.4
-2871  * @param {Array} params JSON object for AdobeTimeStamp extension parameter
-2872  * @see KJUR.asn1.x509.Extensions
-2873  * @see X509#getExtAdobeTimeStamp
-2874  * @description
-2875  * This class represents
-2876  * AdobeTimeStamp X.509v3 extension value defined in
-2877  * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSigDC/oids.html">
-2878  * Adobe site</a> as JSON object.
-2879  * <pre>
-2880  * adbe- OBJECT IDENTIFIER ::=  { adbe(1.2.840.113583) acrobat(1) security(1) x509Ext(9) 1 }
-2881  *  ::= SEQUENCE {
-2882  *     version INTEGER  { v1(1) }, -- extension version
-2883  *     location GeneralName (In v1 GeneralName can be only uniformResourceIdentifier)
-2884  *     requiresAuth        boolean (default false), OPTIONAL }
-2885  * </pre>
-2886  * Constructor of this class may have following parameters:
-2887  * <ul>
-2888  * <li>{String}uri - RFC 3161 time stamp service URL</li>
-2889  * <li>{Boolean}reqauth - authentication required or not</li>
-2890  * </ul>
-2891  * </pre>
-2892  * <br/>
-2893  * NOTE: This extesion doesn't seem to have official name. This may be called as "pdfTimeStamp".
-2894  * @example
-2895  * new KJUR.asn1.x509.AdobeTimesStamp({
-2896  *   uri: "http://tsa.example.com/",
-2897  *   reqauth: true
-2898  * }
-2899  */
-2900 KJUR.asn1.x509.AdobeTimeStamp = function(params) {
-2901     KJUR.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this, params);
+2556     this.getEncodedHex = function() { return this.tohex(); };
+2557 
+2558     if (params !== undefined) this.setByParam(params);
+2559 };
+2560 extendClass(KJUR.asn1.x509.TBSCertList, KJUR.asn1.ASN1Object);
+2561 
+2562 /**
+2563  * ASN.1 CRLEntry structure class for CRL (DEPRECATED)<br/>
+2564  * @name KJUR.asn1.x509.CRLEntry
+2565  * @class ASN.1 CRLEntry structure class for CRL
+2566  * @param {Array} params JSON object for CRL entry parameter
+2567  * @extends KJUR.asn1.ASN1Object
+2568  * @since 1.0.3
+2569  * @see KJUR.asn1.x509.TBSCertList
+2570  * @deprecated since jsrsasign 9.1.0 asn1x509 2.1.0
+2571  * @description
+2572  * This class is to represent revokedCertificate in TBSCertList.
+2573  * However this is no more used by TBSCertList since
+2574  * jsrsasign 9.1.0. So this class have been deprecated in 
+2575  * jsrsasign 9.1.0.
+2576  * <pre>
+2577  * revokedCertificates     SEQUENCE OF SEQUENCE  {
+2578  *     userCertificate         CertificateSerialNumber,
+2579  *     revocationDate          Time,
+2580  *     crlEntryExtensions      Extensions OPTIONAL
+2581  *                             -- if present, version MUST be v2 }
+2582  * </pre>
+2583  * @example
+2584  * var e = new KJUR.asn1.x509.CRLEntry({'time': {'str': '130514235959Z'}, 'sn': {'int': 234}});
+2585  */
+2586 KJUR.asn1.x509.CRLEntry = function(params) {
+2587     KJUR.asn1.x509.CRLEntry.superclass.constructor.call(this);
+2588     var sn = null,
+2589 	time = null,
+2590 	_KJUR = KJUR,
+2591 	_KJUR_asn1 = _KJUR.asn1;
+2592 
+2593     /**
+2594      * set DERInteger parameter for serial number of revoked certificate
+2595      * @name setCertSerial
+2596      * @memberOf KJUR.asn1.x509.CRLEntry
+2597      * @function
+2598      * @param {Array} intParam DERInteger parameter for certificate serial number
+2599      * @description
+2600      * @example
+2601      * entry.setCertSerial({'int': 3});
+2602      */
+2603     this.setCertSerial = function(intParam) {
+2604         this.sn = new _KJUR_asn1.DERInteger(intParam);
+2605     };
+2606 
+2607     /**
+2608      * set Time parameter for revocation date
+2609      * @name setRevocationDate
+2610      * @memberOf KJUR.asn1.x509.CRLEntry
+2611      * @function
+2612      * @param {Array} timeParam Time parameter for revocation date
+2613      * @description
+2614      * @example
+2615      * entry.setRevocationDate({'str': '130508235959Z'});
+2616      */
+2617     this.setRevocationDate = function(timeParam) {
+2618         this.time = new _KJUR_asn1.x509.Time(timeParam);
+2619     };
+2620 
+2621     this.tohex = function() {
+2622         var o = new _KJUR_asn1.DERSequence({"array": [this.sn, this.time]});
+2623         this.TLV = o.tohex();
+2624         return this.TLV;
+2625     };
+2626     this.getEncodedHex = function() { return this.tohex(); };
+2627 
+2628     if (params !== undefined) {
+2629         if (params.time !== undefined) {
+2630             this.setRevocationDate(params.time);
+2631         }
+2632         if (params.sn !== undefined) {
+2633             this.setCertSerial(params.sn);
+2634         }
+2635     }
+2636 };
+2637 extendClass(KJUR.asn1.x509.CRLEntry, KJUR.asn1.ASN1Object);
+2638 
+2639 /**
+2640  * CRLNumber CRL extension ASN.1 structure class<br/>
+2641  * @name KJUR.asn1.x509.CRLNumber
+2642  * @class CRLNumber CRL extension ASN.1 structure class
+2643  * @extends KJUR.asn1.x509.Extension
+2644  * @since jsrsasign 9.1.0 asn1x509 2.1.0
+2645  * @see KJUR.asn1.x509.TBSCertList
+2646  * @see KJUR.asn1.x509.Extensions
+2647  * @description
+2648  * This class represents ASN.1 structure for
+2649  * CRLNumber CRL extension defined in
+2650  * <a href="https://tools.ietf.org/html/rfc5280#section-5.2.3">
+2651  * RFC 5280 5.2.3</a>.
+2652  * <pre>
+2653  * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
+2654  * CRLNumber ::= INTEGER (0..MAX)
+2655  * </pre>
+2656  * Constructor of this class may have following parameters:
+2657  * <ul>
+2658  * <li>{String}extname - name "cRLNumber". It is ignored in this class but
+2659  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
+2660  * <li>{Object}num - CRLNumber value to specify
+2661  * {@link KJUR.asn1.DERInteger} parameter.</li>
+2662  * <li>{Boolean}critical - critical flag. Generally false and not specified
+2663  * in this class.(OPTION)</li>
+2664  * </ul>
+2665  *
+2666  * @example
+2667  * new KJUR.asn1.x509.CRLNumber({extname:'cRLNumber',
+2668  *                               num:{'int':147}})
+2669  */
+2670 KJUR.asn1.x509.CRLNumber = function(params) {
+2671     KJUR.asn1.x509.CRLNumber.superclass.constructor.call(this, params);
+2672     this.params = undefined;
+2673 
+2674     this.getExtnValueHex = function() {
+2675         this.asn1ExtnValue = new KJUR.asn1.DERInteger(this.params.num);
+2676         return this.asn1ExtnValue.tohex();
+2677     };
+2678 
+2679     this.oid = "2.5.29.20";
+2680     if (params != undefined) this.params = params;
+2681 };
+2682 extendClass(KJUR.asn1.x509.CRLNumber, KJUR.asn1.x509.Extension);
+2683 
+2684 /**
+2685  * CRLReason CRL entry extension ASN.1 structure class<br/>
+2686  * @name KJUR.asn1.x509.CRLReason
+2687  * @class CRLReason CRL entry extension ASN.1 structure class
+2688  * @extends KJUR.asn1.x509.Extension
+2689  * @since jsrsasign 9.1.0 asn1x509 2.1.0
+2690  * @see KJUR.asn1.x509.TBSCertList
+2691  * @see KJUR.asn1.x509.Extensions
+2692  * @description
+2693  * This class represents ASN.1 structure for
+2694  * CRLReason CRL entry extension defined in
+2695  * <a href="https://tools.ietf.org/html/rfc5280#section-5.3.1">
+2696  * RFC 5280 5.3.1</a>
+2697  * <pre>
+2698  * id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 }
+2699  * -- reasonCode ::= { CRLReason }
+2700  * CRLReason ::= ENUMERATED {
+2701  *      unspecified             (0),
+2702  *      keyCompromise           (1),
+2703  *      cACompromise            (2),
+2704  *      affiliationChanged      (3),
+2705  *      superseded              (4),
+2706  *      cessationOfOperation    (5),
+2707  *      certificateHold         (6),
+2708  *      removeFromCRL           (8),
+2709  *      privilegeWithdrawn      (9),
+2710  *      aACompromise           (10) }
+2711  * </pre>
+2712  * Constructor of this class may have following parameters:
+2713  * <ul>
+2714  * <li>{String}extname - name "cRLReason". It is ignored in this class but
+2715  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
+2716  * <li>{Integer}code - reasonCode value</li>
+2717  * <li>{Boolean}critical - critical flag. Generally false and not specified
+2718  * in this class.(OPTION)</li>
+2719  * </ul>
+2720  *
+2721  * @example
+2722  * new KJUR.asn1.x509.CRLReason({extname:'cRLReason',code:4})
+2723  */
+2724 KJUR.asn1.x509.CRLReason = function(params) {
+2725     KJUR.asn1.x509.CRLReason.superclass.constructor.call(this, params);
+2726     this.params = undefined;
+2727 
+2728     this.getExtnValueHex = function() {
+2729         this.asn1ExtnValue = new KJUR.asn1.DEREnumerated(this.params.code);
+2730         return this.asn1ExtnValue.tohex();
+2731     };
+2732 
+2733     this.oid = "2.5.29.21";
+2734     if (params != undefined) this.params = params;
+2735 };
+2736 extendClass(KJUR.asn1.x509.CRLReason, KJUR.asn1.x509.Extension);
+2737 
+2738 // === END   CRL Related ===================================================
+2739 
+2740 // === BEGIN OCSP Related ===================================================
+2741 /**
+2742  * Nonce OCSP extension ASN.1 structure class<br/>
+2743  * @name KJUR.asn1.x509.OCSPNonce
+2744  * @class Nonce OCSP extension ASN.1 structure class
+2745  * @extends KJUR.asn1.x509.Extension
+2746  * @since jsrsasign 9.1.6 asn1x509 2.1.2
+2747  * @param {Array} params JSON object for Nonce extension
+2748  * @see KJUR.asn1.ocsp.ResponseData
+2749  * @see KJUR.asn1.x509.Extensions
+2750  * @see X509#getExtOCSPNonce
+2751  * @description
+2752  * This class represents
+2753  * Nonce OCSP extension value defined in
+2754  * <a href="https://tools.ietf.org/html/rfc6960#section-4.4.1">
+2755  * RFC 6960 4.4.1</a> as JSON object.
+2756  * <pre>
+2757  * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
+2758  * id-pkix-ocsp-nonce     OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
+2759  * Nonce ::= OCTET STRING
+2760  * </pre>
+2761  * Constructor of this class may have following parameters:
+2762  * <ul>
+2763  * <li>{String}extname - name "ocspNonce". It is ignored in this class but
+2764  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
+2765  * <li>{String}hex - hexadecimal string of nonce value</li>
+2766  * <li>{Number}int - integer of nonce value. "hex" or "int" needs to be
+2767  * specified.</li>
+2768  * <li>{Boolean}critical - critical flag. Generally false and not specified
+2769  * in this class.(OPTION)</li>
+2770  * </ul>
+2771  *
+2772  * @example
+2773  * new KJUR.asn1.x509.OCSPNonce({extname:'ocspNonce',
+2774  *                               hex: '12ab...'})
+2775  */
+2776 KJUR.asn1.x509.OCSPNonce = function(params) {
+2777     KJUR.asn1.x509.OCSPNonce.superclass.constructor.call(this, params);
+2778     this.params = undefined;
+2779 
+2780     this.getExtnValueHex = function() {
+2781         this.asn1ExtnValue = new KJUR.asn1.DEROctetString(this.params);
+2782         return this.asn1ExtnValue.tohex();
+2783     };
+2784 
+2785     this.oid = "1.3.6.1.5.5.7.48.1.2";
+2786     if (params != undefined) this.params = params;
+2787 };
+2788 extendClass(KJUR.asn1.x509.OCSPNonce, KJUR.asn1.x509.Extension);
+2789 
+2790 /**
+2791  * OCSPNoCheck certificate ASN.1 structure class<br/>
+2792  * @name KJUR.asn1.x509.OCSPNoCheck
+2793  * @class OCSPNoCheck extension ASN.1 structure class
+2794  * @extends KJUR.asn1.x509.Extension
+2795  * @since jsrsasign 9.1.6 asn1x509 2.1.2
+2796  * @param {Array} params JSON object for OCSPNoCheck extension
+2797  * @see KJUR.asn1.x509.Extensions
+2798  * @see X509#getExtOCSPNoCheck
+2799  * @description
+2800  * This class represents
+2801  * OCSPNoCheck extension value defined in
+2802  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.2.2.1">
+2803  * RFC 6960 4.2.2.2.1</a> as JSON object.
+2804  * <pre>
+2805  * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
+2806  * </pre>
+2807  * Constructor of this class may have following parameters:
+2808  * <ul>
+2809  * <li>{String}extname - name "ocspNoCheck". It is ignored in this class but
+2810  * required to use with {@link KJUR.asn1.x509.Extensions} class. (OPTION)</li>
+2811  * <li>{Boolean}critical - critical flag. Generally false and not specified
+2812  * in this class.(OPTION)</li>
+2813  * </ul>
+2814  *
+2815  * @example
+2816  * new KJUR.asn1.x509.OCSPNonce({extname:'ocspNoCheck'})
+2817  */
+2818 KJUR.asn1.x509.OCSPNoCheck = function(params) {
+2819     KJUR.asn1.x509.OCSPNoCheck.superclass.constructor.call(this, params);
+2820     this.params = undefined;
+2821 
+2822     this.getExtnValueHex = function() {
+2823         this.asn1ExtnValue = new KJUR.asn1.DERNull();
+2824         return this.asn1ExtnValue.tohex();
+2825     };
+2826 
+2827     this.oid = "1.3.6.1.5.5.7.48.1.5";
+2828     if (params != undefined) this.params = params;
+2829 };
+2830 extendClass(KJUR.asn1.x509.OCSPNoCheck, KJUR.asn1.x509.Extension);
+2831 
+2832 // === END   OCSP Related ===================================================
+2833 
+2834 // === BEGIN Other X.509v3 Extensions========================================
+2835 
+2836 /**
+2837  * AdobeTimeStamp X.509v3 extension ASN.1 encoder class<br/>
+2838  * @name KJUR.asn1.x509.AdobeTimeStamp
+2839  * @class AdobeTimeStamp X.509v3 extension ASN.1 encoder class
+2840  * @extends KJUR.asn1.x509.Extension
+2841  * @since jsrsasign 10.0.1 asn1x509 2.1.4
+2842  * @param {Array} params JSON object for AdobeTimeStamp extension parameter
+2843  * @see KJUR.asn1.x509.Extensions
+2844  * @see X509#getExtAdobeTimeStamp
+2845  * @description
+2846  * This class represents
+2847  * AdobeTimeStamp X.509v3 extension value defined in
+2848  * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSigDC/oids.html">
+2849  * Adobe site</a> as JSON object.
+2850  * <pre>
+2851  * adbe- OBJECT IDENTIFIER ::=  { adbe(1.2.840.113583) acrobat(1) security(1) x509Ext(9) 1 }
+2852  *  ::= SEQUENCE {
+2853  *     version INTEGER  { v1(1) }, -- extension version
+2854  *     location GeneralName (In v1 GeneralName can be only uniformResourceIdentifier)
+2855  *     requiresAuth        boolean (default false), OPTIONAL }
+2856  * </pre>
+2857  * Constructor of this class may have following parameters:
+2858  * <ul>
+2859  * <li>{String}uri - RFC 3161 time stamp service URL</li>
+2860  * <li>{Boolean}reqauth - authentication required or not</li>
+2861  * </ul>
+2862  * </pre>
+2863  * <br/>
+2864  * NOTE: This extesion doesn't seem to have official name. This may be called as "pdfTimeStamp".
+2865  * @example
+2866  * new KJUR.asn1.x509.AdobeTimesStamp({
+2867  *   uri: "http://tsa.example.com/",
+2868  *   reqauth: true
+2869  * }
+2870  */
+2871 KJUR.asn1.x509.AdobeTimeStamp = function(params) {
+2872     KJUR.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this, params);
+2873 
+2874     var _KJUR = KJUR,
+2875 	_KJUR_asn1 = _KJUR.asn1,
+2876 	_DERInteger = _KJUR_asn1.DERInteger,
+2877 	_DERBoolean = _KJUR_asn1.DERBoolean,
+2878 	_DERSequence = _KJUR_asn1.DERSequence,
+2879 	_GeneralName = _KJUR_asn1.x509.GeneralName;
+2880 
+2881     this.params = null;
+2882 
+2883     this.getExtnValueHex = function() {
+2884 	var params = this.params;
+2885 	var a = [new _DERInteger(1)];
+2886 	a.push(new _GeneralName({uri: params.uri}));
+2887 	if (params.reqauth != undefined) {
+2888 	    a.push(new _DERBoolean(params.reqauth));
+2889 	}
+2890 
+2891         this.asn1ExtnValue = new _DERSequence({array: a});
+2892         return this.asn1ExtnValue.tohex();
+2893     };
+2894 
+2895     this.oid = "1.2.840.113583.1.1.9.1";
+2896     if (params !== undefined) this.setByParam(params);
+2897 };
+2898 extendClass(KJUR.asn1.x509.AdobeTimeStamp, KJUR.asn1.x509.Extension);
+2899  
+2900 // === END   Other X.509v3 Extensions========================================
+2901 
 2902 
-2903     var _KJUR = KJUR,
-2904 	_KJUR_asn1 = _KJUR.asn1,
-2905 	_DERInteger = _KJUR_asn1.DERInteger,
-2906 	_DERBoolean = _KJUR_asn1.DERBoolean,
-2907 	_DERSequence = _KJUR_asn1.DERSequence,
-2908 	_GeneralName = _KJUR_asn1.x509.GeneralName;
-2909 
-2910     this.params = null;
-2911 
-2912     this.getExtnValueHex = function() {
-2913 	var params = this.params;
-2914 	var a = [new _DERInteger(1)];
-2915 	a.push(new _GeneralName({uri: params.uri}));
-2916 	if (params.reqauth != undefined) {
-2917 	    a.push(new _DERBoolean(params.reqauth));
-2918 	}
-2919 
-2920         this.asn1ExtnValue = new _DERSequence({array: a});
-2921         return this.asn1ExtnValue.tohex();
-2922     };
-2923 
-2924     this.oid = "1.2.840.113583.1.1.9.1";
-2925     if (params !== undefined) this.setByParam(params);
-2926 };
-2927 extendClass(KJUR.asn1.x509.AdobeTimeStamp, KJUR.asn1.x509.Extension);
-2928  
-2929 // === END   Other X.509v3 Extensions========================================
-2930 
-2931 
-2932 // === BEGIN X500Name Related =================================================
-2933 /**
-2934  * X500Name ASN.1 structure class
-2935  * @name KJUR.asn1.x509.X500Name
-2936  * @class X500Name ASN.1 structure class
-2937  * @param {Array} params associative array of parameters (ex. {'str': '/C=US/O=a'})
-2938  * @extends KJUR.asn1.ASN1Object
-2939  * @see KJUR.asn1.x509.X500Name
-2940  * @see KJUR.asn1.x509.RDN
-2941  * @see KJUR.asn1.x509.AttributeTypeAndValue
-2942  * @see X509#getX500Name
-2943  * @description
-2944  * This class provides DistinguishedName ASN.1 class structure
-2945  * defined in <a href="https://tools.ietf.org/html/rfc2253#section-2">RFC 2253 section 2</a>.
-2946  * <blockquote><pre>
-2947  * DistinguishedName ::= RDNSequence
-2948  * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
-2949  * RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
-2950  *   AttributeTypeAndValue
-2951  * AttributeTypeAndValue ::= SEQUENCE {
-2952  *   type  AttributeType,
-2953  *   value AttributeValue }
-2954  * </pre></blockquote>
-2955  * <br/>
-2956  * Argument for the constructor can be one of following parameters:
-2957  * <ul>
-2958  * <li>{Array}array - array of {@link KJUR.asn1.x509.RDN} parameter</li>
-2959  * <li>`String}str - string for distingish name in OpenSSL One line foramt (ex: /C=US/O=test/CN=test) See <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">this</a> in detail.</li>
-2960  * <li>{String}ldapstr - string for distinguish name in LDAP format (ex: CN=test,O=test,C=US)</li>
-2961  * <li>{String}hex - hexadecimal string for ASN.1 distinguish name structure</li>
-2962  * <li>{String}certissuer - issuer name in the specified PEM certificate</li>
-2963  * <li>{String}certsubject - subject name in the specified PEM certificate</li>
-2964  * <li>{String}rule - DirectoryString rule (ex. "prn" or "utf8")</li>
-2965  * </ul>
-2966  * <br/>
-2967  * NOTE1: The "array" and "rule" parameters have been supported
-2968  * since jsrsasign 9.0.0 asn1x509 2.0.0.
-2969  * <br/>
-2970  * NOTE2: Multi-valued RDN in "str" parameter have been
-2971  * supported since jsrsasign 6.2.1 asn1x509 1.0.17.
-2972  * @example
-2973  * // 1. construct with array
-2974  * new KJUR.asn1.x509.X500Name({array:[
-2975  *   [{type:'C',value:'JP',ds:'prn'}],
-2976  *   [{type:'O',value:'aaa',ds:'utf8'}, // multi-valued RDN
-2977  *    {type:'CN',value:'bob@example.com',ds:'ia5'}]
-2978  * ]})
-2979  * // 2. construct with string
-2980  * new KJUR.asn1.x509.X500Name({str: "/C=US/ST=NY/L=Ballston Spa/STREET=915 Stillwater Ave"});
-2981  * new KJUR.asn1.x509.X500Name({str: "/CN=AAA/2.5.4.42=John/surname=Ray"});
-2982  * new KJUR.asn1.x509.X500Name({str: "/C=US/O=aaa+CN=contact@example.com"}); // multi valued
-2983  * // 3. construct by LDAP string
-2984  * new KJUR.asn1.x509.X500Name({ldapstr: "CN=foo@example.com,OU=bbb,C=US"});
-2985  * // 4. construct by ASN.1 hex string
-2986  * new KJUR.asn1.x509.X500Name({hex: "304c3120..."});
-2987  * // 5. construct by issuer of PEM certificate
-2988  * new KJUR.asn1.x509.X500Name({certsubject: "-----BEGIN CERT..."});
-2989  * // 6. construct by subject of PEM certificate
-2990  * new KJUR.asn1.x509.X500Name({certissuer: "-----BEGIN CERT..."});
-2991  * // 7. construct by object (DEPRECATED)
-2992  * new KJUR.asn1.x509.X500Name({C:"US",O:"aaa",CN:"http://example.com/"});
-2993  */
-2994 KJUR.asn1.x509.X500Name = function(params) {
-2995     KJUR.asn1.x509.X500Name.superclass.constructor.call(this);
-2996     this.asn1Array = [];
-2997     this.paramArray = [];
-2998     this.sRule = "utf8";
-2999     var _KJUR = KJUR,
-3000 	_KJUR_asn1 = _KJUR.asn1,
-3001 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-3002 	_RDN = _KJUR_asn1_x509.RDN,
-3003 	_pemtohex = pemtohex;
-3004 
-3005     /**
-3006      * set DN by OpenSSL oneline distinguished name string<br/>
-3007      * @name setByString
-3008      * @memberOf KJUR.asn1.x509.X500Name#
-3009      * @function
-3010      * @param {String} dnStr distinguished name by string (ex. /C=US/O=aaa)
-3011      * @description
-3012      * Sets distinguished name by string. 
-3013      * dnStr must be formatted as 
-3014      * "/type0=value0/type1=value1/type2=value2...".
-3015      * No need to escape a slash in an attribute value.
-3016      * @example
-3017      * name = new KJUR.asn1.x509.X500Name();
-3018      * name.setByString("/C=US/O=aaa/OU=bbb/CN=foo@example.com");
-3019      * // no need to escape slash in an attribute value
-3020      * name.setByString("/C=US/O=aaa/CN=1980/12/31");
-3021      */
-3022     this.setByString = function(dnStr, sRule) {
-3023 	if (sRule !== undefined) this.sRule = sRule;
-3024         var a = dnStr.split('/');
-3025         a.shift();
-3026 
-3027 	var a1 = [];
-3028 	for (var i = 0; i < a.length; i++) {
-3029 	  if (a[i].match(/^[^=]+=.+$/)) {
-3030 	    a1.push(a[i]);
-3031 	  } else {
-3032 	    var lastidx = a1.length - 1;
-3033 	    a1[lastidx] = a1[lastidx] + "/" + a[i];
-3034 	  }
-3035 	}
-3036 
-3037         for (var i = 0; i < a1.length; i++) {
-3038             this.asn1Array.push(new _RDN({'str':a1[i], rule:this.sRule}));
-3039         }
-3040     };
-3041 
-3042     /**
-3043      * set DN by LDAP(RFC 2253) distinguished name string<br/>
-3044      * @name setByLdapString
-3045      * @memberOf KJUR.asn1.x509.X500Name#
-3046      * @function
-3047      * @param {String} dnStr distinguished name by LDAP string (ex. O=aaa,C=US)
-3048      * @since jsrsasign 6.2.2 asn1x509 1.0.18
-3049      * @see {@link KJUR.asn1.x509.X500Name.ldapToCompat}
-3050      * @description
-3051      * @example
-3052      * name = new KJUR.asn1.x509.X500Name();
-3053      * name.setByLdapString("CN=foo@example.com,OU=bbb,O=aaa,C=US");
-3054      */
-3055     this.setByLdapString = function(dnStr, sRule) {
-3056 	if (sRule !== undefined) this.sRule = sRule;
-3057 	var compat = _KJUR_asn1_x509.X500Name.ldapToCompat(dnStr);
-3058 	this.setByString(compat, sRule);
-3059     };
+2903 // === BEGIN X500Name Related =================================================
+2904 /**
+2905  * X500Name ASN.1 structure class
+2906  * @name KJUR.asn1.x509.X500Name
+2907  * @class X500Name ASN.1 structure class
+2908  * @param {Array} params associative array of parameters (ex. {'str': '/C=US/O=a'})
+2909  * @extends KJUR.asn1.ASN1Object
+2910  * @see KJUR.asn1.x509.X500Name
+2911  * @see KJUR.asn1.x509.RDN
+2912  * @see KJUR.asn1.x509.AttributeTypeAndValue
+2913  * @see X509#getX500Name
+2914  * @description
+2915  * This class provides DistinguishedName ASN.1 class structure
+2916  * defined in <a href="https://tools.ietf.org/html/rfc2253#section-2">RFC 2253 section 2</a>.
+2917  * <blockquote><pre>
+2918  * DistinguishedName ::= RDNSequence
+2919  * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
+2920  * RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
+2921  *   AttributeTypeAndValue
+2922  * AttributeTypeAndValue ::= SEQUENCE {
+2923  *   type  AttributeType,
+2924  *   value AttributeValue }
+2925  * </pre></blockquote>
+2926  * <br/>
+2927  * Argument for the constructor can be one of following parameters:
+2928  * <ul>
+2929  * <li>{Array}array - array of {@link KJUR.asn1.x509.RDN} parameter</li>
+2930  * <li>`String}str - string for distingish name in OpenSSL One line foramt (ex: /C=US/O=test/CN=test) See <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">this</a> in detail.</li>
+2931  * <li>{String}ldapstr - string for distinguish name in LDAP format (ex: CN=test,O=test,C=US)</li>
+2932  * <li>{String}hex - hexadecimal string for ASN.1 distinguish name structure</li>
+2933  * <li>{String}certissuer - issuer name in the specified PEM certificate</li>
+2934  * <li>{String}certsubject - subject name in the specified PEM certificate</li>
+2935  * <li>{String}rule - DirectoryString rule (ex. "prn" or "utf8")</li>
+2936  * </ul>
+2937  * <br/>
+2938  * NOTE1: The "array" and "rule" parameters have been supported
+2939  * since jsrsasign 9.0.0 asn1x509 2.0.0.
+2940  * <br/>
+2941  * NOTE2: Multi-valued RDN in "str" parameter have been
+2942  * supported since jsrsasign 6.2.1 asn1x509 1.0.17.
+2943  * @example
+2944  * // 1. construct with array
+2945  * new KJUR.asn1.x509.X500Name({array:[
+2946  *   [{type:'C',value:'JP',ds:'prn'}],
+2947  *   [{type:'O',value:'aaa',ds:'utf8'}, // multi-valued RDN
+2948  *    {type:'CN',value:'bob@example.com',ds:'ia5'}]
+2949  * ]})
+2950  * // 2. construct with string
+2951  * new KJUR.asn1.x509.X500Name({str: "/C=US/ST=NY/L=Ballston Spa/STREET=915 Stillwater Ave"});
+2952  * new KJUR.asn1.x509.X500Name({str: "/CN=AAA/2.5.4.42=John/surname=Ray"});
+2953  * new KJUR.asn1.x509.X500Name({str: "/C=US/O=aaa+CN=contact@example.com"}); // multi valued
+2954  * // 3. construct by LDAP string
+2955  * new KJUR.asn1.x509.X500Name({ldapstr: "CN=foo@example.com,OU=bbb,C=US"});
+2956  * // 4. construct by ASN.1 hex string
+2957  * new KJUR.asn1.x509.X500Name({hex: "304c3120..."});
+2958  * // 5. construct by issuer of PEM certificate
+2959  * new KJUR.asn1.x509.X500Name({certsubject: "-----BEGIN CERT..."});
+2960  * // 6. construct by subject of PEM certificate
+2961  * new KJUR.asn1.x509.X500Name({certissuer: "-----BEGIN CERT..."});
+2962  * // 7. construct by object (DEPRECATED)
+2963  * new KJUR.asn1.x509.X500Name({C:"US",O:"aaa",CN:"http://example.com/"});
+2964  */
+2965 KJUR.asn1.x509.X500Name = function(params) {
+2966     KJUR.asn1.x509.X500Name.superclass.constructor.call(this);
+2967     this.asn1Array = [];
+2968     this.paramArray = [];
+2969     this.sRule = "utf8";
+2970     var _KJUR = KJUR,
+2971 	_KJUR_asn1 = _KJUR.asn1,
+2972 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+2973 	_RDN = _KJUR_asn1_x509.RDN,
+2974 	_pemtohex = pemtohex;
+2975 
+2976     /**
+2977      * set DN by OpenSSL oneline distinguished name string<br/>
+2978      * @name setByString
+2979      * @memberOf KJUR.asn1.x509.X500Name#
+2980      * @function
+2981      * @param {String} dnStr distinguished name by string (ex. /C=US/O=aaa)
+2982      * @description
+2983      * Sets distinguished name by string. 
+2984      * dnStr must be formatted as 
+2985      * "/type0=value0/type1=value1/type2=value2...".
+2986      * No need to escape a slash in an attribute value.
+2987      * @example
+2988      * name = new KJUR.asn1.x509.X500Name();
+2989      * name.setByString("/C=US/O=aaa/OU=bbb/CN=foo@example.com");
+2990      * // no need to escape slash in an attribute value
+2991      * name.setByString("/C=US/O=aaa/CN=1980/12/31");
+2992      */
+2993     this.setByString = function(dnStr, sRule) {
+2994 	if (sRule !== undefined) this.sRule = sRule;
+2995         var a = dnStr.split('/');
+2996         a.shift();
+2997 
+2998 	var a1 = [];
+2999 	for (var i = 0; i < a.length; i++) {
+3000 	  if (a[i].match(/^[^=]+=.+$/)) {
+3001 	    a1.push(a[i]);
+3002 	  } else {
+3003 	    var lastidx = a1.length - 1;
+3004 	    a1[lastidx] = a1[lastidx] + "/" + a[i];
+3005 	  }
+3006 	}
+3007 
+3008         for (var i = 0; i < a1.length; i++) {
+3009             this.asn1Array.push(new _RDN({'str':a1[i], rule:this.sRule}));
+3010         }
+3011     };
+3012 
+3013     /**
+3014      * set DN by LDAP(RFC 2253) distinguished name string<br/>
+3015      * @name setByLdapString
+3016      * @memberOf KJUR.asn1.x509.X500Name#
+3017      * @function
+3018      * @param {String} dnStr distinguished name by LDAP string (ex. O=aaa,C=US)
+3019      * @since jsrsasign 6.2.2 asn1x509 1.0.18
+3020      * @see {@link KJUR.asn1.x509.X500Name.ldapToCompat}
+3021      * @description
+3022      * @example
+3023      * name = new KJUR.asn1.x509.X500Name();
+3024      * name.setByLdapString("CN=foo@example.com,OU=bbb,O=aaa,C=US");
+3025      */
+3026     this.setByLdapString = function(dnStr, sRule) {
+3027 	if (sRule !== undefined) this.sRule = sRule;
+3028 	var compat = _KJUR_asn1_x509.X500Name.ldapToCompat(dnStr);
+3029 	this.setByString(compat, sRule);
+3030     };
+3031 
+3032     /**
+3033      * set DN by associative array<br/>
+3034      * @name setByObject
+3035      * @memberOf KJUR.asn1.x509.X500Name#
+3036      * @function
+3037      * @param {Array} dnObj associative array of DN (ex. {C: "US", O: "aaa"})
+3038      * @since jsrsasign 4.9. asn1x509 1.0.13
+3039      * @description
+3040      * @example
+3041      * name = new KJUR.asn1.x509.X500Name();
+3042      * name.setByObject({C: "US", O: "aaa", CN="http://example.com/"1});
+3043      */
+3044     this.setByObject = function(dnObj, sRule) {
+3045 	if (sRule !== undefined) this.sRule = sRule;
+3046 
+3047         // Get all the dnObject attributes and stuff them in the ASN.1 array.
+3048         for (var x in dnObj) {
+3049             if (dnObj.hasOwnProperty(x)) {
+3050                 var newRDN = new _RDN({str: x + '=' + dnObj[x], rule: this.sRule});
+3051                 // Initialize or push into the ANS1 array.
+3052                 this.asn1Array ? this.asn1Array.push(newRDN)
+3053                     : this.asn1Array = [newRDN];
+3054             }
+3055         }
+3056     };
+3057 
+3058     this.setByParam = function(params) {
+3059 	if (params.rule !== undefined) this.sRule = params.rule;
 3060 
-3061     /**
-3062      * set DN by associative array<br/>
-3063      * @name setByObject
-3064      * @memberOf KJUR.asn1.x509.X500Name#
-3065      * @function
-3066      * @param {Array} dnObj associative array of DN (ex. {C: "US", O: "aaa"})
-3067      * @since jsrsasign 4.9. asn1x509 1.0.13
-3068      * @description
-3069      * @example
-3070      * name = new KJUR.asn1.x509.X500Name();
-3071      * name.setByObject({C: "US", O: "aaa", CN="http://example.com/"1});
-3072      */
-3073     this.setByObject = function(dnObj, sRule) {
-3074 	if (sRule !== undefined) this.sRule = sRule;
-3075 
-3076         // Get all the dnObject attributes and stuff them in the ASN.1 array.
-3077         for (var x in dnObj) {
-3078             if (dnObj.hasOwnProperty(x)) {
-3079                 var newRDN = new _RDN({str: x + '=' + dnObj[x], rule: this.sRule});
-3080                 // Initialize or push into the ANS1 array.
-3081                 this.asn1Array ? this.asn1Array.push(newRDN)
-3082                     : this.asn1Array = [newRDN];
-3083             }
-3084         }
-3085     };
-3086 
-3087     this.setByParam = function(params) {
-3088 	if (params.rule !== undefined) this.sRule = params.rule;
+3061 	if (params.array !== undefined) {
+3062 	    this.paramArray = params.array;
+3063 	} else {
+3064             if (params.str !== undefined) {
+3065 		this.setByString(params.str);
+3066             } else if (params.ldapstr !== undefined) {
+3067 		this.setByLdapString(params.ldapstr);
+3068 	    } else if (params.hex !== undefined) {
+3069 		this.hTLV = params.hex;
+3070             } else if (params.certissuer !== undefined) {
+3071 		var x = new X509();
+3072 		x.readCertPEM(params.certissuer);
+3073 		this.hTLV = x.getIssuerHex();
+3074             } else if (params.certsubject !== undefined) {
+3075 		var x = new X509();
+3076 		x.readCertPEM(params.certsubject);
+3077 		this.hTLV = x.getSubjectHex();
+3078 		// If params is an object, then set the ASN1 array
+3079 		// just using the object attributes. 
+3080 		// This is nice for fields that have lots of special
+3081 		// characters (i.e. CN: 'https://www.github.com/kjur//').
+3082             } else if (typeof params === "object" &&
+3083 		       params.certsubject === undefined &&
+3084 		       params.certissuer === undefined) {
+3085 		this.setByObject(params);
+3086             }
+3087 	}
+3088     }
 3089 
-3090 	if (params.array !== undefined) {
-3091 	    this.paramArray = params.array;
-3092 	} else {
-3093             if (params.str !== undefined) {
-3094 		this.setByString(params.str);
-3095             } else if (params.ldapstr !== undefined) {
-3096 		this.setByLdapString(params.ldapstr);
-3097 	    } else if (params.hex !== undefined) {
-3098 		this.hTLV = params.hex;
-3099             } else if (params.certissuer !== undefined) {
-3100 		var x = new X509();
-3101 		x.readCertPEM(params.certissuer);
-3102 		this.hTLV = x.getIssuerHex();
-3103             } else if (params.certsubject !== undefined) {
-3104 		var x = new X509();
-3105 		x.readCertPEM(params.certsubject);
-3106 		this.hTLV = x.getSubjectHex();
-3107 		// If params is an object, then set the ASN1 array
-3108 		// just using the object attributes. 
-3109 		// This is nice for fields that have lots of special
-3110 		// characters (i.e. CN: 'https://www.github.com/kjur//').
-3111             } else if (typeof params === "object" &&
-3112 		       params.certsubject === undefined &&
-3113 		       params.certissuer === undefined) {
-3114 		this.setByObject(params);
-3115             }
-3116 	}
-3117     }
-3118 
-3119     this.tohex = function() {
-3120         if (typeof this.hTLV == "string") return this.hTLV;
-3121 
-3122 	if (this.asn1Array.length == 0 && this.paramArray.length > 0) {
-3123 	    for (var i = 0; i < this.paramArray.length; i++) {
-3124 		var param = {array: this.paramArray[i]};
-3125 		if (this.sRule != "utf8") param.rule = this.sRule;
-3126 		var asn1RDN = new _RDN(param);
-3127 		this.asn1Array.push(asn1RDN);
-3128 	    }
-3129 	}
-3130 
-3131         var o = new _KJUR_asn1.DERSequence({"array": this.asn1Array});
-3132         this.hTLV = o.tohex();
-3133         return this.hTLV;
-3134     };
-3135     this.getEncodedHex = function() { return this.tohex(); };
-3136 
-3137     if (params !== undefined) this.setByParam(params);
-3138 };
-3139 extendClass(KJUR.asn1.x509.X500Name, KJUR.asn1.ASN1Object);
-3140 
-3141 /**
-3142  * convert OpenSSL compat distinguished name format string to LDAP(RFC 2253) format<br/>
-3143  * @name compatToLDAP
-3144  * @memberOf KJUR.asn1.x509.X500Name
-3145  * @function
-3146  * @param {String} s distinguished name string in OpenSSL oneline compat (ex. /C=US/O=test)
-3147  * @return {String} distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
-3148  * @since jsrsasign 8.0.19 asn1x509 1.1.20
-3149  * @description
-3150  * This static method converts a distinguished name string in OpenSSL compat
-3151  * format to LDAP(RFC 2253) format.
-3152  * @see <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">jsrsasign wiki: distinguished name string difference between OpenSSL compat and LDAP(RFC 2253)</a>
-3153  * @see <a href="https://www.openssl.org/docs/man1.0.2/man1/openssl-x509.html#NAME-OPTIONS">OpenSSL x509 command manual - NAME OPTIONS</a>
-3154  * @example
-3155  * KJUR.asn1.x509.X500Name.compatToLDAP("/C=US/O=test") → 'O=test,C=US'
-3156  * KJUR.asn1.x509.X500Name.compatToLDAP("/C=US/O=a,a") → 'O=a\,a,C=US'
-3157  */
-3158 KJUR.asn1.x509.X500Name.compatToLDAP = function(s) {
-3159     if (s.substr(0, 1) !== "/") throw "malformed input";
-3160 
-3161     var result = "";
-3162     s = s.substr(1);
-3163 
-3164     var a = s.split("/");
-3165     a.reverse();
-3166     a = a.map(function(s) {return s.replace(/,/, "\\,")});
-3167 
-3168     return a.join(",");
-3169 };
-3170 
-3171 /**
-3172  * convert OpenSSL compat distinguished name format string to LDAP(RFC 2253) format (DEPRECATED)<br/>
-3173  * @name onelineToLDAP
-3174  * @memberOf KJUR.asn1.x509.X500Name
-3175  * @function
-3176  * @param {String} s distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
-3177  * @return {String} distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
-3178  * @since jsrsasign 6.2.2 asn1x509 1.0.18
-3179  * @see KJUR.asn1.x509.X500Name.compatToLDAP
-3180  * @description
-3181  * This method is deprecated. Please use 
-3182  * {@link KJUR.asn1.x509.X500Name.compatToLDAP} instead.
-3183  */
-3184 KJUR.asn1.x509.X500Name.onelineToLDAP = function(s) {
-3185     return KJUR.asn1.x509.X500Name.compatToLDAP(s);
-3186 }
-3187 
-3188 /**
-3189  * convert LDAP(RFC 2253) distinguished name format string to OpenSSL compat format<br/>
-3190  * @name ldapToCompat
-3191  * @memberOf KJUR.asn1.x509.X500Name
-3192  * @function
-3193  * @param {String} s distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
-3194  * @return {String} distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
-3195  * @since jsrsasign 8.0.19 asn1x509 1.1.10
-3196  * @description
-3197  * This static method converts a distinguished name string in 
-3198  * LDAP(RFC 2253) format to OpenSSL compat format.
-3199  * @see <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">jsrsasign wiki: distinguished name string difference between OpenSSL compat and LDAP(RFC 2253)</a>
-3200  * @example
-3201  * KJUR.asn1.x509.X500Name.ldapToCompat('O=test,C=US') → '/C=US/O=test'
-3202  * KJUR.asn1.x509.X500Name.ldapToCompat('O=a\,a,C=US') → '/C=US/O=a,a'
-3203  * KJUR.asn1.x509.X500Name.ldapToCompat('O=a/a,C=US')  → '/C=US/O=a\/a'
-3204  */
-3205 KJUR.asn1.x509.X500Name.ldapToCompat = function(s) {
-3206     var a = s.split(",");
-3207 
-3208     // join \,
-3209     var isBSbefore = false;
-3210     var a2 = [];
-3211     for (var i = 0; a.length > 0; i++) {
-3212 	var item = a.shift();
-3213 	//console.log("item=" + item);
-3214 
-3215 	if (isBSbefore === true) {
-3216 	    var a2last = a2.pop();
-3217 	    var newitem = (a2last + "," + item).replace(/\\,/g, ",");
-3218 	    a2.push(newitem);
-3219 	    isBSbefore = false;
-3220 	} else {
-3221 	    a2.push(item);
-3222 	}
-3223 
-3224 	if (item.substr(-1, 1) === "\\") isBSbefore = true;
-3225     }
-3226 
-3227     a2 = a2.map(function(s) {return s.replace("/", "\\/")});
-3228     a2.reverse();
-3229     return "/" + a2.join("/");
-3230 };
-3231 
-3232 /**
-3233  * convert LDAP(RFC 2253) distinguished name format string to OpenSSL compat format (DEPRECATED)<br/>
-3234  * @name ldapToOneline
-3235  * @memberOf KJUR.asn1.x509.X500Name
-3236  * @function
-3237  * @param {String} s distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
-3238  * @return {String} distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
-3239  * @since jsrsasign 6.2.2 asn1x509 1.0.18
-3240  * @description
-3241  * This method is deprecated. Please use 
-3242  * {@link KJUR.asn1.x509.X500Name.ldapToCompat} instead.
-3243  */
-3244 KJUR.asn1.x509.X500Name.ldapToOneline = function(s) {
-3245     return KJUR.asn1.x509.X500Name.ldapToCompat(s);
-3246 };
-3247 
-3248 /**
-3249  * RDN (Relative Distinguished Name) ASN.1 structure class
-3250  * @name KJUR.asn1.x509.RDN
-3251  * @class RDN (Relative Distinguished Name) ASN.1 structure class
-3252  * @param {Array} params associative array of parameters (ex. {'str': 'C=US'})
-3253  * @extends KJUR.asn1.ASN1Object
-3254  * @see KJUR.asn1.x509.X500Name
-3255  * @see KJUR.asn1.x509.RDN
-3256  * @see KJUR.asn1.x509.AttributeTypeAndValue
-3257  * @description
-3258  * This class provides RelativeDistinguishedName ASN.1 class structure
-3259  * defined in <a href="https://tools.ietf.org/html/rfc2253#section-2">RFC 2253 section 2</a>.
-3260  * <blockquote><pre>
-3261  * RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
-3262  *   AttributeTypeAndValue
-3263  *
-3264  * AttributeTypeAndValue ::= SEQUENCE {
-3265  *   type  AttributeType,
-3266  *   value AttributeValue }
-3267  * </pre></blockquote>
-3268  * <br/>
-3269  * NOTE1: The "array" and "rule" parameters have been supported
-3270  * since jsrsasign 9.0.0 asn1x509 2.0.0.
-3271  * <br/>
-3272  * NOTE2: Multi-valued RDN in "str" parameter have been
-3273  * supported since jsrsasign 6.2.1 asn1x509 1.0.17.
-3274  * @example
-3275  * new KJUR.asn1.x509.RDN({array: [ // multi-valued
-3276  *    {type:"CN",value:"Bob",ds:"prn"},
-3277  *    {type:"CN",value:"bob@example.com", ds:"ia5"}
-3278  * ]});
-3279  * new KJUR.asn1.x509.RDN({str: "CN=test"});
-3280  * new KJUR.asn1.x509.RDN({str: "O=a+O=bb+O=c"}); // multi-valued
-3281  * new KJUR.asn1.x509.RDN({str: "O=a+O=b\\+b+O=c"}); // plus escaped
-3282  * new KJUR.asn1.x509.RDN({str: "O=a+O=\"b+b\"+O=c"}); // double quoted
-3283  */
-3284 KJUR.asn1.x509.RDN = function(params) {
-3285     KJUR.asn1.x509.RDN.superclass.constructor.call(this);
-3286     this.asn1Array = [];
-3287     this.paramArray = [];
-3288     this.sRule = "utf8"; // DEFAULT "utf8"
-3289     var _AttributeTypeAndValue = KJUR.asn1.x509.AttributeTypeAndValue;
-3290 
-3291     this.setByParam = function(params) {
-3292 	if (params.rule !== undefined) this.sRule = params.rule;
-3293         if (params.str !== undefined) {
-3294             this.addByMultiValuedString(params.str);
-3295         }
-3296 	if (params.array !== undefined) this.paramArray = params.array;
-3297     };
-3298 
-3299     /**
-3300      * add one AttributeTypeAndValue by string<br/>
-3301      * @name addByString
-3302      * @memberOf KJUR.asn1.x509.RDN#
-3303      * @function
-3304      * @param {String} s string of AttributeTypeAndValue
-3305      * @return {Object} unspecified
-3306      * @description
-3307      * This method add one AttributeTypeAndValue to RDN object.
-3308      * @example
-3309      * rdn = new KJUR.asn1.x509.RDN();
-3310      * rdn.addByString("CN=john");
-3311      * rdn.addByString("serialNumber=1234"); // for multi-valued RDN
-3312      */
-3313     this.addByString = function(s) {
-3314         this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({'str': s, rule: this.sRule}));
-3315     };
-3316 
-3317     /**
-3318      * add one AttributeTypeAndValue by multi-valued string<br/>
-3319      * @name addByMultiValuedString
-3320      * @memberOf KJUR.asn1.x509.RDN#
-3321      * @function
-3322      * @param {String} s string of multi-valued RDN
-3323      * @return {Object} unspecified
-3324      * @since jsrsasign 6.2.1 asn1x509 1.0.17
-3325      * @description
-3326      * This method add multi-valued RDN to RDN object.
-3327      * @example
-3328      * rdn = new KJUR.asn1.x509.RDN();
-3329      * rdn.addByMultiValuedString("CN=john+O=test");
-3330      * rdn.addByMultiValuedString("O=a+O=b\+b\+b+O=c"); // multi-valued RDN with quoted plus
-3331      * rdn.addByMultiValuedString("O=a+O=\"b+b+b\"+O=c"); // multi-valued RDN with quoted quotation
-3332      */
-3333     this.addByMultiValuedString = function(s) {
-3334 	var a = KJUR.asn1.x509.RDN.parseString(s);
-3335 	for (var i = 0; i < a.length; i++) {
-3336 	    this.addByString(a[i]);
-3337 	}
-3338     };
-3339 
-3340     this.tohex = function() {
-3341 	if (this.asn1Array.length == 0 && this.paramArray.length > 0) {
-3342 	    for (var i = 0; i < this.paramArray.length; i++) {
-3343 		var param = this.paramArray[i];
-3344 		if (param.rule !== undefined &&
-3345 		    this.sRule != "utf8") {
-3346 		    param.rule = this.sRule;
-3347 		}
-3348 		//alert(JSON.stringify(param));
-3349 		var asn1ATV = new _AttributeTypeAndValue(param);
-3350 		this.asn1Array.push(asn1ATV);
-3351 	    }
-3352 	}
-3353         var o = new KJUR.asn1.DERSet({"array": this.asn1Array});
-3354         this.TLV = o.tohex();
-3355         return this.TLV;
-3356     };
-3357     this.getEncodedHex = function() { return this.tohex(); };
-3358 
-3359     if (params !== undefined) {
-3360 	this.setByParam(params);
-3361     }
-3362 };
-3363 extendClass(KJUR.asn1.x509.RDN, KJUR.asn1.ASN1Object);
-3364 
-3365 /**
-3366  * parse multi-valued RDN string and split into array of 'AttributeTypeAndValue'<br/>
-3367  * @name parseString
-3368  * @memberOf KJUR.asn1.x509.RDN
-3369  * @function
-3370  * @param {String} s multi-valued string of RDN
-3371  * @return {Array} array of string of AttributeTypeAndValue
-3372  * @since jsrsasign 6.2.1 asn1x509 1.0.17
-3373  * @description
-3374  * This static method parses multi-valued RDN string and split into
-3375  * array of AttributeTypeAndValue.
-3376  * @example
-3377  * KJUR.asn1.x509.RDN.parseString("CN=john") → ["CN=john"]
-3378  * KJUR.asn1.x509.RDN.parseString("CN=john+OU=test") → ["CN=john", "OU=test"]
-3379  * KJUR.asn1.x509.RDN.parseString('CN="jo+hn"+OU=test') → ["CN=jo+hn", "OU=test"]
-3380  * KJUR.asn1.x509.RDN.parseString('CN=jo\+hn+OU=test') → ["CN=jo+hn", "OU=test"]
-3381  * KJUR.asn1.x509.RDN.parseString("CN=john+OU=test+OU=t1") → ["CN=john", "OU=test", "OU=t1"]
-3382  */
-3383 KJUR.asn1.x509.RDN.parseString = function(s) {
-3384     var a = s.split(/\+/);
-3385 
-3386     // join \+
-3387     var isBSbefore = false;
-3388     var a2 = [];
-3389     for (var i = 0; a.length > 0; i++) {
-3390 	var item = a.shift();
-3391 	//console.log("item=" + item);
-3392 
-3393 	if (isBSbefore === true) {
-3394 	    var a2last = a2.pop();
-3395 	    var newitem = (a2last + "+" + item).replace(/\\\+/g, "+");
-3396 	    a2.push(newitem);
-3397 	    isBSbefore = false;
-3398 	} else {
-3399 	    a2.push(item);
-3400 	}
-3401 
-3402 	if (item.substr(-1, 1) === "\\") isBSbefore = true;
-3403     }
-3404 
-3405     // join quote
-3406     var beginQuote = false;
-3407     var a3 = [];
-3408     for (var i = 0; a2.length > 0; i++) {
-3409 	var item = a2.shift();
-3410 
-3411 	if (beginQuote === true) {
-3412 	    var a3last = a3.pop();
-3413 	    if (item.match(/"$/)) {
-3414 		var newitem = (a3last + "+" + item).replace(/^([^=]+)="(.*)"$/, "$1=$2");
-3415 		a3.push(newitem);
-3416 		beginQuote = false;
-3417 	    } else {
-3418 		a3.push(a3last + "+" + item);
-3419 	    }
-3420 	} else {
-3421 	    a3.push(item);
-3422 	}
-3423 
-3424 	if (item.match(/^[^=]+="/)) {
-3425 	    //console.log(i + "=" + item);
-3426 	    beginQuote = true;
-3427 	}
-3428     }
-3429     return a3;
-3430 };
-3431 
-3432 /**
-3433  * AttributeTypeAndValue ASN.1 structure class
-3434  * @name KJUR.asn1.x509.AttributeTypeAndValue
-3435  * @class AttributeTypeAndValue ASN.1 structure class
-3436  * @param {Array} params JSON object for parameters (ex. {str: 'C=US'})
-3437  * @extends KJUR.asn1.ASN1Object
-3438  * @see KJUR.asn1.x509.X500Name
-3439  * @see KJUR.asn1.x509.RDN
-3440  * @see KJUR.asn1.x509.AttributeTypeAndValue
-3441  * @see X509#getAttrTypeAndValue
-3442  * @description
-3443  * This class generates AttributeTypeAndValue defined in
-3444  * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
-3445  * RFC 5280 4.1.2.4</a>.
-3446  * <pre>
-3447  * AttributeTypeAndValue ::= SEQUENCE {
-3448  *   type     AttributeType,
-3449  *   value    AttributeValue }
-3450  * AttributeType ::= OBJECT IDENTIFIER
-3451  * AttributeValue ::= ANY -- DEFINED BY AttributeType
-3452  * </pre>
-3453  * The constructor argument can have following parameters:
-3454  * <ul>
-3455  * <li>{String}type - AttributeType name or OID(ex. C,O,CN)</li>
-3456  * <li>{String}value - raw string of ASN.1 value of AttributeValue</li>
-3457  * <li>{String}ds - DirectoryString type of AttributeValue</li>
-3458  * <li>{String}rule - DirectoryString type rule (ex. "prn" or "utf8")
-3459  * set DirectoryString type automatically when "ds" not specified.</li>
-3460  * <li>{String}str - AttributeTypeAndVale string (ex. "C=US").
-3461  * When type and value don't exists, 
-3462  * this "str" will be converted to "type" and "value".
-3463  * </li>
-3464  * </ul>
-3465  * <br
-3466  * NOTE: Parameters "type", "value,", "ds" and "rule" have
-3467  * been supported since jsrsasign 9.0.0 asn1x509 2.0.0.
-3468  * @example
-3469  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'C',value:'US',ds:'prn'})
-3470  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'givenName',value:'John',ds:'prn'})
-3471  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'2.5.4.9',value:'71 Bowman St',ds:'prn'})
-3472  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1'})
-3473  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'streetAddress=71 Bowman St'})
-3474  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1',rule='prn'})
-3475  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1',rule='utf8'})
-3476  */
-3477 KJUR.asn1.x509.AttributeTypeAndValue = function(params) {
-3478     KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);
-3479     this.sRule = "utf8";
-3480     this.sType = null;
-3481     this.sValue = null;
-3482     this.dsType = null;
-3483     var _KJUR = KJUR,
-3484 	_KJUR_asn1 = _KJUR.asn1,
-3485 	_DERSequence = _KJUR_asn1.DERSequence,
-3486 	_DERUTF8String = _KJUR_asn1.DERUTF8String,
-3487 	_DERPrintableString = _KJUR_asn1.DERPrintableString,
-3488 	_DERTeletexString = _KJUR_asn1.DERTeletexString,
-3489 	_DERIA5String = _KJUR_asn1.DERIA5String,
-3490 	_DERVisibleString = _KJUR_asn1.DERVisibleString,
-3491 	_DERBMPString = _KJUR_asn1.DERBMPString,
-3492 	_isMail = _KJUR.lang.String.isMail,
-3493 	_isPrintable = _KJUR.lang.String.isPrintable;
-3494 
-3495     this.setByParam = function(params) {
-3496 	if (params.rule !== undefined) this.sRule = params.rule;
-3497 	if (params.ds !== undefined)   this.dsType = params.ds;
-3498 
-3499         if (params.value === undefined &&
-3500 	    params.str !== undefined) {
-3501 	    var str = params.str;
-3502             var matchResult = str.match(/^([^=]+)=(.+)$/);
-3503             if (matchResult) {
-3504 		this.sType = matchResult[1];
-3505 		this.sValue = matchResult[2];
-3506             } else {
-3507 		throw new Error("malformed attrTypeAndValueStr: " +
-3508 				attrTypeAndValueStr);
-3509             }
-3510 	    
-3511 	    //this.setByString(params.str);
-3512         } else {
-3513 	    this.sType = params.type;
-3514 	    this.sValue = params.value;
-3515 	}
-3516     };
-3517 
-3518     /*
-3519      * @deprecated
-3520      */
-3521     this.setByString = function(sTypeValue, sRule) {
-3522 	if (sRule !== undefined) this.sRule = sRule;
-3523         var matchResult = sTypeValue.match(/^([^=]+)=(.+)$/);
-3524         if (matchResult) {
-3525             this.setByAttrTypeAndValueStr(matchResult[1], matchResult[2]);
-3526         } else {
-3527             throw new Error("malformed attrTypeAndValueStr: " +
-3528 			    attrTypeAndValueStr);
-3529         }
-3530     };
-3531 
-3532     this._getDsType = function() {
-3533 	var sType = this.sType;
-3534 	var sValue = this.sValue;
-3535 	var sRule = this.sRule;
+3090     this.tohex = function() {
+3091         if (typeof this.hTLV == "string") return this.hTLV;
+3092 
+3093 	if (this.asn1Array.length == 0 && this.paramArray.length > 0) {
+3094 	    for (var i = 0; i < this.paramArray.length; i++) {
+3095 		var param = {array: this.paramArray[i]};
+3096 		if (this.sRule != "utf8") param.rule = this.sRule;
+3097 		var asn1RDN = new _RDN(param);
+3098 		this.asn1Array.push(asn1RDN);
+3099 	    }
+3100 	}
+3101 
+3102         var o = new _KJUR_asn1.DERSequence({"array": this.asn1Array});
+3103         this.hTLV = o.tohex();
+3104         return this.hTLV;
+3105     };
+3106     this.getEncodedHex = function() { return this.tohex(); };
+3107 
+3108     if (params !== undefined) this.setByParam(params);
+3109 };
+3110 extendClass(KJUR.asn1.x509.X500Name, KJUR.asn1.ASN1Object);
+3111 
+3112 /**
+3113  * convert OpenSSL compat distinguished name format string to LDAP(RFC 2253) format<br/>
+3114  * @name compatToLDAP
+3115  * @memberOf KJUR.asn1.x509.X500Name
+3116  * @function
+3117  * @param {String} s distinguished name string in OpenSSL oneline compat (ex. /C=US/O=test)
+3118  * @return {String} distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
+3119  * @since jsrsasign 8.0.19 asn1x509 1.1.20
+3120  * @description
+3121  * This static method converts a distinguished name string in OpenSSL compat
+3122  * format to LDAP(RFC 2253) format.
+3123  * @see <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">jsrsasign wiki: distinguished name string difference between OpenSSL compat and LDAP(RFC 2253)</a>
+3124  * @see <a href="https://www.openssl.org/docs/man1.0.2/man1/openssl-x509.html#NAME-OPTIONS">OpenSSL x509 command manual - NAME OPTIONS</a>
+3125  * @example
+3126  * KJUR.asn1.x509.X500Name.compatToLDAP("/C=US/O=test") → 'O=test,C=US'
+3127  * KJUR.asn1.x509.X500Name.compatToLDAP("/C=US/O=a,a") → 'O=a\,a,C=US'
+3128  */
+3129 KJUR.asn1.x509.X500Name.compatToLDAP = function(s) {
+3130     if (s.substr(0, 1) !== "/") throw "malformed input";
+3131 
+3132     var result = "";
+3133     s = s.substr(1);
+3134 
+3135     var a = s.split("/");
+3136     a.reverse();
+3137     a = a.map(function(s) {return s.replace(/,/, "\\,")});
+3138 
+3139     return a.join(",");
+3140 };
+3141 
+3142 /**
+3143  * convert OpenSSL compat distinguished name format string to LDAP(RFC 2253) format (DEPRECATED)<br/>
+3144  * @name onelineToLDAP
+3145  * @memberOf KJUR.asn1.x509.X500Name
+3146  * @function
+3147  * @param {String} s distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
+3148  * @return {String} distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
+3149  * @since jsrsasign 6.2.2 asn1x509 1.0.18
+3150  * @see KJUR.asn1.x509.X500Name.compatToLDAP
+3151  * @description
+3152  * This method is deprecated. Please use 
+3153  * {@link KJUR.asn1.x509.X500Name.compatToLDAP} instead.
+3154  */
+3155 KJUR.asn1.x509.X500Name.onelineToLDAP = function(s) {
+3156     return KJUR.asn1.x509.X500Name.compatToLDAP(s);
+3157 }
+3158 
+3159 /**
+3160  * convert LDAP(RFC 2253) distinguished name format string to OpenSSL compat format<br/>
+3161  * @name ldapToCompat
+3162  * @memberOf KJUR.asn1.x509.X500Name
+3163  * @function
+3164  * @param {String} s distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
+3165  * @return {String} distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
+3166  * @since jsrsasign 8.0.19 asn1x509 1.1.10
+3167  * @description
+3168  * This static method converts a distinguished name string in 
+3169  * LDAP(RFC 2253) format to OpenSSL compat format.
+3170  * @see <a href="https://github.com/kjur/jsrsasign/wiki/NOTE-distinguished-name-representation-in-jsrsasign">jsrsasign wiki: distinguished name string difference between OpenSSL compat and LDAP(RFC 2253)</a>
+3171  * @example
+3172  * KJUR.asn1.x509.X500Name.ldapToCompat('O=test,C=US') → '/C=US/O=test'
+3173  * KJUR.asn1.x509.X500Name.ldapToCompat('O=a\,a,C=US') → '/C=US/O=a,a'
+3174  * KJUR.asn1.x509.X500Name.ldapToCompat('O=a/a,C=US')  → '/C=US/O=a\/a'
+3175  */
+3176 KJUR.asn1.x509.X500Name.ldapToCompat = function(s) {
+3177     var a = s.split(",");
+3178 
+3179     // join \,
+3180     var isBSbefore = false;
+3181     var a2 = [];
+3182     for (var i = 0; a.length > 0; i++) {
+3183 	var item = a.shift();
+3184 	//console.log("item=" + item);
+3185 
+3186 	if (isBSbefore === true) {
+3187 	    var a2last = a2.pop();
+3188 	    var newitem = (a2last + "," + item).replace(/\\,/g, ",");
+3189 	    a2.push(newitem);
+3190 	    isBSbefore = false;
+3191 	} else {
+3192 	    a2.push(item);
+3193 	}
+3194 
+3195 	if (item.substr(-1, 1) === "\\") isBSbefore = true;
+3196     }
+3197 
+3198     a2 = a2.map(function(s) {return s.replace("/", "\\/")});
+3199     a2.reverse();
+3200     return "/" + a2.join("/");
+3201 };
+3202 
+3203 /**
+3204  * convert LDAP(RFC 2253) distinguished name format string to OpenSSL compat format (DEPRECATED)<br/>
+3205  * @name ldapToOneline
+3206  * @memberOf KJUR.asn1.x509.X500Name
+3207  * @function
+3208  * @param {String} s distinguished name string in LDAP(RFC 2253) format (ex. O=test,C=US)
+3209  * @return {String} distinguished name string in OpenSSL compat format (ex. /C=US/O=test)
+3210  * @since jsrsasign 6.2.2 asn1x509 1.0.18
+3211  * @description
+3212  * This method is deprecated. Please use 
+3213  * {@link KJUR.asn1.x509.X500Name.ldapToCompat} instead.
+3214  */
+3215 KJUR.asn1.x509.X500Name.ldapToOneline = function(s) {
+3216     return KJUR.asn1.x509.X500Name.ldapToCompat(s);
+3217 };
+3218 
+3219 /**
+3220  * RDN (Relative Distinguished Name) ASN.1 structure class
+3221  * @name KJUR.asn1.x509.RDN
+3222  * @class RDN (Relative Distinguished Name) ASN.1 structure class
+3223  * @param {Array} params associative array of parameters (ex. {'str': 'C=US'})
+3224  * @extends KJUR.asn1.ASN1Object
+3225  * @see KJUR.asn1.x509.X500Name
+3226  * @see KJUR.asn1.x509.RDN
+3227  * @see KJUR.asn1.x509.AttributeTypeAndValue
+3228  * @description
+3229  * This class provides RelativeDistinguishedName ASN.1 class structure
+3230  * defined in <a href="https://tools.ietf.org/html/rfc2253#section-2">RFC 2253 section 2</a>.
+3231  * <blockquote><pre>
+3232  * RelativeDistinguishedName ::= SET SIZE (1..MAX) OF
+3233  *   AttributeTypeAndValue
+3234  *
+3235  * AttributeTypeAndValue ::= SEQUENCE {
+3236  *   type  AttributeType,
+3237  *   value AttributeValue }
+3238  * </pre></blockquote>
+3239  * <br/>
+3240  * NOTE1: The "array" and "rule" parameters have been supported
+3241  * since jsrsasign 9.0.0 asn1x509 2.0.0.
+3242  * <br/>
+3243  * NOTE2: Multi-valued RDN in "str" parameter have been
+3244  * supported since jsrsasign 6.2.1 asn1x509 1.0.17.
+3245  * @example
+3246  * new KJUR.asn1.x509.RDN({array: [ // multi-valued
+3247  *    {type:"CN",value:"Bob",ds:"prn"},
+3248  *    {type:"CN",value:"bob@example.com", ds:"ia5"}
+3249  * ]});
+3250  * new KJUR.asn1.x509.RDN({str: "CN=test"});
+3251  * new KJUR.asn1.x509.RDN({str: "O=a+O=bb+O=c"}); // multi-valued
+3252  * new KJUR.asn1.x509.RDN({str: "O=a+O=b\\+b+O=c"}); // plus escaped
+3253  * new KJUR.asn1.x509.RDN({str: "O=a+O=\"b+b\"+O=c"}); // double quoted
+3254  */
+3255 KJUR.asn1.x509.RDN = function(params) {
+3256     KJUR.asn1.x509.RDN.superclass.constructor.call(this);
+3257     this.asn1Array = [];
+3258     this.paramArray = [];
+3259     this.sRule = "utf8"; // DEFAULT "utf8"
+3260     var _AttributeTypeAndValue = KJUR.asn1.x509.AttributeTypeAndValue;
+3261 
+3262     this.setByParam = function(params) {
+3263 	if (params.rule !== undefined) this.sRule = params.rule;
+3264         if (params.str !== undefined) {
+3265             this.addByMultiValuedString(params.str);
+3266         }
+3267 	if (params.array !== undefined) this.paramArray = params.array;
+3268     };
+3269 
+3270     /**
+3271      * add one AttributeTypeAndValue by string<br/>
+3272      * @name addByString
+3273      * @memberOf KJUR.asn1.x509.RDN#
+3274      * @function
+3275      * @param {String} s string of AttributeTypeAndValue
+3276      * @return {Object} unspecified
+3277      * @description
+3278      * This method add one AttributeTypeAndValue to RDN object.
+3279      * @example
+3280      * rdn = new KJUR.asn1.x509.RDN();
+3281      * rdn.addByString("CN=john");
+3282      * rdn.addByString("serialNumber=1234"); // for multi-valued RDN
+3283      */
+3284     this.addByString = function(s) {
+3285         this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({'str': s, rule: this.sRule}));
+3286     };
+3287 
+3288     /**
+3289      * add one AttributeTypeAndValue by multi-valued string<br/>
+3290      * @name addByMultiValuedString
+3291      * @memberOf KJUR.asn1.x509.RDN#
+3292      * @function
+3293      * @param {String} s string of multi-valued RDN
+3294      * @return {Object} unspecified
+3295      * @since jsrsasign 6.2.1 asn1x509 1.0.17
+3296      * @description
+3297      * This method add multi-valued RDN to RDN object.
+3298      * @example
+3299      * rdn = new KJUR.asn1.x509.RDN();
+3300      * rdn.addByMultiValuedString("CN=john+O=test");
+3301      * rdn.addByMultiValuedString("O=a+O=b\+b\+b+O=c"); // multi-valued RDN with quoted plus
+3302      * rdn.addByMultiValuedString("O=a+O=\"b+b+b\"+O=c"); // multi-valued RDN with quoted quotation
+3303      */
+3304     this.addByMultiValuedString = function(s) {
+3305 	var a = KJUR.asn1.x509.RDN.parseString(s);
+3306 	for (var i = 0; i < a.length; i++) {
+3307 	    this.addByString(a[i]);
+3308 	}
+3309     };
+3310 
+3311     this.tohex = function() {
+3312 	if (this.asn1Array.length == 0 && this.paramArray.length > 0) {
+3313 	    for (var i = 0; i < this.paramArray.length; i++) {
+3314 		var param = this.paramArray[i];
+3315 		if (param.rule !== undefined &&
+3316 		    this.sRule != "utf8") {
+3317 		    param.rule = this.sRule;
+3318 		}
+3319 		//alert(JSON.stringify(param));
+3320 		var asn1ATV = new _AttributeTypeAndValue(param);
+3321 		this.asn1Array.push(asn1ATV);
+3322 	    }
+3323 	}
+3324         var o = new KJUR.asn1.DERSet({"array": this.asn1Array});
+3325         this.TLV = o.tohex();
+3326         return this.TLV;
+3327     };
+3328     this.getEncodedHex = function() { return this.tohex(); };
+3329 
+3330     if (params !== undefined) {
+3331 	this.setByParam(params);
+3332     }
+3333 };
+3334 extendClass(KJUR.asn1.x509.RDN, KJUR.asn1.ASN1Object);
+3335 
+3336 /**
+3337  * parse multi-valued RDN string and split into array of 'AttributeTypeAndValue'<br/>
+3338  * @name parseString
+3339  * @memberOf KJUR.asn1.x509.RDN
+3340  * @function
+3341  * @param {String} s multi-valued string of RDN
+3342  * @return {Array} array of string of AttributeTypeAndValue
+3343  * @since jsrsasign 6.2.1 asn1x509 1.0.17
+3344  * @description
+3345  * This static method parses multi-valued RDN string and split into
+3346  * array of AttributeTypeAndValue.
+3347  * @example
+3348  * KJUR.asn1.x509.RDN.parseString("CN=john") → ["CN=john"]
+3349  * KJUR.asn1.x509.RDN.parseString("CN=john+OU=test") → ["CN=john", "OU=test"]
+3350  * KJUR.asn1.x509.RDN.parseString('CN="jo+hn"+OU=test') → ["CN=jo+hn", "OU=test"]
+3351  * KJUR.asn1.x509.RDN.parseString('CN=jo\+hn+OU=test') → ["CN=jo+hn", "OU=test"]
+3352  * KJUR.asn1.x509.RDN.parseString("CN=john+OU=test+OU=t1") → ["CN=john", "OU=test", "OU=t1"]
+3353  */
+3354 KJUR.asn1.x509.RDN.parseString = function(s) {
+3355     var a = s.split(/\+/);
+3356 
+3357     // join \+
+3358     var isBSbefore = false;
+3359     var a2 = [];
+3360     for (var i = 0; a.length > 0; i++) {
+3361 	var item = a.shift();
+3362 	//console.log("item=" + item);
+3363 
+3364 	if (isBSbefore === true) {
+3365 	    var a2last = a2.pop();
+3366 	    var newitem = (a2last + "+" + item).replace(/\\\+/g, "+");
+3367 	    a2.push(newitem);
+3368 	    isBSbefore = false;
+3369 	} else {
+3370 	    a2.push(item);
+3371 	}
+3372 
+3373 	if (item.substr(-1, 1) === "\\") isBSbefore = true;
+3374     }
+3375 
+3376     // join quote
+3377     var beginQuote = false;
+3378     var a3 = [];
+3379     for (var i = 0; a2.length > 0; i++) {
+3380 	var item = a2.shift();
+3381 
+3382 	if (beginQuote === true) {
+3383 	    var a3last = a3.pop();
+3384 	    if (item.match(/"$/)) {
+3385 		var newitem = (a3last + "+" + item).replace(/^([^=]+)="(.*)"$/, "$1=$2");
+3386 		a3.push(newitem);
+3387 		beginQuote = false;
+3388 	    } else {
+3389 		a3.push(a3last + "+" + item);
+3390 	    }
+3391 	} else {
+3392 	    a3.push(item);
+3393 	}
+3394 
+3395 	if (item.match(/^[^=]+="/)) {
+3396 	    //console.log(i + "=" + item);
+3397 	    beginQuote = true;
+3398 	}
+3399     }
+3400     return a3;
+3401 };
+3402 
+3403 /**
+3404  * AttributeTypeAndValue ASN.1 structure class
+3405  * @name KJUR.asn1.x509.AttributeTypeAndValue
+3406  * @class AttributeTypeAndValue ASN.1 structure class
+3407  * @param {Array} params JSON object for parameters (ex. {str: 'C=US'})
+3408  * @extends KJUR.asn1.ASN1Object
+3409  * @see KJUR.asn1.x509.X500Name
+3410  * @see KJUR.asn1.x509.RDN
+3411  * @see KJUR.asn1.x509.AttributeTypeAndValue
+3412  * @see X509#getAttrTypeAndValue
+3413  * @description
+3414  * This class generates AttributeTypeAndValue defined in
+3415  * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
+3416  * RFC 5280 4.1.2.4</a>.
+3417  * <pre>
+3418  * AttributeTypeAndValue ::= SEQUENCE {
+3419  *   type     AttributeType,
+3420  *   value    AttributeValue }
+3421  * AttributeType ::= OBJECT IDENTIFIER
+3422  * AttributeValue ::= ANY -- DEFINED BY AttributeType
+3423  * </pre>
+3424  * The constructor argument can have following parameters:
+3425  * <ul>
+3426  * <li>{String}type - AttributeType name or OID(ex. C,O,CN)</li>
+3427  * <li>{String}value - raw string of ASN.1 value of AttributeValue</li>
+3428  * <li>{String}ds - DirectoryString type of AttributeValue</li>
+3429  * <li>{String}rule - DirectoryString type rule (ex. "prn" or "utf8")
+3430  * set DirectoryString type automatically when "ds" not specified.</li>
+3431  * <li>{String}str - AttributeTypeAndVale string (ex. "C=US").
+3432  * When type and value don't exists, 
+3433  * this "str" will be converted to "type" and "value".
+3434  * </li>
+3435  * </ul>
+3436  * <br
+3437  * NOTE: Parameters "type", "value,", "ds" and "rule" have
+3438  * been supported since jsrsasign 9.0.0 asn1x509 2.0.0.
+3439  * @example
+3440  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'C',value:'US',ds:'prn'})
+3441  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'givenName',value:'John',ds:'prn'})
+3442  * new KJUR.asn1.x509.AttributeTypeAndValue({type:'2.5.4.9',value:'71 Bowman St',ds:'prn'})
+3443  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1'})
+3444  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'streetAddress=71 Bowman St'})
+3445  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1',rule='prn'})
+3446  * new KJUR.asn1.x509.AttributeTypeAndValue({str:'O=T1',rule='utf8'})
+3447  */
+3448 KJUR.asn1.x509.AttributeTypeAndValue = function(params) {
+3449     KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);
+3450     this.sRule = "utf8";
+3451     this.sType = null;
+3452     this.sValue = null;
+3453     this.dsType = null;
+3454     var _KJUR = KJUR,
+3455 	_KJUR_asn1 = _KJUR.asn1,
+3456 	_DERSequence = _KJUR_asn1.DERSequence,
+3457 	_DERUTF8String = _KJUR_asn1.DERUTF8String,
+3458 	_DERPrintableString = _KJUR_asn1.DERPrintableString,
+3459 	_DERTeletexString = _KJUR_asn1.DERTeletexString,
+3460 	_DERIA5String = _KJUR_asn1.DERIA5String,
+3461 	_DERVisibleString = _KJUR_asn1.DERVisibleString,
+3462 	_DERBMPString = _KJUR_asn1.DERBMPString,
+3463 	_isMail = _KJUR.lang.String.isMail,
+3464 	_isPrintable = _KJUR.lang.String.isPrintable;
+3465 
+3466     this.setByParam = function(params) {
+3467 	if (params.rule !== undefined) this.sRule = params.rule;
+3468 	if (params.ds !== undefined)   this.dsType = params.ds;
+3469 
+3470         if (params.value === undefined &&
+3471 	    params.str !== undefined) {
+3472 	    var str = params.str;
+3473             var matchResult = str.match(/^([^=]+)=(.+)$/);
+3474             if (matchResult) {
+3475 		this.sType = matchResult[1];
+3476 		this.sValue = matchResult[2];
+3477             } else {
+3478 		throw new Error("malformed attrTypeAndValueStr: " +
+3479 				attrTypeAndValueStr);
+3480             }
+3481 	    
+3482 	    //this.setByString(params.str);
+3483         } else {
+3484 	    this.sType = params.type;
+3485 	    this.sValue = params.value;
+3486 	}
+3487     };
+3488 
+3489     /*
+3490      * @deprecated
+3491      */
+3492     this.setByString = function(sTypeValue, sRule) {
+3493 	if (sRule !== undefined) this.sRule = sRule;
+3494         var matchResult = sTypeValue.match(/^([^=]+)=(.+)$/);
+3495         if (matchResult) {
+3496             this.setByAttrTypeAndValueStr(matchResult[1], matchResult[2]);
+3497         } else {
+3498             throw new Error("malformed attrTypeAndValueStr: " +
+3499 			    attrTypeAndValueStr);
+3500         }
+3501     };
+3502 
+3503     this._getDsType = function() {
+3504 	var sType = this.sType;
+3505 	var sValue = this.sValue;
+3506 	var sRule = this.sRule;
+3507 
+3508 	if (sRule === "prn") {
+3509 	    if (sType == "CN" && _isMail(sValue)) return "ia5";
+3510 	    if (_isPrintable(sValue)) return "prn";
+3511 	    return "utf8";
+3512 	} else if (sRule === "utf8") {
+3513 	    if (sType == "CN" && _isMail(sValue)) return "ia5";
+3514 	    if (sType == "C") return "prn";
+3515 	    return "utf8";
+3516 	}
+3517 	return "utf8"; // default
+3518     };
+3519 
+3520     this.setByAttrTypeAndValueStr = function(sType, sValue, sRule) {
+3521 	if (sRule !== undefined) this.sRule = sRule;
+3522 	this.sType = sType;
+3523 	this.sValue = sValue;
+3524     };
+3525 
+3526     this.getValueObj = function(dsType, valueStr) {
+3527         if (dsType == "utf8") return new _DERUTF8String({"str": valueStr});
+3528         if (dsType == "prn")  return new _DERPrintableString({"str": valueStr});
+3529         if (dsType == "tel")  return new _DERTeletexString({"str": valueStr});
+3530         if (dsType == "ia5")  return new _DERIA5String({"str": valueStr});
+3531         if (dsType == "vis")  return new _DERVisibleString({"str": valueStr});
+3532         if (dsType == "bmp")  return new _DERBMPString({"str": valueStr});
+3533         throw new Error("unsupported directory string type: type=" +
+3534 			dsType + " value=" + valueStr);
+3535     };
 3536 
-3537 	if (sRule === "prn") {
-3538 	    if (sType == "CN" && _isMail(sValue)) return "ia5";
-3539 	    if (_isPrintable(sValue)) return "prn";
-3540 	    return "utf8";
-3541 	} else if (sRule === "utf8") {
-3542 	    if (sType == "CN" && _isMail(sValue)) return "ia5";
-3543 	    if (sType == "C") return "prn";
-3544 	    return "utf8";
-3545 	}
-3546 	return "utf8"; // default
-3547     };
-3548 
-3549     this.setByAttrTypeAndValueStr = function(sType, sValue, sRule) {
-3550 	if (sRule !== undefined) this.sRule = sRule;
-3551 	this.sType = sType;
-3552 	this.sValue = sValue;
-3553     };
-3554 
-3555     this.getValueObj = function(dsType, valueStr) {
-3556         if (dsType == "utf8") return new _DERUTF8String({"str": valueStr});
-3557         if (dsType == "prn")  return new _DERPrintableString({"str": valueStr});
-3558         if (dsType == "tel")  return new _DERTeletexString({"str": valueStr});
-3559         if (dsType == "ia5")  return new _DERIA5String({"str": valueStr});
-3560         if (dsType == "vis")  return new _DERVisibleString({"str": valueStr});
-3561         if (dsType == "bmp")  return new _DERBMPString({"str": valueStr});
-3562         throw new Error("unsupported directory string type: type=" +
-3563 			dsType + " value=" + valueStr);
-3564     };
-3565 
-3566     this.tohex = function() {
-3567 	if (this.dsType == null) this.dsType = this._getDsType();
-3568 	var asn1Type = KJUR.asn1.x509.OID.atype2obj(this.sType);
-3569 	var asn1Value = this.getValueObj(this.dsType, this.sValue);
-3570         var o = new _DERSequence({"array": [asn1Type, asn1Value]});
-3571         this.TLV = o.tohex();
-3572         return this.TLV;
-3573     }
-3574 
-3575     this.getEncodedHex = function() { return this.tohex(); };
-3576 
-3577     if (params !== undefined) {
-3578 	this.setByParam(params);
-3579     }
-3580 };
-3581 extendClass(KJUR.asn1.x509.AttributeTypeAndValue, KJUR.asn1.ASN1Object);
-3582 
-3583 // === END   X500Name Related =================================================
-3584 
-3585 // === BEGIN Other ASN1 structure class  ======================================
-3586 
-3587 /**
-3588  * SubjectPublicKeyInfo ASN.1 structure class
-3589  * @name KJUR.asn1.x509.SubjectPublicKeyInfo
-3590  * @class SubjectPublicKeyInfo ASN.1 structure class
-3591  * @param {Object} params parameter for subject public key
-3592  * @extends KJUR.asn1.ASN1Object
-3593  * @description
-3594  * <br/>
-3595  * As for argument 'params' for constructor, you can specify one of
-3596  * following properties:
-3597  * <ul>
-3598  * <li>{@link RSAKey} object</li>
-3599  * <li>{@link KJUR.crypto.ECDSA} object</li>
-3600  * <li>{@link KJUR.crypto.DSA} object</li>
-3601  * </ul>
-3602  * NOTE1: 'params' can be omitted.<br/>
-3603  * NOTE2: DSA/ECDSA key object is also supported since asn1x509 1.0.6.<br/>
-3604  * <h4>EXAMPLE</h4>
-3605  * @example
-3606  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(RSAKey_object);
-3607  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(KJURcryptoECDSA_object);
-3608  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(KJURcryptoDSA_object);
-3609  */
-3610 KJUR.asn1.x509.SubjectPublicKeyInfo = function(params) {
-3611     KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);
-3612     var asn1AlgId = null,
-3613 	asn1SubjPKey = null,
-3614 	_KJUR = KJUR,
-3615 	_KJUR_asn1 = _KJUR.asn1,
-3616 	_DERInteger = _KJUR_asn1.DERInteger,
-3617 	_DERBitString = _KJUR_asn1.DERBitString,
-3618 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-3619 	_DERSequence = _KJUR_asn1.DERSequence,
-3620 	_newObject = _KJUR_asn1.ASN1Util.newObject,
-3621 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-3622 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
-3623 	_KJUR_crypto = _KJUR.crypto,
-3624 	_KJUR_crypto_ECDSA = _KJUR_crypto.ECDSA,
-3625 	_KJUR_crypto_DSA = _KJUR_crypto.DSA;
-3626 
-3627     /*
-3628      * @since asn1x509 1.0.7
-3629      */
-3630     this.getASN1Object = function() {
-3631         if (this.asn1AlgId == null || this.asn1SubjPKey == null)
-3632             throw "algId and/or subjPubKey not set";
-3633         var o = new _DERSequence({'array':
-3634                                   [this.asn1AlgId, this.asn1SubjPKey]});
-3635         return o;
-3636     };
-3637 
-3638     this.tohex = function() {
-3639         var o = this.getASN1Object();
-3640         this.hTLV = o.tohex();
-3641         return this.hTLV;
-3642     };
-3643     this.getEncodedHex = function() { return this.tohex(); };
-3644 
-3645     /**
-3646      * @name setPubKey
-3647      * @memberOf KJUR.asn1.x509.SubjectPublicKeyInfo#
-3648      * @function
-3649      * @param {Object} {@link RSAKey}, {@link KJUR.crypto.ECDSA} or {@link KJUR.crypto.DSA} object
-3650      * @since jsrsasign 8.0.0 asn1x509 1.1.0
-3651      * @description
-3652      * @example
-3653      * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo();
-3654      * pubKey = KEYUTIL.getKey(PKCS8PUBKEYPEM);
-3655      * spki.setPubKey(pubKey);
-3656      */
-3657     this.setPubKey = function(key) {
-3658 	try {
-3659 	    if (key instanceof RSAKey) {
-3660 		var asn1RsaPub = _newObject({
-3661 		    'seq': [{'int': {'bigint': key.n}}, {'int': {'int': key.e}}]
-3662 		});
-3663 		var rsaKeyHex = asn1RsaPub.tohex();
-3664 		this.asn1AlgId = new _AlgorithmIdentifier({'name':'rsaEncryption'});
-3665 		this.asn1SubjPKey = new _DERBitString({'hex':'00'+rsaKeyHex});
-3666 	    }
-3667 	} catch(ex) {};
-3668 
-3669 	try {
-3670 	    if (key instanceof KJUR.crypto.ECDSA) {
-3671 		var asn1Params = new _DERObjectIdentifier({'name': key.curveName});
-3672 		this.asn1AlgId =
-3673 		    new _AlgorithmIdentifier({'name': 'ecPublicKey',
-3674 					      'asn1params': asn1Params});
-3675 		this.asn1SubjPKey = new _DERBitString({'hex': '00' + key.pubKeyHex});
-3676 	    }
-3677 	} catch(ex) {};
-3678 
-3679 	try {
-3680 	    if (key instanceof KJUR.crypto.DSA) {
-3681 		var asn1Params = new _newObject({
-3682 		    'seq': [{'int': {'bigint': key.p}},
-3683 			    {'int': {'bigint': key.q}},
-3684 			    {'int': {'bigint': key.g}}]
-3685 		});
-3686 		this.asn1AlgId =
-3687 		    new _AlgorithmIdentifier({'name': 'dsa',
-3688 					      'asn1params': asn1Params});
-3689 		var pubInt = new _DERInteger({'bigint': key.y});
-3690 		this.asn1SubjPKey = 
-3691 		    new _DERBitString({'hex': '00' + pubInt.tohex()});
-3692 	    }
-3693 	} catch(ex) {};
-3694     };
-3695 
-3696     if (params !== undefined) {
-3697 	this.setPubKey(params);
-3698     }
-3699 };
-3700 extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo, KJUR.asn1.ASN1Object);
-3701 
-3702 /**
-3703  * Time ASN.1 structure class<br/>
-3704  * @name KJUR.asn1.x509.Time
-3705  * @class Time ASN.1 structure class
-3706  * @param {Array} params associative array of parameters (ex. {'str': '130508235959Z'})
-3707  * @extends KJUR.asn1.ASN1Object
-3708  * @see KJUR.asn1.DERUTCTime
-3709  * @see KJUR.asn1.DERGeneralizedTime
-3710  * @description
-3711  * This class represents Time ASN.1 structure defined in 
-3712  * <a href="https://tools.ietf.org/html/rfc5280">RFC 5280</a>
-3713  * <pre>
-3714  * Time ::= CHOICE {
-3715  *      utcTime        UTCTime,
-3716  *      generalTime    GeneralizedTime }
-3717  * </pre>
-3718  *
-3719  * @example
-3720  * var t1 = new KJUR.asn1.x509.Time{'str': '130508235959Z'} // UTCTime by default
-3721  * var t2 = new KJUR.asn1.x509.Time{'type': 'gen',  'str': '20130508235959Z'} // GeneralizedTime
-3722  */
-3723 KJUR.asn1.x509.Time = function(params) {
-3724     KJUR.asn1.x509.Time.superclass.constructor.call(this);
-3725     var type = null,
-3726 	timeParams = null,
-3727 	_KJUR = KJUR,
-3728 	_KJUR_asn1 = _KJUR.asn1,
-3729 	_DERUTCTime = _KJUR_asn1.DERUTCTime,
-3730 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime;
-3731     this.params = null;
-3732     this.type = null;
-3733 
-3734     // deprecated
-3735     this.setTimeParams = function(timeParams) {
-3736         this.timeParams = timeParams;
-3737     }
-3738 
-3739     this.setByParam = function(params) {
-3740 	this.params = params;
-3741     };
-3742 
-3743     this.getType = function(s) {
-3744         if (s.match(/^[0-9]{12}Z$/)) return "utc";
-3745         if (s.match(/^[0-9]{14}Z$/)) return "gen";
-3746         if (s.match(/^[0-9]{12}\.[0-9]+Z$/)) return "utc";
-3747         if (s.match(/^[0-9]{14}\.[0-9]+Z$/)) return "gen";
-3748 	return null;
-3749     };
-3750 
-3751     this.tohex = function() {
-3752 	var params = this.params;
-3753         var o = null;
-3754 
-3755 	if (typeof params == "string") params = {str: params};
-3756 	if (params != null &&
-3757 	    params.str && 
-3758 	    (params.type == null || params.type == undefined)) {
-3759 	    params.type = this.getType(params.str);
-3760 	}
+3537     this.tohex = function() {
+3538 	if (this.dsType == null) this.dsType = this._getDsType();
+3539 	var asn1Type = KJUR.asn1.x509.OID.atype2obj(this.sType);
+3540 	var asn1Value = this.getValueObj(this.dsType, this.sValue);
+3541         var o = new _DERSequence({"array": [asn1Type, asn1Value]});
+3542         this.TLV = o.tohex();
+3543         return this.TLV;
+3544     }
+3545 
+3546     this.getEncodedHex = function() { return this.tohex(); };
+3547 
+3548     if (params !== undefined) {
+3549 	this.setByParam(params);
+3550     }
+3551 };
+3552 extendClass(KJUR.asn1.x509.AttributeTypeAndValue, KJUR.asn1.ASN1Object);
+3553 
+3554 // === END   X500Name Related =================================================
+3555 
+3556 // === BEGIN Other ASN1 structure class  ======================================
+3557 
+3558 /**
+3559  * SubjectPublicKeyInfo ASN.1 structure class
+3560  * @name KJUR.asn1.x509.SubjectPublicKeyInfo
+3561  * @class SubjectPublicKeyInfo ASN.1 structure class
+3562  * @param {Object} params parameter for subject public key
+3563  * @extends KJUR.asn1.ASN1Object
+3564  * @description
+3565  * <br/>
+3566  * As for argument 'params' for constructor, you can specify one of
+3567  * following properties:
+3568  * <ul>
+3569  * <li>{@link RSAKey} object</li>
+3570  * <li>{@link KJUR.crypto.ECDSA} object</li>
+3571  * <li>{@link KJUR.crypto.DSA} object</li>
+3572  * </ul>
+3573  * NOTE1: 'params' can be omitted.<br/>
+3574  * NOTE2: DSA/ECDSA key object is also supported since asn1x509 1.0.6.<br/>
+3575  * <h4>EXAMPLE</h4>
+3576  * @example
+3577  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(RSAKey_object);
+3578  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(KJURcryptoECDSA_object);
+3579  * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo(KJURcryptoDSA_object);
+3580  */
+3581 KJUR.asn1.x509.SubjectPublicKeyInfo = function(params) {
+3582     KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);
+3583     var asn1AlgId = null,
+3584 	asn1SubjPKey = null,
+3585 	_KJUR = KJUR,
+3586 	_KJUR_asn1 = _KJUR.asn1,
+3587 	_DERInteger = _KJUR_asn1.DERInteger,
+3588 	_DERBitString = _KJUR_asn1.DERBitString,
+3589 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+3590 	_DERSequence = _KJUR_asn1.DERSequence,
+3591 	_newObject = _KJUR_asn1.ASN1Util.newObject,
+3592 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+3593 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
+3594 	_KJUR_crypto = _KJUR.crypto,
+3595 	_KJUR_crypto_ECDSA = _KJUR_crypto.ECDSA,
+3596 	_KJUR_crypto_DSA = _KJUR_crypto.DSA;
+3597 
+3598     /*
+3599      * @since asn1x509 1.0.7
+3600      */
+3601     this.getASN1Object = function() {
+3602         if (this.asn1AlgId == null || this.asn1SubjPKey == null)
+3603             throw "algId and/or subjPubKey not set";
+3604         var o = new _DERSequence({'array':
+3605                                   [this.asn1AlgId, this.asn1SubjPKey]});
+3606         return o;
+3607     };
+3608 
+3609     this.tohex = function() {
+3610         var o = this.getASN1Object();
+3611         this.hTLV = o.tohex();
+3612         return this.hTLV;
+3613     };
+3614     this.getEncodedHex = function() { return this.tohex(); };
+3615 
+3616     /**
+3617      * @name setPubKey
+3618      * @memberOf KJUR.asn1.x509.SubjectPublicKeyInfo#
+3619      * @function
+3620      * @param {Object} {@link RSAKey}, {@link KJUR.crypto.ECDSA} or {@link KJUR.crypto.DSA} object
+3621      * @since jsrsasign 8.0.0 asn1x509 1.1.0
+3622      * @description
+3623      * @example
+3624      * spki = new KJUR.asn1.x509.SubjectPublicKeyInfo();
+3625      * pubKey = KEYUTIL.getKey(PKCS8PUBKEYPEM);
+3626      * spki.setPubKey(pubKey);
+3627      */
+3628     this.setPubKey = function(key) {
+3629 	try {
+3630 	    if (key instanceof RSAKey) {
+3631 		var asn1RsaPub = _newObject({
+3632 		    'seq': [{'int': {'bigint': key.n}}, {'int': {'int': key.e}}]
+3633 		});
+3634 		var rsaKeyHex = asn1RsaPub.tohex();
+3635 		this.asn1AlgId = new _AlgorithmIdentifier({'name':'rsaEncryption'});
+3636 		this.asn1SubjPKey = new _DERBitString({'hex':'00'+rsaKeyHex});
+3637 	    }
+3638 	} catch(ex) {};
+3639 
+3640 	try {
+3641 	    if (key instanceof KJUR.crypto.ECDSA) {
+3642 		var asn1Params = new _DERObjectIdentifier({'name': key.curveName});
+3643 		this.asn1AlgId =
+3644 		    new _AlgorithmIdentifier({'name': 'ecPublicKey',
+3645 					      'asn1params': asn1Params});
+3646 		this.asn1SubjPKey = new _DERBitString({'hex': '00' + key.pubKeyHex});
+3647 	    }
+3648 	} catch(ex) {};
+3649 
+3650 	try {
+3651 	    if (key instanceof KJUR.crypto.DSA) {
+3652 		var asn1Params = new _newObject({
+3653 		    'seq': [{'int': {'bigint': key.p}},
+3654 			    {'int': {'bigint': key.q}},
+3655 			    {'int': {'bigint': key.g}}]
+3656 		});
+3657 		this.asn1AlgId =
+3658 		    new _AlgorithmIdentifier({'name': 'dsa',
+3659 					      'asn1params': asn1Params});
+3660 		var pubInt = new _DERInteger({'bigint': key.y});
+3661 		this.asn1SubjPKey = 
+3662 		    new _DERBitString({'hex': '00' + pubInt.tohex()});
+3663 	    }
+3664 	} catch(ex) {};
+3665     };
+3666 
+3667     if (params !== undefined) {
+3668 	this.setPubKey(params);
+3669     }
+3670 };
+3671 extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo, KJUR.asn1.ASN1Object);
+3672 
+3673 /**
+3674  * Time ASN.1 structure class<br/>
+3675  * @name KJUR.asn1.x509.Time
+3676  * @class Time ASN.1 structure class
+3677  * @param {Array} params associative array of parameters (ex. {'str': '130508235959Z'})
+3678  * @extends KJUR.asn1.ASN1Object
+3679  * @see KJUR.asn1.DERUTCTime
+3680  * @see KJUR.asn1.DERGeneralizedTime
+3681  * @description
+3682  * This class represents Time ASN.1 structure defined in 
+3683  * <a href="https://tools.ietf.org/html/rfc5280">RFC 5280</a>
+3684  * <pre>
+3685  * Time ::= CHOICE {
+3686  *      utcTime        UTCTime,
+3687  *      generalTime    GeneralizedTime }
+3688  * </pre>
+3689  *
+3690  * @example
+3691  * var t1 = new KJUR.asn1.x509.Time{'str': '130508235959Z'} // UTCTime by default
+3692  * var t2 = new KJUR.asn1.x509.Time{'type': 'gen',  'str': '20130508235959Z'} // GeneralizedTime
+3693  */
+3694 KJUR.asn1.x509.Time = function(params) {
+3695     KJUR.asn1.x509.Time.superclass.constructor.call(this);
+3696     var type = null,
+3697 	timeParams = null,
+3698 	_KJUR = KJUR,
+3699 	_KJUR_asn1 = _KJUR.asn1,
+3700 	_DERUTCTime = _KJUR_asn1.DERUTCTime,
+3701 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime;
+3702     this.params = null;
+3703     this.type = null;
+3704 
+3705     // deprecated
+3706     this.setTimeParams = function(timeParams) {
+3707         this.timeParams = timeParams;
+3708     }
+3709 
+3710     this.setByParam = function(params) {
+3711 	this.params = params;
+3712     };
+3713 
+3714     this.getType = function(s) {
+3715         if (s.match(/^[0-9]{12}Z$/)) return "utc";
+3716         if (s.match(/^[0-9]{14}Z$/)) return "gen";
+3717         if (s.match(/^[0-9]{12}\.[0-9]+Z$/)) return "utc";
+3718         if (s.match(/^[0-9]{14}\.[0-9]+Z$/)) return "gen";
+3719 	return null;
+3720     };
+3721 
+3722     this.tohex = function() {
+3723 	var params = this.params;
+3724         var o = null;
+3725 
+3726 	if (typeof params == "string") params = {str: params};
+3727 	if (params != null &&
+3728 	    params.str && 
+3729 	    (params.type == null || params.type == undefined)) {
+3730 	    params.type = this.getType(params.str);
+3731 	}
+3732 
+3733 	if (params != null && params.str) {
+3734 	    if (params.type == "utc") o = new _DERUTCTime(params.str);
+3735 	    if (params.type == "gen") o = new _DERGeneralizedTime(params.str);
+3736 	} else {
+3737 	    if (this.type == "gen") {
+3738 		o = new _DERGeneralizedTime();
+3739 	    } else {
+3740 		o = new _DERUTCTime();
+3741 	    }
+3742 	}
+3743 
+3744 	if (o == null) throw new Error("wrong setting for Time");
+3745         this.TLV = o.tohex();
+3746         return this.TLV;
+3747     };
+3748     this.getEncodedHex = function() { return this.tohex(); };
+3749 
+3750     if (params != undefined) this.setByParam(params);
+3751 };
+3752 
+3753 KJUR.asn1.x509.Time_bak = function(params) {
+3754     KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);
+3755     var type = null,
+3756 	timeParams = null,
+3757 	_KJUR = KJUR,
+3758 	_KJUR_asn1 = _KJUR.asn1,
+3759 	_DERUTCTime = _KJUR_asn1.DERUTCTime,
+3760 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime;
 3761 
-3762 	if (params != null && params.str) {
-3763 	    if (params.type == "utc") o = new _DERUTCTime(params.str);
-3764 	    if (params.type == "gen") o = new _DERGeneralizedTime(params.str);
-3765 	} else {
-3766 	    if (this.type == "gen") {
-3767 		o = new _DERGeneralizedTime();
-3768 	    } else {
-3769 		o = new _DERUTCTime();
-3770 	    }
-3771 	}
-3772 
-3773 	if (o == null) throw new Error("wrong setting for Time");
-3774         this.TLV = o.tohex();
-3775         return this.TLV;
-3776     };
-3777     this.getEncodedHex = function() { return this.tohex(); };
-3778 
-3779     if (params != undefined) this.setByParam(params);
-3780 };
-3781 
-3782 KJUR.asn1.x509.Time_bak = function(params) {
-3783     KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);
-3784     var type = null,
-3785 	timeParams = null,
-3786 	_KJUR = KJUR,
-3787 	_KJUR_asn1 = _KJUR.asn1,
-3788 	_DERUTCTime = _KJUR_asn1.DERUTCTime,
-3789 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime;
-3790 
-3791     this.setTimeParams = function(timeParams) {
-3792         this.timeParams = timeParams;
-3793     }
-3794 
-3795     this.tohex = function() {
-3796         var o = null;
-3797 
-3798         if (this.timeParams != null) {
-3799             if (this.type == "utc") {
-3800                 o = new _DERUTCTime(this.timeParams);
-3801             } else {
-3802                 o = new _DERGeneralizedTime(this.timeParams);
-3803             }
-3804         } else {
-3805             if (this.type == "utc") {
-3806                 o = new _DERUTCTime();
-3807             } else {
-3808                 o = new _DERGeneralizedTime();
-3809             }
-3810         }
-3811         this.TLV = o.tohex();
-3812         return this.TLV;
-3813     };
-3814     this.getEncodedHex = function() { return this.tohex(); };
-3815 
-3816     this.type = "utc";
-3817     if (params !== undefined) {
-3818         if (params.type !== undefined) {
-3819             this.type = params.type;
-3820         } else {
-3821             if (params.str !== undefined) {
-3822                 if (params.str.match(/^[0-9]{12}Z$/)) this.type = "utc";
-3823                 if (params.str.match(/^[0-9]{14}Z$/)) this.type = "gen";
-3824             }
-3825         }
-3826         this.timeParams = params;
-3827     }
-3828 };
-3829 extendClass(KJUR.asn1.x509.Time, KJUR.asn1.ASN1Object);
-3830 
-3831 /**
-3832  * AlgorithmIdentifier ASN.1 structure class
-3833  * @name KJUR.asn1.x509.AlgorithmIdentifier
-3834  * @class AlgorithmIdentifier ASN.1 structure class
-3835  * @param {Array} params associative array of parameters (ex. {'name': 'SHA1withRSA'})
-3836  * @extends KJUR.asn1.ASN1Object
-3837  * @description
-3838  * The 'params' argument is an associative array and has following parameters:
-3839  * <ul>
-3840  * <li>name: algorithm name (MANDATORY, ex. sha1, SHA256withRSA)</li>
-3841  * <li>asn1params: explicitly specify ASN.1 object for algorithm.
-3842  * (OPTION)</li>
-3843  * <li>paramempty: set algorithm parameter to NULL by force.
-3844  * If paramempty is false, algorithm parameter will be set automatically.
-3845  * If paramempty is false and algorithm name is "*withDSA" or "withECDSA" parameter field of
-3846  * AlgorithmIdentifier will be ommitted otherwise
-3847  * it will be NULL by default.
-3848  * (OPTION, DEFAULT = false)</li>
-3849  * </ul>
-3850  * RSA-PSS algorithm names such as SHA{,256,384,512}withRSAandMGF1 are
-3851  * special names. They will set a suite of algorithm OID and multiple algorithm
-3852  * parameters. Its ASN.1 schema is defined in 
-3853  * <a href="https://tools.ietf.org/html/rfc3447#appendix-A.2.3">RFC 3447 PKCS#1 2.1
-3854  * section A.2.3</a>.
-3855  * <blockquote><pre>
-3856  * id-RSASSA-PSS  OBJECT IDENTIFIER ::= { pkcs-1 10 }
-3857  * RSASSA-PSS-params ::= SEQUENCE {
-3858  *   hashAlgorithm      [0] HashAlgorithm    DEFAULT sha1,
-3859  *   maskGenAlgorithm   [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
-3860  *   saltLength         [2] INTEGER          DEFAULT 20,
-3861  *   trailerField       [3] TrailerField     DEFAULT trailerFieldBC }
-3862  * mgf1SHA1    MaskGenAlgorithm ::= {
-3863  *   algorithm   id-mgf1,
-3864  *   parameters  HashAlgorithm : sha1 }
-3865  * id-mgf1     OBJECT IDENTIFIER ::= { pkcs-1 8 }
-3866  * TrailerField ::= INTEGER { trailerFieldBC(1) }
-3867  * </pre></blockquote>
-3868  * Here is a table for PSS parameters:
-3869  * <table>
-3870  * <tr><th>Name</th><th>alg oid</th><th>pss hash</th><th>maskgen</th></th><th>pss saltlen</th><th>trailer</th></tr>
-3871  * <tr><td>SHAwithRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>default(sha1)</td><td>default(mgf1sha1)</td><td>default(20)</td><td>default(1)</td></tr>
-3872  * <tr><td>SHA256withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha256</td><td>mgf1sha256</td><td>32</td><td>default(1)</td></tr>
-3873  * <tr><td>SHA384withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha384</td><td>mgf1sha384</td><td>48</td><td>default(1)</td></tr>
-3874  * <tr><td>SHA512withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha512</td><td>mgf1sha512</td><td>64</td><td>default(1)</td></tr>
-3875  * </table>
-3876  * Default value is omitted as defined in ASN.1 schema.
-3877  * These parameters are interoperable to OpenSSL or IAIK toolkit.
-3878  * <br/>
-3879  * NOTE: RSA-PSS algorihtm names are supported since jsrsasign 8.0.21. 
-3880  * @example
-3881  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "sha1"})
-3882  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA256withRSA"})
-3883  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA512withRSAandMGF1"}) // set parameters automatically
-3884  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA256withRSA", paramempty: true})
-3885  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "rsaEncryption"})
-3886  */
-3887 KJUR.asn1.x509.AlgorithmIdentifier = function(params) {
-3888     KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);
-3889     this.nameAlg = null;
-3890     this.asn1Alg = null;
-3891     this.asn1Params = null;
-3892     this.paramEmpty = false;
-3893 
-3894     var _KJUR = KJUR,
-3895 	_KJUR_asn1 = _KJUR.asn1,
-3896 	_PSSNAME2ASN1TLV = _KJUR_asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;
-3897 
-3898     this.tohex = function() {
-3899         if (this.nameAlg === null && this.asn1Alg === null) {
-3900             throw new Error("algorithm not specified");
-3901         }
-3902 
-3903 	// for RSAPSS algorithm name
-3904 	//  && this.hTLV === null
-3905 	if (this.nameAlg !== null) {
-3906 	    var hTLV = null;
-3907 	    for (var key in _PSSNAME2ASN1TLV) {
-3908 		if (key === this.nameAlg) {
-3909 		    hTLV = _PSSNAME2ASN1TLV[key];
-3910 		}
-3911 	    }
-3912 	    if (hTLV !== null) {
-3913 		this.hTLV = hTLV;
-3914 		return this.hTLV;
-3915 	    }
-3916 	}
-3917 
-3918         if (this.nameAlg !== null && this.asn1Alg === null) {
-3919             this.asn1Alg = _KJUR_asn1.x509.OID.name2obj(this.nameAlg);
-3920         }
-3921         var a = [this.asn1Alg];
-3922         if (this.asn1Params !== null) a.push(this.asn1Params);
+3762     this.setTimeParams = function(timeParams) {
+3763         this.timeParams = timeParams;
+3764     }
+3765 
+3766     this.tohex = function() {
+3767         var o = null;
+3768 
+3769         if (this.timeParams != null) {
+3770             if (this.type == "utc") {
+3771                 o = new _DERUTCTime(this.timeParams);
+3772             } else {
+3773                 o = new _DERGeneralizedTime(this.timeParams);
+3774             }
+3775         } else {
+3776             if (this.type == "utc") {
+3777                 o = new _DERUTCTime();
+3778             } else {
+3779                 o = new _DERGeneralizedTime();
+3780             }
+3781         }
+3782         this.TLV = o.tohex();
+3783         return this.TLV;
+3784     };
+3785     this.getEncodedHex = function() { return this.tohex(); };
+3786 
+3787     this.type = "utc";
+3788     if (params !== undefined) {
+3789         if (params.type !== undefined) {
+3790             this.type = params.type;
+3791         } else {
+3792             if (params.str !== undefined) {
+3793                 if (params.str.match(/^[0-9]{12}Z$/)) this.type = "utc";
+3794                 if (params.str.match(/^[0-9]{14}Z$/)) this.type = "gen";
+3795             }
+3796         }
+3797         this.timeParams = params;
+3798     }
+3799 };
+3800 extendClass(KJUR.asn1.x509.Time, KJUR.asn1.ASN1Object);
+3801 
+3802 /**
+3803  * AlgorithmIdentifier ASN.1 structure class
+3804  * @name KJUR.asn1.x509.AlgorithmIdentifier
+3805  * @class AlgorithmIdentifier ASN.1 structure class
+3806  * @param {Array} params associative array of parameters (ex. {'name': 'SHA1withRSA'})
+3807  * @extends KJUR.asn1.ASN1Object
+3808  * @description
+3809  * The 'params' argument is an associative array and has following parameters:
+3810  * <ul>
+3811  * <li>name: algorithm name (MANDATORY, ex. sha1, SHA256withRSA)</li>
+3812  * <li>asn1params: explicitly specify ASN.1 object for algorithm.
+3813  * (OPTION)</li>
+3814  * <li>paramempty: set algorithm parameter to NULL by force.
+3815  * If paramempty is false, algorithm parameter will be set automatically.
+3816  * If paramempty is false and algorithm name is "*withDSA" or "withECDSA" parameter field of
+3817  * AlgorithmIdentifier will be ommitted otherwise
+3818  * it will be NULL by default.
+3819  * (OPTION, DEFAULT = false)</li>
+3820  * </ul>
+3821  * RSA-PSS algorithm names such as SHA{,256,384,512}withRSAandMGF1 are
+3822  * special names. They will set a suite of algorithm OID and multiple algorithm
+3823  * parameters. Its ASN.1 schema is defined in 
+3824  * <a href="https://tools.ietf.org/html/rfc3447#appendix-A.2.3">RFC 3447 PKCS#1 2.1
+3825  * section A.2.3</a>.
+3826  * <blockquote><pre>
+3827  * id-RSASSA-PSS  OBJECT IDENTIFIER ::= { pkcs-1 10 }
+3828  * RSASSA-PSS-params ::= SEQUENCE {
+3829  *   hashAlgorithm      [0] HashAlgorithm    DEFAULT sha1,
+3830  *   maskGenAlgorithm   [1] MaskGenAlgorithm DEFAULT mgf1SHA1,
+3831  *   saltLength         [2] INTEGER          DEFAULT 20,
+3832  *   trailerField       [3] TrailerField     DEFAULT trailerFieldBC }
+3833  * mgf1SHA1    MaskGenAlgorithm ::= {
+3834  *   algorithm   id-mgf1,
+3835  *   parameters  HashAlgorithm : sha1 }
+3836  * id-mgf1     OBJECT IDENTIFIER ::= { pkcs-1 8 }
+3837  * TrailerField ::= INTEGER { trailerFieldBC(1) }
+3838  * </pre></blockquote>
+3839  * Here is a table for PSS parameters:
+3840  * <table>
+3841  * <tr><th>Name</th><th>alg oid</th><th>pss hash</th><th>maskgen</th></th><th>pss saltlen</th><th>trailer</th></tr>
+3842  * <tr><td>SHAwithRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>default(sha1)</td><td>default(mgf1sha1)</td><td>default(20)</td><td>default(1)</td></tr>
+3843  * <tr><td>SHA256withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha256</td><td>mgf1sha256</td><td>32</td><td>default(1)</td></tr>
+3844  * <tr><td>SHA384withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha384</td><td>mgf1sha384</td><td>48</td><td>default(1)</td></tr>
+3845  * <tr><td>SHA512withRSAandMGF1</td><td>1.2.840.113549.1.1.10(rsapss)</td><td>sha512</td><td>mgf1sha512</td><td>64</td><td>default(1)</td></tr>
+3846  * </table>
+3847  * Default value is omitted as defined in ASN.1 schema.
+3848  * These parameters are interoperable to OpenSSL or IAIK toolkit.
+3849  * <br/>
+3850  * NOTE: RSA-PSS algorihtm names are supported since jsrsasign 8.0.21. 
+3851  * @example
+3852  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "sha1"})
+3853  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA256withRSA"})
+3854  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA512withRSAandMGF1"}) // set parameters automatically
+3855  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "SHA256withRSA", paramempty: true})
+3856  * new KJUR.asn1.x509.AlgorithmIdentifier({name: "rsaEncryption"})
+3857  */
+3858 KJUR.asn1.x509.AlgorithmIdentifier = function(params) {
+3859     KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);
+3860     this.nameAlg = null;
+3861     this.asn1Alg = null;
+3862     this.asn1Params = null;
+3863     this.paramEmpty = false;
+3864 
+3865     var _KJUR = KJUR,
+3866 	_KJUR_asn1 = _KJUR.asn1,
+3867 	_PSSNAME2ASN1TLV = _KJUR_asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;
+3868 
+3869     this.tohex = function() {
+3870         if (this.nameAlg === null && this.asn1Alg === null) {
+3871             throw new Error("algorithm not specified");
+3872         }
+3873 
+3874 	// for RSAPSS algorithm name
+3875 	//  && this.hTLV === null
+3876 	if (this.nameAlg !== null) {
+3877 	    var hTLV = null;
+3878 	    for (var key in _PSSNAME2ASN1TLV) {
+3879 		if (key === this.nameAlg) {
+3880 		    hTLV = _PSSNAME2ASN1TLV[key];
+3881 		}
+3882 	    }
+3883 	    if (hTLV !== null) {
+3884 		this.hTLV = hTLV;
+3885 		return this.hTLV;
+3886 	    }
+3887 	}
+3888 
+3889         if (this.nameAlg !== null && this.asn1Alg === null) {
+3890             this.asn1Alg = _KJUR_asn1.x509.OID.name2obj(this.nameAlg);
+3891         }
+3892         var a = [this.asn1Alg];
+3893         if (this.asn1Params !== null) a.push(this.asn1Params);
+3894 
+3895         var o = new _KJUR_asn1.DERSequence({'array': a});
+3896         this.hTLV = o.tohex();
+3897         return this.hTLV;
+3898     };
+3899     this.getEncodedHex = function() { return this.tohex(); };
+3900 
+3901     if (params !== undefined) {
+3902         if (params.name !== undefined) {
+3903             this.nameAlg = params.name;
+3904         }
+3905         if (params.asn1params !== undefined) {
+3906             this.asn1Params = params.asn1params;
+3907         }
+3908         if (params.paramempty !== undefined) {
+3909             this.paramEmpty = params.paramempty;
+3910         }
+3911     }
+3912 
+3913     // set algorithm parameters will be ommitted for
+3914     // "*withDSA" or "*withECDSA" otherwise will be NULL.
+3915     if (this.asn1Params === null &&
+3916 	this.paramEmpty === false &&
+3917 	this.nameAlg !== null) {
+3918 
+3919 	if (this.nameAlg.name !== undefined) {
+3920 	    this.nameAlg = this.nameAlg.name;
+3921 	}
+3922 	var lcNameAlg = this.nameAlg.toLowerCase();
 3923 
-3924         var o = new _KJUR_asn1.DERSequence({'array': a});
-3925         this.hTLV = o.tohex();
-3926         return this.hTLV;
-3927     };
-3928     this.getEncodedHex = function() { return this.tohex(); };
-3929 
-3930     if (params !== undefined) {
-3931         if (params.name !== undefined) {
-3932             this.nameAlg = params.name;
-3933         }
-3934         if (params.asn1params !== undefined) {
-3935             this.asn1Params = params.asn1params;
-3936         }
-3937         if (params.paramempty !== undefined) {
-3938             this.paramEmpty = params.paramempty;
-3939         }
-3940     }
-3941 
-3942     // set algorithm parameters will be ommitted for
-3943     // "*withDSA" or "*withECDSA" otherwise will be NULL.
-3944     if (this.asn1Params === null &&
-3945 	this.paramEmpty === false &&
-3946 	this.nameAlg !== null) {
-3947 
-3948 	if (this.nameAlg.name !== undefined) {
-3949 	    this.nameAlg = this.nameAlg.name;
-3950 	}
-3951 	var lcNameAlg = this.nameAlg.toLowerCase();
-3952 
-3953 	if (lcNameAlg.substr(-7, 7) !== "withdsa" &&
-3954 	    lcNameAlg.substr(-9, 9) !== "withecdsa") {
-3955             this.asn1Params = new _KJUR_asn1.DERNull();
-3956 	}
-3957     }
-3958 };
-3959 extendClass(KJUR.asn1.x509.AlgorithmIdentifier, KJUR.asn1.ASN1Object);
-3960 
-3961 /**
-3962  * AlgorithmIdentifier ASN.1 TLV string associative array for RSA-PSS algorithm names
-3963  * @const
-3964  */
-3965 KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV = {
-3966     "SHAwithRSAandMGF1":
-3967     "300d06092a864886f70d01010a3000",
-3968     "SHA256withRSAandMGF1":
-3969     "303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",
-3970     "SHA384withRSAandMGF1":
-3971     "303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",
-3972     "SHA512withRSAandMGF1":
-3973     "303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"
-3974 };
-3975 
-3976 /**
-3977  * GeneralName ASN.1 structure class<br/>
-3978  * @name KJUR.asn1.x509.GeneralName
-3979  * @class GeneralName ASN.1 structure class
-3980  * @see KJUR.asn1.x509.OtherName
-3981  * @see KJUR.asn1.x509.X500Name
-3982  *
-3983  * @description
-3984  * <br/>
-3985  * As for argument 'params' for constructor, you can specify one of
-3986  * following properties:
-3987  * <ul>
-3988  * <li>rfc822 - rfc822Name[1] (ex. user1@foo.com)</li>
-3989  * <li>dns - dNSName[2] (ex. foo.com)</li>
-3990  * <li>uri - uniformResourceIdentifier[6] (ex. http://foo.com/)</li>
-3991  * <li>dn - directoryName[4] 
-3992  * distinguished name string or X500Name class parameters can be
-3993  * specified (ex. "/C=US/O=Test", {hex: '301c...')</li>
-3994  * <li>ldapdn - directoryName[4] (ex. O=Test,C=US)</li>
-3995  * <li>certissuer - directoryName[4] (PEM or hex string of cert)</li>
-3996  * <li>certsubj - directoryName[4] (PEM or hex string of cert)</li>
-3997  * <li>ip - iPAddress[7] (ex. 192.168.1.1, 2001:db3::43, 3faa0101...)</li>
-3998  * </ul>
-3999  * NOTE1: certissuer and certsubj were supported since asn1x509 1.0.10.<br/>
-4000  * NOTE2: dn and ldapdn were supported since jsrsasign 6.2.3 asn1x509 1.0.19.<br/>
-4001  * NOTE3: ip were supported since jsrsasign 8.0.10 asn1x509 1.1.4.<br/>
-4002  * NOTE4: X500Name parameters in dn were supported since jsrsasign 8.0.16.<br/>
-4003  * NOTE5: otherName is supported since jsrsasign 10.5.3.<br/>
-4004  *
-4005  * Here is definition of the ASN.1 syntax:
-4006  * <pre>
-4007  * -- NOTE: under the CHOICE, it will always be explicit.
-4008  * GeneralName ::= CHOICE {
-4009  *   otherName                  [0] OtherName,
-4010  *   rfc822Name                 [1] IA5String,
-4011  *   dNSName                    [2] IA5String,
-4012  *   x400Address                [3] ORAddress,
-4013  *   directoryName              [4] Name,
-4014  *   ediPartyName               [5] EDIPartyName,
-4015  *   uniformResourceIdentifier  [6] IA5String,
-4016  *   iPAddress                  [7] OCTET STRING,
-4017  *   registeredID               [8] OBJECT IDENTIFIER }
-4018  *
-4019  * OtherName ::= SEQUENCE {
-4020  *   type-id    OBJECT IDENTIFIER,
-4021  *   value      [0] EXPLICIT ANY DEFINED BY type-id }
-4022  * </pre>
-4023  *
-4024  * @example
-4025  * gn = new KJUR.asn1.x509.GeneralName({dn:     '/C=US/O=Test'});
-4026  * gn = new KJUR.asn1.x509.GeneralName({dn:     X500NameObject);
-4027  * gn = new KJUR.asn1.x509.GeneralName({dn:     {str: /C=US/O=Test'});
-4028  * gn = new KJUR.asn1.x509.GeneralName({dn:     {ldapstr: 'O=Test,C=US'});
-4029  * gn = new KJUR.asn1.x509.GeneralName({dn:     {hex: '301c...'});
-4030  * gn = new KJUR.asn1.x509.GeneralName({dn:     {certissuer: PEMCERTSTRING});
-4031  * gn = new KJUR.asn1.x509.GeneralName({dn:     {certsubject: PEMCERTSTRING});
-4032  * gn = new KJUR.asn1.x509.GeneralName({ip:     '192.168.1.1'});
-4033  * gn = new KJUR.asn1.x509.GeneralName({ip:     '2001:db4::4:1'});
-4034  * gn = new KJUR.asn1.x509.GeneralName({ip:     'c0a80101'});
-4035  * gn = new KJUR.asn1.x509.GeneralName({rfc822: 'test@aaa.com'});
-4036  * gn = new KJUR.asn1.x509.GeneralName({dns:    'aaa.com'});
-4037  * gn = new KJUR.asn1.x509.GeneralName({uri:    'http://aaa.com/'});
-4038  * gn = new KJUR.asn1.x509.GeneralName({other: {
-4039  *   oid: "1.2.3.4",
-4040  *   value: {utf8: "example"} // any ASN.1 which passed to ASN1Util.newObject
-4041  * }});
-4042  *
-4043  * gn = new KJUR.asn1.x509.GeneralName({ldapdn:     'O=Test,C=US'}); // DEPRECATED
-4044  * gn = new KJUR.asn1.x509.GeneralName({certissuer: certPEM});       // DEPRECATED
-4045  * gn = new KJUR.asn1.x509.GeneralName({certsubj:   certPEM});       // DEPRECATED
-4046  */
-4047 KJUR.asn1.x509.GeneralName = function(params) {
-4048     KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);
-4049 
-4050     var pTag = { rfc822: '81', dns: '82', dn: 'a4',  
-4051 		 uri: '86', ip: '87', otherName: 'a0'},
-4052 	_KJUR = KJUR,
-4053 	_KJUR_asn1 = _KJUR.asn1,
-4054 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-4055 	_X500Name = _KJUR_asn1_x509.X500Name,
-4056 	_OtherName = _KJUR_asn1_x509.OtherName,
-4057 	_DERIA5String = _KJUR_asn1.DERIA5String,
-4058 	_DERPrintableString = _KJUR_asn1.DERPrintableString,
-4059 	_DEROctetString = _KJUR_asn1.DEROctetString,
-4060 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
-4061 	_ASN1Object = _KJUR_asn1.ASN1Object,
-4062 	_Error = Error;
-4063 
-4064     this.params = null;
-4065 
-4066     this.setByParam = function(params) {
-4067 	this.params = params;
-4068     };
-4069 
-4070     this.tohex = function() {
-4071 	var params = this.params;
-4072 	var hTag, explicitFlag, dObj;
-4073 	var explicitFlag = false;
-4074 	if (params.other !== undefined) {
-4075 	    hTag = "a0",
-4076 	    dObj = new _OtherName(params.other);
-4077 	} else if (params.rfc822 !== undefined) {
-4078 	    hTag = "81";
-4079 	    dObj = new _DERIA5String({str: params.rfc822});
-4080 	} else if (params.dns !== undefined) {
-4081 	    hTag = "82";
-4082 	    dObj = new _DERIA5String({str: params.dns});
-4083 	} else if (params.dn !== undefined) {
-4084 	    hTag = "a4";
-4085 	    explicitFlag = true;
-4086 	    if (typeof params.dn === "string") {
-4087 		dObj = new _X500Name({str: params.dn});
-4088 	    } else if (params.dn instanceof KJUR.asn1.x509.X500Name) {
-4089 		dObj = params.dn;
-4090 	    } else {
-4091 		dObj = new _X500Name(params.dn);
-4092 	    }
-4093 	} else if (params.ldapdn !== undefined) {
-4094 	    hTag = "a4";
-4095 	    explicitFlag = true;
-4096 	    dObj = new _X500Name({ldapstr: params.ldapdn});
-4097 	} else if (params.certissuer !== undefined ||
-4098 		   params.certsubj !== undefined) {
-4099 	    hTag = "a4";
-4100 	    explicitFlag = true;
-4101 	    var isIssuer, certStr;
-4102 	    var certHex = null;
-4103 	    if (params.certsubj !== undefined) {
-4104 		isIssuer = false;
-4105 		certStr = params.certsubj;
-4106 	    } else {
-4107 		isIssuer = true;
-4108 		certStr = params.certissuer;
-4109 	    }
-4110 
-4111 	    if (certStr.match(/^[0-9A-Fa-f]+$/)) {
-4112 		certHex == certStr;
-4113             }
-4114 	    if (certStr.indexOf("-----BEGIN ") != -1) {
-4115 		certHex = pemtohex(certStr);
-4116 	    }
-4117 	    if (certHex == null) 
-4118 		throw new Error("certsubj/certissuer not cert");
-4119 
-4120 	    var x = new X509();
-4121 	    x.hex = certHex;
-4122 
-4123 	    var hDN;
-4124 	    if (isIssuer) {
-4125 		hDN = x.getIssuerHex();
-4126 	    } else {
-4127 		hDN = x.getSubjectHex();
-4128 	    }
-4129 	    dObj = new _ASN1Object();
-4130 	    dObj.hTLV = hDN;
-4131 	} else if (params.uri !== undefined) {
-4132 	    hTag = "86";
-4133 	    dObj = new _DERIA5String({str: params.uri});
-4134 	} else if (params.ip !== undefined) {
-4135 	    hTag = "87";
-4136 	    var hIP;
-4137 	    var ip = params.ip;
-4138 	    try {
-4139 		if (ip.match(/^[0-9a-f]+$/)) {
-4140 		    var len = ip.length;
-4141 		    if (len == 8 || len == 16 || len == 32 || len == 64) {
-4142 			hIP = ip;
-4143 		    } else {
-4144 			throw "err";
-4145 		    }
-4146 		} else {
-4147 		    hIP = iptohex(ip);
-4148 		}
-4149 	    } catch(ex) {
-4150 		throw new _Error("malformed IP address: " + params.ip + ":" + ex.message);
-4151 	    }
-4152 	    dObj = new _DEROctetString({hex: hIP});
-4153 	} else {
-4154 	    throw new _Error("improper params");
-4155 	}
+3924 	if (lcNameAlg.substr(-7, 7) !== "withdsa" &&
+3925 	    lcNameAlg.substr(-9, 9) !== "withecdsa") {
+3926             this.asn1Params = new _KJUR_asn1.DERNull();
+3927 	}
+3928     }
+3929 };
+3930 extendClass(KJUR.asn1.x509.AlgorithmIdentifier, KJUR.asn1.ASN1Object);
+3931 
+3932 /**
+3933  * AlgorithmIdentifier ASN.1 TLV string associative array for RSA-PSS algorithm names
+3934  * @const
+3935  */
+3936 KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV = {
+3937     "SHAwithRSAandMGF1":
+3938     "300d06092a864886f70d01010a3000",
+3939     "SHA256withRSAandMGF1":
+3940     "303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",
+3941     "SHA384withRSAandMGF1":
+3942     "303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",
+3943     "SHA512withRSAandMGF1":
+3944     "303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"
+3945 };
+3946 
+3947 /**
+3948  * GeneralName ASN.1 structure class<br/>
+3949  * @name KJUR.asn1.x509.GeneralName
+3950  * @class GeneralName ASN.1 structure class
+3951  * @see KJUR.asn1.x509.OtherName
+3952  * @see KJUR.asn1.x509.X500Name
+3953  *
+3954  * @description
+3955  * <br/>
+3956  * As for argument 'params' for constructor, you can specify one of
+3957  * following properties:
+3958  * <ul>
+3959  * <li>rfc822 - rfc822Name[1] (ex. user1@foo.com)</li>
+3960  * <li>dns - dNSName[2] (ex. foo.com)</li>
+3961  * <li>uri - uniformResourceIdentifier[6] (ex. http://foo.com/)</li>
+3962  * <li>dn - directoryName[4] 
+3963  * distinguished name string or X500Name class parameters can be
+3964  * specified (ex. "/C=US/O=Test", {hex: '301c...')</li>
+3965  * <li>ldapdn - directoryName[4] (ex. O=Test,C=US)</li>
+3966  * <li>certissuer - directoryName[4] (PEM or hex string of cert)</li>
+3967  * <li>certsubj - directoryName[4] (PEM or hex string of cert)</li>
+3968  * <li>ip - iPAddress[7] (ex. 192.168.1.1, 2001:db3::43, 3faa0101...)</li>
+3969  * </ul>
+3970  * NOTE1: certissuer and certsubj were supported since asn1x509 1.0.10.<br/>
+3971  * NOTE2: dn and ldapdn were supported since jsrsasign 6.2.3 asn1x509 1.0.19.<br/>
+3972  * NOTE3: ip were supported since jsrsasign 8.0.10 asn1x509 1.1.4.<br/>
+3973  * NOTE4: X500Name parameters in dn were supported since jsrsasign 8.0.16.<br/>
+3974  * NOTE5: otherName is supported since jsrsasign 10.5.3.<br/>
+3975  *
+3976  * Here is definition of the ASN.1 syntax:
+3977  * <pre>
+3978  * -- NOTE: under the CHOICE, it will always be explicit.
+3979  * GeneralName ::= CHOICE {
+3980  *   otherName                  [0] OtherName,
+3981  *   rfc822Name                 [1] IA5String,
+3982  *   dNSName                    [2] IA5String,
+3983  *   x400Address                [3] ORAddress,
+3984  *   directoryName              [4] Name,
+3985  *   ediPartyName               [5] EDIPartyName,
+3986  *   uniformResourceIdentifier  [6] IA5String,
+3987  *   iPAddress                  [7] OCTET STRING,
+3988  *   registeredID               [8] OBJECT IDENTIFIER }
+3989  *
+3990  * OtherName ::= SEQUENCE {
+3991  *   type-id    OBJECT IDENTIFIER,
+3992  *   value      [0] EXPLICIT ANY DEFINED BY type-id }
+3993  * </pre>
+3994  *
+3995  * @example
+3996  * gn = new KJUR.asn1.x509.GeneralName({dn:     '/C=US/O=Test'});
+3997  * gn = new KJUR.asn1.x509.GeneralName({dn:     X500NameObject);
+3998  * gn = new KJUR.asn1.x509.GeneralName({dn:     {str: /C=US/O=Test'});
+3999  * gn = new KJUR.asn1.x509.GeneralName({dn:     {ldapstr: 'O=Test,C=US'});
+4000  * gn = new KJUR.asn1.x509.GeneralName({dn:     {hex: '301c...'});
+4001  * gn = new KJUR.asn1.x509.GeneralName({dn:     {certissuer: PEMCERTSTRING});
+4002  * gn = new KJUR.asn1.x509.GeneralName({dn:     {certsubject: PEMCERTSTRING});
+4003  * gn = new KJUR.asn1.x509.GeneralName({ip:     '192.168.1.1'});
+4004  * gn = new KJUR.asn1.x509.GeneralName({ip:     '2001:db4::4:1'});
+4005  * gn = new KJUR.asn1.x509.GeneralName({ip:     'c0a80101'});
+4006  * gn = new KJUR.asn1.x509.GeneralName({rfc822: 'test@aaa.com'});
+4007  * gn = new KJUR.asn1.x509.GeneralName({dns:    'aaa.com'});
+4008  * gn = new KJUR.asn1.x509.GeneralName({uri:    'http://aaa.com/'});
+4009  * gn = new KJUR.asn1.x509.GeneralName({other: {
+4010  *   oid: "1.2.3.4",
+4011  *   value: {utf8: "example"} // any ASN.1 which passed to ASN1Util.newObject
+4012  * }});
+4013  *
+4014  * gn = new KJUR.asn1.x509.GeneralName({ldapdn:     'O=Test,C=US'}); // DEPRECATED
+4015  * gn = new KJUR.asn1.x509.GeneralName({certissuer: certPEM});       // DEPRECATED
+4016  * gn = new KJUR.asn1.x509.GeneralName({certsubj:   certPEM});       // DEPRECATED
+4017  */
+4018 KJUR.asn1.x509.GeneralName = function(params) {
+4019     KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);
+4020 
+4021     var pTag = { rfc822: '81', dns: '82', dn: 'a4',  
+4022 		 uri: '86', ip: '87', otherName: 'a0'},
+4023 	_KJUR = KJUR,
+4024 	_KJUR_asn1 = _KJUR.asn1,
+4025 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+4026 	_X500Name = _KJUR_asn1_x509.X500Name,
+4027 	_OtherName = _KJUR_asn1_x509.OtherName,
+4028 	_DERIA5String = _KJUR_asn1.DERIA5String,
+4029 	_DERPrintableString = _KJUR_asn1.DERPrintableString,
+4030 	_DEROctetString = _KJUR_asn1.DEROctetString,
+4031 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+4032 	_ASN1Object = _KJUR_asn1.ASN1Object,
+4033 	_Error = Error;
+4034 
+4035     this.params = null;
+4036 
+4037     this.setByParam = function(params) {
+4038 	this.params = params;
+4039     };
+4040 
+4041     this.tohex = function() {
+4042 	var params = this.params;
+4043 	var hTag, explicitFlag, dObj;
+4044 	var explicitFlag = false;
+4045 	if (params.other !== undefined) {
+4046 	    hTag = "a0",
+4047 	    dObj = new _OtherName(params.other);
+4048 	} else if (params.rfc822 !== undefined) {
+4049 	    hTag = "81";
+4050 	    dObj = new _DERIA5String({str: params.rfc822});
+4051 	} else if (params.dns !== undefined) {
+4052 	    hTag = "82";
+4053 	    dObj = new _DERIA5String({str: params.dns});
+4054 	} else if (params.dn !== undefined) {
+4055 	    hTag = "a4";
+4056 	    explicitFlag = true;
+4057 	    if (typeof params.dn === "string") {
+4058 		dObj = new _X500Name({str: params.dn});
+4059 	    } else if (params.dn instanceof KJUR.asn1.x509.X500Name) {
+4060 		dObj = params.dn;
+4061 	    } else {
+4062 		dObj = new _X500Name(params.dn);
+4063 	    }
+4064 	} else if (params.ldapdn !== undefined) {
+4065 	    hTag = "a4";
+4066 	    explicitFlag = true;
+4067 	    dObj = new _X500Name({ldapstr: params.ldapdn});
+4068 	} else if (params.certissuer !== undefined ||
+4069 		   params.certsubj !== undefined) {
+4070 	    hTag = "a4";
+4071 	    explicitFlag = true;
+4072 	    var isIssuer, certStr;
+4073 	    var certHex = null;
+4074 	    if (params.certsubj !== undefined) {
+4075 		isIssuer = false;
+4076 		certStr = params.certsubj;
+4077 	    } else {
+4078 		isIssuer = true;
+4079 		certStr = params.certissuer;
+4080 	    }
+4081 
+4082 	    if (certStr.match(/^[0-9A-Fa-f]+$/)) {
+4083 		certHex == certStr;
+4084             }
+4085 	    if (certStr.indexOf("-----BEGIN ") != -1) {
+4086 		certHex = pemtohex(certStr);
+4087 	    }
+4088 	    if (certHex == null) 
+4089 		throw new Error("certsubj/certissuer not cert");
+4090 
+4091 	    var x = new X509();
+4092 	    x.hex = certHex;
+4093 
+4094 	    var hDN;
+4095 	    if (isIssuer) {
+4096 		hDN = x.getIssuerHex();
+4097 	    } else {
+4098 		hDN = x.getSubjectHex();
+4099 	    }
+4100 	    dObj = new _ASN1Object();
+4101 	    dObj.hTLV = hDN;
+4102 	} else if (params.uri !== undefined) {
+4103 	    hTag = "86";
+4104 	    dObj = new _DERIA5String({str: params.uri});
+4105 	} else if (params.ip !== undefined) {
+4106 	    hTag = "87";
+4107 	    var hIP;
+4108 	    var ip = params.ip;
+4109 	    try {
+4110 		if (ip.match(/^[0-9a-f]+$/)) {
+4111 		    var len = ip.length;
+4112 		    if (len == 8 || len == 16 || len == 32 || len == 64) {
+4113 			hIP = ip;
+4114 		    } else {
+4115 			throw "err";
+4116 		    }
+4117 		} else {
+4118 		    hIP = iptohex(ip);
+4119 		}
+4120 	    } catch(ex) {
+4121 		throw new _Error("malformed IP address: " + params.ip + ":" + ex.message);
+4122 	    }
+4123 	    dObj = new _DEROctetString({hex: hIP});
+4124 	} else {
+4125 	    throw new _Error("improper params");
+4126 	}
+4127 
+4128 	var dTag = new _DERTaggedObject({tag: hTag,
+4129 					 explicit: explicitFlag,
+4130 					 obj: dObj});
+4131 	return dTag.tohex();
+4132     };
+4133     this.getEncodedHex = function() { return this.tohex(); };
+4134 
+4135     if (params !== undefined) this.setByParam(params);
+4136 };
+4137 extendClass(KJUR.asn1.x509.GeneralName, KJUR.asn1.ASN1Object);
+4138 
+4139 /**
+4140  * GeneralNames ASN.1 structure class<br/>
+4141  * @name KJUR.asn1.x509.GeneralNames
+4142  * @class GeneralNames ASN.1 structure class
+4143  * @description
+4144  * <br/>
+4145  * <h4>EXAMPLE AND ASN.1 SYNTAX</h4>
+4146  * @example
+4147  * gns = new KJUR.asn1.x509.GeneralNames([{'uri': 'http://aaa.com/'}, {'uri': 'http://bbb.com/'}]);
+4148  *
+4149  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
+4150  */
+4151 KJUR.asn1.x509.GeneralNames = function(paramsArray) {
+4152     KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);
+4153     var asn1Array = null,
+4154 	_KJUR = KJUR,
+4155 	_KJUR_asn1 = _KJUR.asn1;
 4156 
-4157 	var dTag = new _DERTaggedObject({tag: hTag,
-4158 					 explicit: explicitFlag,
-4159 					 obj: dObj});
-4160 	return dTag.tohex();
-4161     };
-4162     this.getEncodedHex = function() { return this.tohex(); };
-4163 
-4164     if (params !== undefined) this.setByParam(params);
-4165 };
-4166 extendClass(KJUR.asn1.x509.GeneralName, KJUR.asn1.ASN1Object);
-4167 
-4168 /**
-4169  * GeneralNames ASN.1 structure class<br/>
-4170  * @name KJUR.asn1.x509.GeneralNames
-4171  * @class GeneralNames ASN.1 structure class
-4172  * @description
-4173  * <br/>
-4174  * <h4>EXAMPLE AND ASN.1 SYNTAX</h4>
-4175  * @example
-4176  * gns = new KJUR.asn1.x509.GeneralNames([{'uri': 'http://aaa.com/'}, {'uri': 'http://bbb.com/'}]);
-4177  *
-4178  * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
-4179  */
-4180 KJUR.asn1.x509.GeneralNames = function(paramsArray) {
-4181     KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);
-4182     var asn1Array = null,
-4183 	_KJUR = KJUR,
-4184 	_KJUR_asn1 = _KJUR.asn1;
-4185 
-4186     /**
-4187      * set a array of {@link KJUR.asn1.x509.GeneralName} parameters<br/>
-4188      * @name setByParamArray
-4189      * @memberOf KJUR.asn1.x509.GeneralNames#
-4190      * @function
-4191      * @param {Array} paramsArray Array of {@link KJUR.asn1.x509.GeneralNames}
-4192      * @description
-4193      * <br/>
-4194      * <h4>EXAMPLES</h4>
-4195      * @example
-4196      * gns = new KJUR.asn1.x509.GeneralNames();
-4197      * gns.setByParamArray([{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]);
-4198      */
-4199     this.setByParamArray = function(paramsArray) {
-4200         for (var i = 0; i < paramsArray.length; i++) {
-4201             var o = new _KJUR_asn1.x509.GeneralName(paramsArray[i]);
-4202             this.asn1Array.push(o);
-4203         }
-4204     };
-4205 
-4206     this.tohex = function() {
-4207         var o = new _KJUR_asn1.DERSequence({'array': this.asn1Array});
-4208         return o.tohex();
-4209     };
-4210     this.getEncodedHex = function() { return this.tohex(); };
-4211 
-4212     this.asn1Array = new Array();
-4213     if (typeof paramsArray != "undefined") {
-4214         this.setByParamArray(paramsArray);
-4215     }
-4216 };
-4217 extendClass(KJUR.asn1.x509.GeneralNames, KJUR.asn1.ASN1Object);
-4218 
-4219 /**
-4220  * OtherName of GeneralName ASN.1 structure class<br/>
-4221  * @name KJUR.asn1.x509.OtherName
-4222  * @class OtherName ASN.1 structure class
-4223  * @since jsrsasign 10.5.3 asn1x509 2.1.12
-4224  * @see KJUR.asn1.x509.GeneralName
-4225  * @see KJUR.asn1.ASN1Util.newObject
-4226  *
-4227  * @description
-4228  * This class is for OtherName of GeneralName ASN.1 structure.
-4229  * Constructor has two members:
-4230  * <ul>
-4231  * <li>oid - oid string (ex. "1.2.3.4")</li>
-4232  * <li>value - associative array passed to ASN1Util.newObject</li>
-4233  * </ul>
-4234  *
-4235  * <pre>
-4236  * OtherName ::= SEQUENCE {
-4237  *   type-id    OBJECT IDENTIFIER,
-4238  *   value      [0] EXPLICIT ANY DEFINED BY type-id }
-4239  * </pre>
-4240  *
-4241  * @example
-4242  * new KJUR.asn1.x509.OtherName({
-4243  *   oid: "1.2.3.4",
-4244  *   value: {prnstr: {str: "abc"}}
-4245  * })
-4246  */
-4247 KJUR.asn1.x509.OtherName = function(params) {
-4248     KJUR.asn1.x509.OtherName.superclass.constructor.call(this);
-4249 
-4250     var asn1Obj = null,
-4251 	type = null,
-4252 	_KJUR = KJUR,
-4253 	_KJUR_asn1 = _KJUR.asn1,
-4254 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
-4255 	_DERSequence = _KJUR_asn1.DERSequence,
-4256 	_newObject = _KJUR_asn1.ASN1Util.newObject;
-4257 
-4258     this.params = null;
-4259 
-4260     this.setByParam = function(params) {
-4261 	this.params = params;
-4262     };
-4263 
-4264     this.tohex = function() {
-4265 	var params = this.params;
-4266 
-4267 	if (params.oid == undefined || params.value == undefined)
-4268 	    throw new Error("oid or value not specified");
-4269 
-4270 	var dOid = new _DERObjectIdentifier({oid: params.oid});
-4271 	var dValue = _newObject({tag: {tag: "a0",
-4272 				       explicit: true,
-4273 				       obj: params.value}});
-4274 	var dSeq = new _DERSequence({array: [dOid, dValue]});
-4275 
-4276         return dSeq.tohex();
-4277     };
-4278     this.getEncodedHex = function() { return this.tohex(); };
-4279 
-4280     if (params !== undefined) this.setByParam(params);
-4281 };
-4282 extendClass(KJUR.asn1.x509.OtherName, KJUR.asn1.ASN1Object);
-4283 
-4284 /**
-4285  * static object for OID
-4286  * @name KJUR.asn1.x509.OID
-4287  * @class static object for OID
-4288  * @property {Assoc Array} atype2oidList for short attribute type name and oid (ex. 'C' and '2.5.4.6')
-4289  * @property {Assoc Array} name2oidList for oid name and oid (ex. 'keyUsage' and '2.5.29.15')
-4290  * @property {Assoc Array} objCache for caching name and DERObjectIdentifier object
-4291  *
-4292  * @description
-4293  * This class defines OID name and values.
-4294  * AttributeType names registered in OID.atype2oidList are following:
-4295  * <table style="border-width: thin; border-style: solid; witdh: 100%">
-4296  * <tr><th>short</th><th>long</th><th>OID</th></tr>
-4297  * <tr><td>CN</td>commonName<td></td><td>2.5.4.3</td></tr>
-4298  * <tr><td>L</td><td>localityName</td><td>2.5.4.7</td></tr>
-4299  * <tr><td>ST</td><td>stateOrProvinceName</td><td>2.5.4.8</td></tr>
-4300  * <tr><td>O</td><td>organizationName</td><td>2.5.4.10</td></tr>
-4301  * <tr><td>OU</td><td>organizationalUnitName</td><td>2.5.4.11</td></tr>
-4302  * <tr><td>C</td><td></td>countryName<td>2.5.4.6</td></tr>
-4303  * <tr><td>STREET</td>streetAddress<td></td><td>2.5.4.6</td></tr>
-4304  * <tr><td>DC</td><td>domainComponent</td><td>0.9.2342.19200300.100.1.25</td></tr>
-4305  * <tr><td>UID</td><td>userId</td><td>0.9.2342.19200300.100.1.1</td></tr>
-4306  * <tr><td>SN</td><td>surname</td><td>2.5.4.4</td></tr>
-4307  * <tr><td>DN</td><td>distinguishedName</td><td>2.5.4.49</td></tr>
-4308  * <tr><td>E</td><td>emailAddress</td><td>1.2.840.113549.1.9.1</td></tr>
-4309  * <tr><td></td><td>businessCategory</td><td>2.5.4.15</td></tr>
-4310  * <tr><td></td><td>postalCode</td><td>2.5.4.17</td></tr>
-4311  * <tr><td></td><td>jurisdictionOfIncorporationL</td><td>1.3.6.1.4.1.311.60.2.1.1</td></tr>
-4312  * <tr><td></td><td>jurisdictionOfIncorporationSP</td><td>1.3.6.1.4.1.311.60.2.1.2</td></tr>
-4313  * <tr><td></td><td>jurisdictionOfIncorporationC</td><td>1.3.6.1.4.1.311.60.2.1.3</td></tr>
-4314  * </table>
-4315  *
-4316  * @example
-4317  */
-4318 KJUR.asn1.x509.OID = new function() {
-4319     var _DERObjectIdentifier = KJUR.asn1.DERObjectIdentifier;
-4320 
-4321     this.name2oidList = {
-4322         'sha1':                 '1.3.14.3.2.26',
-4323         'sha256':               '2.16.840.1.101.3.4.2.1',
-4324         'sha384':               '2.16.840.1.101.3.4.2.2',
-4325         'sha512':               '2.16.840.1.101.3.4.2.3',
-4326         'sha224':               '2.16.840.1.101.3.4.2.4',
-4327         'md5':                  '1.2.840.113549.2.5',
-4328         'md2':                  '1.3.14.7.2.2.1',
-4329         'ripemd160':            '1.3.36.3.2.1',
-4330 
-4331         'MD2withRSA':           '1.2.840.113549.1.1.2',
-4332         'MD4withRSA':           '1.2.840.113549.1.1.3',
-4333         'MD5withRSA':           '1.2.840.113549.1.1.4',
-4334         'SHA1withRSA':          '1.2.840.113549.1.1.5',
-4335 	'pkcs1-MGF':		'1.2.840.113549.1.1.8',
-4336 	'rsaPSS':		'1.2.840.113549.1.1.10',
-4337         'SHA224withRSA':        '1.2.840.113549.1.1.14',
-4338         'SHA256withRSA':        '1.2.840.113549.1.1.11',
-4339         'SHA384withRSA':        '1.2.840.113549.1.1.12',
-4340         'SHA512withRSA':        '1.2.840.113549.1.1.13',
-4341 
-4342         'SHA1withECDSA':        '1.2.840.10045.4.1',
-4343         'SHA224withECDSA':      '1.2.840.10045.4.3.1',
-4344         'SHA256withECDSA':      '1.2.840.10045.4.3.2',
-4345         'SHA384withECDSA':      '1.2.840.10045.4.3.3',
-4346         'SHA512withECDSA':      '1.2.840.10045.4.3.4',
-4347 
-4348         'dsa':                  '1.2.840.10040.4.1',
-4349         'SHA1withDSA':          '1.2.840.10040.4.3',
-4350         'SHA224withDSA':        '2.16.840.1.101.3.4.3.1',
-4351         'SHA256withDSA':        '2.16.840.1.101.3.4.3.2',
-4352 
-4353         'rsaEncryption':        '1.2.840.113549.1.1.1',
-4354 
-4355 	// X.500 AttributeType defined in RFC 4514
-4356         'commonName':			'2.5.4.3',
-4357         'countryName':			'2.5.4.6',
-4358         'localityName':			'2.5.4.7',
-4359         'stateOrProvinceName':		'2.5.4.8',
-4360         'streetAddress':		'2.5.4.9',
-4361         'organizationName':		'2.5.4.10',
-4362         'organizationalUnitName':	'2.5.4.11',
-4363         'domainComponent':		'0.9.2342.19200300.100.1.25',
-4364         'userId':			'0.9.2342.19200300.100.1.1',
-4365 	// other AttributeType name string
-4366 	'surname':			'2.5.4.4',
-4367         'givenName':                    '2.5.4.42',
-4368         'title':			'2.5.4.12',
-4369 	'distinguishedName':		'2.5.4.49',
-4370 	'emailAddress':			'1.2.840.113549.1.9.1',
-4371 	// other AttributeType name string (no short name)
-4372 	'description':			'2.5.4.13',
-4373 	'businessCategory':		'2.5.4.15',
-4374 	'postalCode':			'2.5.4.17',
-4375 	'uniqueIdentifier':		'2.5.4.45',
-4376 	'organizationIdentifier':	'2.5.4.97',
-4377 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
-4378 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
-4379 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3',
-4380 
-4381         'subjectDirectoryAttributes': '2.5.29.9',
-4382         'subjectKeyIdentifier': '2.5.29.14',
-4383         'keyUsage':             '2.5.29.15',
-4384         'subjectAltName':       '2.5.29.17',
-4385         'issuerAltName':        '2.5.29.18',
-4386         'basicConstraints':     '2.5.29.19',
-4387         'cRLNumber':     	'2.5.29.20',
-4388         'cRLReason':     	'2.5.29.21',
-4389         'nameConstraints':      '2.5.29.30',
-4390         'cRLDistributionPoints':'2.5.29.31',
-4391         'certificatePolicies':  '2.5.29.32',
-4392         'anyPolicy':  		'2.5.29.32.0',
-4393         'authorityKeyIdentifier':'2.5.29.35',
-4394         'policyConstraints':    '2.5.29.36',
-4395         'extKeyUsage':          '2.5.29.37',
-4396         'authorityInfoAccess':  '1.3.6.1.5.5.7.1.1',
-4397         'ocsp':                 '1.3.6.1.5.5.7.48.1',
-4398         'ocspBasic':            '1.3.6.1.5.5.7.48.1.1',
-4399         'ocspNonce':            '1.3.6.1.5.5.7.48.1.2',
-4400         'ocspNoCheck':          '1.3.6.1.5.5.7.48.1.5',
-4401         'caIssuers':            '1.3.6.1.5.5.7.48.2',
-4402 
-4403         'anyExtendedKeyUsage':  '2.5.29.37.0',
-4404         'serverAuth':           '1.3.6.1.5.5.7.3.1',
-4405         'clientAuth':           '1.3.6.1.5.5.7.3.2',
-4406         'codeSigning':          '1.3.6.1.5.5.7.3.3',
-4407         'emailProtection':      '1.3.6.1.5.5.7.3.4',
-4408         'timeStamping':         '1.3.6.1.5.5.7.3.8',
-4409         'ocspSigning':          '1.3.6.1.5.5.7.3.9',
-4410 
-4411         'dateOfBirth':          '1.3.6.1.5.5.7.9.1',
-4412         'placeOfBirth':         '1.3.6.1.5.5.7.9.2',
-4413         'gender':               '1.3.6.1.5.5.7.9.3',
-4414         'countryOfCitizenship': '1.3.6.1.5.5.7.9.4',
-4415         'countryOfResidence':   '1.3.6.1.5.5.7.9.5',
-4416 
-4417         'ecPublicKey':          '1.2.840.10045.2.1',
-4418         'P-256':                '1.2.840.10045.3.1.7',
-4419         'secp256r1':            '1.2.840.10045.3.1.7',
-4420         'secp256k1':            '1.3.132.0.10',
-4421         'secp384r1':            '1.3.132.0.34',
-4422         'secp521r1':            '1.3.132.0.35',
-4423 
-4424         'pkcs5PBES2':           '1.2.840.113549.1.5.13',
-4425         'pkcs5PBKDF2':          '1.2.840.113549.1.5.12',
-4426 
-4427         'des-EDE3-CBC':         '1.2.840.113549.3.7',
-4428 
-4429         'data':                 '1.2.840.113549.1.7.1', // CMS data
-4430         'signed-data':          '1.2.840.113549.1.7.2', // CMS signed-data
-4431         'enveloped-data':       '1.2.840.113549.1.7.3', // CMS enveloped-data
-4432         'digested-data':        '1.2.840.113549.1.7.5', // CMS digested-data
-4433         'encrypted-data':       '1.2.840.113549.1.7.6', // CMS encrypted-data
-4434         'authenticated-data':   '1.2.840.113549.1.9.16.1.2', // CMS authenticated-data
-4435         'tstinfo':              '1.2.840.113549.1.9.16.1.4', // RFC3161 TSTInfo
-4436 	'signingCertificate':	'1.2.840.113549.1.9.16.2.12',// SMIME
-4437 	'timeStampToken':	'1.2.840.113549.1.9.16.2.14',// sigTS
-4438 	'signaturePolicyIdentifier':	'1.2.840.113549.1.9.16.2.15',// cades
-4439 	'etsArchiveTimeStamp':	'1.2.840.113549.1.9.16.2.27',// SMIME
-4440 	'signingCertificateV2':	'1.2.840.113549.1.9.16.2.47',// SMIME
-4441 	'etsArchiveTimeStampV2':'1.2.840.113549.1.9.16.2.48',// SMIME
-4442         'extensionRequest':     '1.2.840.113549.1.9.14',// CSR extensionRequest
-4443 	'contentType':		'1.2.840.113549.1.9.3',//PKCS#9
-4444 	'messageDigest':	'1.2.840.113549.1.9.4',//PKCS#9
-4445 	'signingTime':		'1.2.840.113549.1.9.5',//PKCS#9
-4446 	'counterSignature':	'1.2.840.113549.1.9.6',//PKCS#9
-4447 	'archiveTimeStampV3':	'0.4.0.1733.2.4',//ETSI EN29319122/TS101733
-4448 	'pdfRevocationInfoArchival':'1.2.840.113583.1.1.8', //Adobe
-4449 	'adobeTimeStamp':	'1.2.840.113583.1.1.9.1', // Adobe
+4157     /**
+4158      * set a array of {@link KJUR.asn1.x509.GeneralName} parameters<br/>
+4159      * @name setByParamArray
+4160      * @memberOf KJUR.asn1.x509.GeneralNames#
+4161      * @function
+4162      * @param {Array} paramsArray Array of {@link KJUR.asn1.x509.GeneralNames}
+4163      * @description
+4164      * <br/>
+4165      * <h4>EXAMPLES</h4>
+4166      * @example
+4167      * gns = new KJUR.asn1.x509.GeneralNames();
+4168      * gns.setByParamArray([{uri: 'http://aaa.com/'}, {uri: 'http://bbb.com/'}]);
+4169      */
+4170     this.setByParamArray = function(paramsArray) {
+4171         for (var i = 0; i < paramsArray.length; i++) {
+4172             var o = new _KJUR_asn1.x509.GeneralName(paramsArray[i]);
+4173             this.asn1Array.push(o);
+4174         }
+4175     };
+4176 
+4177     this.tohex = function() {
+4178         var o = new _KJUR_asn1.DERSequence({'array': this.asn1Array});
+4179         return o.tohex();
+4180     };
+4181     this.getEncodedHex = function() { return this.tohex(); };
+4182 
+4183     this.asn1Array = new Array();
+4184     if (typeof paramsArray != "undefined") {
+4185         this.setByParamArray(paramsArray);
+4186     }
+4187 };
+4188 extendClass(KJUR.asn1.x509.GeneralNames, KJUR.asn1.ASN1Object);
+4189 
+4190 /**
+4191  * OtherName of GeneralName ASN.1 structure class<br/>
+4192  * @name KJUR.asn1.x509.OtherName
+4193  * @class OtherName ASN.1 structure class
+4194  * @since jsrsasign 10.5.3 asn1x509 2.1.12
+4195  * @see KJUR.asn1.x509.GeneralName
+4196  * @see KJUR.asn1.ASN1Util.newObject
+4197  *
+4198  * @description
+4199  * This class is for OtherName of GeneralName ASN.1 structure.
+4200  * Constructor has two members:
+4201  * <ul>
+4202  * <li>oid - oid string (ex. "1.2.3.4")</li>
+4203  * <li>value - associative array passed to ASN1Util.newObject</li>
+4204  * </ul>
+4205  *
+4206  * <pre>
+4207  * OtherName ::= SEQUENCE {
+4208  *   type-id    OBJECT IDENTIFIER,
+4209  *   value      [0] EXPLICIT ANY DEFINED BY type-id }
+4210  * </pre>
+4211  *
+4212  * @example
+4213  * new KJUR.asn1.x509.OtherName({
+4214  *   oid: "1.2.3.4",
+4215  *   value: {prnstr: {str: "abc"}}
+4216  * })
+4217  */
+4218 KJUR.asn1.x509.OtherName = function(params) {
+4219     KJUR.asn1.x509.OtherName.superclass.constructor.call(this);
+4220 
+4221     var asn1Obj = null,
+4222 	type = null,
+4223 	_KJUR = KJUR,
+4224 	_KJUR_asn1 = _KJUR.asn1,
+4225 	_DERObjectIdentifier = _KJUR_asn1.DERObjectIdentifier,
+4226 	_DERSequence = _KJUR_asn1.DERSequence,
+4227 	_newObject = _KJUR_asn1.ASN1Util.newObject;
+4228 
+4229     this.params = null;
+4230 
+4231     this.setByParam = function(params) {
+4232 	this.params = params;
+4233     };
+4234 
+4235     this.tohex = function() {
+4236 	var params = this.params;
+4237 
+4238 	if (params.oid == undefined || params.value == undefined)
+4239 	    throw new Error("oid or value not specified");
+4240 
+4241 	var dOid = new _DERObjectIdentifier({oid: params.oid});
+4242 	var dValue = _newObject({tag: {tag: "a0",
+4243 				       explicit: true,
+4244 				       obj: params.value}});
+4245 	var dSeq = new _DERSequence({array: [dOid, dValue]});
+4246 
+4247         return dSeq.tohex();
+4248     };
+4249     this.getEncodedHex = function() { return this.tohex(); };
+4250 
+4251     if (params !== undefined) this.setByParam(params);
+4252 };
+4253 extendClass(KJUR.asn1.x509.OtherName, KJUR.asn1.ASN1Object);
+4254 
+4255 /**
+4256  * static object for OID
+4257  * @name KJUR.asn1.x509.OID
+4258  * @class static object for OID
+4259  * @property {Assoc Array} atype2oidList for short attribute type name and oid (ex. 'C' and '2.5.4.6')
+4260  * @property {Assoc Array} name2oidList for oid name and oid (ex. 'keyUsage' and '2.5.29.15')
+4261  * @property {Assoc Array} objCache for caching name and DERObjectIdentifier object
+4262  *
+4263  * @description
+4264  * This class defines OID name and values.
+4265  * AttributeType names registered in OID.atype2oidList are following:
+4266  * <table style="border-width: thin; border-style: solid; witdh: 100%">
+4267  * <tr><th>short</th><th>long</th><th>OID</th></tr>
+4268  * <tr><td>CN</td>commonName<td></td><td>2.5.4.3</td></tr>
+4269  * <tr><td>L</td><td>localityName</td><td>2.5.4.7</td></tr>
+4270  * <tr><td>ST</td><td>stateOrProvinceName</td><td>2.5.4.8</td></tr>
+4271  * <tr><td>O</td><td>organizationName</td><td>2.5.4.10</td></tr>
+4272  * <tr><td>OU</td><td>organizationalUnitName</td><td>2.5.4.11</td></tr>
+4273  * <tr><td>C</td><td></td>countryName<td>2.5.4.6</td></tr>
+4274  * <tr><td>STREET</td>streetAddress<td></td><td>2.5.4.6</td></tr>
+4275  * <tr><td>DC</td><td>domainComponent</td><td>0.9.2342.19200300.100.1.25</td></tr>
+4276  * <tr><td>UID</td><td>userId</td><td>0.9.2342.19200300.100.1.1</td></tr>
+4277  * <tr><td>SN</td><td>surname</td><td>2.5.4.4</td></tr>
+4278  * <tr><td>DN</td><td>distinguishedName</td><td>2.5.4.49</td></tr>
+4279  * <tr><td>E</td><td>emailAddress</td><td>1.2.840.113549.1.9.1</td></tr>
+4280  * <tr><td></td><td>businessCategory</td><td>2.5.4.15</td></tr>
+4281  * <tr><td></td><td>postalCode</td><td>2.5.4.17</td></tr>
+4282  * <tr><td></td><td>jurisdictionOfIncorporationL</td><td>1.3.6.1.4.1.311.60.2.1.1</td></tr>
+4283  * <tr><td></td><td>jurisdictionOfIncorporationSP</td><td>1.3.6.1.4.1.311.60.2.1.2</td></tr>
+4284  * <tr><td></td><td>jurisdictionOfIncorporationC</td><td>1.3.6.1.4.1.311.60.2.1.3</td></tr>
+4285  * </table>
+4286  *
+4287  * @example
+4288  */
+4289 KJUR.asn1.x509.OID = new function() {
+4290     var _DERObjectIdentifier = KJUR.asn1.DERObjectIdentifier;
+4291 
+4292     this.name2oidList = {
+4293         'sha1':                 '1.3.14.3.2.26',
+4294         'sha256':               '2.16.840.1.101.3.4.2.1',
+4295         'sha384':               '2.16.840.1.101.3.4.2.2',
+4296         'sha512':               '2.16.840.1.101.3.4.2.3',
+4297         'sha224':               '2.16.840.1.101.3.4.2.4',
+4298         'md5':                  '1.2.840.113549.2.5',
+4299         'md2':                  '1.3.14.7.2.2.1',
+4300         'ripemd160':            '1.3.36.3.2.1',
+4301 
+4302         'MD2withRSA':           '1.2.840.113549.1.1.2',
+4303         'MD4withRSA':           '1.2.840.113549.1.1.3',
+4304         'MD5withRSA':           '1.2.840.113549.1.1.4',
+4305         'SHA1withRSA':          '1.2.840.113549.1.1.5',
+4306 	'pkcs1-MGF':		'1.2.840.113549.1.1.8',
+4307 	'rsaPSS':		'1.2.840.113549.1.1.10',
+4308         'SHA224withRSA':        '1.2.840.113549.1.1.14',
+4309         'SHA256withRSA':        '1.2.840.113549.1.1.11',
+4310         'SHA384withRSA':        '1.2.840.113549.1.1.12',
+4311         'SHA512withRSA':        '1.2.840.113549.1.1.13',
+4312 
+4313         'SHA1withECDSA':        '1.2.840.10045.4.1',
+4314         'SHA224withECDSA':      '1.2.840.10045.4.3.1',
+4315         'SHA256withECDSA':      '1.2.840.10045.4.3.2',
+4316         'SHA384withECDSA':      '1.2.840.10045.4.3.3',
+4317         'SHA512withECDSA':      '1.2.840.10045.4.3.4',
+4318 
+4319         'dsa':                  '1.2.840.10040.4.1',
+4320         'SHA1withDSA':          '1.2.840.10040.4.3',
+4321         'SHA224withDSA':        '2.16.840.1.101.3.4.3.1',
+4322         'SHA256withDSA':        '2.16.840.1.101.3.4.3.2',
+4323 
+4324         'rsaEncryption':        '1.2.840.113549.1.1.1',
+4325 
+4326 	// X.500 AttributeType defined in RFC 4514
+4327         'commonName':			'2.5.4.3',
+4328         'countryName':			'2.5.4.6',
+4329         'localityName':			'2.5.4.7',
+4330         'stateOrProvinceName':		'2.5.4.8',
+4331         'streetAddress':		'2.5.4.9',
+4332         'organizationName':		'2.5.4.10',
+4333         'organizationalUnitName':	'2.5.4.11',
+4334         'domainComponent':		'0.9.2342.19200300.100.1.25',
+4335         'userId':			'0.9.2342.19200300.100.1.1',
+4336 	// other AttributeType name string
+4337 	'surname':			'2.5.4.4',
+4338         'givenName':                    '2.5.4.42',
+4339         'title':			'2.5.4.12',
+4340 	'distinguishedName':		'2.5.4.49',
+4341 	'emailAddress':			'1.2.840.113549.1.9.1',
+4342 	// other AttributeType name string (no short name)
+4343 	'description':			'2.5.4.13',
+4344 	'businessCategory':		'2.5.4.15',
+4345 	'postalCode':			'2.5.4.17',
+4346 	'uniqueIdentifier':		'2.5.4.45',
+4347 	'organizationIdentifier':	'2.5.4.97',
+4348 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
+4349 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
+4350 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3',
+4351 
+4352         'subjectDirectoryAttributes': '2.5.29.9',
+4353         'subjectKeyIdentifier': '2.5.29.14',
+4354         'keyUsage':             '2.5.29.15',
+4355         'subjectAltName':       '2.5.29.17',
+4356         'issuerAltName':        '2.5.29.18',
+4357         'basicConstraints':     '2.5.29.19',
+4358         'cRLNumber':     	'2.5.29.20',
+4359         'cRLReason':     	'2.5.29.21',
+4360         'nameConstraints':      '2.5.29.30',
+4361         'cRLDistributionPoints':'2.5.29.31',
+4362         'certificatePolicies':  '2.5.29.32',
+4363         'anyPolicy':  		'2.5.29.32.0',
+4364         'authorityKeyIdentifier':'2.5.29.35',
+4365         'policyConstraints':    '2.5.29.36',
+4366         'extKeyUsage':          '2.5.29.37',
+4367         'authorityInfoAccess':  '1.3.6.1.5.5.7.1.1',
+4368         'ocsp':                 '1.3.6.1.5.5.7.48.1',
+4369         'ocspBasic':            '1.3.6.1.5.5.7.48.1.1',
+4370         'ocspNonce':            '1.3.6.1.5.5.7.48.1.2',
+4371         'ocspNoCheck':          '1.3.6.1.5.5.7.48.1.5',
+4372         'caIssuers':            '1.3.6.1.5.5.7.48.2',
+4373 
+4374         'anyExtendedKeyUsage':  '2.5.29.37.0',
+4375         'serverAuth':           '1.3.6.1.5.5.7.3.1',
+4376         'clientAuth':           '1.3.6.1.5.5.7.3.2',
+4377         'codeSigning':          '1.3.6.1.5.5.7.3.3',
+4378         'emailProtection':      '1.3.6.1.5.5.7.3.4',
+4379         'timeStamping':         '1.3.6.1.5.5.7.3.8',
+4380         'ocspSigning':          '1.3.6.1.5.5.7.3.9',
+4381 
+4382         'dateOfBirth':          '1.3.6.1.5.5.7.9.1',
+4383         'placeOfBirth':         '1.3.6.1.5.5.7.9.2',
+4384         'gender':               '1.3.6.1.5.5.7.9.3',
+4385         'countryOfCitizenship': '1.3.6.1.5.5.7.9.4',
+4386         'countryOfResidence':   '1.3.6.1.5.5.7.9.5',
+4387 
+4388         'ecPublicKey':          '1.2.840.10045.2.1',
+4389         'P-256':                '1.2.840.10045.3.1.7',
+4390         'secp256r1':            '1.2.840.10045.3.1.7',
+4391         'secp256k1':            '1.3.132.0.10',
+4392         'secp384r1':            '1.3.132.0.34',
+4393         'secp521r1':            '1.3.132.0.35',
+4394 
+4395         'pkcs5PBES2':           '1.2.840.113549.1.5.13',
+4396         'pkcs5PBKDF2':          '1.2.840.113549.1.5.12',
+4397 
+4398         'des-EDE3-CBC':         '1.2.840.113549.3.7',
+4399 
+4400         'data':                 '1.2.840.113549.1.7.1', // CMS data
+4401         'signed-data':          '1.2.840.113549.1.7.2', // CMS signed-data
+4402         'enveloped-data':       '1.2.840.113549.1.7.3', // CMS enveloped-data
+4403         'digested-data':        '1.2.840.113549.1.7.5', // CMS digested-data
+4404         'encrypted-data':       '1.2.840.113549.1.7.6', // CMS encrypted-data
+4405         'authenticated-data':   '1.2.840.113549.1.9.16.1.2', // CMS authenticated-data
+4406         'tstinfo':              '1.2.840.113549.1.9.16.1.4', // RFC3161 TSTInfo
+4407 	'signingCertificate':	'1.2.840.113549.1.9.16.2.12',// SMIME
+4408 	'timeStampToken':	'1.2.840.113549.1.9.16.2.14',// sigTS
+4409 	'signaturePolicyIdentifier':	'1.2.840.113549.1.9.16.2.15',// cades
+4410 	'etsArchiveTimeStamp':	'1.2.840.113549.1.9.16.2.27',// SMIME
+4411 	'signingCertificateV2':	'1.2.840.113549.1.9.16.2.47',// SMIME
+4412 	'etsArchiveTimeStampV2':'1.2.840.113549.1.9.16.2.48',// SMIME
+4413         'extensionRequest':     '1.2.840.113549.1.9.14',// CSR extensionRequest
+4414 	'contentType':		'1.2.840.113549.1.9.3',//PKCS#9
+4415 	'messageDigest':	'1.2.840.113549.1.9.4',//PKCS#9
+4416 	'signingTime':		'1.2.840.113549.1.9.5',//PKCS#9
+4417 	'counterSignature':	'1.2.840.113549.1.9.6',//PKCS#9
+4418 	'archiveTimeStampV3':	'0.4.0.1733.2.4',//ETSI EN29319122/TS101733
+4419 	'pdfRevocationInfoArchival':'1.2.840.113583.1.1.8', //Adobe
+4420 	'adobeTimeStamp':	'1.2.840.113583.1.1.9.1', // Adobe
+4421     };
+4422 
+4423     this.atype2oidList = {
+4424 	// RFC 4514 AttributeType name string (MUST recognized)
+4425         'CN':		'2.5.4.3',
+4426         'L':		'2.5.4.7',
+4427         'ST':		'2.5.4.8',
+4428         'O':		'2.5.4.10',
+4429         'OU':		'2.5.4.11',
+4430         'C':		'2.5.4.6',
+4431         'STREET':	'2.5.4.9',
+4432         'DC':		'0.9.2342.19200300.100.1.25',
+4433         'UID':		'0.9.2342.19200300.100.1.1',
+4434 	// other AttributeType name string
+4435 	// http://blog.livedoor.jp/k_urushima/archives/656114.html
+4436         'SN':		'2.5.4.4', // surname
+4437         'T':		'2.5.4.12', // title
+4438         'DN':		'2.5.4.49', // distinguishedName
+4439         'E':		'1.2.840.113549.1.9.1', // emailAddress in MS.NET or Bouncy
+4440 	// other AttributeType name string (no short name)
+4441 	'description':			'2.5.4.13',
+4442 	'businessCategory':		'2.5.4.15',
+4443 	'postalCode':			'2.5.4.17',
+4444 	'serialNumber':			'2.5.4.5',
+4445 	'uniqueIdentifier':		'2.5.4.45',
+4446 	'organizationIdentifier':	'2.5.4.97',
+4447 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
+4448 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
+4449 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3'
 4450     };
-4451 
-4452     this.atype2oidList = {
-4453 	// RFC 4514 AttributeType name string (MUST recognized)
-4454         'CN':		'2.5.4.3',
-4455         'L':		'2.5.4.7',
-4456         'ST':		'2.5.4.8',
-4457         'O':		'2.5.4.10',
-4458         'OU':		'2.5.4.11',
-4459         'C':		'2.5.4.6',
-4460         'STREET':	'2.5.4.9',
-4461         'DC':		'0.9.2342.19200300.100.1.25',
-4462         'UID':		'0.9.2342.19200300.100.1.1',
-4463 	// other AttributeType name string
-4464 	// http://blog.livedoor.jp/k_urushima/archives/656114.html
-4465         'SN':		'2.5.4.4', // surname
-4466         'T':		'2.5.4.12', // title
-4467         'DN':		'2.5.4.49', // distinguishedName
-4468         'E':		'1.2.840.113549.1.9.1', // emailAddress in MS.NET or Bouncy
-4469 	// other AttributeType name string (no short name)
-4470 	'description':			'2.5.4.13',
-4471 	'businessCategory':		'2.5.4.15',
-4472 	'postalCode':			'2.5.4.17',
-4473 	'serialNumber':			'2.5.4.5',
-4474 	'uniqueIdentifier':		'2.5.4.45',
-4475 	'organizationIdentifier':	'2.5.4.97',
-4476 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
-4477 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
-4478 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3'
+4451     
+4452     this.objCache = {};
+4453 
+4454     /**
+4455      * get DERObjectIdentifier by registered OID name
+4456      * @name name2obj
+4457      * @memberOf KJUR.asn1.x509.OID
+4458      * @function
+4459      * @param {String} name OID
+4460      * @return {Object} DERObjectIdentifier instance
+4461      * @see KJUR.asn1.DERObjectIdentifier
+4462      *
+4463      * @description
+4464      * This static method returns DERObjectIdentifier object
+4465      * for the specified OID.
+4466      *
+4467      * @example
+4468      * var asn1ObjOID = KJUR.asn1.x509.OID.name2obj('SHA1withRSA');
+4469      */
+4470     this.name2obj = function(name) {
+4471         if (typeof this.objCache[name] != "undefined")
+4472             return this.objCache[name];
+4473         if (typeof this.name2oidList[name] == "undefined")
+4474             throw "Name of ObjectIdentifier not defined: " + name;
+4475         var oid = this.name2oidList[name];
+4476         var obj = new _DERObjectIdentifier({'oid': oid});
+4477         this.objCache[name] = obj;
+4478         return obj;
 4479     };
-4480     
-4481     this.objCache = {};
-4482 
-4483     /**
-4484      * get DERObjectIdentifier by registered OID name
-4485      * @name name2obj
-4486      * @memberOf KJUR.asn1.x509.OID
-4487      * @function
-4488      * @param {String} name OID
-4489      * @return {Object} DERObjectIdentifier instance
-4490      * @see KJUR.asn1.DERObjectIdentifier
-4491      *
-4492      * @description
-4493      * This static method returns DERObjectIdentifier object
-4494      * for the specified OID.
-4495      *
-4496      * @example
-4497      * var asn1ObjOID = KJUR.asn1.x509.OID.name2obj('SHA1withRSA');
-4498      */
-4499     this.name2obj = function(name) {
-4500         if (typeof this.objCache[name] != "undefined")
-4501             return this.objCache[name];
-4502         if (typeof this.name2oidList[name] == "undefined")
-4503             throw "Name of ObjectIdentifier not defined: " + name;
-4504         var oid = this.name2oidList[name];
-4505         var obj = new _DERObjectIdentifier({'oid': oid});
-4506         this.objCache[name] = obj;
-4507         return obj;
-4508     };
-4509 
-4510     /**
-4511      * get DERObjectIdentifier by registered attribute type name such like 'C' or 'CN'<br/>
-4512      * @name atype2obj
-4513      * @memberOf KJUR.asn1.x509.OID
-4514      * @function
-4515      * @param {String} atype short attribute type name such like 'C', 'CN' or OID
-4516      * @return KJUR.asn1.DERObjectIdentifier instance
-4517      * @description
-4518      * @example
-4519      * KJUR.asn1.x509.OID.atype2obj('CN') → DERObjectIdentifier of 2.5.4.3
-4520      * KJUR.asn1.x509.OID.atype2obj('OU') → DERObjectIdentifier of 2.5.4.11
-4521      * KJUR.asn1.x509.OID.atype2obj('streetAddress') → DERObjectIdentifier of 2.5.4.9
-4522      * KJUR.asn1.x509.OID.atype2obj('2.5.4.9') → DERObjectIdentifier of 2.5.4.9
-4523      */
-4524     this.atype2obj = function(atype) {
-4525         if (this.objCache[atype] !== undefined)
-4526             return this.objCache[atype];
-4527 
-4528 	var oid;
-4529 
-4530 	if (atype.match(/^\d+\.\d+\.[0-9.]+$/)) {
-4531 	    oid = atype;
-4532 	} else if (this.atype2oidList[atype] !== undefined) {
-4533 	    oid = this.atype2oidList[atype];
-4534 	} else if (this.name2oidList[atype] !== undefined) {
-4535 	    oid = this.name2oidList[atype];
-4536     	} else {
-4537             throw new Error("AttributeType name undefined: " + atype);
-4538 	}
-4539         var obj = new _DERObjectIdentifier({'oid': oid});
-4540         this.objCache[atype] = obj;
-4541         return obj;
-4542     };
-4543 
-4544     /**
-4545      * register OID list<br/>
-4546      * @name registerOIDs
-4547      * @memberOf KJUR.asn1.x509.OID
-4548      * @function
-4549      * @param {object} oids associative array of names and oids
-4550      * @since jsrsasign 10.5.2 asn1x509 2.1.11
-4551      * @see KJUR.asn1.x509.OID.checkOIDs
-4552      * 
-4553      * @description
-4554      * This static method to register an oids to existing list
-4555      * additionally.
-4556      *
-4557      * @example
-4558      * KJUR.asn1.x509.OID.checkOIDs({
-4559      *   "test1": "4.5.7.8"
-4560      * }) // do nothing for invalid list
-4561      *
-4562      * KJUR.asn1.x509.OID.registerOIDs({
-4563      *   "test1": "1.2.3",
-4564      *   "test2": "0.2.3.4.23",
-4565      * }) // successfully registered
-4566      *
-4567      * KJUR.asn1.x509.OID.name2oid("test1") → "1.2.3"
-4568      */
-4569     this.registerOIDs = function(oids) {
-4570 	if (! this.checkOIDs(oids)) return;
-4571 	for (var name in oids) {
-4572 	    this.name2oidList[name] = oids[name];
-4573 	}
-4574     };
-4575 
-4576     /**
-4577      * check validity for OID list<br/>
-4578      * @name checkOIDs
-4579      * @memberOf KJUR.asn1.x509.OID
-4580      * @function
-4581      * @param {object} oids associative array of names and oids
-4582      * @return {boolean} return true when valid OID list otherwise false
-4583      * @since jsrsasign 10.5.2 asn1x509 2.1.11
-4584      * @see KJUR.asn1.x509.OID.registOIDs
-4585      * 
-4586      * @description
-4587      * This static method validates an associative array
-4588      * as oid list.
-4589      *
-4590      * @example
-4591      * KJUR.asn1.x509.OID.checkOIDs(*non-assoc-array*) → false
-4592      * KJUR.asn1.x509.OID.checkOIDs({}) → false
-4593      * KJUR.asn1.x509.OID.checkOIDs({"test1": "apple"}) → false
-4594      * KJUR.asn1.x509.OID.checkOIDs({
-4595      *   "test1": "1.2.3",
-4596      *   "test2": "0.2.3.4.23",
-4597      * }) → true // valid oids
-4598      * KJUR.asn1.x509.OID.checkOIDs({
-4599      *   "test1": "4.5.7.8"
-4600      * }) → false // invalid oid
-4601      */
-4602     this.checkOIDs = function(oids) {
-4603 	try {
-4604 	    var nameList = Object.keys(oids);
-4605 	    if (nameList.length == 0)
-4606 		return false;
-4607 	    nameList.map(function(value, index, array) {
-4608 		var oid = this[value];
-4609 		if (! oid.match(/^[0-2]\.[0-9.]+$/))
-4610 		    throw new Error("value is not OID");
-4611 	    }, oids);
-4612 	    return true;
-4613 	} catch(ex) {
-4614 	    return false;
-4615 	}
-4616     };
-4617 
-4618 
-4619 };
-4620 
-4621 /**
-4622  * convert OID to name<br/>
-4623  * @name oid2name
-4624  * @memberOf KJUR.asn1.x509.OID
-4625  * @function
-4626  * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4)
-4627  * @return {String} OID name if registered otherwise empty string
-4628  * @since asn1x509 1.0.9
-4629  * @description
-4630  * This static method converts OID string to its name.
-4631  * If OID is undefined then it returns empty string (i.e. '').
-4632  * @example
-4633  * KJUR.asn1.x509.OID.oid2name("1.3.6.1.5.5.7.1.1") → 'authorityInfoAccess'
-4634  */
-4635 KJUR.asn1.x509.OID.oid2name = function(oid) {
-4636     var list = KJUR.asn1.x509.OID.name2oidList;
-4637     for (var name in list) {
-4638         if (list[name] == oid) return name;
-4639     }
-4640     return '';
-4641 };
-4642 
-4643 /**
-4644  * convert OID to AttributeType name<br/>
-4645  * @name oid2atype
-4646  * @memberOf KJUR.asn1.x509.OID
-4647  * @function
-4648  * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4)
-4649  * @return {String} OID AttributeType name if registered otherwise oid
-4650  * @since jsrsasign 6.2.2 asn1x509 1.0.18
-4651  * @description
-4652  * This static method converts OID string to its AttributeType name.
-4653  * If OID is not defined in OID.atype2oidList associative array then it returns OID
-4654  * specified as argument.
-4655  * @example
-4656  * KJUR.asn1.x509.OID.oid2atype("2.5.4.3") → CN
-4657  * KJUR.asn1.x509.OID.oid2atype("1.3.6.1.4.1.311.60.2.1.3") → jurisdictionOfIncorporationC
-4658  * KJUR.asn1.x509.OID.oid2atype("0.1.2.3.4") → 0.1.2.3.4 // unregistered OID
-4659  */
-4660 KJUR.asn1.x509.OID.oid2atype = function(oid) {
-4661     var list = KJUR.asn1.x509.OID.atype2oidList;
-4662     for (var atype in list) {
-4663         if (list[atype] == oid) return atype;
-4664     }
-4665     return oid;
-4666 };
-4667 
-4668 /**
-4669  * convert OID name to OID value<br/>
-4670  * @name name2oid
-4671  * @memberOf KJUR.asn1.x509.OID
-4672  * @function
-4673  * @param {String} name OID name or OID (ex. "sha1" or "1.2.3.4")
-4674  * @return {String} dot noted Object Identifer string (ex. 1.2.3.4)
-4675  * @since asn1x509 1.0.11
-4676  * @description
-4677  * This static method converts from OID name to OID string.
-4678  * If OID is undefined then it returns empty string (i.e. '').
-4679  * @example
-4680  * KJUR.asn1.x509.OID.name2oid("authorityInfoAccess") → "1.3.6.1.5.5.7.1.1"
-4681  * KJUR.asn1.x509.OID.name2oid("1.2.3.4") → "1.2.3.4"
-4682  * KJUR.asn1.x509.OID.name2oid("UNKNOWN NAME") → ""
-4683  */
-4684 KJUR.asn1.x509.OID.name2oid = function(name) {
-4685     if (name.match(/^[0-9.]+$/)) return name;
-4686     var list = KJUR.asn1.x509.OID.name2oidList;
-4687     if (list[name] === undefined) return '';
-4688     return list[name];
-4689 };
-4690 
-4691 /**
-4692  * X.509 certificate and CRL utilities class<br/>
-4693  * @name KJUR.asn1.x509.X509Util
-4694  * @class X.509 certificate and CRL utilities class
-4695  */
-4696 KJUR.asn1.x509.X509Util = {};
-4697 
-4698 /**
-4699  * issue a certificate in PEM format (DEPRECATED)
-4700  * @name newCertPEM
-4701  * @memberOf KJUR.asn1.x509.X509Util
-4702  * @function
-4703  * @param {Array} param JSON object of parameter to issue a certificate
-4704  * @since asn1x509 1.0.6
-4705  * @deprecated since jsrsasign 9.0.0 asn1x509 2.0.0. please move to {@link KJUR.asn1.x509.Certificate} constructor
-4706  * @description
-4707  * This method can issue a certificate by a simple
-4708  * JSON object.
-4709  * Signature value will be provided by signing with
-4710  * private key using 'cakey' parameter or
-4711  * hexadecimal signature value by 'sighex' parameter.
-4712  * <br/>
-4713  * NOTE: Algorithm parameter of AlgorithmIdentifier will
-4714  * be set automatically by default. 
-4715  * (see {@link KJUR.asn1.x509.AlgorithmIdentifier})
-4716  * from jsrsasign 7.1.1 asn1x509 1.0.20.
-4717  * <br/>
-4718  * NOTE2: 
-4719  * RSA-PSS algorithm has been supported from jsrsasign 8.0.21.
-4720  * As for RSA-PSS signature algorithm names and signing parameters 
-4721  * such as MGF function and salt length, please see
-4722  * {@link KJUR.asn1.x509.AlgorithmIdentifier} class.
-4723  *
-4724  * @example
-4725  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
-4726  *   serial: {int: 4},
-4727  *   sigalg: {name: 'SHA1withECDSA'},
-4728  *   issuer: {str: '/C=US/O=a'},
-4729  *   notbefore: {'str': '130504235959Z'},
-4730  *   notafter: {'str': '140504235959Z'},
-4731  *   subject: {str: '/C=US/O=b'},
-4732  *   sbjpubkey: pubKeyObj,
-4733  *   ext: [
-4734  *     {basicConstraints: {cA: true, critical: true}},
-4735  *     {keyUsage: {bin: '11'}},
-4736  *   ],
-4737  *   cakey: prvKeyObj
-4738  * });
-4739  * // -- or --
-4740  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
-4741  *   serial: {int: 4},
-4742  *   sigalg: {name: 'SHA1withECDSA'},
-4743  *   issuer: {str: '/C=US/O=a'},
-4744  *   notbefore: {'str': '130504235959Z'},
-4745  *   notafter: {'str': '140504235959Z'},
-4746  *   subject: {str: '/C=US/O=b'},
-4747  *   sbjpubkey: pubKeyPEM,
-4748  *   ext: [
-4749  *     {basicConstraints: {cA: true, critical: true}},
-4750  *     {keyUsage: {bin: '11'}},
-4751  *   ],
-4752  *   cakey: [prvkey, pass]}
-4753  * );
-4754  * // -- or --
-4755  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
-4756  *   serial: {int: 1},
-4757  *   sigalg: {name: 'SHA1withRSA'},
-4758  *   issuer: {str: '/C=US/O=T1'},
-4759  *   notbefore: {'str': '130504235959Z'},
-4760  *   notafter: {'str': '140504235959Z'},
-4761  *   subject: {str: '/C=US/O=T1'},
-4762  *   sbjpubkey: pubKeyObj,
-4763  *   sighex: '0102030405..'
-4764  * });
-4765  * // for the issuer and subject field, another
-4766  * // representation is also available
-4767  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
-4768  *   serial: {int: 1},
-4769  *   sigalg: {name: 'SHA256withRSA'},
-4770  *   issuer: {C: "US", O: "T1"},
-4771  *   notbefore: {'str': '130504235959Z'},
-4772  *   notafter: {'str': '140504235959Z'},
-4773  *   subject: {C: "US", O: "T1", CN: "http://example.com/"},
-4774  *   sbjpubkey: pubKeyObj,
-4775  *   sighex: '0102030405..'
-4776  * });
-4777  */
-4778 KJUR.asn1.x509.X509Util.newCertPEM = function(param) {
-4779     var _KJUR_asn1_x509 = KJUR.asn1.x509,
-4780 	_TBSCertificate = _KJUR_asn1_x509.TBSCertificate,
-4781 	_Certificate = _KJUR_asn1_x509.Certificate;
-4782     var cert = new _Certificate(param);
-4783     return cert.getPEM();
-4784 };
-4785 
-4786 
\ No newline at end of file +4480 +4481
/** +4482 * get DERObjectIdentifier by registered attribute type name such like 'C' or 'CN'<br/> +4483 * @name atype2obj +4484 * @memberOf KJUR.asn1.x509.OID +4485 * @function +4486 * @param {String} atype short attribute type name such like 'C', 'CN' or OID +4487 * @return KJUR.asn1.DERObjectIdentifier instance +4488 * @description +4489 * @example +4490 * KJUR.asn1.x509.OID.atype2obj('CN') → DERObjectIdentifier of 2.5.4.3 +4491 * KJUR.asn1.x509.OID.atype2obj('OU') → DERObjectIdentifier of 2.5.4.11 +4492 * KJUR.asn1.x509.OID.atype2obj('streetAddress') → DERObjectIdentifier of 2.5.4.9 +4493 * KJUR.asn1.x509.OID.atype2obj('2.5.4.9') → DERObjectIdentifier of 2.5.4.9 +4494 */ +4495 this.atype2obj = function(atype) { +4496 if (this.objCache[atype] !== undefined) +4497 return this.objCache[atype]; +4498 +4499 var oid; +4500 +4501 if (atype.match(/^\d+\.\d+\.[0-9.]+$/)) { +4502 oid = atype; +4503 } else if (this.atype2oidList[atype] !== undefined) { +4504 oid = this.atype2oidList[atype]; +4505 } else if (this.name2oidList[atype] !== undefined) { +4506 oid = this.name2oidList[atype]; +4507 } else { +4508 throw new Error("AttributeType name undefined: " + atype); +4509 } +4510 var obj = new _DERObjectIdentifier({'oid': oid}); +4511 this.objCache[atype] = obj; +4512 return obj; +4513 }; +4514 +4515 /** +4516 * register OID list<br/> +4517 * @name registerOIDs +4518 * @memberOf KJUR.asn1.x509.OID +4519 * @function +4520 * @param {object} oids associative array of names and oids +4521 * @since jsrsasign 10.5.2 asn1x509 2.1.11 +4522 * @see KJUR.asn1.x509.OID.checkOIDs +4523 * +4524 * @description +4525 * This static method to register an oids to existing list +4526 * additionally. +4527 * +4528 * @example +4529 * KJUR.asn1.x509.OID.checkOIDs({ +4530 * "test1": "4.5.7.8" +4531 * }) // do nothing for invalid list +4532 * +4533 * KJUR.asn1.x509.OID.registerOIDs({ +4534 * "test1": "1.2.3", +4535 * "test2": "0.2.3.4.23", +4536 * }) // successfully registered +4537 * +4538 * KJUR.asn1.x509.OID.name2oid("test1") → "1.2.3" +4539 */ +4540 this.registerOIDs = function(oids) { +4541 if (! this.checkOIDs(oids)) return; +4542 for (var name in oids) { +4543 this.name2oidList[name] = oids[name]; +4544 } +4545 }; +4546 +4547 /** +4548 * check validity for OID list<br/> +4549 * @name checkOIDs +4550 * @memberOf KJUR.asn1.x509.OID +4551 * @function +4552 * @param {object} oids associative array of names and oids +4553 * @return {boolean} return true when valid OID list otherwise false +4554 * @since jsrsasign 10.5.2 asn1x509 2.1.11 +4555 * @see KJUR.asn1.x509.OID.registOIDs +4556 * +4557 * @description +4558 * This static method validates an associative array +4559 * as oid list. +4560 * +4561 * @example +4562 * KJUR.asn1.x509.OID.checkOIDs(*non-assoc-array*) → false +4563 * KJUR.asn1.x509.OID.checkOIDs({}) → false +4564 * KJUR.asn1.x509.OID.checkOIDs({"test1": "apple"}) → false +4565 * KJUR.asn1.x509.OID.checkOIDs({ +4566 * "test1": "1.2.3", +4567 * "test2": "0.2.3.4.23", +4568 * }) → true // valid oids +4569 * KJUR.asn1.x509.OID.checkOIDs({ +4570 * "test1": "4.5.7.8" +4571 * }) → false // invalid oid +4572 */ +4573 this.checkOIDs = function(oids) { +4574 try { +4575 var nameList = Object.keys(oids); +4576 if (nameList.length == 0) +4577 return false; +4578 nameList.map(function(value, index, array) { +4579 var oid = this[value]; +4580 if (! oid.match(/^[0-2]\.[0-9.]+$/)) +4581 throw new Error("value is not OID"); +4582 }, oids); +4583 return true; +4584 } catch(ex) { +4585 return false; +4586 } +4587 }; +4588 +4589 +4590 }; +4591 +4592 /** +4593 * convert OID to name<br/> +4594 * @name oid2name +4595 * @memberOf KJUR.asn1.x509.OID +4596 * @function +4597 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) +4598 * @return {String} OID name if registered otherwise empty string +4599 * @since asn1x509 1.0.9 +4600 * @description +4601 * This static method converts OID string to its name. +4602 * If OID is undefined then it returns empty string (i.e. ''). +4603 * @example +4604 * KJUR.asn1.x509.OID.oid2name("1.3.6.1.5.5.7.1.1") → 'authorityInfoAccess' +4605 */ +4606 KJUR.asn1.x509.OID.oid2name = function(oid) { +4607 var list = KJUR.asn1.x509.OID.name2oidList; +4608 for (var name in list) { +4609 if (list[name] == oid) return name; +4610 } +4611 return ''; +4612 }; +4613 +4614 /** +4615 * convert OID to AttributeType name<br/> +4616 * @name oid2atype +4617 * @memberOf KJUR.asn1.x509.OID +4618 * @function +4619 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) +4620 * @return {String} OID AttributeType name if registered otherwise oid +4621 * @since jsrsasign 6.2.2 asn1x509 1.0.18 +4622 * @description +4623 * This static method converts OID string to its AttributeType name. +4624 * If OID is not defined in OID.atype2oidList associative array then it returns OID +4625 * specified as argument. +4626 * @example +4627 * KJUR.asn1.x509.OID.oid2atype("2.5.4.3") → CN +4628 * KJUR.asn1.x509.OID.oid2atype("1.3.6.1.4.1.311.60.2.1.3") → jurisdictionOfIncorporationC +4629 * KJUR.asn1.x509.OID.oid2atype("0.1.2.3.4") → 0.1.2.3.4 // unregistered OID +4630 */ +4631 KJUR.asn1.x509.OID.oid2atype = function(oid) { +4632 var list = KJUR.asn1.x509.OID.atype2oidList; +4633 for (var atype in list) { +4634 if (list[atype] == oid) return atype; +4635 } +4636 return oid; +4637 }; +4638 +4639 /** +4640 * convert OID name to OID value<br/> +4641 * @name name2oid +4642 * @memberOf KJUR.asn1.x509.OID +4643 * @function +4644 * @param {String} name OID name or OID (ex. "sha1" or "1.2.3.4") +4645 * @return {String} dot noted Object Identifer string (ex. 1.2.3.4) +4646 * @since asn1x509 1.0.11 +4647 * @description +4648 * This static method converts from OID name to OID string. +4649 * If OID is undefined then it returns empty string (i.e. ''). +4650 * @example +4651 * KJUR.asn1.x509.OID.name2oid("authorityInfoAccess") → "1.3.6.1.5.5.7.1.1" +4652 * KJUR.asn1.x509.OID.name2oid("1.2.3.4") → "1.2.3.4" +4653 * KJUR.asn1.x509.OID.name2oid("UNKNOWN NAME") → "" +4654 */ +4655 KJUR.asn1.x509.OID.name2oid = function(name) { +4656 if (name.match(/^[0-9.]+$/)) return name; +4657 var list = KJUR.asn1.x509.OID.name2oidList; +4658 if (list[name] === undefined) return ''; +4659 return list[name]; +4660 }; +4661 +4662 /** +4663 * X.509 certificate and CRL utilities class<br/> +4664 * @name KJUR.asn1.x509.X509Util +4665 * @class X.509 certificate and CRL utilities class +4666 */ +4667 KJUR.asn1.x509.X509Util = {}; +4668 +4669 /** +4670 * issue a certificate in PEM format (DEPRECATED) +4671 * @name newCertPEM +4672 * @memberOf KJUR.asn1.x509.X509Util +4673 * @function +4674 * @param {Array} param JSON object of parameter to issue a certificate +4675 * @since asn1x509 1.0.6 +4676 * @deprecated since jsrsasign 9.0.0 asn1x509 2.0.0. please move to {@link KJUR.asn1.x509.Certificate} constructor +4677 * @description +4678 * This method can issue a certificate by a simple +4679 * JSON object. +4680 * Signature value will be provided by signing with +4681 * private key using 'cakey' parameter or +4682 * hexadecimal signature value by 'sighex' parameter. +4683 * <br/> +4684 * NOTE: Algorithm parameter of AlgorithmIdentifier will +4685 * be set automatically by default. +4686 * (see {@link KJUR.asn1.x509.AlgorithmIdentifier}) +4687 * from jsrsasign 7.1.1 asn1x509 1.0.20. +4688 * <br/> +4689 * NOTE2: +4690 * RSA-PSS algorithm has been supported from jsrsasign 8.0.21. +4691 * As for RSA-PSS signature algorithm names and signing parameters +4692 * such as MGF function and salt length, please see +4693 * {@link KJUR.asn1.x509.AlgorithmIdentifier} class. +4694 * +4695 * @example +4696 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4697 * serial: {int: 4}, +4698 * sigalg: {name: 'SHA1withECDSA'}, +4699 * issuer: {str: '/C=US/O=a'}, +4700 * notbefore: {'str': '130504235959Z'}, +4701 * notafter: {'str': '140504235959Z'}, +4702 * subject: {str: '/C=US/O=b'}, +4703 * sbjpubkey: pubKeyObj, +4704 * ext: [ +4705 * {basicConstraints: {cA: true, critical: true}}, +4706 * {keyUsage: {bin: '11'}}, +4707 * ], +4708 * cakey: prvKeyObj +4709 * }); +4710 * // -- or -- +4711 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4712 * serial: {int: 4}, +4713 * sigalg: {name: 'SHA1withECDSA'}, +4714 * issuer: {str: '/C=US/O=a'}, +4715 * notbefore: {'str': '130504235959Z'}, +4716 * notafter: {'str': '140504235959Z'}, +4717 * subject: {str: '/C=US/O=b'}, +4718 * sbjpubkey: pubKeyPEM, +4719 * ext: [ +4720 * {basicConstraints: {cA: true, critical: true}}, +4721 * {keyUsage: {bin: '11'}}, +4722 * ], +4723 * cakey: [prvkey, pass]} +4724 * ); +4725 * // -- or -- +4726 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4727 * serial: {int: 1}, +4728 * sigalg: {name: 'SHA1withRSA'}, +4729 * issuer: {str: '/C=US/O=T1'}, +4730 * notbefore: {'str': '130504235959Z'}, +4731 * notafter: {'str': '140504235959Z'}, +4732 * subject: {str: '/C=US/O=T1'}, +4733 * sbjpubkey: pubKeyObj, +4734 * sighex: '0102030405..' +4735 * }); +4736 * // for the issuer and subject field, another +4737 * // representation is also available +4738 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4739 * serial: {int: 1}, +4740 * sigalg: {name: 'SHA256withRSA'}, +4741 * issuer: {C: "US", O: "T1"}, +4742 * notbefore: {'str': '130504235959Z'}, +4743 * notafter: {'str': '140504235959Z'}, +4744 * subject: {C: "US", O: "T1", CN: "http://example.com/"}, +4745 * sbjpubkey: pubKeyObj, +4746 * sighex: '0102030405..' +4747 * }); +4748 */ +4749 KJUR.asn1.x509.X509Util.newCertPEM = function(param) { +4750 var _KJUR_asn1_x509 = KJUR.asn1.x509, +4751 _TBSCertificate = _KJUR_asn1_x509.TBSCertificate, +4752 _Certificate = _KJUR_asn1_x509.Certificate; +4753 var cert = new _Certificate(param); +4754 return cert.getPEM(); +4755 }; +4756 +4757
\ No newline at end of file diff --git a/api/symbols/src/base64x-1.1.js.html b/api/symbols/src/base64x-1.1.js.html index e184fcb5..2cc4f1a2 100644 --- a/api/symbols/src/base64x-1.1.js.html +++ b/api/symbols/src/base64x-1.1.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
  1 /* base64x-1.1.27 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* base64x-1.1.28 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name base64x-1.1.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.5.21 base64x 1.1.27 (2022-May-23)
+ 19  * @version jsrsasign 10.5.22 base64x 1.1.28 (2022-May-24)
  20  * @since jsrsasign 2.1
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -1806,52 +1806,58 @@
 1799  *
 1800  * @example
 1801  * db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 };
-1802  * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1100000001'
-1803  * namearraytobinstr(['c', 'b'], db) &rarr: '100001000'
+1802  * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011'
+1803  * namearraytobinstr(['c', 'b'], db) &rarr: '000100001'
 1804  */
 1805 function namearraytobinstr (namearray, namedb) {
 1806     var d = 0;
 1807     for (var i = 0; i < namearray.length; i++) {
 1808 	d |= 1 << namedb[namearray[i]];
 1809     }
-1810     return d.toString(2);
-1811 }
-1812 
-1813 // =======================================================
-1814 /**
-1815  * set class inheritance<br/>
-1816  * @name extendClass
-1817  * @function
-1818  * @param {Function} subClass sub class to set inheritance
-1819  * @param {Function} superClass super class to inherit
-1820  * @since jsrsasign 10.3.0 base64x 1.1.21
-1821  *
-1822  * @description
-1823  * This function extends a class and set an inheritance
-1824  * for member variables and methods.
-1825  *
-1826  * @example
-1827  * var Animal = function() {
-1828  *   this.hello = function(){console.log("Hello")};
-1829  *   this.name="Ani";
-1830  * };
-1831  * var Dog = function() {
-1832  *   Dog.superclass.constructor.call(this);
-1833  *   this.vow = function(){console.log("Vow wow")};
-1834  *   this.tail=true;
-1835  * };
-1836  * extendClass(Dog, Animal);
-1837  */
-1838 function extendClass(subClass, superClass) {
-1839     var F = function() {};
-1840     F.prototype = superClass.prototype;
-1841     subClass.prototype = new F();
-1842     subClass.prototype.constructor = subClass;
-1843     subClass.superclass = superClass.prototype;
-1844      
-1845     if (superClass.prototype.constructor == Object.prototype.constructor) {
-1846         superClass.prototype.constructor = superClass;
-1847     }
-1848 };
-1849 
-1850 
\ No newline at end of file +1810 +1811
var s = d.toString(2); +1812 var r = ""; +1813 for (var i = s.length - 1; i >=0; i--) { +1814 r += s[i]; +1815 } +1816 return r; +1817 } +1818 +1819 // ======================================================= +1820 /** +1821 * set class inheritance<br/> +1822 * @name extendClass +1823 * @function +1824 * @param {Function} subClass sub class to set inheritance +1825 * @param {Function} superClass super class to inherit +1826 * @since jsrsasign 10.3.0 base64x 1.1.21 +1827 * +1828 * @description +1829 * This function extends a class and set an inheritance +1830 * for member variables and methods. +1831 * +1832 * @example +1833 * var Animal = function() { +1834 * this.hello = function(){console.log("Hello")}; +1835 * this.name="Ani"; +1836 * }; +1837 * var Dog = function() { +1838 * Dog.superclass.constructor.call(this); +1839 * this.vow = function(){console.log("Vow wow")}; +1840 * this.tail=true; +1841 * }; +1842 * extendClass(Dog, Animal); +1843 */ +1844 function extendClass(subClass, superClass) { +1845 var F = function() {}; +1846 F.prototype = superClass.prototype; +1847 subClass.prototype = new F(); +1848 subClass.prototype.constructor = subClass; +1849 subClass.superclass = superClass.prototype; +1850 +1851 if (superClass.prototype.constructor == Object.prototype.constructor) { +1852 superClass.prototype.constructor = superClass; +1853 } +1854 }; +1855 +1856
\ No newline at end of file diff --git a/bower.json b/bower.json index 6f1111d9..e5c0b49e 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "kjur-jsrsasign", - "version": "10.5.21", + "version": "10.5.22", "main": "jsrsasign-all-min.js", "description": "The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES, JWS and JWT in pure JavaScript.", "license": "MIT", diff --git a/jsrsasign-all-min.js b/jsrsasign-all-min.js index f1a0d64a..f747d31a 100644 --- a/jsrsasign-all-min.js +++ b/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.5.21 (2022-05-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.5.22 (2022-05-24) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -217,15 +217,15 @@ ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBi /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval */ var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)";var j='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:"'+j+'*")';var d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+i+")","g");var k=new RegExp("\\\\(?:([^u])|u(.{4}))","g");var g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String("");var a="\\";var f={"{":Object,"[":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if("{"===v){x={}}else{if("["===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!="undefined"){d=c[e]}if(typeof b[d]!="undefined"){return b[d]}throw"unregistered EC curve name: "+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex("04"+f+k);b[A]["name"]=A;b[A]["keylen"]=l;b[A]["keycharlen"]=Math.ceil(l/8)*2;b[A]["curve"]=r;b[A]["G"]=q;b[A]["n"]=t;b[A]["h"]=w;b[A]["oid"]=d;b[A]["info"]=x;for(var v=0;v=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -var KJUR;if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.lang=="undefined"||!KJUR.lang){KJUR.lang={}}KJUR.lang.String=function(){};function Base64x(){}function stoBA(d){var b=new Array();for(var c=0;c>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f0){var b=":"+n.join(":")+":";if(b.indexOf(":"+k+":")==-1){throw"algorithm '"+k+"' not accepted in the list"}}if(k!="none"&&B===null){throw"key shall be specified to verify."}if(typeof B=="string"&&B.indexOf("-----BEGIN ")!=-1){B=KEYUTIL.getKey(B)}if(z=="RS"||z=="PS"){if(!(B instanceof m)){throw"key shall be a RSAKey obj for RS* and PS* algs"}}if(z=="ES"){if(!(B instanceof p)){throw"key shall be a ECDSA obj for ES* algs"}}if(k=="none"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw"unsupported alg name: "+k}else{u=t.jwsalg2sigalg[k]}if(u=="none"){throw"not supported"}else{if(u.substr(0,4)=="Hmac"){var o=null;if(B===undefined){throw"hexadecimal key shall be specified for HMAC"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf("withECDSA")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(".");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw"malformed sJWS: wrong number of '.' splitted elements"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null," ");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null," ")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(".");var c=k[0];var i=k[1];var q=c+"."+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw"acceptField.alg shall be specified"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss==="object"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub==="object"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud==="object"){if(typeof g.aud=="string"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud=="object"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt==="number"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!=="number"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp=="number"){if(g.exp+r.gracePeriod=a.length){return null}}var e="";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b="",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g="sha1"}if(typeof g==="string"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw"Invalid RSA private key"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw"RSASetPrivateEx N == null"}if(d==null){throw"RSASetPrivateEx E == null"}if(g.length==0){throw"RSASetPrivateEx N.length == 0"}if(d.length==0){throw"RSASetPrivateEx E.length == 0"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw"Invalid RSA private key in RSASetPrivateEx"}}function RSAGenerate(b,l){var a=new SecureRandom();var g=b>>1;this.e=parseInt(l,16);var c=new BigInteger(l,16);var d=(b/2)-100;var k=BigInteger.ONE.shiftLeft(d);for(;;){for(;;){this.p=new BigInteger(b-g,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(g,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var j=this.p;this.p=this.q;this.q=j}var h=this.q.subtract(this.p).abs();if(h.bitLength()>3)}function RSADecryptOAEP(e,d,b){if(e.length!=Math.ceil(this.n.bitLength()/4)){throw new Error("wrong ctext length")}var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP; -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw new Error("invalid salt length")}}}if(c<(g+k+2)){throw new Error("data too long")}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dk){return false}var j=this.doPublic(b);var i=j.toString(16);if(i.length+3!=k/4){return false}var e=i.replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(m){return KJUR.crypto.Util.hashString(m,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){if(a.length!=Math.ceil(this.n.bitLength()/4)){return false}var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){if(s.length!=Math.ceil(this.n.bitLength()/4)){return false}var k=new BigInteger(s,16);var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw new Error("invalid salt length")}}}if(m<(h+c+2)){throw new Error("data too long")}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw new Error("bits beyond keysize not zero")}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||71){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; \ No newline at end of file diff --git a/npm/lib/jsrsasign-all-min.js b/npm/lib/jsrsasign-all-min.js index f1a0d64a..f747d31a 100644 --- a/npm/lib/jsrsasign-all-min.js +++ b/npm/lib/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.5.21 (2022-05-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.5.22 (2022-05-24) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -217,15 +217,15 @@ ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBi /*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval */ var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)";var j='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:"'+j+'*")';var d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+i+")","g");var k=new RegExp("\\\\(?:([^u])|u(.{4}))","g");var g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String("");var a="\\";var f={"{":Object,"[":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if("{"===v){x={}}else{if("["===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!="undefined"){d=c[e]}if(typeof b[d]!="undefined"){return b[d]}throw"unregistered EC curve name: "+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex("04"+f+k);b[A]["name"]=A;b[A]["keylen"]=l;b[A]["keycharlen"]=Math.ceil(l/8)*2;b[A]["curve"]=r;b[A]["G"]=q;b[A]["n"]=t;b[A]["h"]=w;b[A]["oid"]=d;b[A]["info"]=x;for(var v=0;v=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -var KJUR;if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.lang=="undefined"||!KJUR.lang){KJUR.lang={}}KJUR.lang.String=function(){};function Base64x(){}function stoBA(d){var b=new Array();for(var c=0;c>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f0){var b=":"+n.join(":")+":";if(b.indexOf(":"+k+":")==-1){throw"algorithm '"+k+"' not accepted in the list"}}if(k!="none"&&B===null){throw"key shall be specified to verify."}if(typeof B=="string"&&B.indexOf("-----BEGIN ")!=-1){B=KEYUTIL.getKey(B)}if(z=="RS"||z=="PS"){if(!(B instanceof m)){throw"key shall be a RSAKey obj for RS* and PS* algs"}}if(z=="ES"){if(!(B instanceof p)){throw"key shall be a ECDSA obj for ES* algs"}}if(k=="none"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw"unsupported alg name: "+k}else{u=t.jwsalg2sigalg[k]}if(u=="none"){throw"not supported"}else{if(u.substr(0,4)=="Hmac"){var o=null;if(B===undefined){throw"hexadecimal key shall be specified for HMAC"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf("withECDSA")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(".");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw"malformed sJWS: wrong number of '.' splitted elements"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null," ");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null," ")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;var k=e.split(".");var c=k[0];var i=k[1];var q=c+"."+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw"acceptField.alg shall be specified"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss==="object"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub==="object"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud==="object"){if(typeof g.aud=="string"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud=="object"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt==="number"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!=="number"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp=="number"){if(g.exp+r.gracePeriod=a.length){return null}}var e="";while(++f191)&&(h<224)){e+=String.fromCharCode(((h&31)<<6)|(a[f+1]&63));++f}else{e+=String.fromCharCode(((h&15)<<12)|((a[f+1]&63)<<6)|(a[f+2]&63));f+=2}}}return e}function oaep_mgf1_str(c,a,e){var b="",d=0;while(b.length>24,(d&16711680)>>16,(d&65280)>>8,d&255]));d+=1}return b}function oaep_unpad(o,b,g,p){var e=KJUR.crypto.MessageDigest;var r=KJUR.crypto.Util;var c=null;if(!g){g="sha1"}if(typeof g==="string"){c=e.getCanonicalAlgName(g);p=e.getHashLength(c);g=function(d){return hextorstr(r.hashHex(rstrtohex(d),c))}}o=o.toByteArray();var h;for(h=0;h0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{throw"Invalid RSA private key"}}}function RSASetPrivateEx(g,d,e,c,b,a,h,f){this.isPrivate=true;this.isPublic=false;if(g==null){throw"RSASetPrivateEx N == null"}if(d==null){throw"RSASetPrivateEx E == null"}if(g.length==0){throw"RSASetPrivateEx N.length == 0"}if(d.length==0){throw"RSASetPrivateEx E.length == 0"}if(g!=null&&d!=null&&g.length>0&&d.length>0){this.n=parseBigInt(g,16);this.e=parseInt(d,16);this.d=parseBigInt(e,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(h,16);this.coeff=parseBigInt(f,16)}else{throw"Invalid RSA private key in RSASetPrivateEx"}}function RSAGenerate(b,l){var a=new SecureRandom();var g=b>>1;this.e=parseInt(l,16);var c=new BigInteger(l,16);var d=(b/2)-100;var k=BigInteger.ONE.shiftLeft(d);for(;;){for(;;){this.p=new BigInteger(b-g,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(g,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var j=this.p;this.p=this.q;this.q=j}var h=this.q.subtract(this.p).abs();if(h.bitLength()>3)}function RSADecryptOAEP(e,d,b){if(e.length!=Math.ceil(this.n.bitLength()/4)){throw new Error("wrong ctext length")}var f=parseBigInt(e,16);var a=this.doPrivate(f);if(a==null){return null}return oaep_unpad(a,(this.n.bitLength()+7)>>3,d,b)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.decryptOAEP=RSADecryptOAEP; -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw new Error("invalid salt length")}}}if(c<(g+k+2)){throw new Error("data too long")}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dk){return false}var j=this.doPublic(b);var i=j.toString(16);if(i.length+3!=k/4){return false}var e=i.replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(m){return KJUR.crypto.Util.hashString(m,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){if(a.length!=Math.ceil(this.n.bitLength()/4)){return false}var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){if(s.length!=Math.ceil(this.n.bitLength()/4)){return false}var k=new BigInteger(s,16);var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw new Error("invalid salt length")}}}if(m<(h+c+2)){throw new Error("data too long")}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw new Error("bits beyond keysize not zero")}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||715){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(b,e){var c=0;for(var a=0;a>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function namearraytobinstr(e,g){var f=0;for(var a=0;a=0;a--){c+=b[a]}return c}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.ECParameterDB=new function(){var b={};var c={};function a(d){return new BigInteger(d,16)}this.getByName=function(e){var d=e;if(typeof c[d]!="undefined"){d=c[e]}if(typeof b[d]!="undefined"){return b[d]}throw"unregistered EC curve name: "+d};this.regist=function(A,l,o,g,m,e,j,f,k,u,d,x){b[A]={};var s=a(o);var z=a(g);var y=a(m);var t=a(e);var w=a(j);var r=new ECCurveFp(s,z,y);var q=r.decodePointHex("04"+f+k);b[A]["name"]=A;b[A]["keylen"]=l;b[A]["keycharlen"]=Math.ceil(l/8)*2;b[A]["curve"]=r;b[A]["G"]=q;b[A]["n"]=t;b[A]["h"]=w;b[A]["oid"]=d;b[A]["info"]=x;for(var v=0;vMIT License */ @@ -974,6 +974,7 @@ extendClass(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object); * NOTE1: 'params' can be omitted.
* NOTE2: 'obj' parameter have been supported since * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
+ * * @example * // default constructor * o = new KJUR.asn1.DERBitString(); @@ -1048,7 +1049,7 @@ KJUR.asn1.DERBitString = function(params) { * o.setByBinaryString("001"); // leading zeros ignored */ this.setByBinaryString = function(binaryString) { - binaryString = binaryString.replace(/^0+/, ''); + binaryString = binaryString.replace(/0+$/, ''); var unusedBits = 8 - binaryString.length % 8; if (unusedBits == 8) unusedBits = 0; diff --git a/src/asn1tsp-1.0.js b/src/asn1tsp-1.0.js index 2efdc047..569bf51f 100644 --- a/src/asn1tsp-1.0.js +++ b/src/asn1tsp-1.0.js @@ -1,4 +1,4 @@ -/* asn1tsp-2.0.8.js (c) 2014-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +/* asn1tsp-2.0.9.js (c) 2014-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /* * asn1tsp.js - ASN.1 DER encoder classes for RFC 3161 Time Stamp Protocol @@ -16,7 +16,7 @@ * @fileOverview * @name asn1tsp-1.0.js * @author Kenji Urushima kenji.urushima@gmail.com - * @version jsrsasign 10.5.21 asn1tsp 2.0.8 (2022-May-23) + * @version jsrsasign 10.5.22 asn1tsp 2.0.9 (2022-May-24) * @since jsrsasign 4.5.1 * @license MIT License */ @@ -860,6 +860,10 @@ KJUR.asn1.tsp.PKIFailureInfo = function(params) { if (typeof params == "number" && 0 <= params && params <= 25) { d |= 1 << params; + var s = d.toString(2); + var r = ""; + for (var i = s.length - 1; i >= 0; i--) r += s[i]; + return r; } else if (typeof params == "string" && _nameValue[params] != undefined) { return namearraytobinstr([params], _nameValue); @@ -870,7 +874,7 @@ KJUR.asn1.tsp.PKIFailureInfo = function(params) { throw new _Error("wrong params"); } - return d.toString(2); + return }; this.tohex = function() { diff --git a/src/asn1x509-1.0.js b/src/asn1x509-1.0.js index 46a36a92..aba18d8f 100644 --- a/src/asn1x509-1.0.js +++ b/src/asn1x509-1.0.js @@ -1,4 +1,4 @@ -/* asn1x509-2.1.15.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +/* asn1x509-2.1.16.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /* * asn1x509.js - ASN.1 DER encoder classes for X.509 certificate @@ -16,7 +16,7 @@ * @fileOverview * @name asn1x509-1.0.js * @author Kenji Urushima kenji.urushima@gmail.com - * @version jsrsasign 10.5.21 asn1x509 2.1.15 (2022-May-23) + * @version jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24) * @since jsrsasign 2.1 * @license MIT License */ @@ -638,35 +638,6 @@ KJUR.asn1.x509.KeyUsage = function(params) { this.oid = "2.5.29.15"; if (params !== undefined) this.params = params; }; -KJUR.asn1.x509.KeyUsage_bak = function(params) { - KJUR.asn1.x509.KeyUsage.superclass.constructor.call(this, params); - var _KEYUSAGE_NAME = X509.KEYUSAGE_NAME; - - this.getExtnValueHex = function() { - return this.asn1ExtnValue.tohex(); - }; - - this.oid = "2.5.29.15"; - if (params !== undefined) { - if (params.bin !== undefined) { - this.asn1ExtnValue = new KJUR.asn1.DERBitString(params); - } - if (params.names !== undefined && - params.names.length !== undefined) { - var names = params.names; - var s = "000000000"; - for (var i = 0; i < names.length; i++) { - for (var j = 0; j < _KEYUSAGE_NAME.length; j++) { - if (names[i] === _KEYUSAGE_NAME[j]) { - s = s.substring(0, j) + '1' + - s.substring(j + 1, s.length); - } - } - } - this.asn1ExtnValue = new KJUR.asn1.DERBitString({bin: s}); - } - } -}; extendClass(KJUR.asn1.x509.KeyUsage, KJUR.asn1.x509.Extension); /** diff --git a/src/base64x-1.1.js b/src/base64x-1.1.js index 26e301e5..df7b84b7 100644 --- a/src/base64x-1.1.js +++ b/src/base64x-1.1.js @@ -1,4 +1,4 @@ -/* base64x-1.1.27 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +/* base64x-1.1.28 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /* * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library @@ -16,7 +16,7 @@ * @fileOverview * @name base64x-1.1.js * @author Kenji Urushima kenji.urushima@gmail.com - * @version jsrsasign 10.5.21 base64x 1.1.27 (2022-May-23) + * @version jsrsasign 10.5.22 base64x 1.1.28 (2022-May-24) * @since jsrsasign 2.1 * @license MIT License */ @@ -1799,15 +1799,21 @@ function binstrtobitstr(s) { * * @example * db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 }; - * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1100000001' - * namearraytobinstr(['c', 'b'], db) &rarr: '100001000' + * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011' + * namearraytobinstr(['c', 'b'], db) &rarr: '000100001' */ function namearraytobinstr (namearray, namedb) { var d = 0; for (var i = 0; i < namearray.length; i++) { d |= 1 << namedb[namearray[i]]; } - return d.toString(2); + + var s = d.toString(2); + var r = ""; + for (var i = s.length - 1; i >=0; i--) { + r += s[i]; + } + return r; } // ======================================================= diff --git a/test/qunit-do-asn1.html b/test/qunit-do-asn1.html index 5268cc79..7fbdb5e5 100755 --- a/test/qunit-do-asn1.html +++ b/test/qunit-do-asn1.html @@ -77,12 +77,12 @@ d.setByBinaryString("1"); equal(d.tohex(), "03020780", "1 unused=7"); -d.setByBinaryString("100"); -equal(d.tohex(), "03020580", "100 unused=5"); +d.setByBinaryString("001"); +equal(d.tohex(), "03020520", "001 unused=5"); d.setByBinaryString('1011'); equal(d.tohex(), "030204b0", "1011 > ub=4, b0"); -d.setByBinaryString('1011000'); -equal(d.tohex(), "030201b0", "1011000 > ub=1, b0"); +d.setByBinaryString('01011'); +equal(d.tohex(), "03020358", "01011 > ub=3, b0"); d.setByBinaryString('11111111'); equal(d.tohex(), "030200ff", "11111111 > ub=0, ff"); d.setByBinaryString('111111111'); @@ -96,23 +96,24 @@ d.setUnusedBitsAndHexValue(5, "bad0"); equal(d.tohex(), "030305bad0", "setUnusedBitsAndHexValue > ub=5, bad0"); -d.setByBooleanArray([true, false, true, true, false]); -equal(d.tohex(), "030203b0", "setByBooleanArray([t,f,t,t,f]) > ub=3, b0"); +d.setByBooleanArray([true, false, false, true, true]); +equal(d.tohex(), "03020398", "setByBooleanArray([t,f,f,t,t]) 10011 > ub=3, b0"); + +d = new KJUR.asn1.DERBitString({"hex":"04bac0"}); +equal(d.tohex(), "030304bac0", "constructor hex 04bac0"); + +d = new KJUR.asn1.DERBitString({"bin":"1011"}); +equal(d.tohex(), "030204b0", "constructor bin 1011"); +d = new KJUR.asn1.DERBitString({"bin":"0000011"}); +equal(d.tohex(), "03020106", "constructor bin 0000011"); + -var d2 = new KJUR.asn1.DERBitString({"hex":"04bac0"}); -equal(d2.tohex(), "030304bac0", "constructor hex 04bac0"); -var d3 = new KJUR.asn1.DERBitString({"bin":"1011"}); -equal(d3.tohex(), "030204b0", "constructor bin 1011"); var d4 = new KJUR.asn1.DERBitString({"array": [true,false,true,true]}); equal(d4.tohex(), "030204b0", "constructor array [t,f,t,t]"); var d5 = new KJUR.asn1.DERBitString({obj:{seq: [{int: 3},{prnstr: {str: "aaa"}}]}}); equal(d5.tohex(), "030b0030080201031303616161", "constructor params asn1"); }); - - - - test("OctetString Test", function() { var d = new KJUR.asn1.DEROctetString(); d.setString('aaa'); diff --git a/test/qunit-do-asn1tsp.html b/test/qunit-do-asn1tsp.html index e311dd53..4edd7127 100755 --- a/test/qunit-do-asn1tsp.html +++ b/test/qunit-do-asn1tsp.html @@ -332,17 +332,19 @@ o = new KJUR.asn1.tsp.PKIFailureInfo(0); equal(o.getEncodedHex(), "03020780", "0"); o = new KJUR.asn1.tsp.PKIFailureInfo(2); -equal(o.getEncodedHex(), "03020580", "2"); +equal(o.getEncodedHex(), "03020520", "2"); o = new KJUR.asn1.tsp.PKIFailureInfo(25); -equal(o.getEncodedHex(), "03050680000000", "25"); +equal(o.getEncodedHex(), "03050600000040", "25"); o = new KJUR.asn1.tsp.PKIFailureInfo('badAlg'); equal(o.getEncodedHex(), "03020780", "badAlg"); o = new KJUR.asn1.tsp.PKIFailureInfo('badRequest'); -equal(o.getEncodedHex(), "03020580", "badRequest"); +equal(o.getEncodedHex(), "03020520", "badRequest"); o = new KJUR.asn1.tsp.PKIFailureInfo('systemFailure'); -equal(o.getEncodedHex(), "03050680000000", "systemFailure"); +equal(o.getEncodedHex(), "03050600000040", "systemFailure"); o = new KJUR.asn1.tsp.PKIFailureInfo(['badAlg','badRequest']); equal(o.getEncodedHex(), "030205a0", "[badAlg,badRequest]"); +o = new KJUR.asn1.tsp.PKIFailureInfo(['badAlg','badRequest','systemFailure']); +equal(o.getEncodedHex(), "030506a0000040", "[badAlg,badRequest,systemFailure]"); }); test("PKIFailureInfo.getBinValue test", function() { @@ -350,13 +352,13 @@ o = new KJUR.asn1.tsp.PKIFailureInfo(0); equal(o.getBinValue(), "1", "0"); o = new KJUR.asn1.tsp.PKIFailureInfo(2); -equal(o.getBinValue(), "100", "2"); +equal(o.getBinValue(), "001", "2"); o = new KJUR.asn1.tsp.PKIFailureInfo(25); -equal(o.getBinValue(), "10000000000000000000000000", "25"); +equal(o.getBinValue(), "00000000000000000000000001", "25"); o = new KJUR.asn1.tsp.PKIFailureInfo('timeNotAvailable'); -equal(o.getBinValue(), "100000000000000", "timeNotAvailable"); +equal(o.getBinValue(), "000000000000001", "timeNotAvailable"); o = new KJUR.asn1.tsp.PKIFailureInfo(['badAlg','systemFailure','badRequest']); -equal(o.getBinValue(), "10000000000000000000000101", "[badAlg,systemFailure,badRequest]"); +equal(o.getBinValue(), "10100000000000000000000001", "[badAlg,systemFailure,badRequest]"); }); test("TimeStampReq", function() { diff --git a/test/qunit-do-asn1x509.html b/test/qunit-do-asn1x509.html index f2294511..39a57b74 100755 --- a/test/qunit-do-asn1x509.html +++ b/test/qunit-do-asn1x509.html @@ -682,12 +682,18 @@ equal(o.tohex(), "300e0603551d0f0101ff0404030206c0", "bin 11 critical getEncodedHex"); o = new KJUR.asn1.x509.KeyUsage({'names': ['digitalSignature', 'nonRepudiation']}); equal(o.tohex(), "300b0603551d0f0404030206c0", "name [digitalSignature, nonRepudiation]"); -o = new KJUR.asn1.x509.KeyUsage({'bin':'11000000000'}); -equal(o.tohex(), "300c0603551d0f0405030305c000", "bin 110000000"); +o = new KJUR.asn1.x509.KeyUsage({'bin':'000000011'}); +equal(o.tohex(), "300c0603551d0f04050303070180", "bin 000000011"); o = new KJUR.asn1.x509.KeyUsage({'names': ['encipherOnly', 'decipherOnly']}); -equal(o.tohex(), "300c0603551d0f0405030307c000", "name [encipherOnly, decipherOnly]"); +equal(o.tohex(), "300c0603551d0f04050303070180", "name [encipherOnly, decipherOnly]"); +o = new KJUR.asn1.x509.KeyUsage({'bin':'1000011'}); +equal(o.tohex(), "300b0603551d0f040403020186", "bin 1000011"); o = new KJUR.asn1.x509.KeyUsage({'names': ['digitalSignature','keyCertSign','cRLSign']}); -equal(o.tohex(), "300b0603551d0f0404030201c2", "name [dsig,certsign,crlsign]"); +equal(o.tohex(), "300b0603551d0f040403020186", "name [dsig,certsign,crlsign]"); +o = new KJUR.asn1.x509.KeyUsage({'bin':'0000011'}); +equal(o.tohex(), "300b0603551d0f040403020106", "bin 0000011"); +o = new KJUR.asn1.x509.KeyUsage({'names': ['keyCertSign','cRLSign']}); +equal(o.tohex(), "300b0603551d0f040403020106", "name [certsign,crlsign]"); }); // CRLDP diff --git a/test/qunit-do-base64x.html b/test/qunit-do-base64x.html index 2b8d1fb0..caabdace 100755 --- a/test/qunit-do-base64x.html +++ b/test/qunit-do-base64x.html @@ -420,12 +420,13 @@ var db = { apple: 0, banana: 3, + mango: 4, kiwi: 8, orange: 9 }; -equal(namearraytobitstr(['apple'], db), '1', '> 1'); -equal(namearraytobitstr(['apple','banana'], db), '1001', '> 1001'); -equal(namearraytobitstr(['banana','kiwi','orange'], db), '1100001000', '> 1100001000'); +equal(namearraytobinstr(['apple'], db), '1', '> 1'); +equal(namearraytobinstr(['apple','banana','mango'], db), '10011', '> 10011'); +equal(namearraytobinstr(['banana','kiwi','orange'], db), '0001000011', '> 0001000011'); }); });