|
@@ -1073,7 +1099,7 @@
|
- getParam()
+
get JSON object of certificate parameters
This method returns a JSON object of the certificate
@@ -1491,6 +1517,7 @@
subjectAltName2 - X509#getExtSubjectAltName2 (DEPRECATED)
issuerAltName - X509#getExtIssuerAltName
basicConstraints - X509#getExtBasicConstraints
+ nameConstraints - X509#getExtNameConstraints
extKeyUsage - X509#getExtExtKeyUsage
extKeyUsage - X509#getExtExtKeyUsageName (DEPRECATED)
cRLDistributionPoints - X509#getExtCRLDistributionPoints
@@ -3534,6 +3561,91 @@
+
+
+
+
+
+ {Object}
+ getExtNameConstraints(hExtV, critical)
+
+
+
+ get NameConstraints extension value as object in the certificate
+This method will get name constraints extension value as object with following paramters.
+
+
+
+
+
+
+
+ x = new X509(sCertPEM);
+x.getExtNameConstraints() → {
+ critical: true,
+ permit: [{dns: 'example.com'},{rfc822: 'john@example.com'}],
+ exclude: [{dn: {...X500Name parameter...}}]
+}
+
+
+
+
+
+ - Parameters:
+
+ -
+ {String} hExtV
+
+
+ - hexadecimal string of extension value (OPTIONAL)
+
+ -
+ {Boolean} critical
+
+
+ - flag (OPTIONAL)
+
+
+
+
+
+
+ - Since:
+ - jsrsasign 10.5.16 x509 2.0.16
+
+
+
+
+
+
+ - Returns:
+
+ - {Object} JSON object of NamConstraints parameter or undefined
+
+
+
+
+
+
+ - See:
+
+ - KJUR.asn1.x509.NameConstraints
+
+ - KJUR.asn1.x509.GeneralSubtree
+
+ - KJUR.asn1.x509.GeneralName
+
+ - X509#getGeneralSubtree
+
+ - X509#getGeneralName
+
+
+
+
@@ -4103,7 +4215,7 @@
- get GeneralName ASN.1 structure parameter as JSON object
+ get GeneralName ASN.1 structure parameter as JSON object
This method will get GeneralName parameters defined in
RFC 5280 4.2.1.6.
@@ -4269,6 +4381,86 @@
+
+
+
+
+
+ {Object}
+ getGeneralSubtree(h)
+
+
+
+ get GeneralSubtree ASN.1 structure parameter as JSON object
+This method will get GeneralSubtree parameters defined in
+
+RFC 5280 4.2.1.10.
+
+GeneralSubtree ::= SEQUENCE {
+ base GeneralName,
+ minimum [0] BaseDistance DEFAULT 0,
+ maximum [1] BaseDistance OPTIONAL }
+BaseDistance ::= INTEGER (0..MAX)
+
+Result of this method can be passed to
+ KJUR.asn1.x509.GeneralSubtree constructor.
+
+
+
+
+
+
+ x = new X509(sPEM);
+x.getGeneralSubtree("30...") → { dn: ...X500NameObject..., min: 1, max: 3 }
+x.getGeneralSubtree("30...") → { dns: ".example.com" }
+
+
+
+
+
+ - Parameters:
+
+ -
+ {String} h
+
+
+ - hexadecimal string of GeneralSubtree
+
+
+
+
+
+
+ - Since:
+ - jsrsasign 10.5.16 x509 2.0.16
+
+
+
+
+
+
+ - Returns:
+
+ - {Object} JSON object of GeneralSubtree parameters or undefined
+
+
+
+
+
+
+ - See:
+
+ - KJUR.asn1.x509.GeneralSubtree
+
+ - KJUR.asn1.x509.GeneralName
+
+ - X509#getExtNameConstraints
+
+ - X509#getGeneralName
+
+
+
+
@@ -4554,8 +4746,8 @@
- {Array}
- getParam()
+ {Object}
+ getParam(option)
@@ -4563,6 +4755,15 @@
This method returns a JSON object of the certificate
parameters. Return value can be passed to
KJUR.asn1.x509.X509Util.newCertPEM.
+
+NOTE1: From jsrsasign 10.5.16, optional argument can be applied.
+It can have following members:
+
+- tbshex - if this is true, tbshex member with hex value of
+tbsCertificate will be added
+- nodnarray - if this is true, array member for subject and
+issuer will be deleted to simplify it
-
+
@@ -4589,11 +4790,25 @@
{extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}
],
sighex:"0b76...8"
-};
+};
+
+x.getParam({tbshex: true}) → { ... , tbshex: "30..." }
+x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...}
+
+ - Parameters:
+
+ -
+ {Object} option
+
+
+ - optional setting for return object
+
+
+
@@ -4607,7 +4822,7 @@
- Returns:
- - {Array} JSON object of certificate parameters
+ - {Object} JSON object of certificate parameters
diff --git a/api/symbols/X509CRL.html b/api/symbols/X509CRL.html
index 00fed226..820f536d 100644
--- a/api/symbols/X509CRL.html
+++ b/api/symbols/X509CRL.html
@@ -433,10 +433,14 @@ Classes
KJUR.asn1.x509.GeneralNames
+ KJUR.asn1.x509.GeneralSubtree
+
KJUR.asn1.x509.IssuerAltName
KJUR.asn1.x509.KeyUsage
+ KJUR.asn1.x509.NameConstraints
+
KJUR.asn1.x509.NoticeReference
KJUR.asn1.x509.OCSPNoCheck
@@ -1248,6 +1252,15 @@
parameters.
Return value can be passed to
KJUR.asn1.x509.CRL constructor.
+
+NOTE1: From jsrsasign 10.5.16, optional argument can be applied.
+It can have following members:
+
+- tbshex - if this is true, tbshex member with hex value of
+tbsCertList will be added
+- nodnarray - if this is true, array member for subject and
+issuer will be deleted to simplify it
-
+
@@ -1269,7 +1282,10 @@
ext: [
{extname:"authorityKeyIdentifier",kid:{hex: "03de..."}},
{extname:"cRLNumber",num:{hex:"0211"}}],
- sighex: "3c5e..."}
+ sighex: "3c5e..."}
+
+crl.getParam({tbshex: true}) → { ... , tbshex: "30..." }
+crl.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...}
diff --git a/api/symbols/global__.html b/api/symbols/global__.html
index f2d0725d..1b313663 100644
--- a/api/symbols/global__.html
+++ b/api/symbols/global__.html
@@ -433,10 +433,14 @@ Classes
KJUR.asn1.x509.GeneralNames
+ KJUR.asn1.x509.GeneralSubtree
+
KJUR.asn1.x509.IssuerAltName
KJUR.asn1.x509.KeyUsage
+ KJUR.asn1.x509.NameConstraints
+
KJUR.asn1.x509.NoticeReference
KJUR.asn1.x509.OCSPNoCheck
diff --git a/api/symbols/src/asn1-1.0.js.html b/api/symbols/src/asn1-1.0.js.html
index 0256dd45..2d901418 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.23.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+ 1 /* asn1-1.0.24.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.4 asn1 1.0.23 (2022-Feb-14)
+ 19 * @version jsrsasign 10.5.16 asn1 1.0.24 (2022-Apr-08)
20 * @since jsrsasign 2.1
21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
22 */
@@ -303,1541 +303,1544 @@
296 obj: obj});
297 } else {
298 return new _DERTaggedObject(tagParam);
-299 /*
-300 var newParam = {};
-301 if (tagParam.explicit !== undefined)
-302 newParam.explicit = tagParam.explicit;
-303 if (tagParam.tag !== undefined)
-304 newParam.tag = tagParam.tag;
-305 if (tagParam.obj === undefined)
-306 throw "obj shall be specified for 'tag'.";
-307 newParam.obj = _newObject(tagParam.obj);
-308 return new _DERTaggedObject(newParam);
-309 */
-310 }
-311 }
-312 };
-313
-314 /**
-315 * get encoded hexadecimal string of ASN1Object specifed by JSON parameters
-316 * @name jsonToASN1HEX
-317 * @memberOf KJUR.asn1.ASN1Util
-318 * @function
-319 * @param {Array} param JSON parameter to generate ASN1Object
-320 * @return hexadecimal string of ASN1Object
-321 * @since asn1 1.0.4
-322 * @description
-323 * As for ASN.1 object representation of JSON object,
-324 * please see {@link newObject}.
-325 * @example
-326 * jsonToASN1HEX({'prnstr': 'aaa'});
-327 */
-328 this.jsonToASN1HEX = function(param) {
-329 var asn1Obj = this.newObject(param);
-330 return asn1Obj.getEncodedHex();
-331 };
-332 };
-333
-334 /**
-335 * get dot noted oid number string from hexadecimal value of OID
-336 * @name oidHexToInt
-337 * @memberOf KJUR.asn1.ASN1Util
-338 * @function
-339 * @param {String} hex hexadecimal value of object identifier
-340 * @return {String} dot noted string of object identifier
-341 * @since jsrsasign 4.8.3 asn1 1.0.7
-342 * @description
-343 * This static method converts from hexadecimal string representation of
-344 * ASN.1 value of object identifier to oid number string.
-345 * @example
-346 * KJUR.asn1.ASN1Util.oidHexToInt('550406') → "2.5.4.6"
-347 */
-348 KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
-349 var s = "";
-350 var i01 = parseInt(hex.substr(0, 2), 16);
-351 var i0 = Math.floor(i01 / 40);
-352 var i1 = i01 % 40;
-353 var s = i0 + "." + i1;
-354
-355 var binbuf = "";
-356 for (var i = 2; i < hex.length; i += 2) {
-357 var value = parseInt(hex.substr(i, 2), 16);
-358 var bin = ("00000000" + value.toString(2)).slice(- 8);
-359 binbuf = binbuf + bin.substr(1, 7);
-360 if (bin.substr(0, 1) == "0") {
-361 var bi = new BigInteger(binbuf, 2);
-362 s = s + "." + bi.toString(10);
-363 binbuf = "";
-364 }
-365 };
-366
-367 return s;
-368 };
-369
-370 /**
-371 * get hexadecimal value of object identifier from dot noted oid value (DEPRECATED)
-372 * @name oidIntToHex
-373 * @memberOf KJUR.asn1.ASN1Util
-374 * @function
-375 * @param {String} oidString dot noted string of object identifier
-376 * @return {String} hexadecimal value of object identifier
-377 * @since jsrsasign 4.8.3 asn1 1.0.7
-378 * @see {@link ASN1HEX.hextooidstr}
-379 * @deprecated from jsrsasign 10.0.6. please use {@link oidtohex}
-380 *
-381 * @description
-382 * This static method converts from object identifier value string.
-383 * to hexadecimal string representation of it.
-384 * {@link ASN1HEX.hextooidstr} is a reverse function of this.
-385 * @example
-386 * KJUR.asn1.ASN1Util.oidIntToHex("2.5.4.6") → "550406"
-387 */
-388 KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
-389 var itox = function(i) {
-390 var h = i.toString(16);
-391 if (h.length == 1) h = '0' + h;
-392 return h;
-393 };
-394
-395 var roidtox = function(roid) {
-396 var h = '';
-397 var bi = new BigInteger(roid, 10);
-398 var b = bi.toString(2);
-399 var padLen = 7 - b.length % 7;
-400 if (padLen == 7) padLen = 0;
-401 var bPad = '';
-402 for (var i = 0; i < padLen; i++) bPad += '0';
-403 b = bPad + b;
-404 for (var i = 0; i < b.length - 1; i += 7) {
-405 var b8 = b.substr(i, 7);
-406 if (i != b.length - 7) b8 = '1' + b8;
-407 h += itox(parseInt(b8, 2));
-408 }
-409 return h;
-410 };
-411
-412 if (! oidString.match(/^[0-9.]+$/)) {
-413 throw "malformed oid string: " + oidString;
-414 }
-415 var h = '';
-416 var a = oidString.split('.');
-417 var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
-418 h += itox(i0);
-419 a.splice(0, 2);
-420 for (var i = 0; i < a.length; i++) {
-421 h += roidtox(a[i]);
-422 }
-423 return h;
-424 };
-425
-426
-427 // ********************************************************************
-428 // Abstract ASN.1 Classes
-429 // ********************************************************************
-430
-431 // ********************************************************************
-432
-433 /**
-434 * base class for ASN.1 DER encoder object<br/>
-435 * @name KJUR.asn1.ASN1Object
-436 * @class base class for ASN.1 DER encoder object
-437 * @param {Array} params JSON object parameter for constructor
-438 * @property {Boolean} isModified flag whether internal data was changed
-439 * @property {Array} params JSON object parameter for ASN.1 encode
-440 * @property {String} hTLV hexadecimal string of ASN.1 TLV
-441 * @property {String} hT hexadecimal string of ASN.1 TLV tag(T)
-442 * @property {String} hL hexadecimal string of ASN.1 TLV length(L)
-443 * @property {String} hV hexadecimal string of ASN.1 TLV value(V)
-444 *
-445 * @description
-446 * This class is ASN.1 DER object encode base class.
-447 *
-448 * @example
-449 * new KJUR.asn1.ASN1Object({tlv: "030101"})
-450 */
-451 KJUR.asn1.ASN1Object = function(params) {
-452 var isModified = true;
-453 var hTLV = null;
-454 var hT = '00';
-455 var hL = '00';
-456 var hV = '';
-457 this.params = null;
-458
-459 /**
-460 * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)<br/>
-461 * @name getLengthHexFromValue
-462 * @memberOf KJUR.asn1.ASN1Object#
-463 * @function
-464 * @return {String} hexadecimal string of ASN.1 TLV length(L)
-465 */
-466 this.getLengthHexFromValue = function() {
-467 if (typeof this.hV == "undefined" || this.hV == null) {
-468 throw new Error("this.hV is null or undefined");
-469 }
-470 if (this.hV.length % 2 == 1) {
-471 throw new Error("value hex must be even length: n=" +
-472 hV.length + ",v=" + this.hV);
-473 }
-474 var n = this.hV.length / 2;
-475 var hN = n.toString(16);
-476 if (hN.length % 2 == 1) {
-477 hN = "0" + hN;
+299 }
+300 }
+301 };
+302
+303 /**
+304 * get encoded hexadecimal string of ASN1Object specifed by JSON parameters
+305 * @name jsonToASN1HEX
+306 * @memberOf KJUR.asn1.ASN1Util
+307 * @function
+308 * @param {Array} param JSON parameter to generate ASN1Object
+309 * @return hexadecimal string of ASN1Object
+310 * @since asn1 1.0.4
+311 * @description
+312 * As for ASN.1 object representation of JSON object,
+313 * please see {@link newObject}.
+314 * @example
+315 * jsonToASN1HEX({'prnstr': 'aaa'});
+316 */
+317 this.jsonToASN1HEX = function(param) {
+318 var asn1Obj = this.newObject(param);
+319 return asn1Obj.tohex();
+320 };
+321 };
+322
+323 /**
+324 * get dot noted oid number string from hexadecimal value of OID
+325 * @name oidHexToInt
+326 * @memberOf KJUR.asn1.ASN1Util
+327 * @function
+328 * @param {String} hex hexadecimal value of object identifier
+329 * @return {String} dot noted string of object identifier
+330 * @since jsrsasign 4.8.3 asn1 1.0.7
+331 * @description
+332 * This static method converts from hexadecimal string representation of
+333 * ASN.1 value of object identifier to oid number string.
+334 * @example
+335 * KJUR.asn1.ASN1Util.oidHexToInt('550406') → "2.5.4.6"
+336 */
+337 KJUR.asn1.ASN1Util.oidHexToInt = function(hex) {
+338 var s = "";
+339 var i01 = parseInt(hex.substr(0, 2), 16);
+340 var i0 = Math.floor(i01 / 40);
+341 var i1 = i01 % 40;
+342 var s = i0 + "." + i1;
+343
+344 var binbuf = "";
+345 for (var i = 2; i < hex.length; i += 2) {
+346 var value = parseInt(hex.substr(i, 2), 16);
+347 var bin = ("00000000" + value.toString(2)).slice(- 8);
+348 binbuf = binbuf + bin.substr(1, 7);
+349 if (bin.substr(0, 1) == "0") {
+350 var bi = new BigInteger(binbuf, 2);
+351 s = s + "." + bi.toString(10);
+352 binbuf = "";
+353 }
+354 };
+355
+356 return s;
+357 };
+358
+359 /**
+360 * get hexadecimal value of object identifier from dot noted oid value (DEPRECATED)
+361 * @name oidIntToHex
+362 * @memberOf KJUR.asn1.ASN1Util
+363 * @function
+364 * @param {String} oidString dot noted string of object identifier
+365 * @return {String} hexadecimal value of object identifier
+366 * @since jsrsasign 4.8.3 asn1 1.0.7
+367 * @see {@link ASN1HEX.hextooidstr}
+368 * @deprecated from jsrsasign 10.0.6. please use {@link oidtohex}
+369 *
+370 * @description
+371 * This static method converts from object identifier value string.
+372 * to hexadecimal string representation of it.
+373 * {@link ASN1HEX.hextooidstr} is a reverse function of this.
+374 * @example
+375 * KJUR.asn1.ASN1Util.oidIntToHex("2.5.4.6") → "550406"
+376 */
+377 KJUR.asn1.ASN1Util.oidIntToHex = function(oidString) {
+378 var itox = function(i) {
+379 var h = i.toString(16);
+380 if (h.length == 1) h = '0' + h;
+381 return h;
+382 };
+383
+384 var roidtox = function(roid) {
+385 var h = '';
+386 var bi = new BigInteger(roid, 10);
+387 var b = bi.toString(2);
+388 var padLen = 7 - b.length % 7;
+389 if (padLen == 7) padLen = 0;
+390 var bPad = '';
+391 for (var i = 0; i < padLen; i++) bPad += '0';
+392 b = bPad + b;
+393 for (var i = 0; i < b.length - 1; i += 7) {
+394 var b8 = b.substr(i, 7);
+395 if (i != b.length - 7) b8 = '1' + b8;
+396 h += itox(parseInt(b8, 2));
+397 }
+398 return h;
+399 };
+400
+401 if (! oidString.match(/^[0-9.]+$/)) {
+402 throw "malformed oid string: " + oidString;
+403 }
+404 var h = '';
+405 var a = oidString.split('.');
+406 var i0 = parseInt(a[0]) * 40 + parseInt(a[1]);
+407 h += itox(i0);
+408 a.splice(0, 2);
+409 for (var i = 0; i < a.length; i++) {
+410 h += roidtox(a[i]);
+411 }
+412 return h;
+413 };
+414
+415
+416 // ********************************************************************
+417 // Abstract ASN.1 Classes
+418 // ********************************************************************
+419
+420 // ********************************************************************
+421
+422 /**
+423 * base class for ASN.1 DER encoder object<br/>
+424 * @name KJUR.asn1.ASN1Object
+425 * @class base class for ASN.1 DER encoder object
+426 * @param {Array} params JSON object parameter for constructor
+427 * @property {Boolean} isModified flag whether internal data was changed
+428 * @property {Array} params JSON object parameter for ASN.1 encode
+429 * @property {String} hTLV hexadecimal string of ASN.1 TLV
+430 * @property {String} hT hexadecimal string of ASN.1 TLV tag(T)
+431 * @property {String} hL hexadecimal string of ASN.1 TLV length(L)
+432 * @property {String} hV hexadecimal string of ASN.1 TLV value(V)
+433 *
+434 * @description
+435 * This class is ASN.1 DER object encode base class.
+436 *
+437 * @example
+438 * new KJUR.asn1.ASN1Object({tlv: "030101"})
+439 */
+440 KJUR.asn1.ASN1Object = function(params) {
+441 var isModified = true;
+442 var hTLV = null;
+443 var hT = '00';
+444 var hL = '00';
+445 var hV = '';
+446 this.params = null;
+447
+448 /**
+449 * get hexadecimal ASN.1 TLV length(L) bytes from TLV value(V)<br/>
+450 * @name getLengthHexFromValue
+451 * @memberOf KJUR.asn1.ASN1Object#
+452 * @function
+453 * @return {String} hexadecimal string of ASN.1 TLV length(L)
+454 */
+455 this.getLengthHexFromValue = function() {
+456 if (typeof this.hV == "undefined" || this.hV == null) {
+457 throw new Error("this.hV is null or undefined");
+458 }
+459 if (this.hV.length % 2 == 1) {
+460 throw new Error("value hex must be even length: n=" +
+461 hV.length + ",v=" + this.hV);
+462 }
+463 var n = this.hV.length / 2;
+464 var hN = n.toString(16);
+465 if (hN.length % 2 == 1) {
+466 hN = "0" + hN;
+467 }
+468 if (n < 128) {
+469 return hN;
+470 } else {
+471 var hNlen = hN.length / 2;
+472 if (hNlen > 15) {
+473 throw new Error("ASN.1 length too long to represent by 8x: n = "
+474 + n.toString(16));
+475 }
+476 var head = 128 + hNlen;
+477 return head.toString(16) + hN;
478 }
-479 if (n < 128) {
-480 return hN;
-481 } else {
-482 var hNlen = hN.length / 2;
-483 if (hNlen > 15) {
-484 throw new Error("ASN.1 length too long to represent by 8x: n = "
-485 + n.toString(16));
-486 }
-487 var head = 128 + hNlen;
-488 return head.toString(16) + hN;
-489 }
-490 };
-491
-492 /**
-493 * get hexadecimal string of ASN.1 TLV bytes
-494 * @name getEncodedHex
-495 * @memberOf KJUR.asn1.ASN1Object#
-496 * @function
-497 * @return {String} hexadecimal string of ASN.1 TLV
-498 */
-499 this.getEncodedHex = function() {
-500 if (this.hTLV == null || this.isModified) {
-501 this.hV = this.getFreshValueHex();
-502 this.hL = this.getLengthHexFromValue();
-503 this.hTLV = this.hT + this.hL + this.hV;
-504 this.isModified = false;
-505 //alert("first time: " + this.hTLV);
-506 }
-507 return this.hTLV;
-508 };
-509
-510 /**
-511 * get hexadecimal string of ASN.1 TLV value(V) bytes
-512 * @name getValueHex
-513 * @memberOf KJUR.asn1.ASN1Object#
-514 * @function
-515 * @return {String} hexadecimal string of ASN.1 TLV value(V) bytes
-516 */
-517 this.getValueHex = function() {
-518 this.getEncodedHex();
-519 return this.hV;
-520 }
-521
-522 this.getFreshValueHex = function() {
-523 return '';
-524 };
-525
-526 this.setByParam = function(params) {
-527 this.params = params;
-528 };
-529
-530 if (params != undefined) {
-531 if (params.tlv != undefined) {
-532 this.hTLV = params.tlv;
-533 this.isModified = false;
-534 }
-535 }
-536 };
-537
-538 // == BEGIN DERAbstractString ================================================
-539 /**
-540 * base class for ASN.1 DER string classes
-541 * @name KJUR.asn1.DERAbstractString
-542 * @class base class for ASN.1 DER string classes
-543 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-544 * @property {String} s internal string of value
-545 * @extends KJUR.asn1.ASN1Object
-546 * @description
-547 * <br/>
-548 * As for argument 'params' for constructor, you can specify one of
-549 * following properties:
-550 * <ul>
-551 * <li>str - specify initial ASN.1 value(V) by a string</li>
-552 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-553 * </ul>
-554 * NOTE: 'params' can be omitted.
-555 */
-556 KJUR.asn1.DERAbstractString = function(params) {
-557 KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
-558 var s = null;
-559 var hV = null;
-560
-561 /**
-562 * get string value of this string object
-563 * @name getString
-564 * @memberOf KJUR.asn1.DERAbstractString#
-565 * @function
-566 * @return {String} string value of this string object
-567 */
-568 this.getString = function() {
-569 return this.s;
-570 };
-571
-572 /**
-573 * set value by a string
-574 * @name setString
-575 * @memberOf KJUR.asn1.DERAbstractString#
-576 * @function
-577 * @param {String} newS value by a string to set
-578 * @description
-579 * This method set value by string. <br/>
-580 * NOTE: This method assumes that the argument string is
-581 * UTF-8 encoded even though ASN.1 primitive
-582 * such as IA5String or PrintableString doesn't
-583 * support all of UTF-8 characters.
-584 * @example
-585 * o = new KJUR.asn1.DERIA5String();
-586 * o.setString("abc");
-587 * o.setString("あいう");
-588 */
-589 this.setString = function(newS) {
-590 this.hTLV = null;
-591 this.isModified = true;
-592 this.s = newS;
-593 this.hV = utf8tohex(this.s).toLowerCase();
-594 };
-595
-596 /**
-597 * set value by a hexadecimal string
-598 * @name setStringHex
-599 * @memberOf KJUR.asn1.DERAbstractString#
-600 * @function
-601 * @param {String} newHexString value by a hexadecimal string to set
-602 */
-603 this.setStringHex = function(newHexString) {
-604 this.hTLV = null;
-605 this.isModified = true;
-606 this.s = null;
-607 this.hV = newHexString;
-608 };
-609
-610 this.getFreshValueHex = function() {
-611 return this.hV;
-612 };
-613
-614 if (typeof params != "undefined") {
-615 if (typeof params == "string") {
-616 this.setString(params);
-617 } else if (typeof params['str'] != "undefined") {
-618 this.setString(params['str']);
-619 } else if (typeof params['hex'] != "undefined") {
-620 this.setStringHex(params['hex']);
-621 }
-622 }
-623 };
-624 extendClass(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
-625 // == END DERAbstractString ================================================
-626
-627 // == BEGIN DERAbstractTime ==================================================
-628 /**
-629 * base class for ASN.1 DER Generalized/UTCTime class
-630 * @name KJUR.asn1.DERAbstractTime
-631 * @class base class for ASN.1 DER Generalized/UTCTime class
-632 * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
-633 * @extends KJUR.asn1.ASN1Object
-634 * @description
-635 * @see KJUR.asn1.ASN1Object - superclass
-636 * @see KJUR.asn1.DERGeneralizedTime
-637 * @see KJUR.asn1.DERUTCTime
-638 * @see KJUR.asn1.x509.Time
-639 */
-640 KJUR.asn1.DERAbstractTime = function(params) {
-641 KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
-642 var s = null;
-643 var date = null;
-644
-645 // --- PRIVATE METHODS --------------------
-646 this.localDateToUTC = function(d) {
-647 var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
-648 var utcDate = new Date(utc);
-649 return utcDate;
-650 };
-651
-652 /*
-653 * format date string by Data object
-654 * @name formatDate
-655 * @memberOf KJUR.asn1.AbstractTime;
-656 * @param {Date} dateObject
-657 * @param {string} type 'utc' or 'gen'
-658 * @param {boolean} withMillis flag for with millisections or not
-659 * @description
-660 * 'withMillis' flag is supported from asn1 1.0.6.
-661 */
-662 this.formatDate = function(dateObject, type, withMillis) {
-663 var pad = this.zeroPadding;
-664 var d = this.localDateToUTC(dateObject);
-665 var year = String(d.getFullYear());
-666 if (type == 'utc') year = year.substr(2, 2);
-667 var month = pad(String(d.getMonth() + 1), 2);
-668 var day = pad(String(d.getDate()), 2);
-669 var hour = pad(String(d.getHours()), 2);
-670 var min = pad(String(d.getMinutes()), 2);
-671 var sec = pad(String(d.getSeconds()), 2);
-672 var s = year + month + day + hour + min + sec;
-673 if (withMillis === true) {
-674 var millis = d.getMilliseconds();
-675 if (millis != 0) {
-676 var sMillis = pad(String(millis), 3);
-677 sMillis = sMillis.replace(/[0]+$/, "");
-678 s = s + "." + sMillis;
-679 }
-680 }
-681 return s + "Z";
-682 };
-683
-684 this.zeroPadding = function(s, len) {
-685 if (s.length >= len) return s;
-686 return new Array(len - s.length + 1).join('0') + s;
-687 };
-688
-689 // --- PUBLIC METHODS --------------------
-690
-691 /**
-692 * set parameter of time
-693 * @name setByParam
-694 * @memberOf KJUR.asn1.DERAbstractTime#
-695 * @function
-696 * @param {Object} params JSON object, Date object or string of time
-697 * @since jsrsasign 10.4.1 asn1 1.0.22
-698 *
-699 * NOTE: If a member "millis" has a value "true",
-700 * a fraction of second will be specified for this object.
-701 * This default is "false".
-702 *
-703 * @example
-704 * d1 = new KJUR.asn1.DERGeneralizedTime();
-705 * d1.setByParam("20210930235959.123Z");
-706 * d1.setByParam({str: "20210930235959.123Z"});
-707 *
-708 * d1.setByParam(new Date("2013/12/31 23:59:59.12"));
-709 * date1 = new Date(Date.UTC(2021,8,31,23,59,59,123));
-710 * d1.setByParam(date1);
-711 * d1.setByParam({date: date1});
-712 * d1.setByParam({date: date1, millis: true});
-713 */
-714 this.setByParam = function(params) {
-715 this.hV = null;
-716 this.hTLV = null;
-717 this.params = params;
-718 };
-719
-720 /**
-721 * get string value of this string object (DEPRECATED)
-722 * @name getString
-723 * @memberOf KJUR.asn1.DERAbstractTime#
-724 * @function
-725 * @return {String} string value of this time object
-726 * @deprecated from jsrsasign 10.4.1 asn1 1.0.22.
-727 */
-728 this.getString = function() {
-729 return undefined;
-730 };
-731
-732 /**
-733 * set value by a string (DEPRECATED)
-734 * @name setString
-735 * @memberOf KJUR.asn1.DERAbstractTime#
-736 * @function
-737 * @param {String} newS value by a string to set such like "130430235959Z"
-738 * @deprecated from jsrsasign 10.4.1 asn1 1.0.22.
-739 */
-740 this.setString = function(newS) {
-741 this.hTLV = null;
-742 this.isModified = true;
-743 if (this.params == undefined) this.params = {};
-744 this.params.str = newS;
-745 };
-746
-747 /**
-748 * set value by a Date object<br/>
-749 * @name setByDate
-750 * @memberOf KJUR.asn1.DERAbstractTime#
-751 * @function
-752 * @param {Date} dateObject Date object to set ASN.1 value(V)
-753 * @since jsrsasign 10.4.1 asn1 1.0.22
-754 *
-755 * @example
-756 * o = new KJUR.asn1.DERUTCTime();
-757 * o.setByDate(new Date("2016/12/31 23:59:59.12"));
-758 * // 2015-Jan-31 23:59:59.12
-759 * o.setByDate(new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)));
-760 */
-761 this.setByDate = function(dateObject) {
-762 this.hTLV = null;
-763 this.isModified = true;
-764 if (this.params == undefined) this.params = {};
-765 this.params.date = dateObject;
-766 };
-767
-768 /**
-769 * set value by a Date object
-770 * @name setByDateValue
-771 * @memberOf KJUR.asn1.DERAbstractTime#
-772 * @function
-773 * @param {Integer} year year of date (ex. 2013)
-774 * @param {Integer} month month of date between 1 and 12 (ex. 12)
-775 * @param {Integer} day day of month
-776 * @param {Integer} hour hours of date
-777 * @param {Integer} min minutes of date
-778 * @param {Integer} sec seconds of date
-779 */
-780 this.setByDateValue = function(year, month, day, hour, min, sec) {
-781 var dateObject = new Date(Date.UTC(year, month - 1, day,
-782 hour, min, sec, 0));
-783 this.setByDate(dateObject);
-784 };
-785
-786 this.getFreshValueHex = function() {
-787 return this.hV;
-788 };
-789 };
-790 extendClass(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
-791 // == END DERAbstractTime ==================================================
-792
-793 // == BEGIN DERAbstractStructured ============================================
-794 /**
-795 * base class for ASN.1 DER structured class
-796 * @name KJUR.asn1.DERAbstractStructured
-797 * @class base class for ASN.1 DER structured class
-798 * @property {Array} asn1Array internal array of ASN1Object
-799 * @extends KJUR.asn1.ASN1Object
-800 * @description
-801 * @see KJUR.asn1.ASN1Object - superclass
-802 */
-803 KJUR.asn1.DERAbstractStructured = function(params) {
-804 KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
-805 var asn1Array = null;
-806
-807 /**
-808 * set value by array of ASN1Object
-809 * @name setByASN1ObjectArray
-810 * @memberOf KJUR.asn1.DERAbstractStructured#
-811 * @function
-812 * @param {array} asn1ObjectArray array of ASN1Object to set
-813 */
-814 this.setByASN1ObjectArray = function(asn1ObjectArray) {
-815 this.hTLV = null;
-816 this.isModified = true;
-817 this.asn1Array = asn1ObjectArray;
-818 };
-819
-820 /**
-821 * append an ASN1Object to internal array
-822 * @name appendASN1Object
-823 * @memberOf KJUR.asn1.DERAbstractStructured#
-824 * @function
-825 * @param {ASN1Object} asn1Object to add
-826 */
-827 this.appendASN1Object = function(asn1Object) {
-828 this.hTLV = null;
-829 this.isModified = true;
-830 this.asn1Array.push(asn1Object);
-831 };
-832
-833 this.asn1Array = new Array();
-834 if (typeof params != "undefined") {
-835 if (typeof params['array'] != "undefined") {
-836 this.asn1Array = params['array'];
-837 }
-838 }
-839 };
-840 extendClass(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
-841
-842
-843 // ********************************************************************
-844 // ASN.1 Object Classes
-845 // ********************************************************************
-846
-847 // ********************************************************************
-848 /**
-849 * class for ASN.1 DER Boolean
-850 * @name KJUR.asn1.DERBoolean
-851 * @class class for ASN.1 DER Boolean
-852 * @extends KJUR.asn1.ASN1Object
-853 * @see KJUR.asn1.ASN1Object - superclass
-854 * @description
-855 * In ASN.1 DER, DER Boolean "false" shall be omitted.
-856 * However this supports boolean false for future BER support.
-857 * @example
-858 * new KJUR.asn1.DERBoolean(true)
-859 * new KJUR.asn1.DERBoolean(false)
-860 */
-861 KJUR.asn1.DERBoolean = function(params) {
-862 KJUR.asn1.DERBoolean.superclass.constructor.call(this);
-863 this.hT = "01";
-864 if (params == false)
-865 this.hTLV = "010100";
-866 else
-867 this.hTLV = "0101ff";
-868 };
-869 extendClass(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
-870
-871 // ********************************************************************
-872 /**
-873 * class for ASN.1 DER Integer
-874 * @name KJUR.asn1.DERInteger
-875 * @class class for ASN.1 DER Integer
-876 * @extends KJUR.asn1.ASN1Object
-877 * @description
-878 * <br/>
-879 * As for argument 'params' for constructor, you can specify one of
-880 * following properties:
-881 * <ul>
-882 * <li>int - specify initial ASN.1 value(V) by integer value</li>
-883 * <li>bigint - specify initial ASN.1 value(V) by BigInteger object</li>
-884 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-885 * </ul>
-886 * NOTE: 'params' can be omitted.
-887 */
-888 KJUR.asn1.DERInteger = function(params) {
-889 KJUR.asn1.DERInteger.superclass.constructor.call(this);
-890 this.hT = "02";
-891
-892 /**
-893 * set value by Tom Wu's BigInteger object
-894 * @name setByBigInteger
-895 * @memberOf KJUR.asn1.DERInteger#
-896 * @function
-897 * @param {BigInteger} bigIntegerValue to set
-898 */
-899 this.setByBigInteger = function(bigIntegerValue) {
-900 this.hTLV = null;
-901 this.isModified = true;
-902 this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
-903 };
-904
-905 /**
-906 * set value by integer value
-907 * @name setByInteger
-908 * @memberOf KJUR.asn1.DERInteger
-909 * @function
-910 * @param {Integer} integer value to set
-911 */
-912 this.setByInteger = function(intValue) {
-913 var bi = new BigInteger(String(intValue), 10);
-914 this.setByBigInteger(bi);
-915 };
-916
-917 /**
-918 * set value by integer value
-919 * @name setValueHex
-920 * @memberOf KJUR.asn1.DERInteger#
-921 * @function
-922 * @param {String} hexadecimal string of integer value
-923 * @description
-924 * <br/>
-925 * NOTE: Value shall be represented by minimum octet length of
-926 * two's complement representation.
-927 * @example
-928 * new KJUR.asn1.DERInteger(123);
-929 * new KJUR.asn1.DERInteger({'int': 123});
-930 * new KJUR.asn1.DERInteger({'hex': '1fad'});
-931 */
-932 this.setValueHex = function(newHexString) {
-933 this.hV = newHexString;
-934 };
-935
-936 this.getFreshValueHex = function() {
-937 return this.hV;
-938 };
-939
-940 if (typeof params != "undefined") {
-941 if (typeof params['bigint'] != "undefined") {
-942 this.setByBigInteger(params['bigint']);
-943 } else if (typeof params['int'] != "undefined") {
-944 this.setByInteger(params['int']);
-945 } else if (typeof params == "number") {
-946 this.setByInteger(params);
-947 } else if (typeof params['hex'] != "undefined") {
-948 this.setValueHex(params['hex']);
-949 }
-950 }
-951 };
-952 extendClass(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
-953
-954 // ********************************************************************
-955 /**
-956 * class for ASN.1 DER encoded BitString primitive
-957 * @name KJUR.asn1.DERBitString
-958 * @class class for ASN.1 DER encoded BitString primitive
-959 * @extends KJUR.asn1.ASN1Object
-960 * @description
-961 * <br/>
-962 * As for argument 'params' for constructor, you can specify one of
-963 * following properties:
-964 * <ul>
-965 * <li>bin - specify binary string (ex. '10111')</li>
-966 * <li>array - specify array of boolean (ex. [true,false,true,true])</li>
-967 * <li>hex - specify hexadecimal string of ASN.1 value(V) including unused bits</li>
-968 * <li>obj - specify {@link KJUR.asn1.ASN1Util.newObject}
-969 * argument for "BitString encapsulates" structure.</li>
-970 * </ul>
-971 * NOTE1: 'params' can be omitted.<br/>
-972 * NOTE2: 'obj' parameter have been supported since
-973 * asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).<br/>
-974 * @example
-975 * // default constructor
-976 * o = new KJUR.asn1.DERBitString();
-977 * // initialize with binary string
-978 * o = new KJUR.asn1.DERBitString({bin: "1011"});
-979 * // initialize with boolean array
-980 * o = new KJUR.asn1.DERBitString({array: [true,false,true,true]});
-981 * // initialize with hexadecimal string (04 is unused bits)
-982 * o = new KJUR.asn1.DERBitString({hex: "04bac0"});
-983 * // initialize with ASN1Util.newObject argument for encapsulated
-984 * o = new KJUR.asn1.DERBitString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
-985 * // above generates a ASN.1 data like this:
-986 * // BIT STRING, encapsulates {
-987 * // SEQUENCE {
-988 * // INTEGER 3
-989 * // PrintableString 'aaa'
-990 * // }
-991 * // }
-992 */
-993 KJUR.asn1.DERBitString = function(params) {
-994 if (params !== undefined && typeof params.obj !== "undefined") {
-995 var o = KJUR.asn1.ASN1Util.newObject(params.obj);
-996 params.hex = "00" + o.getEncodedHex();
-997 }
-998 KJUR.asn1.DERBitString.superclass.constructor.call(this);
-999 this.hT = "03";
-1000
-1001 /**
-1002 * set ASN.1 value(V) by a hexadecimal string including unused bits
-1003 * @name setHexValueIncludingUnusedBits
-1004 * @memberOf KJUR.asn1.DERBitString#
-1005 * @function
-1006 * @param {String} newHexStringIncludingUnusedBits
-1007 */
-1008 this.setHexValueIncludingUnusedBits = function(newHexStringIncludingUnusedBits) {
-1009 this.hTLV = null;
-1010 this.isModified = true;
-1011 this.hV = newHexStringIncludingUnusedBits;
-1012 };
-1013
-1014 /**
-1015 * set ASN.1 value(V) by unused bit and hexadecimal string of value
-1016 * @name setUnusedBitsAndHexValue
-1017 * @memberOf KJUR.asn1.DERBitString#
-1018 * @function
-1019 * @param {Integer} unusedBits
-1020 * @param {String} hValue
-1021 */
-1022 this.setUnusedBitsAndHexValue = function(unusedBits, hValue) {
-1023 if (unusedBits < 0 || 7 < unusedBits) {
-1024 throw "unused bits shall be from 0 to 7: u = " + unusedBits;
-1025 }
-1026 var hUnusedBits = "0" + unusedBits;
-1027 this.hTLV = null;
-1028 this.isModified = true;
-1029 this.hV = hUnusedBits + hValue;
-1030 };
-1031
-1032 /**
-1033 * set ASN.1 DER BitString by binary string<br/>
-1034 * @name setByBinaryString
-1035 * @memberOf KJUR.asn1.DERBitString#
-1036 * @function
-1037 * @param {String} binaryString binary value string (i.e. '10111')
-1038 * @description
-1039 * Its unused bits will be calculated automatically by length of
-1040 * 'binaryValue'. <br/>
-1041 * NOTE: Trailing zeros '0' will be ignored.
-1042 * @example
-1043 * o = new KJUR.asn1.DERBitString();
-1044 * o.setByBinaryString("01011");
-1045 */
-1046 this.setByBinaryString = function(binaryString) {
-1047 binaryString = binaryString.replace(/0+$/, '');
-1048 var unusedBits = 8 - binaryString.length % 8;
-1049 if (unusedBits == 8) unusedBits = 0;
-1050 for (var i = 0; i <= unusedBits; i++) {
-1051 binaryString += '0';
-1052 }
-1053 var h = '';
-1054 for (var i = 0; i < binaryString.length - 1; i += 8) {
-1055 var b = binaryString.substr(i, 8);
-1056 var x = parseInt(b, 2).toString(16);
-1057 if (x.length == 1) x = '0' + x;
-1058 h += x;
-1059 }
-1060 this.hTLV = null;
-1061 this.isModified = true;
-1062 this.hV = '0' + unusedBits + h;
-1063 };
-1064
-1065 /**
-1066 * set ASN.1 TLV value(V) by an array of boolean<br/>
-1067 * @name setByBooleanArray
-1068 * @memberOf KJUR.asn1.DERBitString#
-1069 * @function
-1070 * @param {array} booleanArray array of boolean (ex. [true, false, true])
-1071 * @description
-1072 * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
-1073 * @example
-1074 * o = new KJUR.asn1.DERBitString();
-1075 * o.setByBooleanArray([false, true, false, true, true]);
-1076 */
-1077 this.setByBooleanArray = function(booleanArray) {
-1078 var s = '';
-1079 for (var i = 0; i < booleanArray.length; i++) {
-1080 if (booleanArray[i] == true) {
-1081 s += '1';
-1082 } else {
-1083 s += '0';
-1084 }
-1085 }
-1086 this.setByBinaryString(s);
-1087 };
-1088
-1089 /**
-1090 * generate an array of falses with specified length<br/>
-1091 * @name newFalseArray
-1092 * @memberOf KJUR.asn1.DERBitString
-1093 * @function
-1094 * @param {Integer} nLength length of array to generate
-1095 * @return {array} array of boolean falses
-1096 * @description
-1097 * This static method may be useful to initialize boolean array.
-1098 * @example
-1099 * o = new KJUR.asn1.DERBitString();
-1100 * o.newFalseArray(3) → [false, false, false]
-1101 */
-1102 this.newFalseArray = function(nLength) {
-1103 var a = new Array(nLength);
-1104 for (var i = 0; i < nLength; i++) {
-1105 a[i] = false;
-1106 }
-1107 return a;
-1108 };
-1109
-1110 this.getFreshValueHex = function() {
-1111 return this.hV;
-1112 };
-1113
-1114 if (typeof params != "undefined") {
-1115 if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
-1116 this.setHexValueIncludingUnusedBits(params);
-1117 } else if (typeof params['hex'] != "undefined") {
-1118 this.setHexValueIncludingUnusedBits(params['hex']);
-1119 } else if (typeof params['bin'] != "undefined") {
-1120 this.setByBinaryString(params['bin']);
-1121 } else if (typeof params['array'] != "undefined") {
-1122 this.setByBooleanArray(params['array']);
-1123 }
-1124 }
-1125 };
-1126 extendClass(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
-1127
-1128 // ********************************************************************
-1129 /**
-1130 * class for ASN.1 DER OctetString<br/>
-1131 * @name KJUR.asn1.DEROctetString
-1132 * @class class for ASN.1 DER OctetString
-1133 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1134 * @extends KJUR.asn1.DERAbstractString
-1135 * @description
-1136 * This class provides ASN.1 OctetString simple type.<br/>
-1137 * Supported "params" attributes are:
-1138 * <ul>
-1139 * <li>str - to set a string as a value</li>
-1140 * <li>hex - to set a hexadecimal string as a value</li>
-1141 * <li>obj - to set a encapsulated ASN.1 value by JSON object
-1142 * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
-1143 * </ul>
-1144 * NOTE: A parameter 'obj' have been supported
-1145 * for "OCTET STRING, encapsulates" structure.
-1146 * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
-1147 * @see KJUR.asn1.DERAbstractString - superclass
-1148 * @example
-1149 * // default constructor
-1150 * o = new KJUR.asn1.DEROctetString();
-1151 * // initialize with string
-1152 * o = new KJUR.asn1.DEROctetString({str: "aaa"});
-1153 * // initialize with hexadecimal string
-1154 * o = new KJUR.asn1.DEROctetString({hex: "616161"});
-1155 * // initialize with ASN1Util.newObject argument
-1156 * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
-1157 * // above generates a ASN.1 data like this:
-1158 * // OCTET STRING, encapsulates {
-1159 * // SEQUENCE {
-1160 * // INTEGER 3
-1161 * // PrintableString 'aaa'
-1162 * // }
-1163 * // }
-1164 */
-1165 KJUR.asn1.DEROctetString = function(params) {
-1166 if (params !== undefined && typeof params.obj !== "undefined") {
-1167 var o = KJUR.asn1.ASN1Util.newObject(params.obj);
-1168 params.hex = o.getEncodedHex();
-1169 }
-1170 KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
-1171 this.hT = "04";
-1172 };
-1173 extendClass(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
-1174
-1175 // ********************************************************************
-1176 /**
-1177 * class for ASN.1 DER Null
-1178 * @name KJUR.asn1.DERNull
-1179 * @class class for ASN.1 DER Null
-1180 * @extends KJUR.asn1.ASN1Object
-1181 * @description
-1182 * @see KJUR.asn1.ASN1Object - superclass
-1183 */
-1184 KJUR.asn1.DERNull = function() {
-1185 KJUR.asn1.DERNull.superclass.constructor.call(this);
-1186 this.hT = "05";
-1187 this.hTLV = "0500";
-1188 };
-1189 extendClass(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
-1190
-1191 // ********************************************************************
-1192 /**
-1193 * class for ASN.1 DER ObjectIdentifier
-1194 * @name KJUR.asn1.DERObjectIdentifier
-1195 * @class class for ASN.1 DER ObjectIdentifier
-1196 * @param {Object} JSON object or string of parameters (ex. {'oid': '2.5.4.5'})
-1197 * @extends KJUR.asn1.ASN1Object
-1198 * @see oidtohex
-1199 *
-1200 * @description
-1201 * <br/>
-1202 * As for argument 'params' for constructor, you can specify one of
-1203 * following properties:
-1204 * <ul>
-1205 * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
-1206 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-1207 * </ul>
-1208 * NOTE: 'params' can be omitted.
-1209 * @example
-1210 * new DERObjectIdentifier({"name": "sha1"})
-1211 * new DERObjectIdentifier({"oid": "1.2.3.4"})
-1212 * new DERObjectIdentifier({"hex": "2d..."})
-1213 * new DERObjectIdentifier("1.2.3.4")
-1214 * new DERObjectIdentifier("SHA1withRSA")
-1215 */
-1216 KJUR.asn1.DERObjectIdentifier = function(params) {
-1217 KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
-1218 this.hT = "06";
-1219
-1220 /**
-1221 * set value by a hexadecimal string
-1222 * @name setValueHex
-1223 * @memberOf KJUR.asn1.DERObjectIdentifier#
-1224 * @function
-1225 * @param {String} newHexString hexadecimal value of OID bytes
-1226 */
-1227 this.setValueHex = function(newHexString) {
-1228 this.hTLV = null;
-1229 this.isModified = true;
-1230 this.s = null;
-1231 this.hV = newHexString;
-1232 };
-1233
-1234 /**
-1235 * set value by a OID string<br/>
-1236 * @name setValueOidString
-1237 * @memberOf KJUR.asn1.DERObjectIdentifier#
-1238 * @function
-1239 * @param {String} oidString OID string (ex. 2.5.4.13)
-1240 * @example
-1241 * o = new KJUR.asn1.DERObjectIdentifier();
-1242 * o.setValueOidString("2.5.4.13");
-1243 */
-1244 this.setValueOidString = function(oidString) {
-1245 var h = oidtohex(oidString);
-1246 if (h == null)
-1247 throw new Error("malformed oid string: " + oidString);
-1248 this.hTLV = null;
-1249 this.isModified = true;
-1250 this.s = null;
-1251 this.hV = h;
-1252 };
-1253
-1254 /**
-1255 * set value by a OID name
-1256 * @name setValueName
-1257 * @memberOf KJUR.asn1.DERObjectIdentifier#
-1258 * @function
-1259 * @param {String} oidName OID name (ex. 'serverAuth')
-1260 * @since 1.0.1
-1261 * @description
-1262 * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
-1263 * Otherwise raise error.
-1264 * @example
-1265 * o = new KJUR.asn1.DERObjectIdentifier();
-1266 * o.setValueName("serverAuth");
-1267 */
-1268 this.setValueName = function(oidName) {
-1269 var oid = KJUR.asn1.x509.OID.name2oid(oidName);
-1270 if (oid !== '') {
-1271 this.setValueOidString(oid);
-1272 } else {
-1273 throw new Error("DERObjectIdentifier oidName undefined: " + oidName);
-1274 }
-1275 };
-1276
-1277 this.setValueNameOrOid = function(nameOrOid) {
-1278 if (nameOrOid.match(/^[0-2].[0-9.]+$/)) {
-1279 this.setValueOidString(nameOrOid);
-1280 } else {
-1281 this.setValueName(nameOrOid);
-1282 }
-1283 }
-1284
-1285 this.getFreshValueHex = function() {
-1286 return this.hV;
-1287 };
-1288
-1289 this.setByParam = function(params) {
-1290 if (typeof params === "string") {
-1291 this.setValueNameOrOid(params);
-1292 } else if (params.oid !== undefined) {
-1293 this.setValueNameOrOid(params.oid);
-1294 } else if (params.name !== undefined) {
-1295 this.setValueNameOrOid(params.name);
-1296 } else if (params.hex !== undefined) {
-1297 this.setValueHex(params.hex);
-1298 }
-1299 };
-1300
-1301 if (params !== undefined) this.setByParam(params);
-1302 };
-1303 extendClass(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
-1304
-1305 // ********************************************************************
-1306 /**
-1307 * class for ASN.1 DER Enumerated
-1308 * @name KJUR.asn1.DEREnumerated
-1309 * @class class for ASN.1 DER Enumerated
-1310 * @extends KJUR.asn1.ASN1Object
-1311 * @description
-1312 * <br/>
-1313 * As for argument 'params' for constructor, you can specify one of
-1314 * following properties:
-1315 * <ul>
-1316 * <li>int - specify initial ASN.1 value(V) by integer value</li>
-1317 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
-1318 * </ul>
-1319 * NOTE: 'params' can be omitted.
-1320 * @example
-1321 * new KJUR.asn1.DEREnumerated(123);
-1322 * new KJUR.asn1.DEREnumerated({int: 123});
-1323 * new KJUR.asn1.DEREnumerated({hex: '1fad'});
-1324 */
-1325 KJUR.asn1.DEREnumerated = function(params) {
-1326 KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
-1327 this.hT = "0a";
-1328
-1329 /**
-1330 * set value by Tom Wu's BigInteger object
-1331 * @name setByBigInteger
-1332 * @memberOf KJUR.asn1.DEREnumerated#
-1333 * @function
-1334 * @param {BigInteger} bigIntegerValue to set
-1335 */
-1336 this.setByBigInteger = function(bigIntegerValue) {
-1337 this.hTLV = null;
-1338 this.isModified = true;
-1339 this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
-1340 };
-1341
-1342 /**
-1343 * set value by integer value
-1344 * @name setByInteger
-1345 * @memberOf KJUR.asn1.DEREnumerated#
-1346 * @function
-1347 * @param {Integer} integer value to set
-1348 */
-1349 this.setByInteger = function(intValue) {
-1350 var bi = new BigInteger(String(intValue), 10);
-1351 this.setByBigInteger(bi);
-1352 };
-1353
-1354 /**
-1355 * set value by integer value
-1356 * @name setValueHex
-1357 * @memberOf KJUR.asn1.DEREnumerated#
-1358 * @function
-1359 * @param {String} hexadecimal string of integer value
-1360 * @description
-1361 * <br/>
-1362 * NOTE: Value shall be represented by minimum octet length of
-1363 * two's complement representation.
-1364 */
-1365 this.setValueHex = function(newHexString) {
-1366 this.hV = newHexString;
-1367 };
-1368
-1369 this.getFreshValueHex = function() {
-1370 return this.hV;
-1371 };
-1372
-1373 if (typeof params != "undefined") {
-1374 if (typeof params['int'] != "undefined") {
-1375 this.setByInteger(params['int']);
-1376 } else if (typeof params == "number") {
-1377 this.setByInteger(params);
-1378 } else if (typeof params['hex'] != "undefined") {
-1379 this.setValueHex(params['hex']);
-1380 }
-1381 }
-1382 };
-1383 extendClass(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
-1384
-1385 // ********************************************************************
-1386 /**
-1387 * class for ASN.1 DER UTF8String
-1388 * @name KJUR.asn1.DERUTF8String
-1389 * @class class for ASN.1 DER UTF8String
-1390 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1391 * @extends KJUR.asn1.DERAbstractString
-1392 * @description
-1393 * @see KJUR.asn1.DERAbstractString - superclass
-1394 */
-1395 KJUR.asn1.DERUTF8String = function(params) {
-1396 KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
-1397 this.hT = "0c";
-1398 };
-1399 extendClass(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
-1400
-1401 // ********************************************************************
-1402 /**
-1403 * class for ASN.1 DER NumericString
-1404 * @name KJUR.asn1.DERNumericString
-1405 * @class class for ASN.1 DER NumericString
-1406 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1407 * @extends KJUR.asn1.DERAbstractString
-1408 * @description
-1409 * @see KJUR.asn1.DERAbstractString - superclass
-1410 */
-1411 KJUR.asn1.DERNumericString = function(params) {
-1412 KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
-1413 this.hT = "12";
-1414 };
-1415 extendClass(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
-1416
-1417 // ********************************************************************
-1418 /**
-1419 * class for ASN.1 DER PrintableString
-1420 * @name KJUR.asn1.DERPrintableString
-1421 * @class class for ASN.1 DER PrintableString
-1422 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1423 * @extends KJUR.asn1.DERAbstractString
-1424 * @description
-1425 * @see KJUR.asn1.DERAbstractString - superclass
-1426 */
-1427 KJUR.asn1.DERPrintableString = function(params) {
-1428 KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
-1429 this.hT = "13";
-1430 };
-1431 extendClass(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
-1432
-1433 // ********************************************************************
-1434 /**
-1435 * class for ASN.1 DER TeletexString
-1436 * @name KJUR.asn1.DERTeletexString
-1437 * @class class for ASN.1 DER TeletexString
-1438 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1439 * @extends KJUR.asn1.DERAbstractString
-1440 * @description
-1441 * @see KJUR.asn1.DERAbstractString - superclass
-1442 */
-1443 KJUR.asn1.DERTeletexString = function(params) {
-1444 KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
-1445 this.hT = "14";
-1446 };
-1447 extendClass(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
-1448
-1449 // ********************************************************************
-1450 /**
-1451 * class for ASN.1 DER IA5String
-1452 * @name KJUR.asn1.DERIA5String
-1453 * @class class for ASN.1 DER IA5String
-1454 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1455 * @extends KJUR.asn1.DERAbstractString
-1456 * @description
-1457 * @see KJUR.asn1.DERAbstractString - superclass
-1458 */
-1459 KJUR.asn1.DERIA5String = function(params) {
-1460 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
-1461 this.hT = "16";
-1462 };
-1463 extendClass(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
-1464
-1465 // ********************************************************************
-1466 /**
-1467 * class for ASN.1 DER VisibleString
-1468 * @name KJUR.asn1.DERVisibleString
-1469 * @class class for ASN.1 DER VisibleString
-1470 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1471 * @extends KJUR.asn1.DERAbstractString
-1472 * @since jsrsasign 8.0.23 asn1 1.0.15
-1473 * @description
-1474 * @see KJUR.asn1.DERAbstractString - superclass
-1475 */
-1476 KJUR.asn1.DERVisibleString = function(params) {
-1477 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
-1478 this.hT = "1a";
-1479 };
-1480 extendClass(KJUR.asn1.DERVisibleString, KJUR.asn1.DERAbstractString);
-1481
-1482 // ********************************************************************
-1483 /**
-1484 * class for ASN.1 DER BMPString
-1485 * @name KJUR.asn1.DERBMPString
-1486 * @class class for ASN.1 DER BMPString
-1487 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
-1488 * @extends KJUR.asn1.DERAbstractString
-1489 * @since jsrsasign 8.0.23 asn1 1.0.15
-1490 * @description
-1491 * @see KJUR.asn1.DERAbstractString - superclass
-1492 */
-1493 KJUR.asn1.DERBMPString = function(params) {
-1494 KJUR.asn1.DERBMPString.superclass.constructor.call(this, params);
-1495 this.hT = "1e";
-1496 };
-1497 extendClass(KJUR.asn1.DERBMPString, KJUR.asn1.DERAbstractString);
-1498
-1499 // ********************************************************************
-1500 /**
-1501 * class for ASN.1 DER UTCTime
-1502 * @name KJUR.asn1.DERUTCTime
-1503 * @class class for ASN.1 DER UTCTime
-1504 * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
-1505 * @extends KJUR.asn1.DERAbstractTime
-1506 * @see KJUR.asn1.DERGeneralizedTime
-1507 * @see KJUR.asn1.x509.Time
-1508 *
-1509 * @description
-1510 * <br/>
-1511 * As for argument 'params' for constructor, you can specify one of
-1512 * following properties:
-1513 * <ul>
-1514 * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
-1515 * <li>date - specify Date object.</li>
-1516 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
-1517 * </ul>
-1518 * NOTE1: 'params' can be omitted.
-1519 * NOTE2: 'millis' property is supported from jsrsasign 10.4.1 asn1 1.0.22.
-1520 *
-1521 * <h4>EXAMPLES</h4>
-1522 * @example
-1523 * new DERUTCTime("20151231235959Z")
-1524 * new DERUTCTime("20151231235959.123Z")
-1525 * new DERUTCTime(new Date())
-1526 * new DERUTCTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
-1527 * new DERUTCTime({str: "20151231235959.123Z"})
-1528 * new DERUTCTime({date: new Date()})
-1529 * new DERUTCTime({date: new Date(), millis: true})
-1530 * new DERUTCTime({millis: true})
-1531 */
-1532 KJUR.asn1.DERUTCTime = function(params) {
-1533 KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
-1534 this.hT = "17";
-1535 this.params = undefined;
-1536
-1537 this.getFreshValueHex = function() {
-1538 var params = this.params;
+479 };
+480
+481 /**
+482 * get hexadecimal string of ASN.1 TLV bytes<br/>
+483 * @name tohex
+484 * @memberOf KJUR.asn1.ASN1Object#
+485 * @function
+486 * @return {String} hexadecimal string of ASN.1 TLV
+487 * @since jsrsasign 10.5.16 asn1 1.0.24
+488 * @see KJUR.asn1.ASN1Object#getEncodedHex
+489 * @example
+490 * ...ASN1ObjectInstance.tohex() → "3003020101"
+491 */
+492 this.tohex = function() {
+493 if (this.hTLV == null || this.isModified) {
+494 this.hV = this.getFreshValueHex();
+495 this.hL = this.getLengthHexFromValue();
+496 this.hTLV = this.hT + this.hL + this.hV;
+497 this.isModified = false;
+498 //alert("first time: " + this.hTLV);
+499 }
+500 return this.hTLV;
+501 };
+502
+503 /**
+504 * get hexadecimal string of ASN.1 TLV bytes (DEPRECATED)<br/>
+505 * @name getEncodedHex
+506 * @memberOf KJUR.asn1.ASN1Object#
+507 * @function
+508 * @return {String} hexadecimal string of ASN.1 TLV
+509 * @deprecated since jsrsasign 10.5.16 please use {@link KJUR.asn1.ASN1Object#tohex}
+510 */
+511 this.getEncodedHex = function() { return this.tohex(); };
+512
+513 /**
+514 * get hexadecimal string of ASN.1 TLV value(V) bytes
+515 * @name getValueHex
+516 * @memberOf KJUR.asn1.ASN1Object#
+517 * @function
+518 * @return {String} hexadecimal string of ASN.1 TLV value(V) bytes
+519 */
+520 this.getValueHex = function() {
+521 this.tohex();
+522 return this.hV;
+523 }
+524
+525 this.getFreshValueHex = function() {
+526 return '';
+527 };
+528
+529 this.setByParam = function(params) {
+530 this.params = params;
+531 };
+532
+533 if (params != undefined) {
+534 if (params.tlv != undefined) {
+535 this.hTLV = params.tlv;
+536 this.isModified = false;
+537 }
+538 }
+539 };
+540
+541 // == BEGIN DERAbstractString ================================================
+542 /**
+543 * base class for ASN.1 DER string classes
+544 * @name KJUR.asn1.DERAbstractString
+545 * @class base class for ASN.1 DER string classes
+546 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+547 * @property {String} s internal string of value
+548 * @extends KJUR.asn1.ASN1Object
+549 * @description
+550 * <br/>
+551 * As for argument 'params' for constructor, you can specify one of
+552 * following properties:
+553 * <ul>
+554 * <li>str - specify initial ASN.1 value(V) by a string</li>
+555 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+556 * </ul>
+557 * NOTE: 'params' can be omitted.
+558 */
+559 KJUR.asn1.DERAbstractString = function(params) {
+560 KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+561 var s = null;
+562 var hV = null;
+563
+564 /**
+565 * get string value of this string object
+566 * @name getString
+567 * @memberOf KJUR.asn1.DERAbstractString#
+568 * @function
+569 * @return {String} string value of this string object
+570 */
+571 this.getString = function() {
+572 return this.s;
+573 };
+574
+575 /**
+576 * set value by a string
+577 * @name setString
+578 * @memberOf KJUR.asn1.DERAbstractString#
+579 * @function
+580 * @param {String} newS value by a string to set
+581 * @description
+582 * This method set value by string. <br/>
+583 * NOTE: This method assumes that the argument string is
+584 * UTF-8 encoded even though ASN.1 primitive
+585 * such as IA5String or PrintableString doesn't
+586 * support all of UTF-8 characters.
+587 * @example
+588 * o = new KJUR.asn1.DERIA5String();
+589 * o.setString("abc");
+590 * o.setString("あいう");
+591 */
+592 this.setString = function(newS) {
+593 this.hTLV = null;
+594 this.isModified = true;
+595 this.s = newS;
+596 this.hV = utf8tohex(this.s).toLowerCase();
+597 };
+598
+599 /**
+600 * set value by a hexadecimal string
+601 * @name setStringHex
+602 * @memberOf KJUR.asn1.DERAbstractString#
+603 * @function
+604 * @param {String} newHexString value by a hexadecimal string to set
+605 */
+606 this.setStringHex = function(newHexString) {
+607 this.hTLV = null;
+608 this.isModified = true;
+609 this.s = null;
+610 this.hV = newHexString;
+611 };
+612
+613 this.getFreshValueHex = function() {
+614 return this.hV;
+615 };
+616
+617 if (typeof params != "undefined") {
+618 if (typeof params == "string") {
+619 this.setString(params);
+620 } else if (typeof params['str'] != "undefined") {
+621 this.setString(params['str']);
+622 } else if (typeof params['hex'] != "undefined") {
+623 this.setStringHex(params['hex']);
+624 }
+625 }
+626 };
+627 extendClass(KJUR.asn1.DERAbstractString, KJUR.asn1.ASN1Object);
+628 // == END DERAbstractString ================================================
+629
+630 // == BEGIN DERAbstractTime ==================================================
+631 /**
+632 * base class for ASN.1 DER Generalized/UTCTime class
+633 * @name KJUR.asn1.DERAbstractTime
+634 * @class base class for ASN.1 DER Generalized/UTCTime class
+635 * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+636 * @extends KJUR.asn1.ASN1Object
+637 * @description
+638 * @see KJUR.asn1.ASN1Object - superclass
+639 * @see KJUR.asn1.DERGeneralizedTime
+640 * @see KJUR.asn1.DERUTCTime
+641 * @see KJUR.asn1.x509.Time
+642 */
+643 KJUR.asn1.DERAbstractTime = function(params) {
+644 KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);
+645 var s = null;
+646 var date = null;
+647
+648 // --- PRIVATE METHODS --------------------
+649 this.localDateToUTC = function(d) {
+650 var utc = d.getTime() + (d.getTimezoneOffset() * 60000);
+651 var utcDate = new Date(utc);
+652 return utcDate;
+653 };
+654
+655 /*
+656 * format date string by Data object
+657 * @name formatDate
+658 * @memberOf KJUR.asn1.AbstractTime;
+659 * @param {Date} dateObject
+660 * @param {string} type 'utc' or 'gen'
+661 * @param {boolean} withMillis flag for with millisections or not
+662 * @description
+663 * 'withMillis' flag is supported from asn1 1.0.6.
+664 */
+665 this.formatDate = function(dateObject, type, withMillis) {
+666 var pad = this.zeroPadding;
+667 var d = this.localDateToUTC(dateObject);
+668 var year = String(d.getFullYear());
+669 if (type == 'utc') year = year.substr(2, 2);
+670 var month = pad(String(d.getMonth() + 1), 2);
+671 var day = pad(String(d.getDate()), 2);
+672 var hour = pad(String(d.getHours()), 2);
+673 var min = pad(String(d.getMinutes()), 2);
+674 var sec = pad(String(d.getSeconds()), 2);
+675 var s = year + month + day + hour + min + sec;
+676 if (withMillis === true) {
+677 var millis = d.getMilliseconds();
+678 if (millis != 0) {
+679 var sMillis = pad(String(millis), 3);
+680 sMillis = sMillis.replace(/[0]+$/, "");
+681 s = s + "." + sMillis;
+682 }
+683 }
+684 return s + "Z";
+685 };
+686
+687 this.zeroPadding = function(s, len) {
+688 if (s.length >= len) return s;
+689 return new Array(len - s.length + 1).join('0') + s;
+690 };
+691
+692 // --- PUBLIC METHODS --------------------
+693
+694 /**
+695 * set parameter of time
+696 * @name setByParam
+697 * @memberOf KJUR.asn1.DERAbstractTime#
+698 * @function
+699 * @param {Object} params JSON object, Date object or string of time
+700 * @since jsrsasign 10.4.1 asn1 1.0.22
+701 *
+702 * NOTE: If a member "millis" has a value "true",
+703 * a fraction of second will be specified for this object.
+704 * This default is "false".
+705 *
+706 * @example
+707 * d1 = new KJUR.asn1.DERGeneralizedTime();
+708 * d1.setByParam("20210930235959.123Z");
+709 * d1.setByParam({str: "20210930235959.123Z"});
+710 *
+711 * d1.setByParam(new Date("2013/12/31 23:59:59.12"));
+712 * date1 = new Date(Date.UTC(2021,8,31,23,59,59,123));
+713 * d1.setByParam(date1);
+714 * d1.setByParam({date: date1});
+715 * d1.setByParam({date: date1, millis: true});
+716 */
+717 this.setByParam = function(params) {
+718 this.hV = null;
+719 this.hTLV = null;
+720 this.params = params;
+721 };
+722
+723 /**
+724 * get string value of this string object (DEPRECATED)
+725 * @name getString
+726 * @memberOf KJUR.asn1.DERAbstractTime#
+727 * @function
+728 * @return {String} string value of this time object
+729 * @deprecated from jsrsasign 10.4.1 asn1 1.0.22.
+730 */
+731 this.getString = function() {
+732 return undefined;
+733 };
+734
+735 /**
+736 * set value by a string (DEPRECATED)
+737 * @name setString
+738 * @memberOf KJUR.asn1.DERAbstractTime#
+739 * @function
+740 * @param {String} newS value by a string to set such like "130430235959Z"
+741 * @deprecated from jsrsasign 10.4.1 asn1 1.0.22.
+742 */
+743 this.setString = function(newS) {
+744 this.hTLV = null;
+745 this.isModified = true;
+746 if (this.params == undefined) this.params = {};
+747 this.params.str = newS;
+748 };
+749
+750 /**
+751 * set value by a Date object<br/>
+752 * @name setByDate
+753 * @memberOf KJUR.asn1.DERAbstractTime#
+754 * @function
+755 * @param {Date} dateObject Date object to set ASN.1 value(V)
+756 * @since jsrsasign 10.4.1 asn1 1.0.22
+757 *
+758 * @example
+759 * o = new KJUR.asn1.DERUTCTime();
+760 * o.setByDate(new Date("2016/12/31 23:59:59.12"));
+761 * // 2015-Jan-31 23:59:59.12
+762 * o.setByDate(new Date(Date.UTC(2015, 0, 31, 23, 59, 59, 0)));
+763 */
+764 this.setByDate = function(dateObject) {
+765 this.hTLV = null;
+766 this.isModified = true;
+767 if (this.params == undefined) this.params = {};
+768 this.params.date = dateObject;
+769 };
+770
+771 /**
+772 * set value by a Date object
+773 * @name setByDateValue
+774 * @memberOf KJUR.asn1.DERAbstractTime#
+775 * @function
+776 * @param {Integer} year year of date (ex. 2013)
+777 * @param {Integer} month month of date between 1 and 12 (ex. 12)
+778 * @param {Integer} day day of month
+779 * @param {Integer} hour hours of date
+780 * @param {Integer} min minutes of date
+781 * @param {Integer} sec seconds of date
+782 */
+783 this.setByDateValue = function(year, month, day, hour, min, sec) {
+784 var dateObject = new Date(Date.UTC(year, month - 1, day,
+785 hour, min, sec, 0));
+786 this.setByDate(dateObject);
+787 };
+788
+789 this.getFreshValueHex = function() {
+790 return this.hV;
+791 };
+792 };
+793 extendClass(KJUR.asn1.DERAbstractTime, KJUR.asn1.ASN1Object);
+794 // == END DERAbstractTime ==================================================
+795
+796 // == BEGIN DERAbstractStructured ============================================
+797 /**
+798 * base class for ASN.1 DER structured class
+799 * @name KJUR.asn1.DERAbstractStructured
+800 * @class base class for ASN.1 DER structured class
+801 * @property {Array} asn1Array internal array of ASN1Object
+802 * @extends KJUR.asn1.ASN1Object
+803 * @description
+804 * @see KJUR.asn1.ASN1Object - superclass
+805 */
+806 KJUR.asn1.DERAbstractStructured = function(params) {
+807 KJUR.asn1.DERAbstractString.superclass.constructor.call(this);
+808 var asn1Array = null;
+809
+810 /**
+811 * set value by array of ASN1Object
+812 * @name setByASN1ObjectArray
+813 * @memberOf KJUR.asn1.DERAbstractStructured#
+814 * @function
+815 * @param {array} asn1ObjectArray array of ASN1Object to set
+816 */
+817 this.setByASN1ObjectArray = function(asn1ObjectArray) {
+818 this.hTLV = null;
+819 this.isModified = true;
+820 this.asn1Array = asn1ObjectArray;
+821 };
+822
+823 /**
+824 * append an ASN1Object to internal array
+825 * @name appendASN1Object
+826 * @memberOf KJUR.asn1.DERAbstractStructured#
+827 * @function
+828 * @param {ASN1Object} asn1Object to add
+829 */
+830 this.appendASN1Object = function(asn1Object) {
+831 this.hTLV = null;
+832 this.isModified = true;
+833 this.asn1Array.push(asn1Object);
+834 };
+835
+836 this.asn1Array = new Array();
+837 if (typeof params != "undefined") {
+838 if (typeof params['array'] != "undefined") {
+839 this.asn1Array = params['array'];
+840 }
+841 }
+842 };
+843 extendClass(KJUR.asn1.DERAbstractStructured, KJUR.asn1.ASN1Object);
+844
+845
+846 // ********************************************************************
+847 // ASN.1 Object Classes
+848 // ********************************************************************
+849
+850 // ********************************************************************
+851 /**
+852 * class for ASN.1 DER Boolean
+853 * @name KJUR.asn1.DERBoolean
+854 * @class class for ASN.1 DER Boolean
+855 * @extends KJUR.asn1.ASN1Object
+856 * @see KJUR.asn1.ASN1Object - superclass
+857 * @description
+858 * In ASN.1 DER, DER Boolean "false" shall be omitted.
+859 * However this supports boolean false for future BER support.
+860 * @example
+861 * new KJUR.asn1.DERBoolean(true)
+862 * new KJUR.asn1.DERBoolean(false)
+863 */
+864 KJUR.asn1.DERBoolean = function(params) {
+865 KJUR.asn1.DERBoolean.superclass.constructor.call(this);
+866 this.hT = "01";
+867 if (params == false)
+868 this.hTLV = "010100";
+869 else
+870 this.hTLV = "0101ff";
+871 };
+872 extendClass(KJUR.asn1.DERBoolean, KJUR.asn1.ASN1Object);
+873
+874 // ********************************************************************
+875 /**
+876 * class for ASN.1 DER Integer
+877 * @name KJUR.asn1.DERInteger
+878 * @class class for ASN.1 DER Integer
+879 * @extends KJUR.asn1.ASN1Object
+880 * @description
+881 * <br/>
+882 * As for argument 'params' for constructor, you can specify one of
+883 * following properties:
+884 * <ul>
+885 * <li>int - specify initial ASN.1 value(V) by integer value</li>
+886 * <li>bigint - specify initial ASN.1 value(V) by BigInteger object</li>
+887 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+888 * </ul>
+889 * NOTE: 'params' can be omitted.
+890 */
+891 KJUR.asn1.DERInteger = function(params) {
+892 KJUR.asn1.DERInteger.superclass.constructor.call(this);
+893 this.hT = "02";
+894
+895 /**
+896 * set value by Tom Wu's BigInteger object
+897 * @name setByBigInteger
+898 * @memberOf KJUR.asn1.DERInteger#
+899 * @function
+900 * @param {BigInteger} bigIntegerValue to set
+901 */
+902 this.setByBigInteger = function(bigIntegerValue) {
+903 this.hTLV = null;
+904 this.isModified = true;
+905 this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+906 };
+907
+908 /**
+909 * set value by integer value
+910 * @name setByInteger
+911 * @memberOf KJUR.asn1.DERInteger
+912 * @function
+913 * @param {Integer} integer value to set
+914 */
+915 this.setByInteger = function(intValue) {
+916 var bi = new BigInteger(String(intValue), 10);
+917 this.setByBigInteger(bi);
+918 };
+919
+920 /**
+921 * set value by integer value
+922 * @name setValueHex
+923 * @memberOf KJUR.asn1.DERInteger#
+924 * @function
+925 * @param {String} hexadecimal string of integer value
+926 * @description
+927 * <br/>
+928 * NOTE: Value shall be represented by minimum octet length of
+929 * two's complement representation.
+930 * @example
+931 * new KJUR.asn1.DERInteger(123);
+932 * new KJUR.asn1.DERInteger({'int': 123});
+933 * new KJUR.asn1.DERInteger({'hex': '1fad'});
+934 */
+935 this.setValueHex = function(newHexString) {
+936 this.hV = newHexString;
+937 };
+938
+939 this.getFreshValueHex = function() {
+940 return this.hV;
+941 };
+942
+943 if (typeof params != "undefined") {
+944 if (typeof params['bigint'] != "undefined") {
+945 this.setByBigInteger(params['bigint']);
+946 } else if (typeof params['int'] != "undefined") {
+947 this.setByInteger(params['int']);
+948 } else if (typeof params == "number") {
+949 this.setByInteger(params);
+950 } else if (typeof params['hex'] != "undefined") {
+951 this.setValueHex(params['hex']);
+952 }
+953 }
+954 };
+955 extendClass(KJUR.asn1.DERInteger, KJUR.asn1.ASN1Object);
+956
+957 // ********************************************************************
+958 /**
+959 * class for ASN.1 DER encoded BitString primitive
+960 * @name KJUR.asn1.DERBitString
+961 * @class class for ASN.1 DER encoded BitString primitive
+962 * @extends KJUR.asn1.ASN1Object
+963 * @description
+964 * <br/>
+965 * As for argument 'params' for constructor, you can specify one of
+966 * following properties:
+967 * <ul>
+968 * <li>bin - specify binary string (ex. '10111')</li>
+969 * <li>array - specify array of boolean (ex. [true,false,true,true])</li>
+970 * <li>hex - specify hexadecimal string of ASN.1 value(V) including unused bits</li>
+971 * <li>obj - specify {@link KJUR.asn1.ASN1Util.newObject}
+972 * argument for "BitString encapsulates" structure.</li>
+973 * </ul>
+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: Trailing zeros '0' will be ignored.
+1045 * @example
+1046 * o = new KJUR.asn1.DERBitString();
+1047 * o.setByBinaryString("01011");
+1048 */
+1049 this.setByBinaryString = function(binaryString) {
+1050 binaryString = binaryString.replace(/0+$/, '');
+1051 var unusedBits = 8 - binaryString.length % 8;
+1052 if (unusedBits == 8) unusedBits = 0;
+1053 for (var i = 0; i <= unusedBits; i++) {
+1054 binaryString += '0';
+1055 }
+1056 var h = '';
+1057 for (var i = 0; i < binaryString.length - 1; i += 8) {
+1058 var b = binaryString.substr(i, 8);
+1059 var x = parseInt(b, 2).toString(16);
+1060 if (x.length == 1) x = '0' + x;
+1061 h += x;
+1062 }
+1063 this.hTLV = null;
+1064 this.isModified = true;
+1065 this.hV = '0' + unusedBits + h;
+1066 };
+1067
+1068 /**
+1069 * set ASN.1 TLV value(V) by an array of boolean<br/>
+1070 * @name setByBooleanArray
+1071 * @memberOf KJUR.asn1.DERBitString#
+1072 * @function
+1073 * @param {array} booleanArray array of boolean (ex. [true, false, true])
+1074 * @description
+1075 * NOTE: Trailing falses will be ignored in the ASN.1 DER Object.
+1076 * @example
+1077 * o = new KJUR.asn1.DERBitString();
+1078 * o.setByBooleanArray([false, true, false, true, true]);
+1079 */
+1080 this.setByBooleanArray = function(booleanArray) {
+1081 var s = '';
+1082 for (var i = 0; i < booleanArray.length; i++) {
+1083 if (booleanArray[i] == true) {
+1084 s += '1';
+1085 } else {
+1086 s += '0';
+1087 }
+1088 }
+1089 this.setByBinaryString(s);
+1090 };
+1091
+1092 /**
+1093 * generate an array of falses with specified length<br/>
+1094 * @name newFalseArray
+1095 * @memberOf KJUR.asn1.DERBitString
+1096 * @function
+1097 * @param {Integer} nLength length of array to generate
+1098 * @return {array} array of boolean falses
+1099 * @description
+1100 * This static method may be useful to initialize boolean array.
+1101 * @example
+1102 * o = new KJUR.asn1.DERBitString();
+1103 * o.newFalseArray(3) → [false, false, false]
+1104 */
+1105 this.newFalseArray = function(nLength) {
+1106 var a = new Array(nLength);
+1107 for (var i = 0; i < nLength; i++) {
+1108 a[i] = false;
+1109 }
+1110 return a;
+1111 };
+1112
+1113 this.getFreshValueHex = function() {
+1114 return this.hV;
+1115 };
+1116
+1117 if (typeof params != "undefined") {
+1118 if (typeof params == "string" && params.toLowerCase().match(/^[0-9a-f]+$/)) {
+1119 this.setHexValueIncludingUnusedBits(params);
+1120 } else if (typeof params['hex'] != "undefined") {
+1121 this.setHexValueIncludingUnusedBits(params['hex']);
+1122 } else if (typeof params['bin'] != "undefined") {
+1123 this.setByBinaryString(params['bin']);
+1124 } else if (typeof params['array'] != "undefined") {
+1125 this.setByBooleanArray(params['array']);
+1126 }
+1127 }
+1128 };
+1129 extendClass(KJUR.asn1.DERBitString, KJUR.asn1.ASN1Object);
+1130
+1131 // ********************************************************************
+1132 /**
+1133 * class for ASN.1 DER OctetString<br/>
+1134 * @name KJUR.asn1.DEROctetString
+1135 * @class class for ASN.1 DER OctetString
+1136 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1137 * @extends KJUR.asn1.DERAbstractString
+1138 * @description
+1139 * This class provides ASN.1 OctetString simple type.<br/>
+1140 * Supported "params" attributes are:
+1141 * <ul>
+1142 * <li>str - to set a string as a value</li>
+1143 * <li>hex - to set a hexadecimal string as a value</li>
+1144 * <li>obj - to set a encapsulated ASN.1 value by JSON object
+1145 * which is defined in {@link KJUR.asn1.ASN1Util.newObject}</li>
+1146 * </ul>
+1147 * NOTE: A parameter 'obj' have been supported
+1148 * for "OCTET STRING, encapsulates" structure.
+1149 * since asn1 1.0.11, jsrsasign 6.1.1 (2016-Sep-25).
+1150 * @see KJUR.asn1.DERAbstractString - superclass
+1151 * @example
+1152 * // default constructor
+1153 * o = new KJUR.asn1.DEROctetString();
+1154 * // initialize with string
+1155 * o = new KJUR.asn1.DEROctetString({str: "aaa"});
+1156 * // initialize with hexadecimal string
+1157 * o = new KJUR.asn1.DEROctetString({hex: "616161"});
+1158 * // initialize with ASN1Util.newObject argument
+1159 * o = new KJUR.asn1.DEROctetString({obj: {seq: [{int: 3}, {prnstr: 'aaa'}]}});
+1160 * // above generates a ASN.1 data like this:
+1161 * // OCTET STRING, encapsulates {
+1162 * // SEQUENCE {
+1163 * // INTEGER 3
+1164 * // PrintableString 'aaa'
+1165 * // }
+1166 * // }
+1167 */
+1168 KJUR.asn1.DEROctetString = function(params) {
+1169 if (params !== undefined && typeof params.obj !== "undefined") {
+1170 var o = KJUR.asn1.ASN1Util.newObject(params.obj);
+1171 params.hex = o.tohex();
+1172 }
+1173 KJUR.asn1.DEROctetString.superclass.constructor.call(this, params);
+1174 this.hT = "04";
+1175 };
+1176 extendClass(KJUR.asn1.DEROctetString, KJUR.asn1.DERAbstractString);
+1177
+1178 // ********************************************************************
+1179 /**
+1180 * class for ASN.1 DER Null
+1181 * @name KJUR.asn1.DERNull
+1182 * @class class for ASN.1 DER Null
+1183 * @extends KJUR.asn1.ASN1Object
+1184 * @description
+1185 * @see KJUR.asn1.ASN1Object - superclass
+1186 */
+1187 KJUR.asn1.DERNull = function() {
+1188 KJUR.asn1.DERNull.superclass.constructor.call(this);
+1189 this.hT = "05";
+1190 this.hTLV = "0500";
+1191 };
+1192 extendClass(KJUR.asn1.DERNull, KJUR.asn1.ASN1Object);
+1193
+1194 // ********************************************************************
+1195 /**
+1196 * class for ASN.1 DER ObjectIdentifier
+1197 * @name KJUR.asn1.DERObjectIdentifier
+1198 * @class class for ASN.1 DER ObjectIdentifier
+1199 * @param {Object} JSON object or string of parameters (ex. {'oid': '2.5.4.5'})
+1200 * @extends KJUR.asn1.ASN1Object
+1201 * @see oidtohex
+1202 *
+1203 * @description
+1204 * <br/>
+1205 * As for argument 'params' for constructor, you can specify one of
+1206 * following properties:
+1207 * <ul>
+1208 * <li>oid - specify initial ASN.1 value(V) by a oid string (ex. 2.5.4.13)</li>
+1209 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+1210 * </ul>
+1211 * NOTE: 'params' can be omitted.
+1212 * @example
+1213 * new DERObjectIdentifier({"name": "sha1"})
+1214 * new DERObjectIdentifier({"oid": "1.2.3.4"})
+1215 * new DERObjectIdentifier({"hex": "2d..."})
+1216 * new DERObjectIdentifier("1.2.3.4")
+1217 * new DERObjectIdentifier("SHA1withRSA")
+1218 */
+1219 KJUR.asn1.DERObjectIdentifier = function(params) {
+1220 KJUR.asn1.DERObjectIdentifier.superclass.constructor.call(this);
+1221 this.hT = "06";
+1222
+1223 /**
+1224 * set value by a hexadecimal string
+1225 * @name setValueHex
+1226 * @memberOf KJUR.asn1.DERObjectIdentifier#
+1227 * @function
+1228 * @param {String} newHexString hexadecimal value of OID bytes
+1229 */
+1230 this.setValueHex = function(newHexString) {
+1231 this.hTLV = null;
+1232 this.isModified = true;
+1233 this.s = null;
+1234 this.hV = newHexString;
+1235 };
+1236
+1237 /**
+1238 * set value by a OID string<br/>
+1239 * @name setValueOidString
+1240 * @memberOf KJUR.asn1.DERObjectIdentifier#
+1241 * @function
+1242 * @param {String} oidString OID string (ex. 2.5.4.13)
+1243 * @example
+1244 * o = new KJUR.asn1.DERObjectIdentifier();
+1245 * o.setValueOidString("2.5.4.13");
+1246 */
+1247 this.setValueOidString = function(oidString) {
+1248 var h = oidtohex(oidString);
+1249 if (h == null)
+1250 throw new Error("malformed oid string: " + oidString);
+1251 this.hTLV = null;
+1252 this.isModified = true;
+1253 this.s = null;
+1254 this.hV = h;
+1255 };
+1256
+1257 /**
+1258 * set value by a OID name
+1259 * @name setValueName
+1260 * @memberOf KJUR.asn1.DERObjectIdentifier#
+1261 * @function
+1262 * @param {String} oidName OID name (ex. 'serverAuth')
+1263 * @since 1.0.1
+1264 * @description
+1265 * OID name shall be defined in 'KJUR.asn1.x509.OID.name2oidList'.
+1266 * Otherwise raise error.
+1267 * @example
+1268 * o = new KJUR.asn1.DERObjectIdentifier();
+1269 * o.setValueName("serverAuth");
+1270 */
+1271 this.setValueName = function(oidName) {
+1272 var oid = KJUR.asn1.x509.OID.name2oid(oidName);
+1273 if (oid !== '') {
+1274 this.setValueOidString(oid);
+1275 } else {
+1276 throw new Error("DERObjectIdentifier oidName undefined: " + oidName);
+1277 }
+1278 };
+1279
+1280 this.setValueNameOrOid = function(nameOrOid) {
+1281 if (nameOrOid.match(/^[0-2].[0-9.]+$/)) {
+1282 this.setValueOidString(nameOrOid);
+1283 } else {
+1284 this.setValueName(nameOrOid);
+1285 }
+1286 }
+1287
+1288 this.getFreshValueHex = function() {
+1289 return this.hV;
+1290 };
+1291
+1292 this.setByParam = function(params) {
+1293 if (typeof params === "string") {
+1294 this.setValueNameOrOid(params);
+1295 } else if (params.oid !== undefined) {
+1296 this.setValueNameOrOid(params.oid);
+1297 } else if (params.name !== undefined) {
+1298 this.setValueNameOrOid(params.name);
+1299 } else if (params.hex !== undefined) {
+1300 this.setValueHex(params.hex);
+1301 }
+1302 };
+1303
+1304 if (params !== undefined) this.setByParam(params);
+1305 };
+1306 extendClass(KJUR.asn1.DERObjectIdentifier, KJUR.asn1.ASN1Object);
+1307
+1308 // ********************************************************************
+1309 /**
+1310 * class for ASN.1 DER Enumerated
+1311 * @name KJUR.asn1.DEREnumerated
+1312 * @class class for ASN.1 DER Enumerated
+1313 * @extends KJUR.asn1.ASN1Object
+1314 * @description
+1315 * <br/>
+1316 * As for argument 'params' for constructor, you can specify one of
+1317 * following properties:
+1318 * <ul>
+1319 * <li>int - specify initial ASN.1 value(V) by integer value</li>
+1320 * <li>hex - specify initial ASN.1 value(V) by a hexadecimal string</li>
+1321 * </ul>
+1322 * NOTE: 'params' can be omitted.
+1323 * @example
+1324 * new KJUR.asn1.DEREnumerated(123);
+1325 * new KJUR.asn1.DEREnumerated({int: 123});
+1326 * new KJUR.asn1.DEREnumerated({hex: '1fad'});
+1327 */
+1328 KJUR.asn1.DEREnumerated = function(params) {
+1329 KJUR.asn1.DEREnumerated.superclass.constructor.call(this);
+1330 this.hT = "0a";
+1331
+1332 /**
+1333 * set value by Tom Wu's BigInteger object
+1334 * @name setByBigInteger
+1335 * @memberOf KJUR.asn1.DEREnumerated#
+1336 * @function
+1337 * @param {BigInteger} bigIntegerValue to set
+1338 */
+1339 this.setByBigInteger = function(bigIntegerValue) {
+1340 this.hTLV = null;
+1341 this.isModified = true;
+1342 this.hV = KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(bigIntegerValue);
+1343 };
+1344
+1345 /**
+1346 * set value by integer value
+1347 * @name setByInteger
+1348 * @memberOf KJUR.asn1.DEREnumerated#
+1349 * @function
+1350 * @param {Integer} integer value to set
+1351 */
+1352 this.setByInteger = function(intValue) {
+1353 var bi = new BigInteger(String(intValue), 10);
+1354 this.setByBigInteger(bi);
+1355 };
+1356
+1357 /**
+1358 * set value by integer value
+1359 * @name setValueHex
+1360 * @memberOf KJUR.asn1.DEREnumerated#
+1361 * @function
+1362 * @param {String} hexadecimal string of integer value
+1363 * @description
+1364 * <br/>
+1365 * NOTE: Value shall be represented by minimum octet length of
+1366 * two's complement representation.
+1367 */
+1368 this.setValueHex = function(newHexString) {
+1369 this.hV = newHexString;
+1370 };
+1371
+1372 this.getFreshValueHex = function() {
+1373 return this.hV;
+1374 };
+1375
+1376 if (typeof params != "undefined") {
+1377 if (typeof params['int'] != "undefined") {
+1378 this.setByInteger(params['int']);
+1379 } else if (typeof params == "number") {
+1380 this.setByInteger(params);
+1381 } else if (typeof params['hex'] != "undefined") {
+1382 this.setValueHex(params['hex']);
+1383 }
+1384 }
+1385 };
+1386 extendClass(KJUR.asn1.DEREnumerated, KJUR.asn1.ASN1Object);
+1387
+1388 // ********************************************************************
+1389 /**
+1390 * class for ASN.1 DER UTF8String
+1391 * @name KJUR.asn1.DERUTF8String
+1392 * @class class for ASN.1 DER UTF8String
+1393 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1394 * @extends KJUR.asn1.DERAbstractString
+1395 * @description
+1396 * @see KJUR.asn1.DERAbstractString - superclass
+1397 */
+1398 KJUR.asn1.DERUTF8String = function(params) {
+1399 KJUR.asn1.DERUTF8String.superclass.constructor.call(this, params);
+1400 this.hT = "0c";
+1401 };
+1402 extendClass(KJUR.asn1.DERUTF8String, KJUR.asn1.DERAbstractString);
+1403
+1404 // ********************************************************************
+1405 /**
+1406 * class for ASN.1 DER NumericString
+1407 * @name KJUR.asn1.DERNumericString
+1408 * @class class for ASN.1 DER NumericString
+1409 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1410 * @extends KJUR.asn1.DERAbstractString
+1411 * @description
+1412 * @see KJUR.asn1.DERAbstractString - superclass
+1413 */
+1414 KJUR.asn1.DERNumericString = function(params) {
+1415 KJUR.asn1.DERNumericString.superclass.constructor.call(this, params);
+1416 this.hT = "12";
+1417 };
+1418 extendClass(KJUR.asn1.DERNumericString, KJUR.asn1.DERAbstractString);
+1419
+1420 // ********************************************************************
+1421 /**
+1422 * class for ASN.1 DER PrintableString
+1423 * @name KJUR.asn1.DERPrintableString
+1424 * @class class for ASN.1 DER PrintableString
+1425 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1426 * @extends KJUR.asn1.DERAbstractString
+1427 * @description
+1428 * @see KJUR.asn1.DERAbstractString - superclass
+1429 */
+1430 KJUR.asn1.DERPrintableString = function(params) {
+1431 KJUR.asn1.DERPrintableString.superclass.constructor.call(this, params);
+1432 this.hT = "13";
+1433 };
+1434 extendClass(KJUR.asn1.DERPrintableString, KJUR.asn1.DERAbstractString);
+1435
+1436 // ********************************************************************
+1437 /**
+1438 * class for ASN.1 DER TeletexString
+1439 * @name KJUR.asn1.DERTeletexString
+1440 * @class class for ASN.1 DER TeletexString
+1441 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1442 * @extends KJUR.asn1.DERAbstractString
+1443 * @description
+1444 * @see KJUR.asn1.DERAbstractString - superclass
+1445 */
+1446 KJUR.asn1.DERTeletexString = function(params) {
+1447 KJUR.asn1.DERTeletexString.superclass.constructor.call(this, params);
+1448 this.hT = "14";
+1449 };
+1450 extendClass(KJUR.asn1.DERTeletexString, KJUR.asn1.DERAbstractString);
+1451
+1452 // ********************************************************************
+1453 /**
+1454 * class for ASN.1 DER IA5String
+1455 * @name KJUR.asn1.DERIA5String
+1456 * @class class for ASN.1 DER IA5String
+1457 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1458 * @extends KJUR.asn1.DERAbstractString
+1459 * @description
+1460 * @see KJUR.asn1.DERAbstractString - superclass
+1461 */
+1462 KJUR.asn1.DERIA5String = function(params) {
+1463 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
+1464 this.hT = "16";
+1465 };
+1466 extendClass(KJUR.asn1.DERIA5String, KJUR.asn1.DERAbstractString);
+1467
+1468 // ********************************************************************
+1469 /**
+1470 * class for ASN.1 DER VisibleString
+1471 * @name KJUR.asn1.DERVisibleString
+1472 * @class class for ASN.1 DER VisibleString
+1473 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1474 * @extends KJUR.asn1.DERAbstractString
+1475 * @since jsrsasign 8.0.23 asn1 1.0.15
+1476 * @description
+1477 * @see KJUR.asn1.DERAbstractString - superclass
+1478 */
+1479 KJUR.asn1.DERVisibleString = function(params) {
+1480 KJUR.asn1.DERIA5String.superclass.constructor.call(this, params);
+1481 this.hT = "1a";
+1482 };
+1483 extendClass(KJUR.asn1.DERVisibleString, KJUR.asn1.DERAbstractString);
+1484
+1485 // ********************************************************************
+1486 /**
+1487 * class for ASN.1 DER BMPString
+1488 * @name KJUR.asn1.DERBMPString
+1489 * @class class for ASN.1 DER BMPString
+1490 * @param {Array} params associative array of parameters (ex. {'str': 'aaa'})
+1491 * @extends KJUR.asn1.DERAbstractString
+1492 * @since jsrsasign 8.0.23 asn1 1.0.15
+1493 * @description
+1494 * @see KJUR.asn1.DERAbstractString - superclass
+1495 */
+1496 KJUR.asn1.DERBMPString = function(params) {
+1497 KJUR.asn1.DERBMPString.superclass.constructor.call(this, params);
+1498 this.hT = "1e";
+1499 };
+1500 extendClass(KJUR.asn1.DERBMPString, KJUR.asn1.DERAbstractString);
+1501
+1502 // ********************************************************************
+1503 /**
+1504 * class for ASN.1 DER UTCTime
+1505 * @name KJUR.asn1.DERUTCTime
+1506 * @class class for ASN.1 DER UTCTime
+1507 * @param {Array} params associative array of parameters (ex. {'str': '130430235959Z'})
+1508 * @extends KJUR.asn1.DERAbstractTime
+1509 * @see KJUR.asn1.DERGeneralizedTime
+1510 * @see KJUR.asn1.x509.Time
+1511 *
+1512 * @description
+1513 * <br/>
+1514 * As for argument 'params' for constructor, you can specify one of
+1515 * following properties:
+1516 * <ul>
+1517 * <li>str - specify initial ASN.1 value(V) by a string (ex.'130430235959Z')</li>
+1518 * <li>date - specify Date object.</li>
+1519 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
+1520 * </ul>
+1521 * NOTE1: 'params' can be omitted.
+1522 * NOTE2: 'millis' property is supported from jsrsasign 10.4.1 asn1 1.0.22.
+1523 *
+1524 * <h4>EXAMPLES</h4>
+1525 * @example
+1526 * new DERUTCTime("20151231235959Z")
+1527 * new DERUTCTime("20151231235959.123Z")
+1528 * new DERUTCTime(new Date())
+1529 * new DERUTCTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
+1530 * new DERUTCTime({str: "20151231235959.123Z"})
+1531 * new DERUTCTime({date: new Date()})
+1532 * new DERUTCTime({date: new Date(), millis: true})
+1533 * new DERUTCTime({millis: true})
+1534 */
+1535 KJUR.asn1.DERUTCTime = function(params) {
+1536 KJUR.asn1.DERUTCTime.superclass.constructor.call(this, params);
+1537 this.hT = "17";
+1538 this.params = undefined;
1539
-1540 if (this.params == undefined) params = { date: new Date() };
-1541
-1542 if (typeof params == "string") {
-1543 if (params.match(/^[0-9]{12}Z$/) ||
-1544 params.match(/^[0-9]{12}\.[0-9]+Z$/)) {
-1545 this.hV = stohex(params);
-1546 } else {
-1547 throw new Error("malformed string for GeneralizedTime: " + params);
-1548 }
-1549 } else if (params.str != undefined) {
-1550 this.hV = stohex(params.str);
-1551 } else if (params.date == undefined && params.millis == true) {
-1552 var date = new Date();
-1553 this.hV = stohex(this.formatDate(date, 'utc', true));
-1554 } else if (params.date != undefined &&
-1555 params.date instanceof Date) {
-1556 var withMillis = (params.millis === true);
-1557 this.hV = stohex(this.formatDate(params.date, 'utc', withMillis));
-1558 } else if (params instanceof Date) {
-1559 this.hV = stohex(this.formatDate(params, 'utc'));
-1560 }
-1561
-1562 if (this.hV == undefined) {
-1563 throw new Error("parameter not specified properly for UTCTime");
-1564 }
-1565 return this.hV;
-1566 };
-1567
-1568 if (params != undefined) this.setByParam(params);
-1569 };
-1570 extendClass(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
-1571
-1572 // ********************************************************************
-1573 /**
-1574 * class for ASN.1 DER GeneralizedTime
-1575 * @name KJUR.asn1.DERGeneralizedTime
-1576 * @class class for ASN.1 DER GeneralizedTime
-1577 * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
-1578 * @property {Boolean} withMillis flag to show milliseconds or not
-1579 * @extends KJUR.asn1.DERAbstractTime
-1580 * @see KJUR.asn1.DERUTCTime
-1581 * @see KJUR.asn1.x509.Time
-1582 *
-1583 * @description
-1584 * <br/>
-1585 * As for argument 'params' for constructor, you can specify one of
-1586 * following properties:
-1587 * <ul>
-1588 * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
-1589 * <li>date - specify Date object.</li>
-1590 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
-1591 * </ul>
-1592 * NOTE1: 'params' can be omitted.
-1593 * NOTE2: 'millis' property is supported from asn1 1.0.6.
-1594 *
-1595 * <h4>EXAMPLES</h4>
-1596 * @example
-1597 * new DERGeneralizedTime("20151231235959Z")
-1598 * new DERGeneralizedTime("20151231235959.123Z")
-1599 * new DERGeneralizedTime(new Date())
-1600 * new DERGeneralizedTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
-1601 * new DERGeneralizedTime({str: "20151231235959.123Z"})
-1602 * new DERGeneralizedTime({date: new Date()})
-1603 * new DERGeneralizedTime({date: new Date(), millis: true})
-1604 * new DERGeneralizedTime({millis: true})
-1605 */
-1606 KJUR.asn1.DERGeneralizedTime = function(params) {
-1607 KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
-1608 this.hT = "18";
-1609 this.params = params;
-1610
-1611 this.getFreshValueHex = function() {
-1612 var params = this.params;
+1540 this.getFreshValueHex = function() {
+1541 var params = this.params;
+1542
+1543 if (this.params == undefined) params = { date: new Date() };
+1544
+1545 if (typeof params == "string") {
+1546 if (params.match(/^[0-9]{12}Z$/) ||
+1547 params.match(/^[0-9]{12}\.[0-9]+Z$/)) {
+1548 this.hV = stohex(params);
+1549 } else {
+1550 throw new Error("malformed string for UTCTime: " + params);
+1551 }
+1552 } else if (params.str != undefined) {
+1553 this.hV = stohex(params.str);
+1554 } else if (params.date == undefined && params.millis == true) {
+1555 var date = new Date();
+1556 this.hV = stohex(this.formatDate(date, 'utc', true));
+1557 } else if (params.date != undefined &&
+1558 params.date instanceof Date) {
+1559 var withMillis = (params.millis === true);
+1560 this.hV = stohex(this.formatDate(params.date, 'utc', withMillis));
+1561 } else if (params instanceof Date) {
+1562 this.hV = stohex(this.formatDate(params, 'utc'));
+1563 }
+1564
+1565 if (this.hV == undefined) {
+1566 throw new Error("parameter not specified properly for UTCTime");
+1567 }
+1568 return this.hV;
+1569 };
+1570
+1571 if (params != undefined) this.setByParam(params);
+1572 };
+1573 extendClass(KJUR.asn1.DERUTCTime, KJUR.asn1.DERAbstractTime);
+1574
+1575 // ********************************************************************
+1576 /**
+1577 * class for ASN.1 DER GeneralizedTime
+1578 * @name KJUR.asn1.DERGeneralizedTime
+1579 * @class class for ASN.1 DER GeneralizedTime
+1580 * @param {Array} params associative array of parameters (ex. {'str': '20130430235959Z'})
+1581 * @property {Boolean} withMillis flag to show milliseconds or not
+1582 * @extends KJUR.asn1.DERAbstractTime
+1583 * @see KJUR.asn1.DERUTCTime
+1584 * @see KJUR.asn1.x509.Time
+1585 *
+1586 * @description
+1587 * <br/>
+1588 * As for argument 'params' for constructor, you can specify one of
+1589 * following properties:
+1590 * <ul>
+1591 * <li>str - specify initial ASN.1 value(V) by a string (ex.'20130430235959Z')</li>
+1592 * <li>date - specify Date object.</li>
+1593 * <li>millis - specify flag to show milliseconds (from 1.0.6)</li>
+1594 * </ul>
+1595 * NOTE1: 'params' can be omitted.
+1596 * NOTE2: 'millis' property is supported from asn1 1.0.6.
+1597 *
+1598 * <h4>EXAMPLES</h4>
+1599 * @example
+1600 * new DERGeneralizedTime("20151231235959Z")
+1601 * new DERGeneralizedTime("20151231235959.123Z")
+1602 * new DERGeneralizedTime(new Date())
+1603 * new DERGeneralizedTime(new Date(Date.UTC(2015,11,31,23,59,59,123)))
+1604 * new DERGeneralizedTime({str: "20151231235959.123Z"})
+1605 * new DERGeneralizedTime({date: new Date()})
+1606 * new DERGeneralizedTime({date: new Date(), millis: true})
+1607 * new DERGeneralizedTime({millis: true})
+1608 */
+1609 KJUR.asn1.DERGeneralizedTime = function(params) {
+1610 KJUR.asn1.DERGeneralizedTime.superclass.constructor.call(this, params);
+1611 this.hT = "18";
+1612 this.params = params;
1613
-1614 if (this.params == undefined) params = { date: new Date() };
-1615
-1616 if (typeof params == "string") {
-1617 if (params.match(/^[0-9]{14}Z$/) ||
-1618 params.match(/^[0-9]{14}\.[0-9]+Z$/)) {
-1619 this.hV = stohex(params);
-1620 } else {
-1621 throw new Error("malformed string for GeneralizedTime: " + params);
-1622 }
-1623 } else if (params.str != undefined) {
-1624 this.hV = stohex(params.str);
-1625 } else if (params.date == undefined && params.millis == true) {
-1626 var date = new Date();
-1627 this.hV = stohex(this.formatDate(date, 'gen', true));
-1628 } else if (params.date != undefined &&
-1629 params.date instanceof Date) {
-1630 var withMillis = (params.millis === true);
-1631 this.hV = stohex(this.formatDate(params.date, 'gen', withMillis));
-1632 } else if (params instanceof Date) {
-1633 this.hV = stohex(this.formatDate(params, 'gen'));
-1634 }
-1635
-1636 if (this.hV == undefined) {
-1637 throw new Error("parameter not specified properly for GeneralizedTime");
-1638 }
-1639 return this.hV;
-1640 };
-1641
-1642 if (params != undefined) this.setByParam(params);
-1643 };
-1644 extendClass(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
-1645
-1646 // ********************************************************************
-1647 /**
-1648 * class for ASN.1 DER Sequence
-1649 * @name KJUR.asn1.DERSequence
-1650 * @class class for ASN.1 DER Sequence
-1651 * @extends KJUR.asn1.DERAbstractStructured
-1652 * @description
-1653 * <br/>
-1654 * As for argument 'params' for constructor, you can specify one of
-1655 * following properties:
-1656 * <ul>
-1657 * <li>array - specify array of ASN1Object to set elements of content</li>
-1658 * </ul>
-1659 * NOTE: 'params' can be omitted.
-1660 */
-1661 KJUR.asn1.DERSequence = function(params) {
-1662 KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
-1663 this.hT = "30";
-1664 this.getFreshValueHex = function() {
-1665 var h = '';
-1666 for (var i = 0; i < this.asn1Array.length; i++) {
-1667 var asn1Obj = this.asn1Array[i];
-1668 h += asn1Obj.getEncodedHex();
-1669 }
-1670 this.hV = h;
-1671 return this.hV;
-1672 };
-1673 };
-1674 extendClass(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
-1675
-1676 // ********************************************************************
-1677 /**
-1678 * class for ASN.1 DER Set
-1679 * @name KJUR.asn1.DERSet
-1680 * @class class for ASN.1 DER Set
-1681 * @extends KJUR.asn1.DERAbstractStructured
-1682 * @description
-1683 * <br/>
-1684 * As for argument 'params' for constructor, you can specify one of
-1685 * following properties:
-1686 * <ul>
-1687 * <li>array - specify array of ASN1Object to set elements of content</li>
-1688 * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
-1689 * </ul>
-1690 * NOTE1: 'params' can be omitted.<br/>
-1691 * NOTE2: sortflag is supported since 1.0.5.
-1692 */
-1693 KJUR.asn1.DERSet = function(params) {
-1694 KJUR.asn1.DERSet.superclass.constructor.call(this, params);
-1695 this.hT = "31";
-1696 this.sortFlag = true; // item shall be sorted only in ASN.1 DER
-1697 this.getFreshValueHex = function() {
-1698 var a = new Array();
-1699 for (var i = 0; i < this.asn1Array.length; i++) {
-1700 var asn1Obj = this.asn1Array[i];
-1701 a.push(asn1Obj.getEncodedHex());
-1702 }
-1703 if (this.sortFlag == true) a.sort();
-1704 this.hV = a.join('');
-1705 return this.hV;
-1706 };
-1707
-1708 if (typeof params != "undefined") {
-1709 if (typeof params.sortflag != "undefined" &&
-1710 params.sortflag == false)
-1711 this.sortFlag = false;
-1712 }
-1713 };
-1714 extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
-1715
-1716 // ********************************************************************
-1717 /**
-1718 * class for ASN.1 DER TaggedObject
-1719 * @name KJUR.asn1.DERTaggedObject
-1720 * @class class for ASN.1 DER TaggedObject
-1721 * @extends KJUR.asn1.ASN1Object
-1722 *
-1723 * @description
-1724 * <br/>
-1725 * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
-1726 * For example, if you find '[1]' tag in a ASN.1 dump,
-1727 * 'tagNoHex' will be 'a1'.
-1728 * <br/>
-1729 * As for optional argument 'params' for constructor, you can specify *ANY* of
-1730 * following properties:
-1731 * <ul>
-1732 * <li>tag - specify tag (default is 'a0' which means [0])</li>
-1733 * <li>explicit - specify true if this is explicit tag otherwise false
-1734 * (default is 'true').</li>
-1735 * <li>obj - specify ASN1Object which is tagged</li>
-1736 * <li>tage - specify tag with explicit</li>
-1737 * <li>tagi - specify tag with implicit</li>
-1738 * </ul>
-1739 *
-1740 * @example
-1741 * new KJUR.asn1.DERTaggedObject({
-1742 * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
-1743 * })
+1614 this.getFreshValueHex = function() {
+1615 var params = this.params;
+1616
+1617 if (this.params == undefined) params = { date: new Date() };
+1618
+1619 if (typeof params == "string") {
+1620 if (params.match(/^[0-9]{14}Z$/) ||
+1621 params.match(/^[0-9]{14}\.[0-9]+Z$/)) {
+1622 this.hV = stohex(params);
+1623 } else {
+1624 throw new Error("malformed string for GeneralizedTime: " + params);
+1625 }
+1626 } else if (params.str != undefined) {
+1627 this.hV = stohex(params.str);
+1628 } else if (params.date == undefined && params.millis == true) {
+1629 var date = new Date();
+1630 this.hV = stohex(this.formatDate(date, 'gen', true));
+1631 } else if (params.date != undefined &&
+1632 params.date instanceof Date) {
+1633 var withMillis = (params.millis === true);
+1634 this.hV = stohex(this.formatDate(params.date, 'gen', withMillis));
+1635 } else if (params instanceof Date) {
+1636 this.hV = stohex(this.formatDate(params, 'gen'));
+1637 }
+1638
+1639 if (this.hV == undefined) {
+1640 throw new Error("parameter not specified properly for GeneralizedTime");
+1641 }
+1642 return this.hV;
+1643 };
+1644
+1645 if (params != undefined) this.setByParam(params);
+1646 };
+1647 extendClass(KJUR.asn1.DERGeneralizedTime, KJUR.asn1.DERAbstractTime);
+1648
+1649 // ********************************************************************
+1650 /**
+1651 * class for ASN.1 DER Sequence
+1652 * @name KJUR.asn1.DERSequence
+1653 * @class class for ASN.1 DER Sequence
+1654 * @extends KJUR.asn1.DERAbstractStructured
+1655 * @description
+1656 * <br/>
+1657 * As for argument 'params' for constructor, you can specify one of
+1658 * following properties:
+1659 * <ul>
+1660 * <li>array - specify array of ASN1Object to set elements of content</li>
+1661 * </ul>
+1662 * NOTE: 'params' can be omitted.
+1663 */
+1664 KJUR.asn1.DERSequence = function(params) {
+1665 KJUR.asn1.DERSequence.superclass.constructor.call(this, params);
+1666 this.hT = "30";
+1667 this.getFreshValueHex = function() {
+1668 var h = '';
+1669 for (var i = 0; i < this.asn1Array.length; i++) {
+1670 var asn1Obj = this.asn1Array[i];
+1671 h += asn1Obj.tohex();
+1672 }
+1673 this.hV = h;
+1674 return this.hV;
+1675 };
+1676 };
+1677 extendClass(KJUR.asn1.DERSequence, KJUR.asn1.DERAbstractStructured);
+1678
+1679 // ********************************************************************
+1680 /**
+1681 * class for ASN.1 DER Set
+1682 * @name KJUR.asn1.DERSet
+1683 * @class class for ASN.1 DER Set
+1684 * @extends KJUR.asn1.DERAbstractStructured
+1685 * @description
+1686 * <br/>
+1687 * As for argument 'params' for constructor, you can specify one of
+1688 * following properties:
+1689 * <ul>
+1690 * <li>array - specify array of ASN1Object to set elements of content</li>
+1691 * <li>sortflag - flag for sort (default: true). ASN.1 BER is not sorted in 'SET OF'.</li>
+1692 * </ul>
+1693 * NOTE1: 'params' can be omitted.<br/>
+1694 * NOTE2: sortflag is supported since 1.0.5.
+1695 */
+1696 KJUR.asn1.DERSet = function(params) {
+1697 KJUR.asn1.DERSet.superclass.constructor.call(this, params);
+1698 this.hT = "31";
+1699 this.sortFlag = true; // item shall be sorted only in ASN.1 DER
+1700 this.getFreshValueHex = function() {
+1701 var a = new Array();
+1702 for (var i = 0; i < this.asn1Array.length; i++) {
+1703 var asn1Obj = this.asn1Array[i];
+1704 a.push(asn1Obj.tohex());
+1705 }
+1706 if (this.sortFlag == true) a.sort();
+1707 this.hV = a.join('');
+1708 return this.hV;
+1709 };
+1710
+1711 if (typeof params != "undefined") {
+1712 if (typeof params.sortflag != "undefined" &&
+1713 params.sortflag == false)
+1714 this.sortFlag = false;
+1715 }
+1716 };
+1717 extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured);
+1718
+1719 // ********************************************************************
+1720 /**
+1721 * class for ASN.1 DER TaggedObject
+1722 * @name KJUR.asn1.DERTaggedObject
+1723 * @class class for ASN.1 DER TaggedObject
+1724 * @extends KJUR.asn1.ASN1Object
+1725 *
+1726 * @description
+1727 * <br/>
+1728 * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object.
+1729 * For example, if you find '[1]' tag in a ASN.1 dump,
+1730 * 'tagNoHex' will be 'a1'.
+1731 * <br/>
+1732 * As for optional argument 'params' for constructor, you can specify *ANY* of
+1733 * following properties:
+1734 * <ul>
+1735 * <li>tag - specify tag (default is 'a0' which means [0])</li>
+1736 * <li>explicit - specify true if this is explicit tag otherwise false
+1737 * (default is 'true').</li>
+1738 * <li>obj - specify ASN1Object which is tagged</li>
+1739 * <li>tage - specify tag with explicit</li>
+1740 * <li>tagi - specify tag with implicit</li>
+1741 * </ul>
+1742 *
+1743 * @example
1744 * new KJUR.asn1.DERTaggedObject({
-1745 * tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit
+1745 * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
1746 * })
1747 * new KJUR.asn1.DERTaggedObject({
-1748 * tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
+1748 * tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit
1749 * })
-1750 *
-1751 * // to hexadecimal
-1752 * d1 = new KJUR.asn1.DERUTF8String({str':'a'})
-1753 * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
-1754 * hex = d2.getEncodedHex();
-1755 */
-1756 KJUR.asn1.DERTaggedObject = function(params) {
-1757 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
-1758
-1759 var _KJUR_asn1 = KJUR.asn1,
-1760 _ASN1HEX = ASN1HEX,
-1761 _getV = _ASN1HEX.getV,
-1762 _isASN1HEX = _ASN1HEX.isASN1HEX,
-1763 _newObject = _KJUR_asn1.ASN1Util.newObject;
-1764
-1765 this.hT = "a0";
-1766 this.hV = '';
-1767 this.isExplicit = true;
-1768 this.asn1Object = null;
-1769 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true};
-1770
-1771 /**
-1772 * set value by an ASN1Object
-1773 * @name setString
-1774 * @memberOf KJUR.asn1.DERTaggedObject#
-1775 * @function
-1776 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
-1777 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
-1778 * @param {ASN1Object} asn1Object ASN.1 to encapsulate
-1779 * @deprecated since jsrsasign 10.5.4 please use setByParam instead
-1780 */
-1781 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
-1782 this.params = {tag: tagNoHex,
-1783 explicit: isExplicitFlag,
-1784 obj: asn1Object};
-1785 };
-1786
-1787 this.getFreshValueHex = function() {
-1788 var params = this.params;
+1750 * new KJUR.asn1.DERTaggedObject({
+1751 * tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
+1752 * })
+1753 *
+1754 * // to hexadecimal
+1755 * d1 = new KJUR.asn1.DERUTF8String({str':'a'})
+1756 * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1});
+1757 * hex = d2.tohex();
+1758 */
+1759 KJUR.asn1.DERTaggedObject = function(params) {
+1760 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this);
+1761
+1762 var _KJUR_asn1 = KJUR.asn1,
+1763 _ASN1HEX = ASN1HEX,
+1764 _getV = _ASN1HEX.getV,
+1765 _isASN1HEX = _ASN1HEX.isASN1HEX,
+1766 _newObject = _KJUR_asn1.ASN1Util.newObject;
+1767
+1768 this.hT = "a0";
+1769 this.hV = '';
+1770 this.isExplicit = true;
+1771 this.asn1Object = null;
+1772 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true};
+1773
+1774 /**
+1775 * set value by an ASN1Object
+1776 * @name setString
+1777 * @memberOf KJUR.asn1.DERTaggedObject#
+1778 * @function
+1779 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag
+1780 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag
+1781 * @param {ASN1Object} asn1Object ASN.1 to encapsulate
+1782 * @deprecated since jsrsasign 10.5.4 please use setByParam instead
+1783 */
+1784 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) {
+1785 this.params = {tag: tagNoHex,
+1786 explicit: isExplicitFlag,
+1787 obj: asn1Object};
+1788 };
1789
-1790 if (params.explicit == undefined) params.explicit = true;
-1791
-1792 if (params.tage != undefined) {
-1793 params.tag = params.tage;
-1794 params.explicit = true;
-1795 }
-1796 if (params.tagi != undefined) {
-1797 params.tag = params.tagi;
-1798 params.explicit = false;
-1799 }
-1800
-1801 if (params.str != undefined) {
-1802 this.hV = utf8tohex(params.str);
-1803 } else if (params.hex != undefined) {
-1804 this.hV = params.hex;
-1805 } else if (params.obj != undefined) {
-1806 var hV1;
-1807 if (params.obj instanceof _KJUR_asn1.ASN1Object) {
-1808 hV1 = params.obj.getEncodedHex();
-1809 } else if (typeof params.obj == "object") {
-1810 hV1 = _newObject(params.obj).getEncodedHex();
-1811 }
-1812 if (params.explicit) {
-1813 this.hV = hV1;
-1814 } else {
-1815 this.hV = _getV(hV1, 0);
-1816 }
-1817 } else {
-1818 throw new Error("str, hex nor obj not specified");
-1819 }
-1820
-1821 if (params.tag == undefined) params.tag = "a0";
-1822 this.hT = params.tag;
-1823 this.hTLV = null;
-1824 this.isModified = true;
-1825
-1826 return this.hV;
-1827 };
+1790 this.getFreshValueHex = function() {
+1791 var params = this.params;
+1792
+1793 if (params.explicit == undefined) params.explicit = true;
+1794
+1795 if (params.tage != undefined) {
+1796 params.tag = params.tage;
+1797 params.explicit = true;
+1798 }
+1799 if (params.tagi != undefined) {
+1800 params.tag = params.tagi;
+1801 params.explicit = false;
+1802 }
+1803
+1804 if (params.str != undefined) {
+1805 this.hV = utf8tohex(params.str);
+1806 } else if (params.hex != undefined) {
+1807 this.hV = params.hex;
+1808 } else if (params.obj != undefined) {
+1809 var hV1;
+1810 if (params.obj instanceof _KJUR_asn1.ASN1Object) {
+1811 hV1 = params.obj.tohex();
+1812 } else if (typeof params.obj == "object") {
+1813 hV1 = _newObject(params.obj).tohex();
+1814 }
+1815 if (params.explicit) {
+1816 this.hV = hV1;
+1817 } else {
+1818 this.hV = _getV(hV1, 0);
+1819 }
+1820 } else {
+1821 throw new Error("str, hex nor obj not specified");
+1822 }
+1823
+1824 if (params.tag == undefined) params.tag = "a0";
+1825 this.hT = params.tag;
+1826 this.hTLV = null;
+1827 this.isModified = true;
1828
-1829 this.setByParam = function(params) {
-1830 this.params = params;
-1831 };
-1832
-1833 if (params !== undefined) this.setByParam(params);
-1834 };
-1835 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object);
-1836 | |