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