diff --git a/ChangeLog.txt b/ChangeLog.txt index 76b27532..e927b560 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,13 +1,31 @@ ChangeLog for jsrsasign -extend CertificationRequestInfo class for challengePassword and unstructuredName -* Changes from 10.5.26 to 10.5.27 (2022-Aug-19) - - src/asn1csr.js - - CertificationRequestInfo class - - add support for challengePassword and unstructuredName (#522) - - "attrs" member support in constructure argument - - test/qunit-do-asn1csr.html +StringPrep DN canonicalization support and some fix +* Changes from 10.5.27 to 10.6.0 (2022-Nov-04) + - x509.js + - X509.getParam + - add support for optional parameter "dncanon" and "dnhex" + - X509.getInfo + - update representation for AltName + - X509.{getIssuer,getSubect} + - add support for optional argument flagCanon, flagHex + - X509.c14RDNArray added to convert from RDN array to canonicalized + DN name (a.k.a. StringPrep). + - X509.getX500Name + - API document updated + - X509.getOtherName + - member name changed from "other" to "value" for + consistency with KJUR.asn1.x509.OtherName class constructor. + - Also oid member value in return object will be an oid name if defined. + - X509.setCanonicalizedDN added to set "canon" member value + - asn1x509.js + - smtpUTF8Mailbox oid added to OID class + - API document fix + - asn1.js + - DERTaggedObject API document update + - test/qunit-do-{asn1x509,x509-ext,x509-getinfo,x509-param,x509}.html + - update some test cases for above CSRUtil class enhancement * Changes from 10.5.25 to 10.5.26 (2022-Jul-14) diff --git a/api/files.html b/api/files.html index 4cf8c7c5..938d4037 100644 --- a/api/files.html +++ b/api/files.html @@ -662,7 +662,7 @@

asn1x509-1.0.js

Version:
-
jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24)
+
jsrsasign 10.6.0 asn1x509 2.1.17 (2022-Nov-04)
@@ -890,7 +890,7 @@

x509-1.1.js

Version:
-
jsrsasign 10.5.24 x509 2.0.17 (2022-Jun-04)
+
jsrsasign 10.6.0 x509 2.1.0 (2022-Nov-04)
diff --git a/api/symbols/KJUR.asn1.DERTaggedObject.html b/api/symbols/KJUR.asn1.DERTaggedObject.html index b8046599..0d4c4538 100644 --- a/api/symbols/KJUR.asn1.DERTaggedObject.html +++ b/api/symbols/KJUR.asn1.DERTaggedObject.html @@ -639,16 +639,24 @@

  • tag - specify tag (default is 'a0' which means [0])
  • explicit - specify true if this is explicit tag otherwise false (default is 'true').
  • -
  • obj - specify ASN1Object which is tagged
  • +
  • obj - specify ASN1Object or JSON object which will be tagged
  • tage - specify tag with explicit
  • tagi - specify tag with implicit
  • +As for the member "obj" value of JSON object, +KJUR_asn1.ASN1Util.newObject is used to generate. -
    new KJUR.asn1.DERTaggedObject({
    +				
    // by JSON
    +new KJUR.asn1.DERTaggedObject({
    + tag:'a0', explicit: true, obj: { "prnstr": { "str": "aaa" } }
    +}).tohex()
    +
    +// by ASN1Object object
    +new KJUR.asn1.DERTaggedObject({
      tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit
     }) 
     new KJUR.asn1.DERTaggedObject({
    @@ -673,6 +681,13 @@ 

    +
    +
    See:
    + +
    KJUR_asn1.ASN1Util.newObject
    + +
    + diff --git a/api/symbols/KJUR.asn1.x509.GeneralName.html b/api/symbols/KJUR.asn1.x509.GeneralName.html index fd9c71ba..be0d1140 100644 --- a/api/symbols/KJUR.asn1.x509.GeneralName.html +++ b/api/symbols/KJUR.asn1.x509.GeneralName.html @@ -648,7 +648,7 @@

    gn = new KJUR.asn1.x509.GeneralName({uri: 'http://aaa.com/'}); gn = new KJUR.asn1.x509.GeneralName({other: { oid: "1.2.3.4", - value: {utf8: "example"} // any ASN.1 which passed to ASN1Util.newObject + value: {utf8str: "example"} // any ASN.1 which passed to ASN1Util.newObject }}); gn = new KJUR.asn1.x509.GeneralName({ldapdn: 'O=Test,C=US'}); // DEPRECATED diff --git a/api/symbols/KJUR.asn1.x509.OtherName.html b/api/symbols/KJUR.asn1.x509.OtherName.html index 6a81c8d8..bc7c91cf 100644 --- a/api/symbols/KJUR.asn1.x509.OtherName.html +++ b/api/symbols/KJUR.asn1.x509.OtherName.html @@ -589,7 +589,7 @@

    Constructor has two members:
    • oid - oid string (ex. "1.2.3.4")
    • -
    • value - associative array passed to ASN1Util.newObject
    • +
    • value - JSON object passed to ASN1Util.newObject or ASN1Object object
    diff --git a/api/symbols/X509.html b/api/symbols/X509.html
    index 69d8fcac..8377152f 100644
    --- a/api/symbols/X509.html
    +++ b/api/symbols/X509.html
    @@ -643,6 +643,23 @@ 

    + +   + +
    c14nRDNArray(aRDN) +
    +
    simple canonicalization(c14n) for RDN array
    +This method canonicalizes a DN string according to + +"RFC 4518 StringPrep Appendix B Substring Matching" as following: +
      +
    • convert to lower case
    • +
    • convert from all sequence of spaces to a space
    • +
    • remove leading and trailing spaces
    • +
    + + +   @@ -1053,10 +1070,10 @@

      -
    getIssuer() +
    getIssuer(flagCanon, flagHex)
    get JSON object of issuer field
    -
    +Get a JSON object of an issuer field.
    @@ -1275,10 +1292,10 @@

      -
    getSubject() +
    getSubject(flagCanon, flagHex)
    get JSON object of subject field
    -
    +Get a JSON object of a subject field.
    @@ -1325,7 +1342,7 @@

      -
    getX500Name(h) +
    getX500Name(h, flagCanon, flagHex)
    get Name ASN.1 structure parameter array
    This method will get Name parameter defined in @@ -1409,6 +1426,20 @@

    + +   + + +
    set canonicalized DN to a DN parameter
    +This method canonicalizes a DN string as following: +
      +
    • convert to lower case
    • +
    • convert from all multiple spaces to a space
    • +
    + + +   @@ -1632,7 +1663,7 @@

    x = new X509();
     x.getOtherName("30...") →
     { oid: "1.2.3.4",
    -  other: {utf8str: {str: "aaa"}} }
    + value: {utf8str: {str: "aaa"}} }

    @@ -1715,6 +1746,72 @@

    Method Detail + +
    + + {string} + c14nRDNArray(aRDN) + +
    +
    + simple canonicalization(c14n) for RDN array
    +This method canonicalizes a DN string according to + +"RFC 4518 StringPrep Appendix B Substring Matching" as following: +
      +
    • convert to lower case
    • +
    • convert from all sequence of spaces to a space
    • +
    • remove leading and trailing spaces
    • +
    + + +
    + + + +
    var x = new X509();
    +x.c14nRDNArray([
    +  [{type:"C", value:"JP", ds: "prn"}],
    +  [{type:"O", value:"    Test    1234     ", ds: "utf8"}],
    +  [{type:"OU", value:"HR   45", ds: "utf8"}]
    +]) → "/c=jp/o=test 1234/ou=hr 45"
    + + + + +
    +
    Parameters:
    + +
    + {array} aRDN + +
    +
    array of RDN parameters
    + +
    + + + +
    +
    Since:
    +
    jsrsasign 10.6.0 x509 2.1.0
    +
    + + + + +
    +
    Returns:
    + +
    {string} canonicalized distinguish name (ex. "/c=jp/o=test ca")
    + +
    + + + + +
    +
    @@ -4534,12 +4631,17 @@

    {Array} - getIssuer() + getIssuer(flagCanon, flagHex)
    get JSON object of issuer field
    - +Get a JSON object of an issuer field. +
    +NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been +supported to conclude a canonicalized name for caseIgnoreMatch +desribed in +RFC 4518.
    @@ -4549,11 +4651,35 @@

    var x = new X509(sCertPEM);
     x.getIssuer() →
     { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    -  str: "/C=JP/..." }
    + str: "/C=JP/..." } + +// with flags +x.getIssuer(true, true) → +{ array: ..., + str: "/C=JP/O= Test 123 ", + canon: "/c=jp/o=test 123", + hex: "30..." }

    +
    +
    Parameters:
    + +
    + {boolean} flagCanon + +
    +
    flag to conclude canonicalized name (DEFAULT false)
    + +
    + {boolean} flagHex + +
    +
    flag to conclude hexadecimal string (DEFAULT false)
    + +
    +
    @@ -4755,15 +4881,20 @@

    This method returns a JSON object of the certificate parameters. Return value can be passed to KJUR.asn1.x509.X509Util.newCertPEM. -
    +
    NOTE1: From jsrsasign 10.5.16, optional argument can be applied. It can have following members:
      -
    • tbshex - if this is true, tbshex member with hex value of -tbsCertificate will be added
    • -
    • nodnarray - if this is true, array member for subject and -issuer will be deleted to simplify it
    • +
    • tbshex - (boolean) tbshex member with hex value of +tbsCertificate will be added if true (DEFAULT undefined)
    • +
    • nodnarray - (boolean) array member for subject and +issuer will be deleted to simplify it if true (DEFAULT undefined)
    • +
    • dncanon - (boolean) add canon member to subject and issuer for DN StringPrep if true(DEFAULT undefined)
    • +
    • dnhex - (boolean) add hex member to subject and issuer if true(DEFAULT undefined)
    +
    +NOTE2: From jsrsasign 10.6.0, member "dncanon" and "dnhex" supported +in the "option" argument. @@ -4793,7 +4924,9 @@

    }; x.getParam({tbshex: true}) → { ... , tbshex: "30..." } -x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...}

    +x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...} +x.getParam({dncanon: true}) → {... {issuer: {canon: "/c=jp/o=..."} ...} ...} +x.getParam({dnhex: true}) → {... {issuer: {hex: "30..."} ...} ...} @@ -5716,13 +5849,18 @@

    - {Array} - getSubject() + {object} + getSubject(flagCanon, flagHex)
    get JSON object of subject field
    - +Get a JSON object of a subject field. +
    +NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been +supported to conclude a canonicalized name for caseIgnoreMatch +desribed in +RFC 4518.
    @@ -5732,11 +5870,35 @@

    var x = new X509(sCertPEM);
     x.getSubject() →
     { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    -  str: "/C=JP/..." }
    + str: "/C=JP/..." } + +// with flags +x.getSubject(true, true) → +{ array: ..., + str: "/C=JP/O= Test 123 ", + canon: "/c=jp/o=test 123", + hex: "30..." } +
    +
    Parameters:
    + +
    + {boolean} flagCanon + +
    +
    flag to conclude canonicalized name (DEFAULT false)
    + +
    + {boolean} flagHex + +
    +
    flag to conclude hexadecimal string (DEFAULT false)
    + +
    +
    @@ -5750,7 +5912,7 @@

    Returns:
    -
    {Array} JSON object of subject field
    +
    {object} JSON object of subject field
    @@ -5983,7 +6145,7 @@

    {Array} - getX500Name(h) + getX500Name(h, flagCanon, flagHex)
    @@ -5996,6 +6158,11 @@

    rdnSequence RDNSequence } RDNSequence ::= SEQUENCE OF RelativeDistinguishedName +
    +NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been +supported to conclude a canonicalized name for caseIgnoreMatch +desribed in +RFC 4518.

    @@ -6010,8 +6177,16 @@

    [{type:"CN",value:"john.smith@example.com",ds:"ia5"}] ], str: "/C=US/O=Sample Corp./CN=john.smith@example.com", - hex: "30..." -} + hex: "30..." } + +x.getX500Name("30...", true) → +{ array: [ + [{type:"C",value:"US",ds:"prn"}], + [{type:"O",value:"Sample Corp.",ds:"utf8"}] + ], + str: "/C=US/O=Sample Corp.", + canon: "/c=us/o=sample corp.", + hex: "30..." } @@ -6025,6 +6200,18 @@

    hexadecimal string of Name
    +
    + {boolean} flagCanon + +
    +
    flag to conclude canonicalized name (DEFAULT false)
    + +
    + {boolean} flagHex + +
    +
    flag to conclude hexadecimal string (DEFAULT false)
    +

    @@ -6055,6 +6242,8 @@

    X509#getAttrTypeAndValue
    +
    X509#c14nRDNArray
    +
    KJUR.asn1.x509.X500Name
    KJUR.asn1.x509.GeneralName
    @@ -6479,6 +6668,70 @@

    +
    + + +
    + + + setCanonicalizedDN(pDN) + +
    +
    + set canonicalized DN to a DN parameter
    +This method canonicalizes a DN string as following: + + + +
    + + + +
    var x = new X509();
    +var pDN = {
    +  array: [
    +    [{type:'C',value:'JP',ds:'prn'}],
    +    [{type:'O',value:'Test    1',ds:'prn'}] ],
    +  str: "/C=JP/O=Test    1" };
    +x.setCanonicalizedDN(pDN);
    +// pDN will become following
    +pDN = {
    +  array: [
    +    [{type:'C',value:'JP',ds:'prn'}],
    +    [{type:'O',value:'Test    1',ds:'prn'}] ],
    +  str: "/C=JP/O=Test    1",
    +  canon: "/c=jp/o=test 1" };
    + + + + +
    +
    Parameters:
    + +
    + {object} pDN + +
    +
    DN parameter associative array
    + +
    + + + +
    +
    Since:
    +
    jsrsasign 10.6.0 x509 2.1.0
    +
    + + + + + + +
    diff --git a/api/symbols/src/asn1-1.0.js.html b/api/symbols/src/asn1-1.0.js.html index b3a9cb62..edbab84f 100644 --- a/api/symbols/src/asn1-1.0.js.html +++ b/api/symbols/src/asn1-1.0.js.html @@ -1731,118 +1731,127 @@ 1724 * @name KJUR.asn1.DERTaggedObject 1725 * @class class for ASN.1 DER TaggedObject 1726 * @extends KJUR.asn1.ASN1Object -1727 * -1728 * @description -1729 * <br/> -1730 * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object. -1731 * For example, if you find '[1]' tag in a ASN.1 dump, -1732 * 'tagNoHex' will be 'a1'. -1733 * <br/> -1734 * As for optional argument 'params' for constructor, you can specify *ANY* of -1735 * following properties: -1736 * <ul> -1737 * <li>tag - specify tag (default is 'a0' which means [0])</li> -1738 * <li>explicit - specify true if this is explicit tag otherwise false -1739 * (default is 'true').</li> -1740 * <li>obj - specify ASN1Object which is tagged</li> -1741 * <li>tage - specify tag with explicit</li> -1742 * <li>tagi - specify tag with implicit</li> -1743 * </ul> -1744 * -1745 * @example -1746 * new KJUR.asn1.DERTaggedObject({ -1747 * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit -1748 * }) -1749 * new KJUR.asn1.DERTaggedObject({ -1750 * tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit -1751 * }) -1752 * new KJUR.asn1.DERTaggedObject({ -1753 * tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit -1754 * }) -1755 * -1756 * // to hexadecimal -1757 * d1 = new KJUR.asn1.DERUTF8String({str':'a'}) -1758 * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1}); -1759 * hex = d2.tohex(); -1760 */ -1761 KJUR.asn1.DERTaggedObject = function(params) { -1762 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this); -1763 -1764 var _KJUR_asn1 = KJUR.asn1, -1765 _ASN1HEX = ASN1HEX, -1766 _getV = _ASN1HEX.getV, -1767 _isASN1HEX = _ASN1HEX.isASN1HEX, -1768 _newObject = _KJUR_asn1.ASN1Util.newObject; -1769 -1770 this.hT = "a0"; -1771 this.hV = ''; -1772 this.isExplicit = true; -1773 this.asn1Object = null; -1774 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true}; -1775 -1776 /** -1777 * set value by an ASN1Object -1778 * @name setString -1779 * @memberOf KJUR.asn1.DERTaggedObject# -1780 * @function -1781 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag -1782 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag -1783 * @param {ASN1Object} asn1Object ASN.1 to encapsulate -1784 * @deprecated since jsrsasign 10.5.4 please use setByParam instead -1785 */ -1786 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) { -1787 this.params = {tag: tagNoHex, -1788 explicit: isExplicitFlag, -1789 obj: asn1Object}; -1790 }; -1791 -1792 this.getFreshValueHex = function() { -1793 var params = this.params; -1794 -1795 if (params.explicit == undefined) params.explicit = true; -1796 -1797 if (params.tage != undefined) { -1798 params.tag = params.tage; -1799 params.explicit = true; -1800 } -1801 if (params.tagi != undefined) { -1802 params.tag = params.tagi; -1803 params.explicit = false; -1804 } +1727 * @see KJUR_asn1.ASN1Util.newObject +1728 * +1729 * @description +1730 * <br/> +1731 * Parameter 'tagNoNex' is ASN.1 tag(T) value for this object. +1732 * For example, if you find '[1]' tag in a ASN.1 dump, +1733 * 'tagNoHex' will be 'a1'. +1734 * <br/> +1735 * As for optional argument 'params' for constructor, you can specify *ANY* of +1736 * following properties: +1737 * <ul> +1738 * <li>tag - specify tag (default is 'a0' which means [0])</li> +1739 * <li>explicit - specify true if this is explicit tag otherwise false +1740 * (default is 'true').</li> +1741 * <li>obj - specify ASN1Object or JSON object which will be tagged</li> +1742 * <li>tage - specify tag with explicit</li> +1743 * <li>tagi - specify tag with implicit</li> +1744 * </ul> +1745 * As for the member "obj" value of JSON object, +1746 * {@link KJUR_asn1.ASN1Util.newObject} is used to generate. +1747 * +1748 * @example +1749 * // by JSON +1750 * new KJUR.asn1.DERTaggedObject({ +1751 * tag:'a0', explicit: true, obj: { "prnstr": { "str": "aaa" } } +1752 * }).tohex() +1753 * +1754 * // by ASN1Object object +1755 * new KJUR.asn1.DERTaggedObject({ +1756 * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit +1757 * }) +1758 * new KJUR.asn1.DERTaggedObject({ +1759 * tagi:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // implicit +1760 * }) +1761 * new KJUR.asn1.DERTaggedObject({ +1762 * tag:'a0', explicit: true, obj: new KJUR.asn1.DERInteger({int: 3}) // explicit +1763 * }) +1764 * +1765 * // to hexadecimal +1766 * d1 = new KJUR.asn1.DERUTF8String({str':'a'}) +1767 * d2 = new KJUR.asn1.DERTaggedObject({'obj': d1}); +1768 * hex = d2.tohex(); +1769 */ +1770 KJUR.asn1.DERTaggedObject = function(params) { +1771 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this); +1772 +1773 var _KJUR_asn1 = KJUR.asn1, +1774 _ASN1HEX = ASN1HEX, +1775 _getV = _ASN1HEX.getV, +1776 _isASN1HEX = _ASN1HEX.isASN1HEX, +1777 _newObject = _KJUR_asn1.ASN1Util.newObject; +1778 +1779 this.hT = "a0"; +1780 this.hV = ''; +1781 this.isExplicit = true; +1782 this.asn1Object = null; +1783 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true}; +1784 +1785 /** +1786 * set value by an ASN1Object +1787 * @name setString +1788 * @memberOf KJUR.asn1.DERTaggedObject# +1789 * @function +1790 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag +1791 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag +1792 * @param {ASN1Object} asn1Object ASN.1 to encapsulate +1793 * @deprecated since jsrsasign 10.5.4 please use setByParam instead +1794 */ +1795 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) { +1796 this.params = {tag: tagNoHex, +1797 explicit: isExplicitFlag, +1798 obj: asn1Object}; +1799 }; +1800 +1801 this.getFreshValueHex = function() { +1802 var params = this.params; +1803 +1804 if (params.explicit == undefined) params.explicit = true; 1805 -1806 if (params.str != undefined) { -1807 this.hV = utf8tohex(params.str); -1808 } else if (params.hex != undefined) { -1809 this.hV = params.hex; -1810 } else if (params.obj != undefined) { -1811 var hV1; -1812 if (params.obj instanceof _KJUR_asn1.ASN1Object) { -1813 hV1 = params.obj.tohex(); -1814 } else if (typeof params.obj == "object") { -1815 hV1 = _newObject(params.obj).tohex(); -1816 } -1817 if (params.explicit) { -1818 this.hV = hV1; -1819 } else { -1820 this.hV = _getV(hV1, 0); -1821 } -1822 } else { -1823 throw new Error("str, hex nor obj not specified"); -1824 } -1825 -1826 if (params.tag == undefined) params.tag = "a0"; -1827 this.hT = params.tag; -1828 this.hTLV = null; -1829 this.isModified = true; -1830 -1831 return this.hV; -1832 }; -1833 -1834 this.setByParam = function(params) { -1835 this.params = params; -1836 }; -1837 -1838 if (params !== undefined) this.setByParam(params); -1839 }; -1840 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object); -1841 \ No newline at end of file +1806 if (params.tage != undefined) { +1807 params.tag = params.tage; +1808 params.explicit = true; +1809 } +1810 if (params.tagi != undefined) { +1811 params.tag = params.tagi; +1812 params.explicit = false; +1813 } +1814 +1815 if (params.str != undefined) { +1816 this.hV = utf8tohex(params.str); +1817 } else if (params.hex != undefined) { +1818 this.hV = params.hex; +1819 } else if (params.obj != undefined) { +1820 var hV1; +1821 if (params.obj instanceof _KJUR_asn1.ASN1Object) { +1822 hV1 = params.obj.tohex(); +1823 } else if (typeof params.obj == "object") { +1824 hV1 = _newObject(params.obj).tohex(); +1825 } +1826 if (params.explicit) { +1827 this.hV = hV1; +1828 } else { +1829 this.hV = _getV(hV1, 0); +1830 } +1831 } else { +1832 throw new Error("str, hex nor obj not specified"); +1833 } +1834 +1835 if (params.tag == undefined) params.tag = "a0"; +1836 this.hT = params.tag; +1837 this.hTLV = null; +1838 this.isModified = true; +1839 +1840 return this.hV; +1841 }; +1842 +1843 this.setByParam = function(params) { +1844 this.params = params; +1845 }; +1846 +1847 if (params !== undefined) this.setByParam(params); +1848 }; +1849 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object); +1850 \ No newline at end of file diff --git a/api/symbols/src/asn1x509-1.0.js.html b/api/symbols/src/asn1x509-1.0.js.html index a18ad3d2..b8e6c2c0 100644 --- a/api/symbols/src/asn1x509-1.0.js.html +++ b/api/symbols/src/asn1x509-1.0.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
      1 /* asn1x509-2.1.16.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
    +	
      1 /* asn1x509-2.1.17.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
       2  */
       3 /*
       4  * asn1x509.js - ASN.1 DER encoder classes for X.509 certificate
    @@ -23,7 +23,7 @@
      16  * @fileOverview
      17  * @name asn1x509-1.0.js
      18  * @author Kenji Urushima kenji.urushima@gmail.com
    - 19  * @version jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24)
    + 19  * @version jsrsasign 10.6.0 asn1x509 2.1.17 (2022-Nov-04)
      20  * @since jsrsasign 2.1
      21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
      22  */
    @@ -4015,7 +4015,7 @@
     4008  * gn = new KJUR.asn1.x509.GeneralName({uri:    'http://aaa.com/'});
     4009  * gn = new KJUR.asn1.x509.GeneralName({other: {
     4010  *   oid: "1.2.3.4",
    -4011  *   value: {utf8: "example"} // any ASN.1 which passed to ASN1Util.newObject
    +4011  *   value: {utf8str: "example"} // any ASN.1 which passed to ASN1Util.newObject
     4012  * }});
     4013  *
     4014  * gn = new KJUR.asn1.x509.GeneralName({ldapdn:     'O=Test,C=US'}); // DEPRECATED
    @@ -4207,7 +4207,7 @@
     4200  * Constructor has two members:
     4201  * <ul>
     4202  * <li>oid - oid string (ex. "1.2.3.4")</li>
    -4203  * <li>value - associative array passed to ASN1Util.newObject</li>
    +4203  * <li>value - JSON object passed to ASN1Util.newObject or ASN1Object object</li>
     4204  * </ul>
     4205  *
     4206  * <pre>
    @@ -4386,379 +4386,382 @@
     4379         'timeStamping':         '1.3.6.1.5.5.7.3.8',
     4380         'ocspSigning':          '1.3.6.1.5.5.7.3.9',
     4381 
    -4382         'dateOfBirth':          '1.3.6.1.5.5.7.9.1',
    -4383         'placeOfBirth':         '1.3.6.1.5.5.7.9.2',
    -4384         'gender':               '1.3.6.1.5.5.7.9.3',
    -4385         'countryOfCitizenship': '1.3.6.1.5.5.7.9.4',
    -4386         'countryOfResidence':   '1.3.6.1.5.5.7.9.5',
    -4387 
    -4388         'ecPublicKey':          '1.2.840.10045.2.1',
    -4389         'P-256':                '1.2.840.10045.3.1.7',
    -4390         'secp256r1':            '1.2.840.10045.3.1.7',
    -4391         'secp256k1':            '1.3.132.0.10',
    -4392         'secp384r1':            '1.3.132.0.34',
    -4393         'secp521r1':            '1.3.132.0.35',
    -4394 
    -4395         'pkcs5PBES2':           '1.2.840.113549.1.5.13',
    -4396         'pkcs5PBKDF2':          '1.2.840.113549.1.5.12',
    +4382 	// 'otherNameForms':	'1.3.6.1.5.5.7.8',
    +4383 	'smtpUTF8Mailbox':	'1.3.6.1.5.5.7.8.9',
    +4384 
    +4385         'dateOfBirth':          '1.3.6.1.5.5.7.9.1',
    +4386         'placeOfBirth':         '1.3.6.1.5.5.7.9.2',
    +4387         'gender':               '1.3.6.1.5.5.7.9.3',
    +4388         'countryOfCitizenship': '1.3.6.1.5.5.7.9.4',
    +4389         'countryOfResidence':   '1.3.6.1.5.5.7.9.5',
    +4390 
    +4391         'ecPublicKey':          '1.2.840.10045.2.1',
    +4392         'P-256':                '1.2.840.10045.3.1.7',
    +4393         'secp256r1':            '1.2.840.10045.3.1.7',
    +4394         'secp256k1':            '1.3.132.0.10',
    +4395         'secp384r1':            '1.3.132.0.34',
    +4396         'secp521r1':            '1.3.132.0.35',
     4397 
    -4398         'des-EDE3-CBC':         '1.2.840.113549.3.7',
    -4399 
    -4400         'data':                 '1.2.840.113549.1.7.1', // CMS data
    -4401         'signed-data':          '1.2.840.113549.1.7.2', // CMS signed-data
    -4402         'enveloped-data':       '1.2.840.113549.1.7.3', // CMS enveloped-data
    -4403         'digested-data':        '1.2.840.113549.1.7.5', // CMS digested-data
    -4404         'encrypted-data':       '1.2.840.113549.1.7.6', // CMS encrypted-data
    -4405         'authenticated-data':   '1.2.840.113549.1.9.16.1.2', // CMS authenticated-data
    -4406         'tstinfo':              '1.2.840.113549.1.9.16.1.4', // RFC3161 TSTInfo
    -4407 	'signingCertificate':	'1.2.840.113549.1.9.16.2.12',// SMIME
    -4408 	'timeStampToken':	'1.2.840.113549.1.9.16.2.14',// sigTS
    -4409 	'signaturePolicyIdentifier':	'1.2.840.113549.1.9.16.2.15',// cades
    -4410 	'etsArchiveTimeStamp':	'1.2.840.113549.1.9.16.2.27',// SMIME
    -4411 	'signingCertificateV2':	'1.2.840.113549.1.9.16.2.47',// SMIME
    -4412 	'etsArchiveTimeStampV2':'1.2.840.113549.1.9.16.2.48',// SMIME
    -4413         'extensionRequest':     '1.2.840.113549.1.9.14',// CSR extensionRequest
    -4414 	'contentType':		'1.2.840.113549.1.9.3',//PKCS#9
    -4415 	'messageDigest':	'1.2.840.113549.1.9.4',//PKCS#9
    -4416 	'signingTime':		'1.2.840.113549.1.9.5',//PKCS#9
    -4417 	'counterSignature':	'1.2.840.113549.1.9.6',//PKCS#9
    -4418 	'archiveTimeStampV3':	'0.4.0.1733.2.4',//ETSI EN29319122/TS101733
    -4419 	'pdfRevocationInfoArchival':'1.2.840.113583.1.1.8', //Adobe
    -4420 	'adobeTimeStamp':	'1.2.840.113583.1.1.9.1', // Adobe
    -4421     };
    -4422 
    -4423     this.atype2oidList = {
    -4424 	// RFC 4514 AttributeType name string (MUST recognized)
    -4425         'CN':		'2.5.4.3',
    -4426         'L':		'2.5.4.7',
    -4427         'ST':		'2.5.4.8',
    -4428         'O':		'2.5.4.10',
    -4429         'OU':		'2.5.4.11',
    -4430         'C':		'2.5.4.6',
    -4431         'STREET':	'2.5.4.9',
    -4432         'DC':		'0.9.2342.19200300.100.1.25',
    -4433         'UID':		'0.9.2342.19200300.100.1.1',
    -4434 	// other AttributeType name string
    -4435 	// http://blog.livedoor.jp/k_urushima/archives/656114.html
    -4436         'SN':		'2.5.4.4', // surname
    -4437         'T':		'2.5.4.12', // title
    -4438         'DN':		'2.5.4.49', // distinguishedName
    -4439         'E':		'1.2.840.113549.1.9.1', // emailAddress in MS.NET or Bouncy
    -4440 	// other AttributeType name string (no short name)
    -4441 	'description':			'2.5.4.13',
    -4442 	'businessCategory':		'2.5.4.15',
    -4443 	'postalCode':			'2.5.4.17',
    -4444 	'serialNumber':			'2.5.4.5',
    -4445 	'uniqueIdentifier':		'2.5.4.45',
    -4446 	'organizationIdentifier':	'2.5.4.97',
    -4447 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
    -4448 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
    -4449 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3'
    -4450     };
    -4451     
    -4452     this.objCache = {};
    -4453 
    -4454     /**
    -4455      * get DERObjectIdentifier by registered OID name
    -4456      * @name name2obj
    -4457      * @memberOf KJUR.asn1.x509.OID
    -4458      * @function
    -4459      * @param {String} name OID
    -4460      * @return {Object} DERObjectIdentifier instance
    -4461      * @see KJUR.asn1.DERObjectIdentifier
    -4462      *
    -4463      * @description
    -4464      * This static method returns DERObjectIdentifier object
    -4465      * for the specified OID.
    -4466      *
    -4467      * @example
    -4468      * var asn1ObjOID = KJUR.asn1.x509.OID.name2obj('SHA1withRSA');
    -4469      */
    -4470     this.name2obj = function(name) {
    -4471         if (typeof this.objCache[name] != "undefined")
    -4472             return this.objCache[name];
    -4473         if (typeof this.name2oidList[name] == "undefined")
    -4474             throw "Name of ObjectIdentifier not defined: " + name;
    -4475         var oid = this.name2oidList[name];
    -4476         var obj = new _DERObjectIdentifier({'oid': oid});
    -4477         this.objCache[name] = obj;
    -4478         return obj;
    -4479     };
    -4480 
    -4481     /**
    -4482      * get DERObjectIdentifier by registered attribute type name such like 'C' or 'CN'<br/>
    -4483      * @name atype2obj
    -4484      * @memberOf KJUR.asn1.x509.OID
    -4485      * @function
    -4486      * @param {String} atype short attribute type name such like 'C', 'CN' or OID
    -4487      * @return KJUR.asn1.DERObjectIdentifier instance
    -4488      * @description
    -4489      * @example
    -4490      * KJUR.asn1.x509.OID.atype2obj('CN') → DERObjectIdentifier of 2.5.4.3
    -4491      * KJUR.asn1.x509.OID.atype2obj('OU') → DERObjectIdentifier of 2.5.4.11
    -4492      * KJUR.asn1.x509.OID.atype2obj('streetAddress') → DERObjectIdentifier of 2.5.4.9
    -4493      * KJUR.asn1.x509.OID.atype2obj('2.5.4.9') → DERObjectIdentifier of 2.5.4.9
    -4494      */
    -4495     this.atype2obj = function(atype) {
    -4496         if (this.objCache[atype] !== undefined)
    -4497             return this.objCache[atype];
    -4498 
    -4499 	var oid;
    -4500 
    -4501 	if (atype.match(/^\d+\.\d+\.[0-9.]+$/)) {
    -4502 	    oid = atype;
    -4503 	} else if (this.atype2oidList[atype] !== undefined) {
    -4504 	    oid = this.atype2oidList[atype];
    -4505 	} else if (this.name2oidList[atype] !== undefined) {
    -4506 	    oid = this.name2oidList[atype];
    -4507     	} else {
    -4508             throw new Error("AttributeType name undefined: " + atype);
    -4509 	}
    -4510         var obj = new _DERObjectIdentifier({'oid': oid});
    -4511         this.objCache[atype] = obj;
    -4512         return obj;
    -4513     };
    -4514 
    -4515     /**
    -4516      * register OID list<br/>
    -4517      * @name registerOIDs
    -4518      * @memberOf KJUR.asn1.x509.OID
    -4519      * @function
    -4520      * @param {object} oids associative array of names and oids
    -4521      * @since jsrsasign 10.5.2 asn1x509 2.1.11
    -4522      * @see KJUR.asn1.x509.OID.checkOIDs
    -4523      * 
    -4524      * @description
    -4525      * This static method to register an oids to existing list
    -4526      * additionally.
    -4527      *
    -4528      * @example
    -4529      * KJUR.asn1.x509.OID.checkOIDs({
    -4530      *   "test1": "4.5.7.8"
    -4531      * }) // do nothing for invalid list
    -4532      *
    -4533      * KJUR.asn1.x509.OID.registerOIDs({
    -4534      *   "test1": "1.2.3",
    -4535      *   "test2": "0.2.3.4.23",
    -4536      * }) // successfully registered
    -4537      *
    -4538      * KJUR.asn1.x509.OID.name2oid("test1") → "1.2.3"
    -4539      */
    -4540     this.registerOIDs = function(oids) {
    -4541 	if (! this.checkOIDs(oids)) return;
    -4542 	for (var name in oids) {
    -4543 	    this.name2oidList[name] = oids[name];
    -4544 	}
    -4545     };
    -4546 
    -4547     /**
    -4548      * check validity for OID list<br/>
    -4549      * @name checkOIDs
    -4550      * @memberOf KJUR.asn1.x509.OID
    -4551      * @function
    -4552      * @param {object} oids associative array of names and oids
    -4553      * @return {boolean} return true when valid OID list otherwise false
    -4554      * @since jsrsasign 10.5.2 asn1x509 2.1.11
    -4555      * @see KJUR.asn1.x509.OID.registOIDs
    -4556      * 
    -4557      * @description
    -4558      * This static method validates an associative array
    -4559      * as oid list.
    -4560      *
    -4561      * @example
    -4562      * KJUR.asn1.x509.OID.checkOIDs(*non-assoc-array*) → false
    -4563      * KJUR.asn1.x509.OID.checkOIDs({}) → false
    -4564      * KJUR.asn1.x509.OID.checkOIDs({"test1": "apple"}) → false
    -4565      * KJUR.asn1.x509.OID.checkOIDs({
    -4566      *   "test1": "1.2.3",
    -4567      *   "test2": "0.2.3.4.23",
    -4568      * }) → true // valid oids
    -4569      * KJUR.asn1.x509.OID.checkOIDs({
    -4570      *   "test1": "4.5.7.8"
    -4571      * }) → false // invalid oid
    -4572      */
    -4573     this.checkOIDs = function(oids) {
    -4574 	try {
    -4575 	    var nameList = Object.keys(oids);
    -4576 	    if (nameList.length == 0)
    -4577 		return false;
    -4578 	    nameList.map(function(value, index, array) {
    -4579 		var oid = this[value];
    -4580 		if (! oid.match(/^[0-2]\.[0-9.]+$/))
    -4581 		    throw new Error("value is not OID");
    -4582 	    }, oids);
    -4583 	    return true;
    -4584 	} catch(ex) {
    -4585 	    return false;
    -4586 	}
    -4587     };
    -4588 
    -4589 
    -4590 };
    +4398         'pkcs5PBES2':           '1.2.840.113549.1.5.13',
    +4399         'pkcs5PBKDF2':          '1.2.840.113549.1.5.12',
    +4400 
    +4401         'des-EDE3-CBC':         '1.2.840.113549.3.7',
    +4402 
    +4403         'data':                 '1.2.840.113549.1.7.1', // CMS data
    +4404         'signed-data':          '1.2.840.113549.1.7.2', // CMS signed-data
    +4405         'enveloped-data':       '1.2.840.113549.1.7.3', // CMS enveloped-data
    +4406         'digested-data':        '1.2.840.113549.1.7.5', // CMS digested-data
    +4407         'encrypted-data':       '1.2.840.113549.1.7.6', // CMS encrypted-data
    +4408         'authenticated-data':   '1.2.840.113549.1.9.16.1.2', // CMS authenticated-data
    +4409         'tstinfo':              '1.2.840.113549.1.9.16.1.4', // RFC3161 TSTInfo
    +4410 	'signingCertificate':	'1.2.840.113549.1.9.16.2.12',// SMIME
    +4411 	'timeStampToken':	'1.2.840.113549.1.9.16.2.14',// sigTS
    +4412 	'signaturePolicyIdentifier':	'1.2.840.113549.1.9.16.2.15',// cades
    +4413 	'etsArchiveTimeStamp':	'1.2.840.113549.1.9.16.2.27',// SMIME
    +4414 	'signingCertificateV2':	'1.2.840.113549.1.9.16.2.47',// SMIME
    +4415 	'etsArchiveTimeStampV2':'1.2.840.113549.1.9.16.2.48',// SMIME
    +4416         'extensionRequest':     '1.2.840.113549.1.9.14',// CSR extensionRequest
    +4417 	'contentType':		'1.2.840.113549.1.9.3',//PKCS#9
    +4418 	'messageDigest':	'1.2.840.113549.1.9.4',//PKCS#9
    +4419 	'signingTime':		'1.2.840.113549.1.9.5',//PKCS#9
    +4420 	'counterSignature':	'1.2.840.113549.1.9.6',//PKCS#9
    +4421 	'archiveTimeStampV3':	'0.4.0.1733.2.4',//ETSI EN29319122/TS101733
    +4422 	'pdfRevocationInfoArchival':'1.2.840.113583.1.1.8', //Adobe
    +4423 	'adobeTimeStamp':	'1.2.840.113583.1.1.9.1', // Adobe
    +4424     };
    +4425 
    +4426     this.atype2oidList = {
    +4427 	// RFC 4514 AttributeType name string (MUST recognized)
    +4428         'CN':		'2.5.4.3',
    +4429         'L':		'2.5.4.7',
    +4430         'ST':		'2.5.4.8',
    +4431         'O':		'2.5.4.10',
    +4432         'OU':		'2.5.4.11',
    +4433         'C':		'2.5.4.6',
    +4434         'STREET':	'2.5.4.9',
    +4435         'DC':		'0.9.2342.19200300.100.1.25',
    +4436         'UID':		'0.9.2342.19200300.100.1.1',
    +4437 	// other AttributeType name string
    +4438 	// http://blog.livedoor.jp/k_urushima/archives/656114.html
    +4439         'SN':		'2.5.4.4', // surname
    +4440         'T':		'2.5.4.12', // title
    +4441         'DN':		'2.5.4.49', // distinguishedName
    +4442         'E':		'1.2.840.113549.1.9.1', // emailAddress in MS.NET or Bouncy
    +4443 	// other AttributeType name string (no short name)
    +4444 	'description':			'2.5.4.13',
    +4445 	'businessCategory':		'2.5.4.15',
    +4446 	'postalCode':			'2.5.4.17',
    +4447 	'serialNumber':			'2.5.4.5',
    +4448 	'uniqueIdentifier':		'2.5.4.45',
    +4449 	'organizationIdentifier':	'2.5.4.97',
    +4450 	'jurisdictionOfIncorporationL':	'1.3.6.1.4.1.311.60.2.1.1',
    +4451 	'jurisdictionOfIncorporationSP':'1.3.6.1.4.1.311.60.2.1.2',
    +4452 	'jurisdictionOfIncorporationC':	'1.3.6.1.4.1.311.60.2.1.3'
    +4453     };
    +4454     
    +4455     this.objCache = {};
    +4456 
    +4457     /**
    +4458      * get DERObjectIdentifier by registered OID name
    +4459      * @name name2obj
    +4460      * @memberOf KJUR.asn1.x509.OID
    +4461      * @function
    +4462      * @param {String} name OID
    +4463      * @return {Object} DERObjectIdentifier instance
    +4464      * @see KJUR.asn1.DERObjectIdentifier
    +4465      *
    +4466      * @description
    +4467      * This static method returns DERObjectIdentifier object
    +4468      * for the specified OID.
    +4469      *
    +4470      * @example
    +4471      * var asn1ObjOID = KJUR.asn1.x509.OID.name2obj('SHA1withRSA');
    +4472      */
    +4473     this.name2obj = function(name) {
    +4474         if (typeof this.objCache[name] != "undefined")
    +4475             return this.objCache[name];
    +4476         if (typeof this.name2oidList[name] == "undefined")
    +4477             throw "Name of ObjectIdentifier not defined: " + name;
    +4478         var oid = this.name2oidList[name];
    +4479         var obj = new _DERObjectIdentifier({'oid': oid});
    +4480         this.objCache[name] = obj;
    +4481         return obj;
    +4482     };
    +4483 
    +4484     /**
    +4485      * get DERObjectIdentifier by registered attribute type name such like 'C' or 'CN'<br/>
    +4486      * @name atype2obj
    +4487      * @memberOf KJUR.asn1.x509.OID
    +4488      * @function
    +4489      * @param {String} atype short attribute type name such like 'C', 'CN' or OID
    +4490      * @return KJUR.asn1.DERObjectIdentifier instance
    +4491      * @description
    +4492      * @example
    +4493      * KJUR.asn1.x509.OID.atype2obj('CN') → DERObjectIdentifier of 2.5.4.3
    +4494      * KJUR.asn1.x509.OID.atype2obj('OU') → DERObjectIdentifier of 2.5.4.11
    +4495      * KJUR.asn1.x509.OID.atype2obj('streetAddress') → DERObjectIdentifier of 2.5.4.9
    +4496      * KJUR.asn1.x509.OID.atype2obj('2.5.4.9') → DERObjectIdentifier of 2.5.4.9
    +4497      */
    +4498     this.atype2obj = function(atype) {
    +4499         if (this.objCache[atype] !== undefined)
    +4500             return this.objCache[atype];
    +4501 
    +4502 	var oid;
    +4503 
    +4504 	if (atype.match(/^\d+\.\d+\.[0-9.]+$/)) {
    +4505 	    oid = atype;
    +4506 	} else if (this.atype2oidList[atype] !== undefined) {
    +4507 	    oid = this.atype2oidList[atype];
    +4508 	} else if (this.name2oidList[atype] !== undefined) {
    +4509 	    oid = this.name2oidList[atype];
    +4510     	} else {
    +4511             throw new Error("AttributeType name undefined: " + atype);
    +4512 	}
    +4513         var obj = new _DERObjectIdentifier({'oid': oid});
    +4514         this.objCache[atype] = obj;
    +4515         return obj;
    +4516     };
    +4517 
    +4518     /**
    +4519      * register OID list<br/>
    +4520      * @name registerOIDs
    +4521      * @memberOf KJUR.asn1.x509.OID
    +4522      * @function
    +4523      * @param {object} oids associative array of names and oids
    +4524      * @since jsrsasign 10.5.2 asn1x509 2.1.11
    +4525      * @see KJUR.asn1.x509.OID.checkOIDs
    +4526      * 
    +4527      * @description
    +4528      * This static method to register an oids to existing list
    +4529      * additionally.
    +4530      *
    +4531      * @example
    +4532      * KJUR.asn1.x509.OID.checkOIDs({
    +4533      *   "test1": "4.5.7.8"
    +4534      * }) // do nothing for invalid list
    +4535      *
    +4536      * KJUR.asn1.x509.OID.registerOIDs({
    +4537      *   "test1": "1.2.3",
    +4538      *   "test2": "0.2.3.4.23",
    +4539      * }) // successfully registered
    +4540      *
    +4541      * KJUR.asn1.x509.OID.name2oid("test1") → "1.2.3"
    +4542      */
    +4543     this.registerOIDs = function(oids) {
    +4544 	if (! this.checkOIDs(oids)) return;
    +4545 	for (var name in oids) {
    +4546 	    this.name2oidList[name] = oids[name];
    +4547 	}
    +4548     };
    +4549 
    +4550     /**
    +4551      * check validity for OID list<br/>
    +4552      * @name checkOIDs
    +4553      * @memberOf KJUR.asn1.x509.OID
    +4554      * @function
    +4555      * @param {object} oids associative array of names and oids
    +4556      * @return {boolean} return true when valid OID list otherwise false
    +4557      * @since jsrsasign 10.5.2 asn1x509 2.1.11
    +4558      * @see KJUR.asn1.x509.OID.registOIDs
    +4559      * 
    +4560      * @description
    +4561      * This static method validates an associative array
    +4562      * as oid list.
    +4563      *
    +4564      * @example
    +4565      * KJUR.asn1.x509.OID.checkOIDs(*non-assoc-array*) → false
    +4566      * KJUR.asn1.x509.OID.checkOIDs({}) → false
    +4567      * KJUR.asn1.x509.OID.checkOIDs({"test1": "apple"}) → false
    +4568      * KJUR.asn1.x509.OID.checkOIDs({
    +4569      *   "test1": "1.2.3",
    +4570      *   "test2": "0.2.3.4.23",
    +4571      * }) → true // valid oids
    +4572      * KJUR.asn1.x509.OID.checkOIDs({
    +4573      *   "test1": "4.5.7.8"
    +4574      * }) → false // invalid oid
    +4575      */
    +4576     this.checkOIDs = function(oids) {
    +4577 	try {
    +4578 	    var nameList = Object.keys(oids);
    +4579 	    if (nameList.length == 0)
    +4580 		return false;
    +4581 	    nameList.map(function(value, index, array) {
    +4582 		var oid = this[value];
    +4583 		if (! oid.match(/^[0-2]\.[0-9.]+$/))
    +4584 		    throw new Error("value is not OID");
    +4585 	    }, oids);
    +4586 	    return true;
    +4587 	} catch(ex) {
    +4588 	    return false;
    +4589 	}
    +4590     };
     4591 
    -4592 /**
    -4593  * convert OID to name<br/>
    -4594  * @name oid2name
    -4595  * @memberOf KJUR.asn1.x509.OID
    -4596  * @function
    -4597  * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4)
    -4598  * @return {String} OID name if registered otherwise empty string
    -4599  * @since asn1x509 1.0.9
    -4600  * @description
    -4601  * This static method converts OID string to its name.
    -4602  * If OID is undefined then it returns empty string (i.e. '').
    -4603  * @example
    -4604  * KJUR.asn1.x509.OID.oid2name("1.3.6.1.5.5.7.1.1") → 'authorityInfoAccess'
    -4605  */
    -4606 KJUR.asn1.x509.OID.oid2name = function(oid) {
    -4607     var list = KJUR.asn1.x509.OID.name2oidList;
    -4608     for (var name in list) {
    -4609         if (list[name] == oid) return name;
    -4610     }
    -4611     return '';
    -4612 };
    -4613 
    -4614 /**
    -4615  * convert OID to AttributeType name<br/>
    -4616  * @name oid2atype
    -4617  * @memberOf KJUR.asn1.x509.OID
    -4618  * @function
    -4619  * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4)
    -4620  * @return {String} OID AttributeType name if registered otherwise oid
    -4621  * @since jsrsasign 6.2.2 asn1x509 1.0.18
    -4622  * @description
    -4623  * This static method converts OID string to its AttributeType name.
    -4624  * If OID is not defined in OID.atype2oidList associative array then it returns OID
    -4625  * specified as argument.
    -4626  * @example
    -4627  * KJUR.asn1.x509.OID.oid2atype("2.5.4.3") → CN
    -4628  * KJUR.asn1.x509.OID.oid2atype("1.3.6.1.4.1.311.60.2.1.3") → jurisdictionOfIncorporationC
    -4629  * KJUR.asn1.x509.OID.oid2atype("0.1.2.3.4") → 0.1.2.3.4 // unregistered OID
    -4630  */
    -4631 KJUR.asn1.x509.OID.oid2atype = function(oid) {
    -4632     var list = KJUR.asn1.x509.OID.atype2oidList;
    -4633     for (var atype in list) {
    -4634         if (list[atype] == oid) return atype;
    -4635     }
    -4636     return oid;
    -4637 };
    -4638 
    -4639 /**
    -4640  * convert OID name to OID value<br/>
    -4641  * @name name2oid
    -4642  * @memberOf KJUR.asn1.x509.OID
    -4643  * @function
    -4644  * @param {String} name OID name or OID (ex. "sha1" or "1.2.3.4")
    -4645  * @return {String} dot noted Object Identifer string (ex. 1.2.3.4)
    -4646  * @since asn1x509 1.0.11
    -4647  * @description
    -4648  * This static method converts from OID name to OID string.
    -4649  * If OID is undefined then it returns empty string (i.e. '').
    -4650  * @example
    -4651  * KJUR.asn1.x509.OID.name2oid("authorityInfoAccess") → "1.3.6.1.5.5.7.1.1"
    -4652  * KJUR.asn1.x509.OID.name2oid("1.2.3.4") → "1.2.3.4"
    -4653  * KJUR.asn1.x509.OID.name2oid("UNKNOWN NAME") → ""
    -4654  */
    -4655 KJUR.asn1.x509.OID.name2oid = function(name) {
    -4656     if (name.match(/^[0-9.]+$/)) return name;
    -4657     var list = KJUR.asn1.x509.OID.name2oidList;
    -4658     if (list[name] === undefined) return '';
    -4659     return list[name];
    -4660 };
    -4661 
    -4662 /**
    -4663  * X.509 certificate and CRL utilities class<br/>
    -4664  * @name KJUR.asn1.x509.X509Util
    -4665  * @class X.509 certificate and CRL utilities class
    -4666  */
    -4667 KJUR.asn1.x509.X509Util = {};
    -4668 
    -4669 /**
    -4670  * issue a certificate in PEM format (DEPRECATED)
    -4671  * @name newCertPEM
    -4672  * @memberOf KJUR.asn1.x509.X509Util
    -4673  * @function
    -4674  * @param {Array} param JSON object of parameter to issue a certificate
    -4675  * @since asn1x509 1.0.6
    -4676  * @deprecated since jsrsasign 9.0.0 asn1x509 2.0.0. please move to {@link KJUR.asn1.x509.Certificate} constructor
    -4677  * @description
    -4678  * This method can issue a certificate by a simple
    -4679  * JSON object.
    -4680  * Signature value will be provided by signing with
    -4681  * private key using 'cakey' parameter or
    -4682  * hexadecimal signature value by 'sighex' parameter.
    -4683  * <br/>
    -4684  * NOTE: Algorithm parameter of AlgorithmIdentifier will
    -4685  * be set automatically by default. 
    -4686  * (see {@link KJUR.asn1.x509.AlgorithmIdentifier})
    -4687  * from jsrsasign 7.1.1 asn1x509 1.0.20.
    -4688  * <br/>
    -4689  * NOTE2: 
    -4690  * RSA-PSS algorithm has been supported from jsrsasign 8.0.21.
    -4691  * As for RSA-PSS signature algorithm names and signing parameters 
    -4692  * such as MGF function and salt length, please see
    -4693  * {@link KJUR.asn1.x509.AlgorithmIdentifier} class.
    -4694  *
    -4695  * @example
    -4696  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
    -4697  *   serial: {int: 4},
    -4698  *   sigalg: {name: 'SHA1withECDSA'},
    -4699  *   issuer: {str: '/C=US/O=a'},
    -4700  *   notbefore: {'str': '130504235959Z'},
    -4701  *   notafter: {'str': '140504235959Z'},
    -4702  *   subject: {str: '/C=US/O=b'},
    -4703  *   sbjpubkey: pubKeyObj,
    -4704  *   ext: [
    -4705  *     {basicConstraints: {cA: true, critical: true}},
    -4706  *     {keyUsage: {bin: '11'}},
    -4707  *   ],
    -4708  *   cakey: prvKeyObj
    -4709  * });
    -4710  * // -- or --
    -4711  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
    -4712  *   serial: {int: 4},
    -4713  *   sigalg: {name: 'SHA1withECDSA'},
    -4714  *   issuer: {str: '/C=US/O=a'},
    -4715  *   notbefore: {'str': '130504235959Z'},
    -4716  *   notafter: {'str': '140504235959Z'},
    -4717  *   subject: {str: '/C=US/O=b'},
    -4718  *   sbjpubkey: pubKeyPEM,
    -4719  *   ext: [
    -4720  *     {basicConstraints: {cA: true, critical: true}},
    -4721  *     {keyUsage: {bin: '11'}},
    -4722  *   ],
    -4723  *   cakey: [prvkey, pass]}
    -4724  * );
    -4725  * // -- or --
    -4726  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
    -4727  *   serial: {int: 1},
    -4728  *   sigalg: {name: 'SHA1withRSA'},
    -4729  *   issuer: {str: '/C=US/O=T1'},
    -4730  *   notbefore: {'str': '130504235959Z'},
    -4731  *   notafter: {'str': '140504235959Z'},
    -4732  *   subject: {str: '/C=US/O=T1'},
    -4733  *   sbjpubkey: pubKeyObj,
    -4734  *   sighex: '0102030405..'
    -4735  * });
    -4736  * // for the issuer and subject field, another
    -4737  * // representation is also available
    -4738  * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({
    -4739  *   serial: {int: 1},
    -4740  *   sigalg: {name: 'SHA256withRSA'},
    -4741  *   issuer: {C: "US", O: "T1"},
    -4742  *   notbefore: {'str': '130504235959Z'},
    -4743  *   notafter: {'str': '140504235959Z'},
    -4744  *   subject: {C: "US", O: "T1", CN: "http://example.com/"},
    -4745  *   sbjpubkey: pubKeyObj,
    -4746  *   sighex: '0102030405..'
    -4747  * });
    -4748  */
    -4749 KJUR.asn1.x509.X509Util.newCertPEM = function(param) {
    -4750     var _KJUR_asn1_x509 = KJUR.asn1.x509,
    -4751 	_TBSCertificate = _KJUR_asn1_x509.TBSCertificate,
    -4752 	_Certificate = _KJUR_asn1_x509.Certificate;
    -4753     var cert = new _Certificate(param);
    -4754     return cert.getPEM();
    -4755 };
    -4756 
    -4757 
    \ No newline at end of file +4592 +4593
    }; +4594 +4595 /** +4596 * convert OID to name<br/> +4597 * @name oid2name +4598 * @memberOf KJUR.asn1.x509.OID +4599 * @function +4600 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) +4601 * @return {String} OID name if registered otherwise empty string +4602 * @since asn1x509 1.0.9 +4603 * @description +4604 * This static method converts OID string to its name. +4605 * If OID is undefined then it returns empty string (i.e. ''). +4606 * @example +4607 * KJUR.asn1.x509.OID.oid2name("1.3.6.1.5.5.7.1.1") → 'authorityInfoAccess' +4608 */ +4609 KJUR.asn1.x509.OID.oid2name = function(oid) { +4610 var list = KJUR.asn1.x509.OID.name2oidList; +4611 for (var name in list) { +4612 if (list[name] == oid) return name; +4613 } +4614 return ''; +4615 }; +4616 +4617 /** +4618 * convert OID to AttributeType name<br/> +4619 * @name oid2atype +4620 * @memberOf KJUR.asn1.x509.OID +4621 * @function +4622 * @param {String} oid dot noted Object Identifer string (ex. 1.2.3.4) +4623 * @return {String} OID AttributeType name if registered otherwise oid +4624 * @since jsrsasign 6.2.2 asn1x509 1.0.18 +4625 * @description +4626 * This static method converts OID string to its AttributeType name. +4627 * If OID is not defined in OID.atype2oidList associative array then it returns OID +4628 * specified as argument. +4629 * @example +4630 * KJUR.asn1.x509.OID.oid2atype("2.5.4.3") → CN +4631 * KJUR.asn1.x509.OID.oid2atype("1.3.6.1.4.1.311.60.2.1.3") → jurisdictionOfIncorporationC +4632 * KJUR.asn1.x509.OID.oid2atype("0.1.2.3.4") → 0.1.2.3.4 // unregistered OID +4633 */ +4634 KJUR.asn1.x509.OID.oid2atype = function(oid) { +4635 var list = KJUR.asn1.x509.OID.atype2oidList; +4636 for (var atype in list) { +4637 if (list[atype] == oid) return atype; +4638 } +4639 return oid; +4640 }; +4641 +4642 /** +4643 * convert OID name to OID value<br/> +4644 * @name name2oid +4645 * @memberOf KJUR.asn1.x509.OID +4646 * @function +4647 * @param {String} name OID name or OID (ex. "sha1" or "1.2.3.4") +4648 * @return {String} dot noted Object Identifer string (ex. 1.2.3.4) +4649 * @since asn1x509 1.0.11 +4650 * @description +4651 * This static method converts from OID name to OID string. +4652 * If OID is undefined then it returns empty string (i.e. ''). +4653 * @example +4654 * KJUR.asn1.x509.OID.name2oid("authorityInfoAccess") → "1.3.6.1.5.5.7.1.1" +4655 * KJUR.asn1.x509.OID.name2oid("1.2.3.4") → "1.2.3.4" +4656 * KJUR.asn1.x509.OID.name2oid("UNKNOWN NAME") → "" +4657 */ +4658 KJUR.asn1.x509.OID.name2oid = function(name) { +4659 if (name.match(/^[0-9.]+$/)) return name; +4660 var list = KJUR.asn1.x509.OID.name2oidList; +4661 if (list[name] === undefined) return ''; +4662 return list[name]; +4663 }; +4664 +4665 /** +4666 * X.509 certificate and CRL utilities class<br/> +4667 * @name KJUR.asn1.x509.X509Util +4668 * @class X.509 certificate and CRL utilities class +4669 */ +4670 KJUR.asn1.x509.X509Util = {}; +4671 +4672 /** +4673 * issue a certificate in PEM format (DEPRECATED) +4674 * @name newCertPEM +4675 * @memberOf KJUR.asn1.x509.X509Util +4676 * @function +4677 * @param {Array} param JSON object of parameter to issue a certificate +4678 * @since asn1x509 1.0.6 +4679 * @deprecated since jsrsasign 9.0.0 asn1x509 2.0.0. please move to {@link KJUR.asn1.x509.Certificate} constructor +4680 * @description +4681 * This method can issue a certificate by a simple +4682 * JSON object. +4683 * Signature value will be provided by signing with +4684 * private key using 'cakey' parameter or +4685 * hexadecimal signature value by 'sighex' parameter. +4686 * <br/> +4687 * NOTE: Algorithm parameter of AlgorithmIdentifier will +4688 * be set automatically by default. +4689 * (see {@link KJUR.asn1.x509.AlgorithmIdentifier}) +4690 * from jsrsasign 7.1.1 asn1x509 1.0.20. +4691 * <br/> +4692 * NOTE2: +4693 * RSA-PSS algorithm has been supported from jsrsasign 8.0.21. +4694 * As for RSA-PSS signature algorithm names and signing parameters +4695 * such as MGF function and salt length, please see +4696 * {@link KJUR.asn1.x509.AlgorithmIdentifier} class. +4697 * +4698 * @example +4699 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4700 * serial: {int: 4}, +4701 * sigalg: {name: 'SHA1withECDSA'}, +4702 * issuer: {str: '/C=US/O=a'}, +4703 * notbefore: {'str': '130504235959Z'}, +4704 * notafter: {'str': '140504235959Z'}, +4705 * subject: {str: '/C=US/O=b'}, +4706 * sbjpubkey: pubKeyObj, +4707 * ext: [ +4708 * {basicConstraints: {cA: true, critical: true}}, +4709 * {keyUsage: {bin: '11'}}, +4710 * ], +4711 * cakey: prvKeyObj +4712 * }); +4713 * // -- or -- +4714 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4715 * serial: {int: 4}, +4716 * sigalg: {name: 'SHA1withECDSA'}, +4717 * issuer: {str: '/C=US/O=a'}, +4718 * notbefore: {'str': '130504235959Z'}, +4719 * notafter: {'str': '140504235959Z'}, +4720 * subject: {str: '/C=US/O=b'}, +4721 * sbjpubkey: pubKeyPEM, +4722 * ext: [ +4723 * {basicConstraints: {cA: true, critical: true}}, +4724 * {keyUsage: {bin: '11'}}, +4725 * ], +4726 * cakey: [prvkey, pass]} +4727 * ); +4728 * // -- or -- +4729 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4730 * serial: {int: 1}, +4731 * sigalg: {name: 'SHA1withRSA'}, +4732 * issuer: {str: '/C=US/O=T1'}, +4733 * notbefore: {'str': '130504235959Z'}, +4734 * notafter: {'str': '140504235959Z'}, +4735 * subject: {str: '/C=US/O=T1'}, +4736 * sbjpubkey: pubKeyObj, +4737 * sighex: '0102030405..' +4738 * }); +4739 * // for the issuer and subject field, another +4740 * // representation is also available +4741 * var certPEM = KJUR.asn1.x509.X509Util.newCertPEM({ +4742 * serial: {int: 1}, +4743 * sigalg: {name: 'SHA256withRSA'}, +4744 * issuer: {C: "US", O: "T1"}, +4745 * notbefore: {'str': '130504235959Z'}, +4746 * notafter: {'str': '140504235959Z'}, +4747 * subject: {C: "US", O: "T1", CN: "http://example.com/"}, +4748 * sbjpubkey: pubKeyObj, +4749 * sighex: '0102030405..' +4750 * }); +4751 */ +4752 KJUR.asn1.x509.X509Util.newCertPEM = function(param) { +4753 var _KJUR_asn1_x509 = KJUR.asn1.x509, +4754 _TBSCertificate = _KJUR_asn1_x509.TBSCertificate, +4755 _Certificate = _KJUR_asn1_x509.Certificate; +4756 var cert = new _Certificate(param); +4757 return cert.getPEM(); +4758 }; +4759 +4760
    \ No newline at end of file diff --git a/api/symbols/src/x509-1.1.js.html b/api/symbols/src/x509-1.1.js.html index d99aa134..34d4c25d 100644 --- a/api/symbols/src/x509-1.1.js.html +++ b/api/symbols/src/x509-1.1.js.html @@ -5,7 +5,7 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
      1 /* x509-2.0.17.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
    +	
      1 /* x509-2.1.0.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
       2  */
       3 /*
       4  * x509.js - X509 class to read subject public key from certificate.
    @@ -23,7 +23,7 @@
      16  * @fileOverview
      17  * @name x509-1.1.js
      18  * @author Kenji Urushima kenji.urushima@gmail.com
    - 19  * @version jsrsasign 10.5.24 x509 2.0.17 (2022-Jun-04)
    + 19  * @version jsrsasign 10.6.0 x509 2.1.0 (2022-Nov-04)
      20  * @since jsrsasign 1.x.x
      21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
      22  */
    @@ -246,3104 +246,3277 @@
     239      * @name getIssuer
     240      * @memberOf X509#
     241      * @function
    -242      * @return {Array} JSON object of issuer field
    -243      * @since jsrsasign 9.0.0 x509 2.0.0
    -244      * @see X509#getX500Name
    -245      * @description
    -246      * @example
    -247      * var x = new X509(sCertPEM);
    -248      * x.getIssuer() →
    -249      * { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    -250      *   str: "/C=JP/..." }
    -251      */
    -252     this.getIssuer = function() {
    -253 	return this.getX500Name(this.getIssuerHex())
    -254     };
    -255 
    -256     /**
    -257      * get hexadecimal string of issuer field TLV of certificate.<br/>
    -258      * @name getIssuerHex
    -259      * @memberOf X509#
    -260      * @function
    -261      * @return {String} hexadecial string of issuer DN ASN.1
    -262      * @example
    -263      * var x = new X509();
    -264      * x.readCertPEM(sCertPEM);
    -265      * var issuer = x.getIssuerHex(); // return string like "3013..."
    -266      */
    -267     this.getIssuerHex = function() {
    -268 	return _getTLVbyList(this.hex, 0, [0, 3 + this.foffset], "30");
    -269     };
    -270 
    -271     /**
    -272      * get string of issuer field of certificate.<br/>
    -273      * @name getIssuerString
    -274      * @memberOf X509#
    -275      * @function
    -276      * @return {String} issuer DN string
    -277      * @see X509#getIssuer
    -278      * @example
    -279      * var x = new X509();
    -280      * x.readCertPEM(sCertPEM);
    -281      * var dn1 = x.getIssuerString(); // return string like "/C=US/O=TEST"
    -282      * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US"
    +242      * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false)
    +243      * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false)
    +244      * @return {Array} JSON object of issuer field
    +245      * @since jsrsasign 9.0.0 x509 2.0.0
    +246      * @see X509#getX500Name
    +247      *
    +248      * @description
    +249      * Get a JSON object of an issuer field.
    +250      * <br>
    +251      * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been 
    +252      * supported to conclude a canonicalized name for caseIgnoreMatch
    +253      * desribed in <a href="https://tools.ietf.org/html/rfc4518">
    +254      * RFC 4518</a>.
    +255      *
    +256      * @example
    +257      * var x = new X509(sCertPEM);
    +258      * x.getIssuer() →
    +259      * { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    +260      *   str: "/C=JP/..." }
    +261      *
    +262      * // with flags
    +263      * x.getIssuer(true, true) →
    +264      * { array: ...,
    +265      *   str: "/C=JP/O=   Test    123   ",
    +266      *   canon: "/c=jp/o=test 123",
    +267      *   hex: "30..." }
    +268      */
    +269     this.getIssuer = function(flagCanon, flagHex) {
    +270 	return this.getX500Name(this.getIssuerHex(), flagCanon, flagHex);
    +271     };
    +272 
    +273     /**
    +274      * get hexadecimal string of issuer field TLV of certificate.<br/>
    +275      * @name getIssuerHex
    +276      * @memberOf X509#
    +277      * @function
    +278      * @return {String} hexadecial string of issuer DN ASN.1
    +279      * @example
    +280      * var x = new X509();
    +281      * x.readCertPEM(sCertPEM);
    +282      * var issuer = x.getIssuerHex(); // return string like "3013..."
     283      */
    -284     this.getIssuerString = function() {
    -285 	var pIssuer = this.getIssuer();
    -286 	return pIssuer.str;
    -287     };
    -288 
    -289     /**
    -290      * get JSON object of subject field<br/>
    -291      * @name getSubject
    -292      * @memberOf X509#
    -293      * @function
    -294      * @return {Array} JSON object of subject field
    -295      * @since jsrsasign 9.0.0 x509 2.0.0
    -296      * @see X509#getX500Name
    -297      * @description
    -298      * @example
    -299      * var x = new X509(sCertPEM);
    -300      * x.getSubject() →
    -301      * { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    -302      *   str: "/C=JP/..." }
    -303      */
    -304     this.getSubject = function() {
    -305 	return this.getX500Name(this.getSubjectHex());
    -306     };
    -307 
    -308     /**
    -309      * get hexadecimal string of subject field of certificate.<br/>
    -310      * @name getSubjectHex
    -311      * @memberOf X509#
    -312      * @function
    -313      * @return {String} hexadecial string of subject DN ASN.1
    -314      * @example
    -315      * var x = new X509();
    -316      * x.readCertPEM(sCertPEM);
    -317      * var subject = x.getSubjectHex(); // return string like "3013..."
    -318      */
    -319     this.getSubjectHex = function() {
    -320 	return _getTLVbyList(this.hex, 0, [0, 5 + this.foffset], "30");
    -321     };
    -322 
    -323     /**
    -324      * get string of subject field of certificate.<br/>
    -325      * @name getSubjectString
    -326      * @memberOf X509#
    -327      * @function
    -328      * @return {String} subject DN string
    -329      * @see X509#getSubject
    -330      * @example
    -331      * var x = new X509();
    -332      * x.readCertPEM(sCertPEM);
    -333      * var dn1 = x.getSubjectString(); // return string like "/C=US/O=TEST"
    -334      * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US"
    -335      */
    -336     this.getSubjectString = function() {
    -337 	var pSubject = this.getSubject();
    -338 	return pSubject.str;
    -339     };
    -340 
    -341     /**
    -342      * get notBefore field string of certificate.<br/>
    -343      * @name getNotBefore
    -344      * @memberOf X509#
    -345      * @function
    -346      * @return {String} not before time value (ex. "151231235959Z")
    -347      * @example
    -348      * var x = new X509();
    -349      * x.readCertPEM(sCertPEM);
    -350      * var notBefore = x.getNotBefore(); // return string like "151231235959Z"
    -351      */
    -352     this.getNotBefore = function() {
    -353         var s = _getVbyList(this.hex, 0, [0, 4 + this.foffset, 0]);
    -354         s = s.replace(/(..)/g, "%$1");
    -355         s = decodeURIComponent(s);
    -356         return s;
    -357     };
    -358 
    -359     /**
    -360      * get notAfter field string of certificate.<br/>
    -361      * @name getNotAfter
    -362      * @memberOf X509#
    -363      * @function
    -364      * @return {String} not after time value (ex. "151231235959Z")
    -365      * @example
    -366      * var x = new X509();
    -367      * x.readCertPEM(sCertPEM);
    -368      * var notAfter = x.getNotAfter(); // return string like "151231235959Z"
    +284     this.getIssuerHex = function() {
    +285 	return _getTLVbyList(this.hex, 0, [0, 3 + this.foffset], "30");
    +286     };
    +287 
    +288     /**
    +289      * get string of issuer field of certificate.<br/>
    +290      * @name getIssuerString
    +291      * @memberOf X509#
    +292      * @function
    +293      * @return {String} issuer DN string
    +294      * @see X509#getIssuer
    +295      * @example
    +296      * var x = new X509();
    +297      * x.readCertPEM(sCertPEM);
    +298      * var dn1 = x.getIssuerString(); // return string like "/C=US/O=TEST"
    +299      * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US"
    +300      */
    +301     this.getIssuerString = function() {
    +302 	var pIssuer = this.getIssuer();
    +303 	return pIssuer.str;
    +304     };
    +305 
    +306     /**
    +307      * get JSON object of subject field<br/>
    +308      * @name getSubject
    +309      * @memberOf X509#
    +310      * @function
    +311      * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false)
    +312      * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false)
    +313      * @return {object} JSON object of subject field
    +314      * @since jsrsasign 9.0.0 x509 2.0.0
    +315      * @see X509#getX500Name
    +316      *
    +317      * @description
    +318      * Get a JSON object of a subject field.
    +319      * <br>
    +320      * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been 
    +321      * supported to conclude a canonicalized name for caseIgnoreMatch
    +322      * desribed in <a href="https://tools.ietf.org/html/rfc4518">
    +323      * RFC 4518</a>.
    +324      *
    +325      * @example
    +326      * var x = new X509(sCertPEM);
    +327      * x.getSubject() →
    +328      * { array: [[{type:'C',value:'JP',ds:'prn'}],...],
    +329      *   str: "/C=JP/..." }
    +330      *
    +331      * // with flags
    +332      * x.getSubject(true, true) →
    +333      * { array: ...,
    +334      *   str: "/C=JP/O=   Test    123   ",
    +335      *   canon: "/c=jp/o=test 123",
    +336      *   hex: "30..." }
    +337      */
    +338     this.getSubject = function(flagCanon, flagHex) {
    +339 	return this.getX500Name(this.getSubjectHex(), flagCanon, flagHex);
    +340     };
    +341 
    +342     /**
    +343      * get hexadecimal string of subject field of certificate.<br/>
    +344      * @name getSubjectHex
    +345      * @memberOf X509#
    +346      * @function
    +347      * @return {String} hexadecial string of subject DN ASN.1
    +348      * @example
    +349      * var x = new X509();
    +350      * x.readCertPEM(sCertPEM);
    +351      * var subject = x.getSubjectHex(); // return string like "3013..."
    +352      */
    +353     this.getSubjectHex = function() {
    +354 	return _getTLVbyList(this.hex, 0, [0, 5 + this.foffset], "30");
    +355     };
    +356 
    +357     /**
    +358      * get string of subject field of certificate.<br/>
    +359      * @name getSubjectString
    +360      * @memberOf X509#
    +361      * @function
    +362      * @return {String} subject DN string
    +363      * @see X509#getSubject
    +364      * @example
    +365      * var x = new X509();
    +366      * x.readCertPEM(sCertPEM);
    +367      * var dn1 = x.getSubjectString(); // return string like "/C=US/O=TEST"
    +368      * var dn2 = KJUR.asn1.x509.X500Name.compatToLDAP(dn1); // returns "O=TEST, C=US"
     369      */
    -370     this.getNotAfter = function() {
    -371 	var s = _getVbyList(this.hex, 0, [0, 4 + this.foffset, 1]);
    -372         s = s.replace(/(..)/g, "%$1");
    -373         s = decodeURIComponent(s);
    -374         return s;
    -375     };
    -376 
    -377     /**
    -378      * get a hexadecimal string of subjectPublicKeyInfo field.<br/>
    -379      * @name getPublicKeyHex
    -380      * @memberOf X509#
    -381      * @function
    -382      * @return {String} ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field
    -383      * @since jsrsasign 7.1.4 x509 1.1.13
    -384      * @deprecated since jsrsasign 10.5.7 x509 2.0.13. Please use {@link X509#getSPKI} instead.
    -385      *
    -386      * @example
    -387      * x = new X509(sCertPEM);
    -388      * hSPKI = x.getPublicKeyHex(); // return string like "30820122..."
    -389      */
    -390     this.getPublicKeyHex = function() {
    -391 	return this.getSPKI();
    -392     };
    -393 
    -394     /**
    -395      * get ASN.1 TLV hexadecimal string of subjectPublicKeyInfo field.<br/>
    -396      * @name getSPKI
    -397      * @memberOf X509#
    -398      * @function
    -399      * @return {string} ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field
    -400      * @since jsrsasign 10.5.8 x509 2.0.13
    -401      * @see X509#getPublicKeyHex
    -402      * @see X509#getSPKIValue
    -403      *
    -404      * @description
    -405      * Get a hexadecimal string of SubjectPublicKeyInfo ASN.1 TLV of the certificate.<br/>
    -406      * <pre>
    -407      * SubjectPublicKeyInfo  ::=  SEQUENCE  {
    -408      *    algorithm         AlgorithmIdentifier,
    -409      *    subjectPublicKey  BIT STRING  }
    -410      * </pre>
    -411      *
    -412      * @example
    -413      * x = new X509(sCertPEM);
    -414      * hSPKI = x.getSPKI(); // return string like "30820122..."
    -415      */
    -416     this.getSPKI = function() {
    -417 	return _getTLVbyList(this.hex, 0, [0, 6 + this.foffset], "30");
    -418     };
    -419 
    -420     /**
    -421      * get hexadecimal string of subjectPublicKey of subjectPublicKeyInfo field.<br/>
    -422      * @name getSPKIValue
    -423      * @memberOf X509#
    -424      * @function
    -425      * @return {string} ASN.1 hexadecimal string of subjectPublicKey
    -426      * @since jsrsasign 10.5.8 x509 2.0.13
    -427      * @see X509#getSPKI
    -428      *
    -429      * @description
    -430      * Get a hexadecimal string of subjectPublicKey ASN.1 value of SubjectPublicKeyInfo 
    -431      * of the certificate without unusedbit "00".
    -432      * The "subjectPublicKey" is encapsulated by BIT STRING.
    -433      * This method returns BIT STRING value without unusedbits.
    -434      * <br/>
    -435      * <pre>
    -436      * SubjectPublicKeyInfo  ::=  SEQUENCE  {
    -437      *    algorithm         AlgorithmIdentifier,
    -438      *    subjectPublicKey  BIT STRING  }
    -439      * </pre>
    -440      *
    -441      * @example
    -442      * x = new X509(sCertPEM);
    -443      * hSPKIValue = x.getSPKIValue(); // without BIT STRING Encapusulation.
    -444      */
    -445     this.getSPKIValue = function() {
    -446 	var hSPKI = this.getSPKI();
    -447 	if (hSPKI == null) return null;
    -448 	return _getVbyList(hSPKI, 0, [1], "03", true); // true: remove unused bit
    -449     };
    -450 
    -451     /**
    -452      * get a string index of subjectPublicKeyInfo field for hexadecimal string certificate.<br/>
    -453      * @name getPublicKeyIdx
    -454      * @memberOf X509#
    -455      * @function
    -456      * @return {Number} string index of subjectPublicKeyInfo field for hexadecimal string certificate.
    -457      * @since jsrsasign 7.1.4 x509 1.1.13
    -458      * @example
    -459      * x = new X509();
    -460      * x.readCertPEM(sCertPEM);
    -461      * idx = x.getPublicKeyIdx(); // return string index in x.hex parameter
    -462      */
    -463     this.getPublicKeyIdx = function() {
    -464 	return _getIdxbyList(this.hex, 0, [0, 6 + this.foffset], "30");
    -465     };
    -466 
    -467     /**
    -468      * get a string index of contents of subjectPublicKeyInfo BITSTRING value from hexadecimal certificate<br/>
    -469      * @name getPublicKeyContentIdx
    -470      * @memberOf X509#
    -471      * @function
    -472      * @return {Integer} string index of key contents
    -473      * @since jsrsasign 8.0.0 x509 1.2.0
    -474      * @example
    -475      * x = new X509();
    -476      * x.readCertPEM(sCertPEM);
    -477      * idx = x.getPublicKeyContentIdx(); // return string index in x.hex parameter
    +370     this.getSubjectString = function() {
    +371 	var pSubject = this.getSubject();
    +372 	return pSubject.str;
    +373     };
    +374 
    +375     /**
    +376      * get notBefore field string of certificate.<br/>
    +377      * @name getNotBefore
    +378      * @memberOf X509#
    +379      * @function
    +380      * @return {String} not before time value (ex. "151231235959Z")
    +381      * @example
    +382      * var x = new X509();
    +383      * x.readCertPEM(sCertPEM);
    +384      * var notBefore = x.getNotBefore(); // return string like "151231235959Z"
    +385      */
    +386     this.getNotBefore = function() {
    +387         var s = _getVbyList(this.hex, 0, [0, 4 + this.foffset, 0]);
    +388         s = s.replace(/(..)/g, "%$1");
    +389         s = decodeURIComponent(s);
    +390         return s;
    +391     };
    +392 
    +393     /**
    +394      * get notAfter field string of certificate.<br/>
    +395      * @name getNotAfter
    +396      * @memberOf X509#
    +397      * @function
    +398      * @return {String} not after time value (ex. "151231235959Z")
    +399      * @example
    +400      * var x = new X509();
    +401      * x.readCertPEM(sCertPEM);
    +402      * var notAfter = x.getNotAfter(); // return string like "151231235959Z"
    +403      */
    +404     this.getNotAfter = function() {
    +405 	var s = _getVbyList(this.hex, 0, [0, 4 + this.foffset, 1]);
    +406         s = s.replace(/(..)/g, "%$1");
    +407         s = decodeURIComponent(s);
    +408         return s;
    +409     };
    +410 
    +411     /**
    +412      * get a hexadecimal string of subjectPublicKeyInfo field.<br/>
    +413      * @name getPublicKeyHex
    +414      * @memberOf X509#
    +415      * @function
    +416      * @return {String} ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field
    +417      * @since jsrsasign 7.1.4 x509 1.1.13
    +418      * @deprecated since jsrsasign 10.5.7 x509 2.0.13. Please use {@link X509#getSPKI} instead.
    +419      *
    +420      * @example
    +421      * x = new X509(sCertPEM);
    +422      * hSPKI = x.getPublicKeyHex(); // return string like "30820122..."
    +423      */
    +424     this.getPublicKeyHex = function() {
    +425 	return this.getSPKI();
    +426     };
    +427 
    +428     /**
    +429      * get ASN.1 TLV hexadecimal string of subjectPublicKeyInfo field.<br/>
    +430      * @name getSPKI
    +431      * @memberOf X509#
    +432      * @function
    +433      * @return {string} ASN.1 SEQUENCE hexadecimal string of subjectPublicKeyInfo field
    +434      * @since jsrsasign 10.5.8 x509 2.0.13
    +435      * @see X509#getPublicKeyHex
    +436      * @see X509#getSPKIValue
    +437      *
    +438      * @description
    +439      * Get a hexadecimal string of SubjectPublicKeyInfo ASN.1 TLV of the certificate.<br/>
    +440      * <pre>
    +441      * SubjectPublicKeyInfo  ::=  SEQUENCE  {
    +442      *    algorithm         AlgorithmIdentifier,
    +443      *    subjectPublicKey  BIT STRING  }
    +444      * </pre>
    +445      *
    +446      * @example
    +447      * x = new X509(sCertPEM);
    +448      * hSPKI = x.getSPKI(); // return string like "30820122..."
    +449      */
    +450     this.getSPKI = function() {
    +451 	return _getTLVbyList(this.hex, 0, [0, 6 + this.foffset], "30");
    +452     };
    +453 
    +454     /**
    +455      * get hexadecimal string of subjectPublicKey of subjectPublicKeyInfo field.<br/>
    +456      * @name getSPKIValue
    +457      * @memberOf X509#
    +458      * @function
    +459      * @return {string} ASN.1 hexadecimal string of subjectPublicKey
    +460      * @since jsrsasign 10.5.8 x509 2.0.13
    +461      * @see X509#getSPKI
    +462      *
    +463      * @description
    +464      * Get a hexadecimal string of subjectPublicKey ASN.1 value of SubjectPublicKeyInfo 
    +465      * of the certificate without unusedbit "00".
    +466      * The "subjectPublicKey" is encapsulated by BIT STRING.
    +467      * This method returns BIT STRING value without unusedbits.
    +468      * <br/>
    +469      * <pre>
    +470      * SubjectPublicKeyInfo  ::=  SEQUENCE  {
    +471      *    algorithm         AlgorithmIdentifier,
    +472      *    subjectPublicKey  BIT STRING  }
    +473      * </pre>
    +474      *
    +475      * @example
    +476      * x = new X509(sCertPEM);
    +477      * hSPKIValue = x.getSPKIValue(); // without BIT STRING Encapusulation.
     478      */
    -479     // NOTE: Without BITSTRING encapsulation.
    -480     this.getPublicKeyContentIdx = function() {
    -481 	var idx = this.getPublicKeyIdx();
    -482 	return _getIdxbyList(this.hex, idx, [1, 0], "30");
    +479     this.getSPKIValue = function() {
    +480 	var hSPKI = this.getSPKI();
    +481 	if (hSPKI == null) return null;
    +482 	return _getVbyList(hSPKI, 0, [1], "03", true); // true: remove unused bit
     483     };
     484 
     485     /**
    -486      * get a RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field.<br/>
    -487      * @name getPublicKey
    +486      * get a string index of subjectPublicKeyInfo field for hexadecimal string certificate.<br/>
    +487      * @name getPublicKeyIdx
     488      * @memberOf X509#
     489      * @function
    -490      * @return {Object} RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field
    +490      * @return {Number} string index of subjectPublicKeyInfo field for hexadecimal string certificate.
     491      * @since jsrsasign 7.1.4 x509 1.1.13
     492      * @example
     493      * x = new X509();
     494      * x.readCertPEM(sCertPEM);
    -495      * pubkey= x.getPublicKey();
    +495      * idx = x.getPublicKeyIdx(); // return string index in x.hex parameter
     496      */
    -497     this.getPublicKey = function() {
    -498 	return KEYUTIL.getKey(this.getPublicKeyHex(), null, "pkcs8pub");
    +497     this.getPublicKeyIdx = function() {
    +498 	return _getIdxbyList(this.hex, 0, [0, 6 + this.foffset], "30");
     499     };
     500 
     501     /**
    -502      * get signature algorithm name from hexadecimal certificate data
    -503      * @name getSignatureAlgorithmName
    +502      * get a string index of contents of subjectPublicKeyInfo BITSTRING value from hexadecimal certificate<br/>
    +503      * @name getPublicKeyContentIdx
     504      * @memberOf X509#
     505      * @function
    -506      * @return {String} signature algorithm name (ex. SHA1withRSA, SHA256withECDSA)
    -507      * @since jsrsasign 7.2.0 x509 1.1.14
    -508      * @see X509#getAlgorithmIdentifierName
    -509      * @description
    -510      * This method will get signature algorithm name of certificate:
    -511      * @example
    -512      * var x = new X509();
    -513      * x.readCertPEM(sCertPEM);
    -514      * x.getSignatureAlgorithmName() → "SHA256withRSA"
    -515      */
    -516     this.getSignatureAlgorithmName = function() {
    -517 	var hTLV = _getTLVbyList(this.hex, 0, [1], "30");
    -518 	return this.getAlgorithmIdentifierName(hTLV);
    -519     };
    -520 
    -521     /**
    -522      * get signature value as hexadecimal string<br/>
    -523      * @name getSignatureValueHex
    -524      * @memberOf X509#
    -525      * @function
    -526      * @return {String} signature value hexadecimal string without BitString unused bits
    -527      * @since jsrsasign 7.2.0 x509 1.1.14
    -528      *
    -529      * @description
    -530      * This method will get signature value of certificate:
    -531      *
    -532      * @example
    -533      * var x = new X509();
    -534      * x.readCertPEM(sCertPEM);
    -535      * x.getSignatureValueHex() &rarr "8a4c47913..."
    -536      */
    -537     this.getSignatureValueHex = function() {
    -538 	return _getVbyList(this.hex, 0, [2], "03", true);
    -539     };
    -540 
    -541     /**
    -542      * verifies signature value by public key<br/>
    -543      * @name verifySignature
    -544      * @memberOf X509#
    -545      * @function
    -546      * @param {Object} pubKey public key object
    -547      * @return {Boolean} true if signature value is valid otherwise false
    -548      * @since jsrsasign 7.2.0 x509 1.1.14
    -549      *
    -550      * @description
    -551      * This method verifies signature value of hexadecimal string of 
    -552      * X.509 certificate by specified public key object.
    -553      * The signature algorithm used to verify will refer
    -554      * signatureAlgorithm field. (See {@link X509#getSignatureAlgorithmField})
    -555      * RSA-PSS signature algorithms (SHA{,256,384,512}withRSAandMGF1)
    -556      * are available.
    -557      *
    -558      * @example
    -559      * pubKey = KEYUTIL.getKey(pemPublicKey); // or certificate
    -560      * x = new X509();
    -561      * x.readCertPEM(pemCert);
    -562      * x.verifySignature(pubKey) → true, false or raising exception
    -563      */
    -564     this.verifySignature = function(pubKey) {
    -565 	var algName = this.getSignatureAlgorithmField();
    -566 	var hSigVal = this.getSignatureValueHex();
    -567 	var hTbsCert = _getTLVbyList(this.hex, 0, [0], "30");
    -568 	
    -569 	var sig = new KJUR.crypto.Signature({alg: algName});
    -570 	sig.init(pubKey);
    -571 	sig.updateHex(hTbsCert);
    -572 	return sig.verify(hSigVal);
    +506      * @return {Integer} string index of key contents
    +507      * @since jsrsasign 8.0.0 x509 1.2.0
    +508      * @example
    +509      * x = new X509();
    +510      * x.readCertPEM(sCertPEM);
    +511      * idx = x.getPublicKeyContentIdx(); // return string index in x.hex parameter
    +512      */
    +513     // NOTE: Without BITSTRING encapsulation.
    +514     this.getPublicKeyContentIdx = function() {
    +515 	var idx = this.getPublicKeyIdx();
    +516 	return _getIdxbyList(this.hex, idx, [1, 0], "30");
    +517     };
    +518 
    +519     /**
    +520      * get a RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field.<br/>
    +521      * @name getPublicKey
    +522      * @memberOf X509#
    +523      * @function
    +524      * @return {Object} RSAKey/ECDSA/DSA public key object of subjectPublicKeyInfo field
    +525      * @since jsrsasign 7.1.4 x509 1.1.13
    +526      * @example
    +527      * x = new X509();
    +528      * x.readCertPEM(sCertPEM);
    +529      * pubkey= x.getPublicKey();
    +530      */
    +531     this.getPublicKey = function() {
    +532 	return KEYUTIL.getKey(this.getPublicKeyHex(), null, "pkcs8pub");
    +533     };
    +534 
    +535     /**
    +536      * get signature algorithm name from hexadecimal certificate data
    +537      * @name getSignatureAlgorithmName
    +538      * @memberOf X509#
    +539      * @function
    +540      * @return {String} signature algorithm name (ex. SHA1withRSA, SHA256withECDSA)
    +541      * @since jsrsasign 7.2.0 x509 1.1.14
    +542      * @see X509#getAlgorithmIdentifierName
    +543      * @description
    +544      * This method will get signature algorithm name of certificate:
    +545      * @example
    +546      * var x = new X509();
    +547      * x.readCertPEM(sCertPEM);
    +548      * x.getSignatureAlgorithmName() → "SHA256withRSA"
    +549      */
    +550     this.getSignatureAlgorithmName = function() {
    +551 	var hTLV = _getTLVbyList(this.hex, 0, [1], "30");
    +552 	return this.getAlgorithmIdentifierName(hTLV);
    +553     };
    +554 
    +555     /**
    +556      * get signature value as hexadecimal string<br/>
    +557      * @name getSignatureValueHex
    +558      * @memberOf X509#
    +559      * @function
    +560      * @return {String} signature value hexadecimal string without BitString unused bits
    +561      * @since jsrsasign 7.2.0 x509 1.1.14
    +562      *
    +563      * @description
    +564      * This method will get signature value of certificate:
    +565      *
    +566      * @example
    +567      * var x = new X509();
    +568      * x.readCertPEM(sCertPEM);
    +569      * x.getSignatureValueHex() &rarr "8a4c47913..."
    +570      */
    +571     this.getSignatureValueHex = function() {
    +572 	return _getVbyList(this.hex, 0, [2], "03", true);
     573     };
     574 
    -575     // ===== parse extension ======================================
    -576     /**
    -577      * set array of X.509v3 and CSR extesion information such as extension OID, criticality and value index. (DEPRECATED)<br/>
    -578      * @name parseExt
    -579      * @memberOf X509#
    -580      * @function
    -581      * @param {String} hCSR - PEM string of certificate signing requrest(CSR) (OPTION)
    +575     /**
    +576      * verifies signature value by public key<br/>
    +577      * @name verifySignature
    +578      * @memberOf X509#
    +579      * @function
    +580      * @param {Object} pubKey public key object
    +581      * @return {Boolean} true if signature value is valid otherwise false
     582      * @since jsrsasign 7.2.0 x509 1.1.14
    -583      * @deprecated jsrsasign 9.1.1 x509 2.0.1
    -584      *
    -585      * @description
    -586      * This method will set an array of X.509v3 extension information having 
    -587      * following parameters:
    -588      * <ul>
    -589      * <li>oid - extension OID (ex. 2.5.29.19)</li>
    -590      * <li>critical - true or false</li>
    -591      * <li>vidx - string index for extension value</li>
    -592      * <br/>
    -593      * When you want to parse extensionRequest of CSR,
    -594      * argument 'hCSR' shall be specified.
    -595      * <br/>
    -596      * NOTE: CSR is supported from jsrsasign 8.0.20 x509 1.1.22.
    -597      * <br/>
    -598      * This method and X509.aExtInfo property
    -599      * have been *deprecated* since jsrsasign 9.1.1.
    -600      * All extension parser method such as X509.getExt* shall be
    -601      * call with argument "hExtV" and "critical" explicitly.
    -602      *
    -603      * @example
    -604      * x = new X509();
    -605      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -606      *
    -607      * x.aExtInfo →
    -608      * [ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ]
    -609      *
    -610      * // to parse CSR
    -611      * X = new X509()
    -612      * x.parseExt("-----BEGIN CERTIFICATE REQUEST-----...");
    -613      * x.aExtInfo →
    -614      * [ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ]
    -615      */
    -616     this.parseExt = function(hCSR) {
    -617 	var iExtSeq, aExtIdx, h;
    -618 
    -619 	if (hCSR === undefined) {
    -620 	    h = this.hex;
    -621 	    if (this.version !== 3) return -1;
    -622 	    iExtSeq = _getIdxbyList(h, 0, [0, 7, 0], "30");
    -623 	    aExtIdx = _getChildIdx(h, iExtSeq);
    -624 	} else {
    -625 	    h = pemtohex(hCSR);
    -626 	    var idx1 = _getIdxbyList(h, 0, [0, 3, 0, 0], "06");
    -627 
    -628 	    if (_getV(h, idx1) != "2a864886f70d01090e") {
    -629 		this.aExtInfo = new Array();
    -630 		return;
    -631 	    }
    -632 
    -633 	    iExtSeq = _getIdxbyList(h, 0, [0, 3, 0, 1, 0], "30");
    -634 	    aExtIdx = _getChildIdx(h, iExtSeq);
    -635 
    -636 	    this.hex = h;
    -637 	}
    -638 	    
    -639 	this.aExtInfo = new Array();
    -640 	for (var i = 0; i < aExtIdx.length; i++) {
    -641 	    var item = {};
    -642 	    item.critical = false;
    -643 	    var a = _getChildIdx(h, aExtIdx[i]);
    -644 	    var offset = 0;
    -645 
    -646 	    if (a.length === 3) {
    -647 		item.critical = true;
    -648 		offset = 1;
    -649 	    }
    -650 
    -651 	    item.oid = _ASN1HEX.hextooidstr(_getVbyList(h, aExtIdx[i], [0], "06"));
    -652 	    var octidx = _getIdxbyList(h, aExtIdx[i], [1 + offset]);
    -653 	    item.vidx = _getVidx(h, octidx);
    -654 	    this.aExtInfo.push(item);
    -655 	}
    -656     };
    -657 
    -658     /**
    -659      * get a X.509v3 extesion information such as extension OID, criticality and value index for specified oid or name.<br/>
    -660      * @name getExtInfo
    -661      * @memberOf X509#
    -662      * @function
    -663      * @param {String} oidOrName X.509 extension oid or name (ex. keyUsage or 2.5.29.19)
    -664      * @return X.509 extension information such as extension OID or value indx (see {@link X509#parseExt})
    -665      * @since jsrsasign 7.2.0 x509 1.1.14
    -666      * @description
    -667      * This method will get an X.509v3 extension information JSON object
    -668      * having extension OID, criticality and value idx for specified
    -669      * extension OID or name.
    -670      * If there is no such extension, this returns undefined.
    -671      * @example
    -672      * x = new X509();
    -673      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -674      *
    -675      * x.getExtInfo("keyUsage") → { oid: "2.5.29.15", critical: true, vidx: 1714 }
    -676      * x.getExtInfo("unknownExt") → undefined
    -677      */
    -678     this.getExtInfo = function(oidOrName) {
    -679 	var a = this.aExtInfo;
    -680 	var oid = oidOrName;
    -681 	if (! oidOrName.match(/^[0-9.]+$/)) {
    -682 	    oid = KJUR.asn1.x509.OID.name2oid(oidOrName);
    -683 	}
    -684 	if (oid === '') return undefined;
    -685 
    -686 	for (var i = 0; i < a.length; i++) {
    -687 	    if (a[i].oid === oid) return a[i];
    -688 	}
    -689 	return undefined;
    +583      *
    +584      * @description
    +585      * This method verifies signature value of hexadecimal string of 
    +586      * X.509 certificate by specified public key object.
    +587      * The signature algorithm used to verify will refer
    +588      * signatureAlgorithm field. (See {@link X509#getSignatureAlgorithmField})
    +589      * RSA-PSS signature algorithms (SHA{,256,384,512}withRSAandMGF1)
    +590      * are available.
    +591      *
    +592      * @example
    +593      * pubKey = KEYUTIL.getKey(pemPublicKey); // or certificate
    +594      * x = new X509();
    +595      * x.readCertPEM(pemCert);
    +596      * x.verifySignature(pubKey) → true, false or raising exception
    +597      */
    +598     this.verifySignature = function(pubKey) {
    +599 	var algName = this.getSignatureAlgorithmField();
    +600 	var hSigVal = this.getSignatureValueHex();
    +601 	var hTbsCert = _getTLVbyList(this.hex, 0, [0], "30");
    +602 	
    +603 	var sig = new KJUR.crypto.Signature({alg: algName});
    +604 	sig.init(pubKey);
    +605 	sig.updateHex(hTbsCert);
    +606 	return sig.verify(hSigVal);
    +607     };
    +608 
    +609     // ===== parse extension ======================================
    +610     /**
    +611      * set array of X.509v3 and CSR extesion information such as extension OID, criticality and value index. (DEPRECATED)<br/>
    +612      * @name parseExt
    +613      * @memberOf X509#
    +614      * @function
    +615      * @param {String} hCSR - PEM string of certificate signing requrest(CSR) (OPTION)
    +616      * @since jsrsasign 7.2.0 x509 1.1.14
    +617      * @deprecated jsrsasign 9.1.1 x509 2.0.1
    +618      *
    +619      * @description
    +620      * This method will set an array of X.509v3 extension information having 
    +621      * following parameters:
    +622      * <ul>
    +623      * <li>oid - extension OID (ex. 2.5.29.19)</li>
    +624      * <li>critical - true or false</li>
    +625      * <li>vidx - string index for extension value</li>
    +626      * <br/>
    +627      * When you want to parse extensionRequest of CSR,
    +628      * argument 'hCSR' shall be specified.
    +629      * <br/>
    +630      * NOTE: CSR is supported from jsrsasign 8.0.20 x509 1.1.22.
    +631      * <br/>
    +632      * This method and X509.aExtInfo property
    +633      * have been *deprecated* since jsrsasign 9.1.1.
    +634      * All extension parser method such as X509.getExt* shall be
    +635      * call with argument "hExtV" and "critical" explicitly.
    +636      *
    +637      * @example
    +638      * x = new X509();
    +639      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +640      *
    +641      * x.aExtInfo →
    +642      * [ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ]
    +643      *
    +644      * // to parse CSR
    +645      * X = new X509()
    +646      * x.parseExt("-----BEGIN CERTIFICATE REQUEST-----...");
    +647      * x.aExtInfo →
    +648      * [ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ]
    +649      */
    +650     this.parseExt = function(hCSR) {
    +651 	var iExtSeq, aExtIdx, h;
    +652 
    +653 	if (hCSR === undefined) {
    +654 	    h = this.hex;
    +655 	    if (this.version !== 3) return -1;
    +656 	    iExtSeq = _getIdxbyList(h, 0, [0, 7, 0], "30");
    +657 	    aExtIdx = _getChildIdx(h, iExtSeq);
    +658 	} else {
    +659 	    h = pemtohex(hCSR);
    +660 	    var idx1 = _getIdxbyList(h, 0, [0, 3, 0, 0], "06");
    +661 
    +662 	    if (_getV(h, idx1) != "2a864886f70d01090e") {
    +663 		this.aExtInfo = new Array();
    +664 		return;
    +665 	    }
    +666 
    +667 	    iExtSeq = _getIdxbyList(h, 0, [0, 3, 0, 1, 0], "30");
    +668 	    aExtIdx = _getChildIdx(h, iExtSeq);
    +669 
    +670 	    this.hex = h;
    +671 	}
    +672 	    
    +673 	this.aExtInfo = new Array();
    +674 	for (var i = 0; i < aExtIdx.length; i++) {
    +675 	    var item = {};
    +676 	    item.critical = false;
    +677 	    var a = _getChildIdx(h, aExtIdx[i]);
    +678 	    var offset = 0;
    +679 
    +680 	    if (a.length === 3) {
    +681 		item.critical = true;
    +682 		offset = 1;
    +683 	    }
    +684 
    +685 	    item.oid = _ASN1HEX.hextooidstr(_getVbyList(h, aExtIdx[i], [0], "06"));
    +686 	    var octidx = _getIdxbyList(h, aExtIdx[i], [1 + offset]);
    +687 	    item.vidx = _getVidx(h, octidx);
    +688 	    this.aExtInfo.push(item);
    +689 	}
     690     };
     691 
     692     /**
    -693      * get BasicConstraints extension value as object in the certificate
    -694      * @name getExtBasicConstraints
    +693      * get a X.509v3 extesion information such as extension OID, criticality and value index for specified oid or name.<br/>
    +694      * @name getExtInfo
     695      * @memberOf X509#
     696      * @function
    -697      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -698      * @param {Boolean} critical flag (OPTIONAL)
    -699      * @return {Array} JSON object of BasicConstraints parameter or undefined
    -700      * @since jsrsasign 7.2.0 x509 1.1.14
    -701      * @see KJUR.asn1.x509.BasicConstraints
    -702      * @description
    -703      * This method will get basic constraints extension value as object with following paramters.
    -704      * <ul>
    -705      * <li>{Boolean}cA - CA flag whether CA or not</li>
    -706      * <li>{Integer}pathLen - maximum intermediate certificate length</li>
    -707      * <li>{Boolean}critical - critical flag</li>
    -708      * </ul>
    -709      * There are use cases for return values:
    -710      * <ul>
    -711      * <li>{cA:true,pathLen:3,critical:true} - cA flag is true and pathLen is 3</li>
    -712      * <li>{cA:true,critical:true} - cA flag is true and no pathLen</li>
    -713      * <li>{} - basic constraints has no value in case of end entity certificate</li>
    -714      * <li>undefined - there is no basic constraints extension</li>
    -715      * </ul>
    -716      * @example
    -717      * x = new X509();
    -718      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -719      * x.getExtBasicConstraints() → {cA:true,pathLen:3,critical:true}
    -720      */
    -721     this.getExtBasicConstraints = function(hExtV, critical) {
    -722 	if (hExtV === undefined && critical === undefined) {
    -723 	    var info = this.getExtInfo("basicConstraints");
    -724 	    if (info === undefined) return undefined;
    -725 	    hExtV = _getTLV(this.hex, info.vidx);
    -726 	    critical = info.critical;
    -727 	}
    -728 
    -729 	var result = {extname:"basicConstraints"};
    -730 	if (critical) result.critical = true;
    -731 
    -732 	if (hExtV === '3000') return result;
    -733 	if (hExtV === '30030101ff') {
    -734 	    result.cA = true;
    -735 	    return result;
    -736 	}
    -737 	if (hExtV.substr(0, 12) === '30060101ff02') {
    -738 	    var pathLexHex = _getV(hExtV, 10);
    -739 	    var pathLen = parseInt(pathLexHex, 16);
    -740 	    result.cA = true;
    -741 	    result.pathLen = pathLen;
    -742 	    return result;
    -743 	}
    -744 	throw new Error("hExtV parse error: " + hExtV);
    -745     };
    -746 
    -747     /**
    -748      * get NameConstraints extension value as object in the certificate<br/>
    -749      * @name getExtNameConstraints
    -750      * @memberOf X509#
    -751      * @function
    -752      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -753      * @param {Boolean} critical flag (OPTIONAL)
    -754      * @return {Object} JSON object of NamConstraints parameter or undefined
    -755      * @since jsrsasign 10.5.16 x509 2.0.16
    -756      * @see KJUR.asn1.x509.NameConstraints
    -757      * @see KJUR.asn1.x509.GeneralSubtree
    -758      * @see KJUR.asn1.x509.GeneralName
    -759      * @see X509#getGeneralSubtree
    -760      * @see X509#getGeneralName
    -761      *
    -762      * @description
    -763      * This method will get name constraints extension value as object with following paramters.
    -764      * <ul>
    -765      * <li>{Array}permit - array of {@link KJUR.asn1.x509.GeneralSubtree} parameter</li>
    -766      * <li>{Array}exclude - array of {@link KJUR.asn1.x509.GeneralSubtree} parameter</li>
    -767      * <li>{Boolean}critical - critical flag</li>
    -768      * </ul>
    -769      *
    -770      * @example
    -771      * x = new X509(sCertPEM);
    -772      * x.getExtNameConstraints() → {
    -773      *   critical: true,
    -774      *   permit: [{dns: 'example.com'},{rfc822: 'john@example.com'}],
    -775      *   exclude: [{dn: {...X500Name parameter...}}]
    -776      * }
    -777      */
    -778     this.getExtNameConstraints = function(hExtV, critical) {
    -779 	if (hExtV === undefined && critical === undefined) {
    -780 	    var info = this.getExtInfo("nameConstraints");
    -781 	    if (info === undefined) return undefined;
    -782 	    hExtV = _getTLV(this.hex, info.vidx);
    -783 	    critical = info.critical;
    -784 	}
    -785 
    -786 	var result = {extname:"nameConstraints"};
    -787 	if (critical) result.critical = true;
    -788 
    -789 	var aIdx = _getChildIdx(hExtV, 0);
    -790 	for (var i = 0; i < aIdx.length; i++) {
    -791 	    var aList = [];
    -792 	    var aIdx2 = _getChildIdx(hExtV, aIdx[i]);
    -793 	    for (var j = 0; j < aIdx2.length; j++) {
    -794 		var hSub = _getTLV(hExtV, aIdx2[j]);
    -795 		var p = this.getGeneralSubtree(hSub);
    -796 		aList.push(p);
    -797 	    }
    -798 
    -799 	    var tag = hExtV.substr(aIdx[i], 2); 
    -800 	    if (tag == "a0") {
    -801 		result.permit = aList;
    -802 	    } else if (tag == "a1") {
    -803 		result.exclude = aList;
    -804 	    }
    -805 	}
    -806 	return result;
    -807     };
    -808 
    -809     /**
    -810      * get GeneralSubtree ASN.1 structure parameter as JSON object<br/>
    -811      * @name getGeneralSubtree
    -812      * @memberOf X509#
    -813      * @function
    -814      * @param {String} h hexadecimal string of GeneralSubtree
    -815      * @return {Object} JSON object of GeneralSubtree parameters or undefined
    -816      * @since jsrsasign 10.5.16 x509 2.0.16
    -817      * @see KJUR.asn1.x509.GeneralSubtree
    -818      * @see KJUR.asn1.x509.GeneralName
    -819      * @see X509#getExtNameConstraints
    -820      * @see X509#getGeneralName
    -821      *
    -822      * @description
    -823      * This method will get GeneralSubtree parameters defined in
    -824      * <a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.10">
    -825      * RFC 5280 4.2.1.10</a>.
    -826      * <pre>
    -827      * GeneralSubtree ::= SEQUENCE {
    -828      *      base                    GeneralName,
    -829      *      minimum         [0]     BaseDistance DEFAULT 0,
    -830      *      maximum         [1]     BaseDistance OPTIONAL }
    -831      * BaseDistance ::= INTEGER (0..MAX)
    -832      * </pre>
    -833      * Result of this method can be passed to
    -834      * {@link KJUR.asn1.x509.GeneralSubtree} constructor.
    -835      * 
    -836      * @example
    -837      * x = new X509(sPEM);
    -838      * x.getGeneralSubtree("30...") → { dn: ...X500NameObject..., min: 1, max: 3 }
    -839      * x.getGeneralSubtree("30...") → { dns: ".example.com" }
    -840      */
    -841     this.getGeneralSubtree = function(h) {
    -842 	var aIdx = _getChildIdx(h, 0);
    -843 	var len = aIdx.length;
    -844 	if (len < 1 || 2 < len) throw new Error("wrong num elements");
    -845 	var result = this.getGeneralName(_getTLV(h, aIdx[0]));
    -846 
    -847 	for (var i = 1; i < len; i++) {
    -848 	    var tag = h.substr(aIdx[i], 2);
    -849 	    var hV = _getV(h, aIdx[i]);
    -850 	    var minmaxValue = parseInt(hV, 16);
    -851 	    if (tag == "80") result.min = minmaxValue;
    -852 	    if (tag == "81") result.max = minmaxValue;
    -853 	}
    -854 	return result;
    -855     };
    -856 
    -857     /**
    -858      * get KeyUsage extension value as JSON object
    -859      * @memberOf X509#
    -860      * @function
    -861      * @name getExtKeyUsage
    -862      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -863      * @param {Boolean} critical flag (OPTIONAL)
    -864      * @return {Array} JSON object of KeyUsage parameter or undefined
    -865      * @since jsrsasign 9.0.0 x509 2.0.0
    -866      * @see KJUR.asn1.x509.KeyUsage
    -867      * @see X509#getExtKeyUsageString
    -868      * @description
    -869      * This method parse keyUsage extension. When arguments are
    -870      * not specified, its extension in X509 object will be parsed.
    -871      * Result of this method can be passed to 
    -872      * {@link KJUR.asn1.x509.KeyUsage} constructor.
    -873      * <br>
    -874      * When hExtV and critical specified as arguments, return value
    -875      * will be generated from them.
    -876      * <pre>
    -877      * id-ce-keyUsage OBJECT IDENTIFIER ::=  { id-ce 15 }
    -878      * KeyUsage ::= BIT STRING {
    -879      *      digitalSignature        (0),
    -880      *      nonRepudiation          (1),
    -881      *      keyEncipherment         (2),
    -882      *      dataEncipherment        (3),
    -883      *      keyAgreement            (4),
    -884      *      keyCertSign             (5),
    -885      *      cRLSign                 (6),
    -886      *      encipherOnly            (7),
    -887      *      decipherOnly            (8) }     
    -888      * </pre>
    -889      * @example
    -890      * x = new X509();
    -891      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -892      * x.getExtKeyUsage() →
    -893      * {
    -894      *   critial: true,
    -895      *   names: ["digitalSignature", "decipherOnly"]
    -896      * }
    -897      *
    -898      * x = new X509();
    -899      * x.getExtKeyUsage("306230...") 
    -900      * x.getExtKeyUsage("306230...", true) 
    -901      */
    -902     this.getExtKeyUsage = function(hExtV, critical) {
    -903 	if (hExtV === undefined && critical === undefined) {
    -904 	    var info = this.getExtInfo("keyUsage");
    -905 	    if (info === undefined) return undefined;
    -906 	    hExtV = _getTLV(this.hex, info.vidx);
    -907 	    critical = info.critical;
    -908 	}
    -909 
    -910 	var result = {extname:"keyUsage"};
    -911 	if (critical) result.critical = true;
    -912 
    -913 	result.names = this.getExtKeyUsageString(hExtV).split(",");
    -914 
    -915 	return result;
    -916     };
    -917 
    -918     /**
    -919      * get KeyUsage extension value as binary string in the certificate<br/>
    -920      * @name getExtKeyUsageBin
    -921      * @memberOf X509#
    -922      * @function
    -923      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -924      * @return {String} binary string of key usage bits (ex. '101')
    -925      * @since jsrsasign 7.2.0 x509 1.1.14
    -926      * @see X509#getExtKeyUsage
    -927      * @description
    -928      * This method will get key usage extension value
    -929      * as binary string such like '101'.
    -930      * Key usage bits definition is in the RFC 5280.
    -931      * If there is no key usage extension in the certificate,
    -932      * it returns empty string (i.e. '').
    -933      * <br/>
    -934      * NOTE: argument 'hExtV' supported since jsrsasign 9.0.0 x509 2.0.0.
    -935      * @example
    -936      * x = new X509();
    -937      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -938      * x.getExtKeyUsageBin() → '101'
    -939      * // 1 - digitalSignature
    -940      * // 0 - nonRepudiation
    -941      * // 1 - keyEncipherment
    -942      */
    -943     this.getExtKeyUsageBin = function(hExtV) {
    -944 	if (hExtV === undefined) {
    -945 	    var info = this.getExtInfo("keyUsage");
    -946 	    if (info === undefined) return '';
    -947 	    hExtV = _getTLV(this.hex, info.vidx);
    -948 	}
    -949 	
    -950 	if (hExtV.length != 8 && hExtV.length != 10)
    -951 	    throw new Error("malformed key usage value: " + hExtV);
    -952 
    -953 	var s = "000000000000000" + parseInt(hExtV.substr(6), 16).toString(2);
    -954 	if (hExtV.length == 8) s = s.slice(-8);
    -955 	if (hExtV.length == 10) s = s.slice(-16);
    -956 	s = s.replace(/0+$/, '');
    -957 	if (s == '') s = '0';
    -958 	return s;
    -959     };
    -960 
    -961     /**
    -962      * get KeyUsage extension value as names in the certificate<br/>
    -963      * @name getExtKeyUsageString
    -964      * @memberOf X509#
    -965      * @function
    -966      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -967      * @return {String} comma separated string of key usage
    -968      * @since jsrsasign 7.2.0 x509 1.1.14
    -969      * @see X509#getExtKeyUsage
    -970      * @description
    -971      * This method will get key usage extension value
    -972      * as comma separated string of usage names.
    -973      * If there is no key usage extension in the certificate,
    -974      * it returns empty string (i.e. '').
    -975      * <br/>
    -976      * NOTE: argument 'hExtV' supported since jsrsasign 9.0.0 x509 2.0.0.
    -977      * @example
    -978      * x = new X509();
    -979      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -980      * x.getExtKeyUsageString() → "digitalSignature,keyEncipherment"
    -981      */
    -982     this.getExtKeyUsageString = function(hExtV) {
    -983 	var bKeyUsage = this.getExtKeyUsageBin(hExtV);
    -984 	var a = new Array();
    -985 	for (var i = 0; i < bKeyUsage.length; i++) {
    -986 	    if (bKeyUsage.substr(i, 1) == "1") a.push(X509.KEYUSAGE_NAME[i]);
    -987 	}
    -988 	return a.join(",");
    -989     };
    -990 
    -991     /**
    -992      * get subjectKeyIdentifier value as hexadecimal string in the certificate<br/>
    -993      * @name getExtSubjectKeyIdentifier
    -994      * @memberOf X509#
    -995      * @function
    -996      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -997      * @param {Boolean} critical flag (OPTIONAL)
    -998      * @return {Array} JSON object of SubjectKeyIdentifier parameter or undefined
    -999      * @since jsrsasign 7.2.0 x509 1.1.14
    -1000      * @description
    -1001      * This method will get 
    -1002      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">
    -1003      * SubjectKeyIdentifier extension</a> value as JSON object.
    -1004      * <br>
    -1005      * When hExtV and critical specified as arguments, return value
    -1006      * will be generated from them.
    -1007      * If there is no such extension in the certificate, it returns undefined.
    -1008      * <br>
    -1009      * Result of this method can be passed to 
    -1010      * {@link KJUR.asn1.x509.SubjectKeyIdentifier} constructor.
    -1011      * <pre>
    -1012      * id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 14 }
    -1013      * SubjectKeyIdentifier ::= KeyIdentifier
    -1014      * </pre>
    -1015      * <br>
    -1016      * CAUTION:
    -1017      * Returned JSON value format have been changed without 
    -1018      * backward compatibility since jsrsasign 9.0.0 x509 2.0.0.
    -1019      *
    -1020      * @example
    -1021      * x = new X509();
    -1022      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1023      * x.getExtSubjectKeyIdentifier() → 
    -1024      * { kid: {hex: "1b3347ab..."}, critical: true };
    -1025      */
    -1026     this.getExtSubjectKeyIdentifier = function(hExtV, critical) {
    -1027 	if (hExtV === undefined && critical === undefined) {
    -1028 	    var info = this.getExtInfo("subjectKeyIdentifier");
    -1029 	    if (info === undefined) return undefined;
    -1030 	    hExtV = _getTLV(this.hex, info.vidx);
    -1031 	    critical = info.critical;
    -1032 	}
    -1033 
    -1034 	var result = {extname:"subjectKeyIdentifier"};
    -1035 	if (critical) result.critical = true;
    -1036 
    -1037 	var hKID = _getV(hExtV, 0);
    -1038 	result.kid = {hex: hKID};
    -1039 
    -1040 	return result;
    -1041     };
    -1042 
    -1043     /**
    -1044      * get authorityKeyIdentifier value as JSON object in the certificate<br/>
    -1045      * @name getExtAuthorityKeyIdentifier
    -1046      * @memberOf X509#
    -1047      * @function
    -1048      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1049      * @param {Boolean} critical flag (OPTIONAL)
    -1050      * @return {Array} JSON object of AuthorityKeyIdentifier parameter or undefined
    -1051      * @since jsrsasign 7.2.0 x509 1.1.14
    -1052      * @see KJUR.asn1.x509.AuthorityKeyIdentifier
    -1053      * @description
    -1054      * This method will get 
    -1055      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.1">
    -1056      * AuthorityKeyIdentifier extension</a> value as JSON object.
    -1057      * <br>
    -1058      * When hExtV and critical specified as arguments, return value
    -1059      * will be generated from them.
    -1060      * If there is no such extension in the certificate, it returns undefined.
    -1061      * <br/>
    -1062      * Result of this method can be passed to 
    -1063      * {@link KJUR.asn1.x509.AuthorityKeyIdentifier} constructor.
    -1064      * <pre>
    -1065      *    id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 35 }
    -1066      *    AuthorityKeyIdentifier ::= SEQUENCE {
    -1067      *       keyIdentifier             [0] KeyIdentifier           OPTIONAL,
    -1068      *       authorityCertIssuer       [1] GeneralNames            OPTIONAL,
    -1069      *       authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL  }
    -1070      *    KeyIdentifier ::= OCTET STRING
    -1071      * </pre>
    -1072      * Constructor may have following parameters:
    -1073      * <ul>
    -1074      * <li>{Array}kid - JSON object of {@link KJUR.asn1.DEROctetString} parameters</li>
    -1075      * <li>{Array}issuer - JSON object of {@link KJUR.asn1.x509.X500Name} parameters</li>
    -1076      * <li>{Array}sn - JSON object of {@link KJUR.asn1.DERInteger} parameters</li>
    -1077      * <li>{Boolean}critical - critical flag</li>
    -1078      * </ul>
    -1079      * <br>
    -1080      * NOTE: The 'authorityCertIssuer' and 'authorityCertSerialNumber'
    -1081      * supported since jsrsasign 9.0.0 x509 2.0.0.
    -1082      * @example
    -1083      * x = new X509();
    -1084      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1085      * x.getExtAuthorityKeyIdentifier() → 
    -1086      * { kid: {hex: "1234abcd..."},
    -1087      *   issuer: {hex: "30..."},
    -1088      *   sn: {hex: "1234..."},
    -1089      *   critical: true}
    -1090      */
    -1091     this.getExtAuthorityKeyIdentifier = function(hExtV, critical) {
    -1092 	if (hExtV === undefined && critical === undefined) {
    -1093 	    var info = this.getExtInfo("authorityKeyIdentifier");
    -1094 	    if (info === undefined) return undefined;
    -1095 	    hExtV = _getTLV(this.hex, info.vidx);
    -1096 	    critical = info.critical;
    -1097 	}
    -1098 
    -1099 	var result = {extname:"authorityKeyIdentifier"};
    -1100 	if (critical) result.critical = true;
    -1101 
    -1102 	var a = _getChildIdx(hExtV, 0);
    -1103 	for (var i = 0; i < a.length; i++) {
    -1104 	    var tag = hExtV.substr(a[i], 2);
    -1105 	    if (tag === "80") {
    -1106 		result.kid = {hex: _getV(hExtV, a[i])};
    -1107 	    }
    -1108 	    if (tag === "a1") {
    -1109 		var hGNS = _getTLV(hExtV, a[i]);
    -1110 		var gnsParam = this.getGeneralNames(hGNS);
    -1111 		result.issuer = gnsParam[0]["dn"];
    -1112 	    }
    -1113 	    if (tag === "82") {
    -1114 		result.sn = {hex: _getV(hExtV, a[i])};
    -1115 	    }
    -1116 	}
    -1117 	return result;
    -1118     };
    -1119 
    -1120     /**
    -1121      * get extKeyUsage value as JSON object
    -1122      * @name getExtExtKeyUsage
    -1123      * @memberOf X509#
    -1124      * @function
    -1125      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1126      * @param {Boolean} critical flag (OPTIONAL)
    -1127      * @return {Array} JSON object of ExtKeyUsage parameter or undefined
    -1128      * @return {Object} JSONarray of extended key usage ID name or oid
    -1129      * @since jsrsasign 9.0.0 x509 2.0.0
    -1130      * @see KJUR.asn1.x509.ExtKeyUsage
    -1131      * @description
    -1132      * This method parse extKeyUsage extension. When arguments are
    -1133      * not specified, its extension in X509 object will be parsed.
    -1134      * Result of this method can be passed to 
    -1135      * {@link KJUR.asn1.x509.ExtKeyUsage} constructor.
    -1136      * <br>
    -1137      * When hExtV and critical specified as arguments, return value
    -1138      * will be generated from them.
    -1139      * @example
    -1140      * x = new X509();
    -1141      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1142      * x.getExtExtKeyUsage() →
    -1143      * { array: ["clientAuth", "emailProtection", "1.3.6.1.4.1.311.10.3.4"], 
    -1144      *   critical: true},
    -1145      */
    -1146     this.getExtExtKeyUsage = function(hExtV, critical) {
    -1147 	if (hExtV === undefined && critical === undefined) {
    -1148 	    var info = this.getExtInfo("extKeyUsage");
    -1149 	    if (info === undefined) return undefined;
    -1150 	    hExtV = _getTLV(this.hex, info.vidx);
    -1151 	    critical = info.critical;
    -1152 	}
    +697      * @param {String} oidOrName X.509 extension oid or name (ex. keyUsage or 2.5.29.19)
    +698      * @return X.509 extension information such as extension OID or value indx (see {@link X509#parseExt})
    +699      * @since jsrsasign 7.2.0 x509 1.1.14
    +700      * @description
    +701      * This method will get an X.509v3 extension information JSON object
    +702      * having extension OID, criticality and value idx for specified
    +703      * extension OID or name.
    +704      * If there is no such extension, this returns undefined.
    +705      * @example
    +706      * x = new X509();
    +707      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +708      *
    +709      * x.getExtInfo("keyUsage") → { oid: "2.5.29.15", critical: true, vidx: 1714 }
    +710      * x.getExtInfo("unknownExt") → undefined
    +711      */
    +712     this.getExtInfo = function(oidOrName) {
    +713 	var a = this.aExtInfo;
    +714 	var oid = oidOrName;
    +715 	if (! oidOrName.match(/^[0-9.]+$/)) {
    +716 	    oid = KJUR.asn1.x509.OID.name2oid(oidOrName);
    +717 	}
    +718 	if (oid === '') return undefined;
    +719 
    +720 	for (var i = 0; i < a.length; i++) {
    +721 	    if (a[i].oid === oid) return a[i];
    +722 	}
    +723 	return undefined;
    +724     };
    +725 
    +726     /**
    +727      * get BasicConstraints extension value as object in the certificate
    +728      * @name getExtBasicConstraints
    +729      * @memberOf X509#
    +730      * @function
    +731      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +732      * @param {Boolean} critical flag (OPTIONAL)
    +733      * @return {Array} JSON object of BasicConstraints parameter or undefined
    +734      * @since jsrsasign 7.2.0 x509 1.1.14
    +735      * @see KJUR.asn1.x509.BasicConstraints
    +736      * @description
    +737      * This method will get basic constraints extension value as object with following paramters.
    +738      * <ul>
    +739      * <li>{Boolean}cA - CA flag whether CA or not</li>
    +740      * <li>{Integer}pathLen - maximum intermediate certificate length</li>
    +741      * <li>{Boolean}critical - critical flag</li>
    +742      * </ul>
    +743      * There are use cases for return values:
    +744      * <ul>
    +745      * <li>{cA:true,pathLen:3,critical:true} - cA flag is true and pathLen is 3</li>
    +746      * <li>{cA:true,critical:true} - cA flag is true and no pathLen</li>
    +747      * <li>{} - basic constraints has no value in case of end entity certificate</li>
    +748      * <li>undefined - there is no basic constraints extension</li>
    +749      * </ul>
    +750      * @example
    +751      * x = new X509();
    +752      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +753      * x.getExtBasicConstraints() → {cA:true,pathLen:3,critical:true}
    +754      */
    +755     this.getExtBasicConstraints = function(hExtV, critical) {
    +756 	if (hExtV === undefined && critical === undefined) {
    +757 	    var info = this.getExtInfo("basicConstraints");
    +758 	    if (info === undefined) return undefined;
    +759 	    hExtV = _getTLV(this.hex, info.vidx);
    +760 	    critical = info.critical;
    +761 	}
    +762 
    +763 	var result = {extname:"basicConstraints"};
    +764 	if (critical) result.critical = true;
    +765 
    +766 	if (hExtV === '3000') return result;
    +767 	if (hExtV === '30030101ff') {
    +768 	    result.cA = true;
    +769 	    return result;
    +770 	}
    +771 	if (hExtV.substr(0, 12) === '30060101ff02') {
    +772 	    var pathLexHex = _getV(hExtV, 10);
    +773 	    var pathLen = parseInt(pathLexHex, 16);
    +774 	    result.cA = true;
    +775 	    result.pathLen = pathLen;
    +776 	    return result;
    +777 	}
    +778 	throw new Error("hExtV parse error: " + hExtV);
    +779     };
    +780 
    +781     /**
    +782      * get NameConstraints extension value as object in the certificate<br/>
    +783      * @name getExtNameConstraints
    +784      * @memberOf X509#
    +785      * @function
    +786      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +787      * @param {Boolean} critical flag (OPTIONAL)
    +788      * @return {Object} JSON object of NamConstraints parameter or undefined
    +789      * @since jsrsasign 10.5.16 x509 2.0.16
    +790      * @see KJUR.asn1.x509.NameConstraints
    +791      * @see KJUR.asn1.x509.GeneralSubtree
    +792      * @see KJUR.asn1.x509.GeneralName
    +793      * @see X509#getGeneralSubtree
    +794      * @see X509#getGeneralName
    +795      *
    +796      * @description
    +797      * This method will get name constraints extension value as object with following paramters.
    +798      * <ul>
    +799      * <li>{Array}permit - array of {@link KJUR.asn1.x509.GeneralSubtree} parameter</li>
    +800      * <li>{Array}exclude - array of {@link KJUR.asn1.x509.GeneralSubtree} parameter</li>
    +801      * <li>{Boolean}critical - critical flag</li>
    +802      * </ul>
    +803      *
    +804      * @example
    +805      * x = new X509(sCertPEM);
    +806      * x.getExtNameConstraints() → {
    +807      *   critical: true,
    +808      *   permit: [{dns: 'example.com'},{rfc822: 'john@example.com'}],
    +809      *   exclude: [{dn: {...X500Name parameter...}}]
    +810      * }
    +811      */
    +812     this.getExtNameConstraints = function(hExtV, critical) {
    +813 	if (hExtV === undefined && critical === undefined) {
    +814 	    var info = this.getExtInfo("nameConstraints");
    +815 	    if (info === undefined) return undefined;
    +816 	    hExtV = _getTLV(this.hex, info.vidx);
    +817 	    critical = info.critical;
    +818 	}
    +819 
    +820 	var result = {extname:"nameConstraints"};
    +821 	if (critical) result.critical = true;
    +822 
    +823 	var aIdx = _getChildIdx(hExtV, 0);
    +824 	for (var i = 0; i < aIdx.length; i++) {
    +825 	    var aList = [];
    +826 	    var aIdx2 = _getChildIdx(hExtV, aIdx[i]);
    +827 	    for (var j = 0; j < aIdx2.length; j++) {
    +828 		var hSub = _getTLV(hExtV, aIdx2[j]);
    +829 		var p = this.getGeneralSubtree(hSub);
    +830 		aList.push(p);
    +831 	    }
    +832 
    +833 	    var tag = hExtV.substr(aIdx[i], 2); 
    +834 	    if (tag == "a0") {
    +835 		result.permit = aList;
    +836 	    } else if (tag == "a1") {
    +837 		result.exclude = aList;
    +838 	    }
    +839 	}
    +840 	return result;
    +841     };
    +842 
    +843     /**
    +844      * get GeneralSubtree ASN.1 structure parameter as JSON object<br/>
    +845      * @name getGeneralSubtree
    +846      * @memberOf X509#
    +847      * @function
    +848      * @param {String} h hexadecimal string of GeneralSubtree
    +849      * @return {Object} JSON object of GeneralSubtree parameters or undefined
    +850      * @since jsrsasign 10.5.16 x509 2.0.16
    +851      * @see KJUR.asn1.x509.GeneralSubtree
    +852      * @see KJUR.asn1.x509.GeneralName
    +853      * @see X509#getExtNameConstraints
    +854      * @see X509#getGeneralName
    +855      *
    +856      * @description
    +857      * This method will get GeneralSubtree parameters defined in
    +858      * <a href="https://datatracker.ietf.org/doc/html/rfc5280#section-4.2.1.10">
    +859      * RFC 5280 4.2.1.10</a>.
    +860      * <pre>
    +861      * GeneralSubtree ::= SEQUENCE {
    +862      *      base                    GeneralName,
    +863      *      minimum         [0]     BaseDistance DEFAULT 0,
    +864      *      maximum         [1]     BaseDistance OPTIONAL }
    +865      * BaseDistance ::= INTEGER (0..MAX)
    +866      * </pre>
    +867      * Result of this method can be passed to
    +868      * {@link KJUR.asn1.x509.GeneralSubtree} constructor.
    +869      * 
    +870      * @example
    +871      * x = new X509(sPEM);
    +872      * x.getGeneralSubtree("30...") → { dn: ...X500NameObject..., min: 1, max: 3 }
    +873      * x.getGeneralSubtree("30...") → { dns: ".example.com" }
    +874      */
    +875     this.getGeneralSubtree = function(h) {
    +876 	var aIdx = _getChildIdx(h, 0);
    +877 	var len = aIdx.length;
    +878 	if (len < 1 || 2 < len) throw new Error("wrong num elements");
    +879 	var result = this.getGeneralName(_getTLV(h, aIdx[0]));
    +880 
    +881 	for (var i = 1; i < len; i++) {
    +882 	    var tag = h.substr(aIdx[i], 2);
    +883 	    var hV = _getV(h, aIdx[i]);
    +884 	    var minmaxValue = parseInt(hV, 16);
    +885 	    if (tag == "80") result.min = minmaxValue;
    +886 	    if (tag == "81") result.max = minmaxValue;
    +887 	}
    +888 	return result;
    +889     };
    +890 
    +891     /**
    +892      * get KeyUsage extension value as JSON object
    +893      * @memberOf X509#
    +894      * @function
    +895      * @name getExtKeyUsage
    +896      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +897      * @param {Boolean} critical flag (OPTIONAL)
    +898      * @return {Array} JSON object of KeyUsage parameter or undefined
    +899      * @since jsrsasign 9.0.0 x509 2.0.0
    +900      * @see KJUR.asn1.x509.KeyUsage
    +901      * @see X509#getExtKeyUsageString
    +902      * @description
    +903      * This method parse keyUsage extension. When arguments are
    +904      * not specified, its extension in X509 object will be parsed.
    +905      * Result of this method can be passed to 
    +906      * {@link KJUR.asn1.x509.KeyUsage} constructor.
    +907      * <br>
    +908      * When hExtV and critical specified as arguments, return value
    +909      * will be generated from them.
    +910      * <pre>
    +911      * id-ce-keyUsage OBJECT IDENTIFIER ::=  { id-ce 15 }
    +912      * KeyUsage ::= BIT STRING {
    +913      *      digitalSignature        (0),
    +914      *      nonRepudiation          (1),
    +915      *      keyEncipherment         (2),
    +916      *      dataEncipherment        (3),
    +917      *      keyAgreement            (4),
    +918      *      keyCertSign             (5),
    +919      *      cRLSign                 (6),
    +920      *      encipherOnly            (7),
    +921      *      decipherOnly            (8) }     
    +922      * </pre>
    +923      * @example
    +924      * x = new X509();
    +925      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +926      * x.getExtKeyUsage() →
    +927      * {
    +928      *   critial: true,
    +929      *   names: ["digitalSignature", "decipherOnly"]
    +930      * }
    +931      *
    +932      * x = new X509();
    +933      * x.getExtKeyUsage("306230...") 
    +934      * x.getExtKeyUsage("306230...", true) 
    +935      */
    +936     this.getExtKeyUsage = function(hExtV, critical) {
    +937 	if (hExtV === undefined && critical === undefined) {
    +938 	    var info = this.getExtInfo("keyUsage");
    +939 	    if (info === undefined) return undefined;
    +940 	    hExtV = _getTLV(this.hex, info.vidx);
    +941 	    critical = info.critical;
    +942 	}
    +943 
    +944 	var result = {extname:"keyUsage"};
    +945 	if (critical) result.critical = true;
    +946 
    +947 	result.names = this.getExtKeyUsageString(hExtV).split(",");
    +948 
    +949 	return result;
    +950     };
    +951 
    +952     /**
    +953      * get KeyUsage extension value as binary string in the certificate<br/>
    +954      * @name getExtKeyUsageBin
    +955      * @memberOf X509#
    +956      * @function
    +957      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +958      * @return {String} binary string of key usage bits (ex. '101')
    +959      * @since jsrsasign 7.2.0 x509 1.1.14
    +960      * @see X509#getExtKeyUsage
    +961      * @description
    +962      * This method will get key usage extension value
    +963      * as binary string such like '101'.
    +964      * Key usage bits definition is in the RFC 5280.
    +965      * If there is no key usage extension in the certificate,
    +966      * it returns empty string (i.e. '').
    +967      * <br/>
    +968      * NOTE: argument 'hExtV' supported since jsrsasign 9.0.0 x509 2.0.0.
    +969      * @example
    +970      * x = new X509();
    +971      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +972      * x.getExtKeyUsageBin() → '101'
    +973      * // 1 - digitalSignature
    +974      * // 0 - nonRepudiation
    +975      * // 1 - keyEncipherment
    +976      */
    +977     this.getExtKeyUsageBin = function(hExtV) {
    +978 	if (hExtV === undefined) {
    +979 	    var info = this.getExtInfo("keyUsage");
    +980 	    if (info === undefined) return '';
    +981 	    hExtV = _getTLV(this.hex, info.vidx);
    +982 	}
    +983 	
    +984 	if (hExtV.length != 8 && hExtV.length != 10)
    +985 	    throw new Error("malformed key usage value: " + hExtV);
    +986 
    +987 	var s = "000000000000000" + parseInt(hExtV.substr(6), 16).toString(2);
    +988 	if (hExtV.length == 8) s = s.slice(-8);
    +989 	if (hExtV.length == 10) s = s.slice(-16);
    +990 	s = s.replace(/0+$/, '');
    +991 	if (s == '') s = '0';
    +992 	return s;
    +993     };
    +994 
    +995     /**
    +996      * get KeyUsage extension value as names in the certificate<br/>
    +997      * @name getExtKeyUsageString
    +998      * @memberOf X509#
    +999      * @function
    +1000      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1001      * @return {String} comma separated string of key usage
    +1002      * @since jsrsasign 7.2.0 x509 1.1.14
    +1003      * @see X509#getExtKeyUsage
    +1004      * @description
    +1005      * This method will get key usage extension value
    +1006      * as comma separated string of usage names.
    +1007      * If there is no key usage extension in the certificate,
    +1008      * it returns empty string (i.e. '').
    +1009      * <br/>
    +1010      * NOTE: argument 'hExtV' supported since jsrsasign 9.0.0 x509 2.0.0.
    +1011      * @example
    +1012      * x = new X509();
    +1013      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1014      * x.getExtKeyUsageString() → "digitalSignature,keyEncipherment"
    +1015      */
    +1016     this.getExtKeyUsageString = function(hExtV) {
    +1017 	var bKeyUsage = this.getExtKeyUsageBin(hExtV);
    +1018 	var a = new Array();
    +1019 	for (var i = 0; i < bKeyUsage.length; i++) {
    +1020 	    if (bKeyUsage.substr(i, 1) == "1") a.push(X509.KEYUSAGE_NAME[i]);
    +1021 	}
    +1022 	return a.join(",");
    +1023     };
    +1024 
    +1025     /**
    +1026      * get subjectKeyIdentifier value as hexadecimal string in the certificate<br/>
    +1027      * @name getExtSubjectKeyIdentifier
    +1028      * @memberOf X509#
    +1029      * @function
    +1030      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1031      * @param {Boolean} critical flag (OPTIONAL)
    +1032      * @return {Array} JSON object of SubjectKeyIdentifier parameter or undefined
    +1033      * @since jsrsasign 7.2.0 x509 1.1.14
    +1034      * @description
    +1035      * This method will get 
    +1036      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.2">
    +1037      * SubjectKeyIdentifier extension</a> value as JSON object.
    +1038      * <br>
    +1039      * When hExtV and critical specified as arguments, return value
    +1040      * will be generated from them.
    +1041      * If there is no such extension in the certificate, it returns undefined.
    +1042      * <br>
    +1043      * Result of this method can be passed to 
    +1044      * {@link KJUR.asn1.x509.SubjectKeyIdentifier} constructor.
    +1045      * <pre>
    +1046      * id-ce-subjectKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 14 }
    +1047      * SubjectKeyIdentifier ::= KeyIdentifier
    +1048      * </pre>
    +1049      * <br>
    +1050      * CAUTION:
    +1051      * Returned JSON value format have been changed without 
    +1052      * backward compatibility since jsrsasign 9.0.0 x509 2.0.0.
    +1053      *
    +1054      * @example
    +1055      * x = new X509();
    +1056      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1057      * x.getExtSubjectKeyIdentifier() → 
    +1058      * { kid: {hex: "1b3347ab..."}, critical: true };
    +1059      */
    +1060     this.getExtSubjectKeyIdentifier = function(hExtV, critical) {
    +1061 	if (hExtV === undefined && critical === undefined) {
    +1062 	    var info = this.getExtInfo("subjectKeyIdentifier");
    +1063 	    if (info === undefined) return undefined;
    +1064 	    hExtV = _getTLV(this.hex, info.vidx);
    +1065 	    critical = info.critical;
    +1066 	}
    +1067 
    +1068 	var result = {extname:"subjectKeyIdentifier"};
    +1069 	if (critical) result.critical = true;
    +1070 
    +1071 	var hKID = _getV(hExtV, 0);
    +1072 	result.kid = {hex: hKID};
    +1073 
    +1074 	return result;
    +1075     };
    +1076 
    +1077     /**
    +1078      * get authorityKeyIdentifier value as JSON object in the certificate<br/>
    +1079      * @name getExtAuthorityKeyIdentifier
    +1080      * @memberOf X509#
    +1081      * @function
    +1082      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1083      * @param {Boolean} critical flag (OPTIONAL)
    +1084      * @return {Array} JSON object of AuthorityKeyIdentifier parameter or undefined
    +1085      * @since jsrsasign 7.2.0 x509 1.1.14
    +1086      * @see KJUR.asn1.x509.AuthorityKeyIdentifier
    +1087      * @description
    +1088      * This method will get 
    +1089      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.1">
    +1090      * AuthorityKeyIdentifier extension</a> value as JSON object.
    +1091      * <br>
    +1092      * When hExtV and critical specified as arguments, return value
    +1093      * will be generated from them.
    +1094      * If there is no such extension in the certificate, it returns undefined.
    +1095      * <br/>
    +1096      * Result of this method can be passed to 
    +1097      * {@link KJUR.asn1.x509.AuthorityKeyIdentifier} constructor.
    +1098      * <pre>
    +1099      *    id-ce-authorityKeyIdentifier OBJECT IDENTIFIER ::=  { id-ce 35 }
    +1100      *    AuthorityKeyIdentifier ::= SEQUENCE {
    +1101      *       keyIdentifier             [0] KeyIdentifier           OPTIONAL,
    +1102      *       authorityCertIssuer       [1] GeneralNames            OPTIONAL,
    +1103      *       authorityCertSerialNumber [2] CertificateSerialNumber OPTIONAL  }
    +1104      *    KeyIdentifier ::= OCTET STRING
    +1105      * </pre>
    +1106      * Constructor may have following parameters:
    +1107      * <ul>
    +1108      * <li>{Array}kid - JSON object of {@link KJUR.asn1.DEROctetString} parameters</li>
    +1109      * <li>{Array}issuer - JSON object of {@link KJUR.asn1.x509.X500Name} parameters</li>
    +1110      * <li>{Array}sn - JSON object of {@link KJUR.asn1.DERInteger} parameters</li>
    +1111      * <li>{Boolean}critical - critical flag</li>
    +1112      * </ul>
    +1113      * <br>
    +1114      * NOTE: The 'authorityCertIssuer' and 'authorityCertSerialNumber'
    +1115      * supported since jsrsasign 9.0.0 x509 2.0.0.
    +1116      * @example
    +1117      * x = new X509();
    +1118      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1119      * x.getExtAuthorityKeyIdentifier() → 
    +1120      * { kid: {hex: "1234abcd..."},
    +1121      *   issuer: {hex: "30..."},
    +1122      *   sn: {hex: "1234..."},
    +1123      *   critical: true}
    +1124      */
    +1125     this.getExtAuthorityKeyIdentifier = function(hExtV, critical) {
    +1126 	if (hExtV === undefined && critical === undefined) {
    +1127 	    var info = this.getExtInfo("authorityKeyIdentifier");
    +1128 	    if (info === undefined) return undefined;
    +1129 	    hExtV = _getTLV(this.hex, info.vidx);
    +1130 	    critical = info.critical;
    +1131 	}
    +1132 
    +1133 	var result = {extname:"authorityKeyIdentifier"};
    +1134 	if (critical) result.critical = true;
    +1135 
    +1136 	var a = _getChildIdx(hExtV, 0);
    +1137 	for (var i = 0; i < a.length; i++) {
    +1138 	    var tag = hExtV.substr(a[i], 2);
    +1139 	    if (tag === "80") {
    +1140 		result.kid = {hex: _getV(hExtV, a[i])};
    +1141 	    }
    +1142 	    if (tag === "a1") {
    +1143 		var hGNS = _getTLV(hExtV, a[i]);
    +1144 		var gnsParam = this.getGeneralNames(hGNS);
    +1145 		result.issuer = gnsParam[0]["dn"];
    +1146 	    }
    +1147 	    if (tag === "82") {
    +1148 		result.sn = {hex: _getV(hExtV, a[i])};
    +1149 	    }
    +1150 	}
    +1151 	return result;
    +1152     };
     1153 
    -1154 	var result = {extname:"extKeyUsage",array:[]};
    -1155 	if (critical) result.critical = true;
    -1156 
    -1157 	var a = _getChildIdx(hExtV, 0);
    -1158 
    -1159 	for (var i = 0; i < a.length; i++) {
    -1160 	    result.array.push(_oidname(_getV(hExtV, a[i])));
    -1161 	}
    -1162 
    -1163 	return result;
    -1164     };
    -1165 
    -1166     /**
    -1167      * get extKeyUsage value as array of name string in the certificate(DEPRECATED)<br/>
    -1168      * @name getExtExtKeyUsageName
    -1169      * @memberOf X509#
    -1170      * @function
    -1171      * @return {Object} array of extended key usage ID name or oid
    -1172      * @since jsrsasign 7.2.0 x509 1.1.14
    -1173      * @deprecated since jsrsasign 9.0.0 x509 2.0.0
    -1174      * @description
    -1175      * This method will get extended key usage extension value
    -1176      * as array of name or OID string.
    -1177      * If there is this in the certificate, it returns undefined;
    -1178      * <br>
    -1179      * NOTE: Supported extended key usage ID names are defined in
    -1180      * name2oidList parameter in asn1x509.js file.
    -1181      * @example
    -1182      * x = new X509();
    -1183      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1184      * x.getExtExtKeyUsageName() → ["serverAuth", "clientAuth", "0.1.2.3.4.5"]
    -1185      */
    -1186     this.getExtExtKeyUsageName = function() {
    -1187 	var info = this.getExtInfo("extKeyUsage");
    -1188 	if (info === undefined) return info;
    -1189 
    -1190 	var result = new Array();
    -1191 	
    -1192 	var h = _getTLV(this.hex, info.vidx);
    -1193 	if (h === '') return result;
    -1194 
    -1195 	var a = _getChildIdx(h, 0);
    -1196 	for (var i = 0; i < a.length; i++) {
    -1197 	    result.push(_oidname(_getV(h, a[i])));
    -1198 	}
    +1154     /**
    +1155      * get extKeyUsage value as JSON object
    +1156      * @name getExtExtKeyUsage
    +1157      * @memberOf X509#
    +1158      * @function
    +1159      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1160      * @param {Boolean} critical flag (OPTIONAL)
    +1161      * @return {Array} JSON object of ExtKeyUsage parameter or undefined
    +1162      * @return {Object} JSONarray of extended key usage ID name or oid
    +1163      * @since jsrsasign 9.0.0 x509 2.0.0
    +1164      * @see KJUR.asn1.x509.ExtKeyUsage
    +1165      * @description
    +1166      * This method parse extKeyUsage extension. When arguments are
    +1167      * not specified, its extension in X509 object will be parsed.
    +1168      * Result of this method can be passed to 
    +1169      * {@link KJUR.asn1.x509.ExtKeyUsage} constructor.
    +1170      * <br>
    +1171      * When hExtV and critical specified as arguments, return value
    +1172      * will be generated from them.
    +1173      * @example
    +1174      * x = new X509();
    +1175      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1176      * x.getExtExtKeyUsage() →
    +1177      * { array: ["clientAuth", "emailProtection", "1.3.6.1.4.1.311.10.3.4"], 
    +1178      *   critical: true},
    +1179      */
    +1180     this.getExtExtKeyUsage = function(hExtV, critical) {
    +1181 	if (hExtV === undefined && critical === undefined) {
    +1182 	    var info = this.getExtInfo("extKeyUsage");
    +1183 	    if (info === undefined) return undefined;
    +1184 	    hExtV = _getTLV(this.hex, info.vidx);
    +1185 	    critical = info.critical;
    +1186 	}
    +1187 
    +1188 	var result = {extname:"extKeyUsage",array:[]};
    +1189 	if (critical) result.critical = true;
    +1190 
    +1191 	var a = _getChildIdx(hExtV, 0);
    +1192 
    +1193 	for (var i = 0; i < a.length; i++) {
    +1194 	    result.array.push(_oidname(_getV(hExtV, a[i])));
    +1195 	}
    +1196 
    +1197 	return result;
    +1198     };
     1199 
    -1200 	return result;
    -1201     };
    -1202 
    -1203     /**
    -1204      * get subjectAltName value as array of string in the certificate
    -1205      * @name getExtSubjectAltName
    -1206      * @memberOf X509#
    -1207      * @function
    -1208      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1209      * @param {Boolean} critical flag (OPTIONAL)
    -1210      * @return {Array} JSON object of SubjectAltName parameters or undefined
    -1211      * @since jsrsasign 7.2.0 x509 1.1.14
    -1212      * @see KJUR.asn1.x509.SubjectAltName
    -1213      * @see X509#getExtIssuerAltName
    -1214      * @description
    -1215      * This method will get subjectAltName value
    -1216      * as an array of JSON object which has properties defined
    -1217      * in {@link KJUR.asn1.x509.SubjectAltName}.
    -1218      * Result of this method can be passed to 
    -1219      * {@link KJUR.asn1.x509.SubjectAltName} constructor.
    -1220      * If there is no this extension in the certificate,
    -1221      * it returns undefined.
    -1222      * <br>
    -1223      * When hExtV and critical specified as arguments, return value
    -1224      * will be generated from them.
    -1225      * <br>
    -1226      * CAUTION: return value of JSON object format have been changed
    -1227      * from jsrsasign 9.0.0 x509 2.0.0 without backword compatibility.
    -1228      * @example
    -1229      * x = new X509();
    -1230      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1231      * x.getExtSubjectAltName() → 
    -1232      * { array: [
    -1233      *     {uri: "http://example.com/"},
    -1234      *     {rfc822: "user1@example.com"},
    -1235      *     {dns: "example.com"}
    -1236      *   ],
    -1237      *   critical: true
    -1238      * }
    -1239      *
    -1240      * x.getExtSubjectAltName("3026...") →
    -1241      * { array: [{ip: "192.168.1.1"}] }
    -1242      */
    -1243     this.getExtSubjectAltName = function(hExtV, critical) {
    -1244 	if (hExtV === undefined && critical === undefined) {
    -1245 	    var info = this.getExtInfo("subjectAltName");
    -1246 	    if (info === undefined) return undefined;
    -1247 	    hExtV = _getTLV(this.hex, info.vidx);
    -1248 	    critical = info.critical;
    -1249 	}
    -1250 
    -1251 	var result = {extname:"subjectAltName",array:[]};
    -1252 	if (critical) result.critical = true;
    -1253 
    -1254 	result.array = this.getGeneralNames(hExtV);
    -1255 
    -1256 	return result;
    -1257     };
    -1258 
    -1259     /**
    -1260      * get issuerAltName value as array of string in the certificate
    -1261      * @name getExtIssuerAltName
    -1262      * @memberOf X509#
    -1263      * @function
    -1264      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1265      * @param {Boolean} critical flag (OPTIONAL)
    -1266      * @return {Array} JSON object of IssuerAltName parameters
    -1267      * @since jsrsasign 9.0.0 x509 2.0.0
    -1268      * @see KJUR.asn1.x509.IssuerAltName
    -1269      * @see X509#getExtSubjectAltName
    -1270      * @description
    -1271      * This method will get issuerAltName value
    -1272      * as an array of JSON object which has properties defined
    -1273      * in {@link KJUR.asn1.x509.IssuerAltName}.
    -1274      * Result of this method can be passed to 
    -1275      * {@link KJUR.asn1.x509.IssuerAltName} constructor.
    -1276      * If there is no this extension in the certificate,
    -1277      * it returns undefined.
    -1278      * <br>
    -1279      * When hExtV and critical specified as arguments, return value
    -1280      * will be generated from them.
    -1281      * @example
    -1282      * x = new X509();
    -1283      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1284      * x.getExtIssuerAltName() → 
    -1285      * { array: [
    -1286      *     {uri: "http://example.com/"},
    -1287      *     {rfc822: "user1@example.com"},
    -1288      *     {dns: "example.com"}
    -1289      *   ],
    -1290      *   critical: true
    -1291      * }
    -1292      *
    -1293      * x.getExtIssuerAltName("3026...") →
    -1294      * { array: [{ip: "192.168.1.1"}] }
    -1295      */
    -1296     this.getExtIssuerAltName = function(hExtV, critical) {
    -1297 	if (hExtV === undefined && critical === undefined) {
    -1298 	    var info = this.getExtInfo("issuerAltName");
    -1299 	    if (info === undefined) return undefined;
    -1300 	    hExtV = _getTLV(this.hex, info.vidx);
    -1301 	    critical = info.critical;
    -1302 	}
    -1303 
    -1304 	var result = {extname:"issuerAltName",array:[]};
    -1305 	if (critical) result.critical = true;
    -1306 
    -1307 	result.array = this.getGeneralNames(hExtV);
    -1308 
    -1309 	return result;
    -1310     };
    -1311 
    -1312     /**
    -1313      * get GeneralNames ASN.1 structure parameter as JSON object
    -1314      * @name getGeneralNames
    -1315      * @memberOf X509#
    -1316      * @function
    -1317      * @param {String} h hexadecimal string of GeneralNames
    -1318      * @return {Array} array of GeneralNames parameters
    -1319      * @see KJUR.asn1.x509.GeneralNames
    -1320      * @see KJUR.asn1.x509.GeneralName
    -1321      * @see X509#getGeneralNames
    -1322      * @since jsrsasign 9.0.0 x509 2.0.0
    -1323      * @description
    -1324      * This method will get GeneralNames parameters defined in
    -1325      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    -1326      * RFC 5280 4.2.1.6</a>.
    -1327      * <pre>
    -1328      * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
    -1329      * </pre>
    -1330      * Result of this method can be passed to
    -1331      * {@link KJUR.asn1.x509.GeneralNames} constructor.
    -1332      * @example
    -1333      * x = new X509();
    -1334      * x.getGeneralNames("3011860f687474703a2f2f6161612e636f6d2f")
    -1335      * → [{uri: "http://aaa.com/"}]
    -1336      *
    -1337      * x.getGeneralNames("301ea41c30...") →
    -1338      * [{ dn: {
    -1339      *     array: [
    -1340      *       [{type:"C", value:"JP", ds:"prn"}],
    -1341      *       [{type:"O", value:"T1", ds:"utf8"}]
    -1342      *     ],
    -1343      *     str: "/C=JP/O=T1" } }]
    -1344      */
    -1345     this.getGeneralNames = function(h) {
    -1346 	var aIdx = _getChildIdx(h, 0);
    -1347 	var result = [];
    -1348 	for (var i = 0; i < aIdx.length; i++) {
    -1349 	    var gnParam = this.getGeneralName(_getTLV(h, aIdx[i]));
    -1350 	    if (gnParam !== undefined) result.push(gnParam);
    -1351 	}
    -1352 	return result;
    -1353     };
    -1354 
    -1355     /**
    -1356      * get GeneralName ASN.1 structure parameter as JSON object<br/>
    -1357      * @name getGeneralName
    -1358      * @memberOf X509#
    -1359      * @function
    -1360      * @param {String} h hexadecimal string of GeneralName
    -1361      * @return {Array} JSON object of GeneralName parameters or undefined
    -1362      * @since jsrsasign 9.0.0 x509 2.0.0
    -1363      * @see KJUR.asn1.x509.GeneralNames
    -1364      * @see KJUR.asn1.x509.GeneralName
    -1365      * @see KJUR.asn1.x509.OtherName
    -1366      * @see X509#getGeneralName
    -1367      * @see X509#getOtherName
    -1368      *
    -1369      * @description
    -1370      * This method will get GeneralName parameters defined in
    -1371      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    -1372      * RFC 5280 4.2.1.6</a>.
    -1373      * <pre>
    -1374      * GeneralName ::= CHOICE {
    -1375      *      otherName                       [0]     OtherName,
    -1376      *      rfc822Name                      [1]     IA5String,
    -1377      *      dNSName                         [2]     IA5String,
    -1378      *      x400Address                     [3]     ORAddress,
    -1379      *      directoryName                   [4]     Name,
    -1380      *      ediPartyName                    [5]     EDIPartyName,
    -1381      *      uniformResourceIdentifier       [6]     IA5String,
    -1382      *      iPAddress                       [7]     OCTET STRING,
    -1383      *      registeredID                    [8]     OBJECT IDENTIFIER }
    -1384      * </pre>
    -1385      * Result of this method can be passed to
    -1386      * {@link KJUR.asn1.x509.GeneralName} constructor.
    -1387      * @example
    -1388      * x = new X509();
    -1389      * x.getGeneralName("860f687474703a2f2f6161612e636f6d2f") 
    -1390      * → {uri: "http://aaa.com/"}
    -1391      * x.getGeneralName("a41c30...") →
    -1392      * { dn: {
    -1393      *     array: [
    -1394      *       [{type:"C", value:"JP", ds:"prn"}],
    -1395      *       [{type:"O", value:"T1", ds:"utf8"}]
    -1396      *     ],
    -1397      *     str: "/C=JP/O=T1" } }
    -1398      */
    -1399     this.getGeneralName = function(h) {
    -1400 	var tag = h.substr(0, 2);
    -1401 	var hValue = _getV(h, 0);
    -1402 	var sValue = hextorstr(hValue);
    -1403 	if (tag == "81") return {rfc822: sValue};
    -1404 	if (tag == "82") return {dns: sValue};
    -1405 	if (tag == "86") return {uri: sValue};
    -1406 	if (tag == "87") return {ip: hextoip(hValue)};
    -1407 	if (tag == "a4") return {dn: this.getX500Name(hValue)};
    -1408 	if (tag == "a0") return {other: this.getOtherName(h)};
    -1409 	return undefined;
    -1410     };
    -1411 
    -1412     /**
    -1413      * get subjectAltName value as array of string in the certificate (DEPRECATED)
    -1414      * @name getExtSubjectAltName2
    -1415      * @memberOf X509#
    -1416      * @function
    -1417      * @return {Object} array of alt name array
    -1418      * @since jsrsasign 8.0.1 x509 1.1.17
    -1419      * @deprecated jsrsasign 9.0.0 x509 2.0.0
    -1420      * @description
    -1421      * This method will get subject alt name extension value
    -1422      * as array of type and name.
    -1423      * If there is this in the certificate, it returns undefined;
    -1424      * Type of GeneralName will be shown as following:
    -1425      * <ul>
    -1426      * <li>"MAIL" - [1]rfc822Name</li>
    -1427      * <li>"DNS"  - [2]dNSName</li>
    -1428      * <li>"DN"   - [4]directoryName</li>
    -1429      * <li>"URI"  - [6]uniformResourceIdentifier</li>
    -1430      * <li>"IP"   - [7]iPAddress</li>
    -1431      * </ul>
    -1432      * @example
    -1433      * x = new X509();
    -1434      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1435      * x.getExtSubjectAltName2() →
    -1436      * [["DNS",  "example.com"],
    -1437      *  ["DNS",  "example.org"],
    -1438      *  ["MAIL", "foo@example.com"],
    -1439      *  ["IP",   "192.168.1.1"],
    -1440      *  ["IP",   "2001:db8::2:1"],
    -1441      *  ["DN",   "/C=US/O=TEST1"]]
    -1442      */
    -1443     this.getExtSubjectAltName2 = function() {
    -1444 	var gnValueHex, gnValueStr, gnTag;
    -1445 	var info = this.getExtInfo("subjectAltName");
    -1446 	if (info === undefined) return info;
    -1447 
    -1448 	var result = new Array();
    -1449 	var h = _getTLV(this.hex, info.vidx);
    -1450 
    -1451 	var a = _getChildIdx(h, 0);
    -1452 	for (var i = 0; i < a.length; i++) {
    -1453 	    gnTag = h.substr(a[i], 2);
    -1454 	    gnValueHex = _getV(h, a[i]);
    -1455 	    
    -1456 	    if (gnTag === "81") { // rfc822Name [1]
    -1457 		gnValueStr = hextoutf8(gnValueHex);
    -1458 		result.push(["MAIL", gnValueStr]);
    -1459 	    }
    -1460 	    if (gnTag === "82") { // dNSName [2]
    -1461 		gnValueStr = hextoutf8(gnValueHex);
    -1462 		result.push(["DNS", gnValueStr]);
    -1463 	    }
    -1464 	    if (gnTag === "84") { // directoryName [4]
    -1465 		gnValueStr = X509.hex2dn(gnValueHex, 0);
    -1466 		result.push(["DN", gnValueStr]);
    -1467 	    }
    -1468 	    if (gnTag === "86") { // uniformResourceIdentifier [6]
    -1469 		gnValueStr = hextoutf8(gnValueHex);
    -1470 		result.push(["URI", gnValueStr]);
    -1471 	    }
    -1472 	    if (gnTag === "87") { // iPAddress [7]
    -1473 		gnValueStr = hextoip(gnValueHex);
    -1474 		result.push(["IP", gnValueStr]);
    -1475 	    }
    -1476 	}
    -1477 	return result;
    -1478     };
    -1479 
    -1480     /**
    -1481      * get CRLDistributionPoints extension value as JSON object
    -1482      * @name getExtCRLDistributionPoints
    -1483      * @memberOf X509#
    -1484      * @function
    -1485      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1486      * @param {Boolean} critical flag (OPTIONAL)
    -1487      * @return {Object} JSON object of CRLDistributionPoints parameters or undefined
    -1488      * @since jsrsasign 9.0.0 x509 2.0.0
    -1489      * @see KJUR.asn1.x509.CRLDistributionPoints
    -1490      * @see X509#getDistributionPoint
    -1491      * @see X509#getDistributionPointName
    -1492      * @see X509#getGeneralNames
    -1493      * @see X509#getGeneralName
    -1494      * @description
    -1495      * This method will get certificate policies value
    -1496      * as an array of JSON object which has properties defined
    -1497      * in {@link KJUR.asn1.x509.CRLDistributionPoints}.
    -1498      * Result of this method can be passed to 
    -1499      * {@link KJUR.asn1.x509.CRLDistributionPoints} constructor.
    -1500      * If there is no this extension in the certificate,
    -1501      * it returns undefined.
    -1502      * @example
    -1503      * x = new X509();
    -1504      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1505      * x.getExtCRLDistributionPoints() → 
    -1506      * {array: [
    -1507      *   {dpname: {full: [{uri: "http://example.com/"}]}},
    -1508      *   {dpname: {full: [{uri: "ldap://example.com/"}]}}
    -1509      *  ],
    -1510      *  critical: true}
    -1511      */
    -1512     this.getExtCRLDistributionPoints = function(hExtV, critical) {
    -1513 	if (hExtV === undefined && critical === undefined) {
    -1514 	    var info = this.getExtInfo("cRLDistributionPoints");
    -1515 	    if (info === undefined) return undefined;
    -1516 	    hExtV = _getTLV(this.hex, info.vidx);
    -1517 	    critical = info.critical;
    -1518 	}
    -1519 
    -1520 	var result = {extname:"cRLDistributionPoints",array:[]};
    -1521 	if (critical) result.critical = true;
    -1522 
    -1523 	var a = _getChildIdx(hExtV, 0);
    -1524 	for (var i = 0; i < a.length; i++) {
    -1525 	    var hTLV = _getTLV(hExtV, a[i]);
    -1526 	    result.array.push(this.getDistributionPoint(hTLV));
    -1527 	}
    -1528 
    -1529 	return result;
    -1530     };
    -1531 
    -1532     /**
    -1533      * get DistributionPoint ASN.1 structure parameter as JSON object
    -1534      * @name getDistributionPoint
    -1535      * @memberOf X509#
    -1536      * @function
    -1537      * @param {String} h hexadecimal string of DistributionPoint
    -1538      * @return {Object} JSON object of DistributionPoint parameters
    -1539      * @since jsrsasign 9.0.0 x509 2.0.0
    -1540      * @see X509#getExtCRLDistributionPoints
    -1541      * @see X509#getDistributionPointName
    -1542      * @see X509#getGeneralNames
    -1543      * @see X509#getGeneralName
    -1544      * @description
    -1545      * This method will get DistributionPoint parameters.
    -1546      * Result of this method can be passed to
    -1547      * {@link KJUR.asn1.x509.DistributionPoint} constructor.
    -1548      * <br/>
    -1549      * NOTE: reasons[1] and CRLIssuer[2] field not supported
    -1550      * @example
    -1551      * x = new X509();
    -1552      * x.getDistributionPoint("30...") →
    -1553      * {dpname: {full: [{uri: "http://aaa.com/"}]}}
    -1554      */
    -1555     this.getDistributionPoint = function(h) {
    -1556 	var result = {};
    -1557 	var a = _getChildIdx(h, 0);
    +1200     /**
    +1201      * get extKeyUsage value as array of name string in the certificate(DEPRECATED)<br/>
    +1202      * @name getExtExtKeyUsageName
    +1203      * @memberOf X509#
    +1204      * @function
    +1205      * @return {Object} array of extended key usage ID name or oid
    +1206      * @since jsrsasign 7.2.0 x509 1.1.14
    +1207      * @deprecated since jsrsasign 9.0.0 x509 2.0.0
    +1208      * @description
    +1209      * This method will get extended key usage extension value
    +1210      * as array of name or OID string.
    +1211      * If there is this in the certificate, it returns undefined;
    +1212      * <br>
    +1213      * NOTE: Supported extended key usage ID names are defined in
    +1214      * name2oidList parameter in asn1x509.js file.
    +1215      * @example
    +1216      * x = new X509();
    +1217      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1218      * x.getExtExtKeyUsageName() → ["serverAuth", "clientAuth", "0.1.2.3.4.5"]
    +1219      */
    +1220     this.getExtExtKeyUsageName = function() {
    +1221 	var info = this.getExtInfo("extKeyUsage");
    +1222 	if (info === undefined) return info;
    +1223 
    +1224 	var result = new Array();
    +1225 	
    +1226 	var h = _getTLV(this.hex, info.vidx);
    +1227 	if (h === '') return result;
    +1228 
    +1229 	var a = _getChildIdx(h, 0);
    +1230 	for (var i = 0; i < a.length; i++) {
    +1231 	    result.push(_oidname(_getV(h, a[i])));
    +1232 	}
    +1233 
    +1234 	return result;
    +1235     };
    +1236 
    +1237     /**
    +1238      * get subjectAltName value as array of string in the certificate
    +1239      * @name getExtSubjectAltName
    +1240      * @memberOf X509#
    +1241      * @function
    +1242      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1243      * @param {Boolean} critical flag (OPTIONAL)
    +1244      * @return {Array} JSON object of SubjectAltName parameters or undefined
    +1245      * @since jsrsasign 7.2.0 x509 1.1.14
    +1246      * @see KJUR.asn1.x509.SubjectAltName
    +1247      * @see X509#getExtIssuerAltName
    +1248      * @description
    +1249      * This method will get subjectAltName value
    +1250      * as an array of JSON object which has properties defined
    +1251      * in {@link KJUR.asn1.x509.SubjectAltName}.
    +1252      * Result of this method can be passed to 
    +1253      * {@link KJUR.asn1.x509.SubjectAltName} constructor.
    +1254      * If there is no this extension in the certificate,
    +1255      * it returns undefined.
    +1256      * <br>
    +1257      * When hExtV and critical specified as arguments, return value
    +1258      * will be generated from them.
    +1259      * <br>
    +1260      * CAUTION: return value of JSON object format have been changed
    +1261      * from jsrsasign 9.0.0 x509 2.0.0 without backword compatibility.
    +1262      * @example
    +1263      * x = new X509();
    +1264      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1265      * x.getExtSubjectAltName() → 
    +1266      * { array: [
    +1267      *     {uri: "http://example.com/"},
    +1268      *     {rfc822: "user1@example.com"},
    +1269      *     {dns: "example.com"}
    +1270      *   ],
    +1271      *   critical: true
    +1272      * }
    +1273      *
    +1274      * x.getExtSubjectAltName("3026...") →
    +1275      * { array: [{ip: "192.168.1.1"}] }
    +1276      */
    +1277     this.getExtSubjectAltName = function(hExtV, critical) {
    +1278 	if (hExtV === undefined && critical === undefined) {
    +1279 	    var info = this.getExtInfo("subjectAltName");
    +1280 	    if (info === undefined) return undefined;
    +1281 	    hExtV = _getTLV(this.hex, info.vidx);
    +1282 	    critical = info.critical;
    +1283 	}
    +1284 
    +1285 	var result = {extname:"subjectAltName",array:[]};
    +1286 	if (critical) result.critical = true;
    +1287 
    +1288 	result.array = this.getGeneralNames(hExtV);
    +1289 
    +1290 	return result;
    +1291     };
    +1292 
    +1293     /**
    +1294      * get issuerAltName value as array of string in the certificate
    +1295      * @name getExtIssuerAltName
    +1296      * @memberOf X509#
    +1297      * @function
    +1298      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1299      * @param {Boolean} critical flag (OPTIONAL)
    +1300      * @return {Array} JSON object of IssuerAltName parameters
    +1301      * @since jsrsasign 9.0.0 x509 2.0.0
    +1302      * @see KJUR.asn1.x509.IssuerAltName
    +1303      * @see X509#getExtSubjectAltName
    +1304      * @description
    +1305      * This method will get issuerAltName value
    +1306      * as an array of JSON object which has properties defined
    +1307      * in {@link KJUR.asn1.x509.IssuerAltName}.
    +1308      * Result of this method can be passed to 
    +1309      * {@link KJUR.asn1.x509.IssuerAltName} constructor.
    +1310      * If there is no this extension in the certificate,
    +1311      * it returns undefined.
    +1312      * <br>
    +1313      * When hExtV and critical specified as arguments, return value
    +1314      * will be generated from them.
    +1315      * @example
    +1316      * x = new X509();
    +1317      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1318      * x.getExtIssuerAltName() → 
    +1319      * { array: [
    +1320      *     {uri: "http://example.com/"},
    +1321      *     {rfc822: "user1@example.com"},
    +1322      *     {dns: "example.com"}
    +1323      *   ],
    +1324      *   critical: true
    +1325      * }
    +1326      *
    +1327      * x.getExtIssuerAltName("3026...") →
    +1328      * { array: [{ip: "192.168.1.1"}] }
    +1329      */
    +1330     this.getExtIssuerAltName = function(hExtV, critical) {
    +1331 	if (hExtV === undefined && critical === undefined) {
    +1332 	    var info = this.getExtInfo("issuerAltName");
    +1333 	    if (info === undefined) return undefined;
    +1334 	    hExtV = _getTLV(this.hex, info.vidx);
    +1335 	    critical = info.critical;
    +1336 	}
    +1337 
    +1338 	var result = {extname:"issuerAltName",array:[]};
    +1339 	if (critical) result.critical = true;
    +1340 
    +1341 	result.array = this.getGeneralNames(hExtV);
    +1342 
    +1343 	return result;
    +1344     };
    +1345 
    +1346     /**
    +1347      * get GeneralNames ASN.1 structure parameter as JSON object
    +1348      * @name getGeneralNames
    +1349      * @memberOf X509#
    +1350      * @function
    +1351      * @param {String} h hexadecimal string of GeneralNames
    +1352      * @return {Array} array of GeneralNames parameters
    +1353      * @see KJUR.asn1.x509.GeneralNames
    +1354      * @see KJUR.asn1.x509.GeneralName
    +1355      * @see X509#getGeneralNames
    +1356      * @since jsrsasign 9.0.0 x509 2.0.0
    +1357      * @description
    +1358      * This method will get GeneralNames parameters defined in
    +1359      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    +1360      * RFC 5280 4.2.1.6</a>.
    +1361      * <pre>
    +1362      * GeneralNames ::= SEQUENCE SIZE (1..MAX) OF GeneralName
    +1363      * </pre>
    +1364      * Result of this method can be passed to
    +1365      * {@link KJUR.asn1.x509.GeneralNames} constructor.
    +1366      * @example
    +1367      * x = new X509();
    +1368      * x.getGeneralNames("3011860f687474703a2f2f6161612e636f6d2f")
    +1369      * → [{uri: "http://aaa.com/"}]
    +1370      *
    +1371      * x.getGeneralNames("301ea41c30...") →
    +1372      * [{ dn: {
    +1373      *     array: [
    +1374      *       [{type:"C", value:"JP", ds:"prn"}],
    +1375      *       [{type:"O", value:"T1", ds:"utf8"}]
    +1376      *     ],
    +1377      *     str: "/C=JP/O=T1" } }]
    +1378      */
    +1379     this.getGeneralNames = function(h) {
    +1380 	var aIdx = _getChildIdx(h, 0);
    +1381 	var result = [];
    +1382 	for (var i = 0; i < aIdx.length; i++) {
    +1383 	    var gnParam = this.getGeneralName(_getTLV(h, aIdx[i]));
    +1384 	    if (gnParam !== undefined) result.push(gnParam);
    +1385 	}
    +1386 	return result;
    +1387     };
    +1388 
    +1389     /**
    +1390      * get GeneralName ASN.1 structure parameter as JSON object<br/>
    +1391      * @name getGeneralName
    +1392      * @memberOf X509#
    +1393      * @function
    +1394      * @param {String} h hexadecimal string of GeneralName
    +1395      * @return {Array} JSON object of GeneralName parameters or undefined
    +1396      * @since jsrsasign 9.0.0 x509 2.0.0
    +1397      * @see KJUR.asn1.x509.GeneralNames
    +1398      * @see KJUR.asn1.x509.GeneralName
    +1399      * @see KJUR.asn1.x509.OtherName
    +1400      * @see X509#getGeneralName
    +1401      * @see X509#getOtherName
    +1402      *
    +1403      * @description
    +1404      * This method will get GeneralName parameters defined in
    +1405      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    +1406      * RFC 5280 4.2.1.6</a>.
    +1407      * <pre>
    +1408      * GeneralName ::= CHOICE {
    +1409      *      otherName                       [0]     OtherName,
    +1410      *      rfc822Name                      [1]     IA5String,
    +1411      *      dNSName                         [2]     IA5String,
    +1412      *      x400Address                     [3]     ORAddress,
    +1413      *      directoryName                   [4]     Name,
    +1414      *      ediPartyName                    [5]     EDIPartyName,
    +1415      *      uniformResourceIdentifier       [6]     IA5String,
    +1416      *      iPAddress                       [7]     OCTET STRING,
    +1417      *      registeredID                    [8]     OBJECT IDENTIFIER }
    +1418      * </pre>
    +1419      * Result of this method can be passed to
    +1420      * {@link KJUR.asn1.x509.GeneralName} constructor.
    +1421      * @example
    +1422      * x = new X509();
    +1423      * x.getGeneralName("860f687474703a2f2f6161612e636f6d2f") 
    +1424      * → {uri: "http://aaa.com/"}
    +1425      * x.getGeneralName("a41c30...") →
    +1426      * { dn: {
    +1427      *     array: [
    +1428      *       [{type:"C", value:"JP", ds:"prn"}],
    +1429      *       [{type:"O", value:"T1", ds:"utf8"}]
    +1430      *     ],
    +1431      *     str: "/C=JP/O=T1" } }
    +1432      */
    +1433     this.getGeneralName = function(h) {
    +1434 	var tag = h.substr(0, 2);
    +1435 	var hValue = _getV(h, 0);
    +1436 	var sValue = hextorstr(hValue);
    +1437 	if (tag == "81") return {rfc822: sValue};
    +1438 	if (tag == "82") return {dns: sValue};
    +1439 	if (tag == "86") return {uri: sValue};
    +1440 	if (tag == "87") return {ip: hextoip(hValue)};
    +1441 	if (tag == "a4") return {dn: this.getX500Name(hValue)};
    +1442 	if (tag == "a0") return {other: this.getOtherName(h)};
    +1443 	return undefined;
    +1444     };
    +1445 
    +1446     /**
    +1447      * get subjectAltName value as array of string in the certificate (DEPRECATED)
    +1448      * @name getExtSubjectAltName2
    +1449      * @memberOf X509#
    +1450      * @function
    +1451      * @return {Object} array of alt name array
    +1452      * @since jsrsasign 8.0.1 x509 1.1.17
    +1453      * @deprecated jsrsasign 9.0.0 x509 2.0.0
    +1454      * @description
    +1455      * This method will get subject alt name extension value
    +1456      * as array of type and name.
    +1457      * If there is this in the certificate, it returns undefined;
    +1458      * Type of GeneralName will be shown as following:
    +1459      * <ul>
    +1460      * <li>"MAIL" - [1]rfc822Name</li>
    +1461      * <li>"DNS"  - [2]dNSName</li>
    +1462      * <li>"DN"   - [4]directoryName</li>
    +1463      * <li>"URI"  - [6]uniformResourceIdentifier</li>
    +1464      * <li>"IP"   - [7]iPAddress</li>
    +1465      * </ul>
    +1466      * @example
    +1467      * x = new X509();
    +1468      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1469      * x.getExtSubjectAltName2() →
    +1470      * [["DNS",  "example.com"],
    +1471      *  ["DNS",  "example.org"],
    +1472      *  ["MAIL", "foo@example.com"],
    +1473      *  ["IP",   "192.168.1.1"],
    +1474      *  ["IP",   "2001:db8::2:1"],
    +1475      *  ["DN",   "/C=US/O=TEST1"]]
    +1476      */
    +1477     this.getExtSubjectAltName2 = function() {
    +1478 	var gnValueHex, gnValueStr, gnTag;
    +1479 	var info = this.getExtInfo("subjectAltName");
    +1480 	if (info === undefined) return info;
    +1481 
    +1482 	var result = new Array();
    +1483 	var h = _getTLV(this.hex, info.vidx);
    +1484 
    +1485 	var a = _getChildIdx(h, 0);
    +1486 	for (var i = 0; i < a.length; i++) {
    +1487 	    gnTag = h.substr(a[i], 2);
    +1488 	    gnValueHex = _getV(h, a[i]);
    +1489 	    
    +1490 	    if (gnTag === "81") { // rfc822Name [1]
    +1491 		gnValueStr = hextoutf8(gnValueHex);
    +1492 		result.push(["MAIL", gnValueStr]);
    +1493 	    }
    +1494 	    if (gnTag === "82") { // dNSName [2]
    +1495 		gnValueStr = hextoutf8(gnValueHex);
    +1496 		result.push(["DNS", gnValueStr]);
    +1497 	    }
    +1498 	    if (gnTag === "84") { // directoryName [4]
    +1499 		gnValueStr = X509.hex2dn(gnValueHex, 0);
    +1500 		result.push(["DN", gnValueStr]);
    +1501 	    }
    +1502 	    if (gnTag === "86") { // uniformResourceIdentifier [6]
    +1503 		gnValueStr = hextoutf8(gnValueHex);
    +1504 		result.push(["URI", gnValueStr]);
    +1505 	    }
    +1506 	    if (gnTag === "87") { // iPAddress [7]
    +1507 		gnValueStr = hextoip(gnValueHex);
    +1508 		result.push(["IP", gnValueStr]);
    +1509 	    }
    +1510 	}
    +1511 	return result;
    +1512     };
    +1513 
    +1514     /**
    +1515      * get CRLDistributionPoints extension value as JSON object
    +1516      * @name getExtCRLDistributionPoints
    +1517      * @memberOf X509#
    +1518      * @function
    +1519      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1520      * @param {Boolean} critical flag (OPTIONAL)
    +1521      * @return {Object} JSON object of CRLDistributionPoints parameters or undefined
    +1522      * @since jsrsasign 9.0.0 x509 2.0.0
    +1523      * @see KJUR.asn1.x509.CRLDistributionPoints
    +1524      * @see X509#getDistributionPoint
    +1525      * @see X509#getDistributionPointName
    +1526      * @see X509#getGeneralNames
    +1527      * @see X509#getGeneralName
    +1528      * @description
    +1529      * This method will get certificate policies value
    +1530      * as an array of JSON object which has properties defined
    +1531      * in {@link KJUR.asn1.x509.CRLDistributionPoints}.
    +1532      * Result of this method can be passed to 
    +1533      * {@link KJUR.asn1.x509.CRLDistributionPoints} constructor.
    +1534      * If there is no this extension in the certificate,
    +1535      * it returns undefined.
    +1536      * @example
    +1537      * x = new X509();
    +1538      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1539      * x.getExtCRLDistributionPoints() → 
    +1540      * {array: [
    +1541      *   {dpname: {full: [{uri: "http://example.com/"}]}},
    +1542      *   {dpname: {full: [{uri: "ldap://example.com/"}]}}
    +1543      *  ],
    +1544      *  critical: true}
    +1545      */
    +1546     this.getExtCRLDistributionPoints = function(hExtV, critical) {
    +1547 	if (hExtV === undefined && critical === undefined) {
    +1548 	    var info = this.getExtInfo("cRLDistributionPoints");
    +1549 	    if (info === undefined) return undefined;
    +1550 	    hExtV = _getTLV(this.hex, info.vidx);
    +1551 	    critical = info.critical;
    +1552 	}
    +1553 
    +1554 	var result = {extname:"cRLDistributionPoints",array:[]};
    +1555 	if (critical) result.critical = true;
    +1556 
    +1557 	var a = _getChildIdx(hExtV, 0);
     1558 	for (var i = 0; i < a.length; i++) {
    -1559 	    var tag = h.substr(a[i], 2);
    -1560 	    var hTLV = _getTLV(h, a[i]);
    -1561 	    if (tag == "a0") {
    -1562 		result.dpname = this.getDistributionPointName(hTLV);
    -1563 	    }
    -1564 	}
    -1565 	return result;
    -1566     };
    -1567 
    -1568     /**
    -1569      * get DistributionPointName ASN.1 structure parameter as JSON object
    -1570      * @name getDistributionPointName
    -1571      * @memberOf X509#
    -1572      * @function
    -1573      * @param {String} h hexadecimal string of DistributionPointName
    -1574      * @return {Object} JSON object of DistributionPointName parameters
    -1575      * @since jsrsasign 9.0.0 x509 2.0.0
    -1576      * @see X509#getExtCRLDistributionPoints
    -1577      * @see X509#getDistributionPoint
    -1578      * @see X509#getGeneralNames
    -1579      * @see X509#getGeneralName
    -1580      * @description
    -1581      * This method will get DistributionPointName parameters.
    -1582      * Result of this method can be passed to
    -1583      * {@link KJUR.asn1.x509.DistributionPointName} constructor.
    -1584      * <br/>
    -1585      * NOTE: nameRelativeToCRLIssuer[1] not supported
    -1586      * @example
    -1587      * x = new X509();
    -1588      * x.getDistributionPointName("a0...") →
    -1589      * {full: [{uri: "http://aaa.com/"}]}
    -1590      */
    -1591     this.getDistributionPointName = function(h) {
    -1592 	var result = {};
    -1593 	var a = _getChildIdx(h, 0);
    -1594 	for (var i = 0; i < a.length; i++) {
    -1595 	    var tag = h.substr(a[i], 2);
    -1596 	    var hTLV = _getTLV(h, a[i]);
    -1597 	    if (tag == "a0") {
    -1598 		result.full = this.getGeneralNames(hTLV);
    -1599 	    }
    -1600 	}
    -1601 	return result;
    -1602     };
    -1603 
    -1604     /**
    -1605      * get array of string for fullName URIs in cRLDistributionPoints(CDP) in the certificate (DEPRECATED)
    -1606      * @name getExtCRLDistributionPointsURI
    -1607      * @memberOf X509#
    -1608      * @function
    -1609      * @return {Object} array of fullName URIs of CDP of the certificate
    -1610      * @since jsrsasign 7.2.0 x509 1.1.14
    -1611      * @description
    -1612      * This method will get all fullName URIs of cRLDistributionPoints extension
    -1613      * in the certificate as array of URI string.
    -1614      * If there is this in the certificate, it returns undefined;
    -1615      * <br>
    -1616      * NOTE: Currently this method supports only fullName URI so that
    -1617      * other parameters will not be returned.
    -1618      * @example
    -1619      * x = new X509();
    -1620      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1621      * x.getExtCRLDistributionPointsURI() →
    -1622      * ["http://example.com/aaa.crl", "http://example.org/aaa.crl"]
    -1623      */
    -1624     this.getExtCRLDistributionPointsURI = function() {
    -1625 	var p = this.getExtCRLDistributionPoints();
    -1626 	if (p == undefined) return p;
    -1627 	var a = p.array;
    -1628 	var result = [];
    -1629 	for (var i = 0; i < a.length; i++) {
    -1630 	    try {
    -1631 		if (a[i].dpname.full[0].uri != undefined) {
    -1632 		    result.push(a[i].dpname.full[0].uri);
    -1633 		}
    -1634 	    } catch(ex) {}
    -1635 	}
    -1636 	return result;
    -1637     };
    -1638 
    -1639     /**
    -1640      * get AuthorityInfoAccess extension value in the certificate as associative array
    -1641      * @name getExtAIAInfo
    -1642      * @memberOf X509#
    -1643      * @function
    -1644      * @return {Object} associative array of AIA extension properties
    -1645      * @since jsrsasign 7.2.0 x509 1.1.14
    -1646      * @description
    -1647      * This method will get authority info access value
    -1648      * as associate array which has following properties:
    -1649      * <ul>
    -1650      * <li>ocsp - array of string for OCSP responder URL</li>
    -1651      * <li>caissuer - array of string for caIssuer value (i.e. CA certificates URL)</li>
    -1652      * </ul>
    -1653      * If there is this in the certificate, it returns undefined;
    -1654      * @example
    -1655      * x = new X509();
    -1656      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1657      * x.getExtAIAInfo(hCert) → 
    -1658      * { ocsp:     ["http://ocsp.foo.com"],
    -1659      *   caissuer: ["http://rep.foo.com/aaa.p8m"] }
    -1660      */
    -1661     this.getExtAIAInfo = function() {
    -1662 	var info = this.getExtInfo("authorityInfoAccess");
    -1663 	if (info === undefined) return info;
    -1664 
    -1665 	var result = { ocsp: [], caissuer: [] };
    -1666 	var a = _getChildIdx(this.hex, info.vidx);
    -1667 	for (var i = 0; i < a.length; i++) {
    -1668 	    var hOID = _getVbyList(this.hex, a[i], [0], "06");
    -1669 	    var hName = _getVbyList(this.hex, a[i], [1], "86");
    -1670 	    if (hOID === "2b06010505073001") {
    -1671 		result.ocsp.push(hextoutf8(hName));
    -1672 	    }
    -1673 	    if (hOID === "2b06010505073002") {
    -1674 		result.caissuer.push(hextoutf8(hName));
    -1675 	    }
    -1676 	}
    -1677 
    -1678 	return result;
    -1679     };
    -1680 
    -1681     /**
    -1682      * get AuthorityInfoAccess extension value as JSON object
    -1683      * @name getExtAuthorityInfoAccess
    -1684      * @memberOf X509#
    -1685      * @function
    -1686      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1687      * @param {Boolean} critical flag (OPTIONAL)
    -1688      * @return {Array} JSON object of AuthorityInfoAccess parameters or undefined
    -1689      * @since jsrsasign 9.0.0 x509 2.0.0
    -1690      * @see KJUR.asn1.x509.AuthorityInfoAccess
    -1691      * @description
    -1692      * This method parse authorityInfoAccess extension. When arguments are
    -1693      * not specified, its extension in X509 object will be parsed.
    -1694      * Result of this method can be passed to 
    -1695      * {@link KJUR.asn1.x509.AuthorityInfoAccess} constructor.
    -1696      * <br>
    -1697      * When hExtV and critical specified as arguments, return value
    -1698      * will be generated from them.
    -1699      * @example
    -1700      * x = new X509();
    -1701      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1702      * x.getExtAuthorityInfoAccess() →
    -1703      * {
    -1704      *   critial: true, // 
    -1705      *   array: [{ocsp: http://ocsp.example.com/},
    -1706      *           {caissuer: https://repository.example.com/}]
    -1707      * }
    -1708      *
    -1709      * x = new X509();
    -1710      * x.getExtAuthorityInfoAccesss("306230...") 
    -1711      * x.getExtAuthorityInfoAccesss("306230...", true) 
    -1712      */
    -1713     this.getExtAuthorityInfoAccess = function(hExtV, critical) {
    -1714 	if (hExtV === undefined && critical === undefined) {
    -1715 	    var info = this.getExtInfo("authorityInfoAccess");
    -1716 	    if (info === undefined) return undefined;
    -1717 	    hExtV = _getTLV(this.hex, info.vidx);
    -1718 	    critical = info.critical;
    -1719 	}
    -1720 
    -1721 	var result = {extname:"authorityInfoAccess",array:[]};
    -1722 	if (critical) result.critical = true;
    -1723 
    -1724 	var a = _getChildIdx(hExtV, 0);
    -1725 	for (var i = 0; i < a.length; i++) {
    -1726 	    var hMethod = _getVbyListEx(hExtV, a[i], [0], "06");
    -1727 	    var hLoc = _getVbyList(hExtV, a[i], [1], "86");
    -1728 	    var sLoc = hextoutf8(hLoc);
    -1729 	    if (hMethod == "2b06010505073001") {
    -1730 		result.array.push({ocsp: sLoc});
    -1731 	    } else if (hMethod == "2b06010505073002") {
    -1732 		result.array.push({caissuer: sLoc});
    -1733 	    } else {
    -1734 		throw new Error("unknown method: " + hMethod);
    -1735 	    }
    -1736 	}
    -1737 
    -1738 	return result;
    -1739     }
    -1740 
    -1741     /**
    -1742      * get CertificatePolicies extension value as JSON object
    -1743      * @name getExtCertificatePolicies
    -1744      * @memberOf X509#
    -1745      * @function
    -1746      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    -1747      * @param {Boolean} critical flag (OPTIONAL)
    -1748      * @return {Object} JSON object of CertificatePolicies parameters or undefined
    -1749      * @since jsrsasign 7.2.0 x509 1.1.14
    -1750      * @description
    -1751      * This method will get certificate policies value
    -1752      * as an array of JSON object which has properties defined
    -1753      * in {@link KJUR.asn1.x509.CertificatePolicies}.
    -1754      * Result of this method can be passed to 
    -1755      * {@link KJUR.asn1.x509.CertificatePolicies} constructor.
    -1756      * If there is no this extension in the certificate,
    -1757      * it returns undefined.
    -1758      * <br>
    -1759      * CAUTION: return value of JSON object format have been changed
    -1760      * from jsrsasign 9.0.0 without backword compatibility.
    -1761      * <br>
    -1762      * When hExtV and critical specified as arguments, return value
    -1763      * will be generated from them.
    -1764      * @example
    -1765      * x = new X509();
    -1766      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    -1767      * x.getExtCertificatePolicies() → 
    -1768      * { array: [
    -1769      *   { policyoid: "1.2.3.4" }
    -1770      *   { policyoid: "1.2.3.5",
    -1771      *     array: [
    -1772      *       { cps: "https://example.com/" },
    -1773      *       { unotice: { exptext: { type: "bmp", str: "sample text" } } }
    -1774      *     ] 
    -1775      *   }
    -1776      * ]}
    -1777      */
    -1778     this.getExtCertificatePolicies = function(hExtV, critical) {
    -1779 	if (hExtV === undefined && critical === undefined) {
    -1780 	    var info = this.getExtInfo("certificatePolicies");
    -1781 	    if (info === undefined) return undefined;
    -1782 	    hExtV = _getTLV(this.hex, info.vidx);
    -1783 	    critical = info.critical;
    -1784 	}
    -1785 	var result = {extname:"certificatePolicies",array:[]};
    -1786 	if (critical) result.critical = true;
    -1787 
    -1788 	var aIdxPI = _getChildIdx(hExtV, 0); // PolicyInformation list index
    -1789 	for (var i = 0; i < aIdxPI.length; i++) {
    -1790 	    var hPolicyInformation = _getTLV(hExtV, aIdxPI[i]);
    -1791 	    var polinfo = this.getPolicyInformation(hPolicyInformation);
    -1792 	    result.array.push(polinfo);
    -1793 	}
    -1794 	return result;
    -1795     }
    -1796 
    -1797     /**
    -1798      * get PolicyInformation ASN.1 structure parameter as JSON object
    -1799      * @name getPolicyInformation
    -1800      * @memberOf X509#
    -1801      * @function
    -1802      * @param {String} h hexadecimal string of PolicyInformation
    -1803      * @return {Object} JSON object of PolicyInformation parameters
    -1804      * @since jsrsasign 9.0.0 x509 2.0.0
    -1805      * @description
    -1806      * This method will get PolicyInformation parameters defined in
    -1807      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    -1808      * RFC 5280 4.2.1.4</a>.
    -1809      * <pre>
    -1810      * PolicyInformation ::= SEQUENCE {
    -1811      *      policyIdentifier   CertPolicyId,
    -1812      *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
    -1813      *                              PolicyQualifierInfo OPTIONAL }
    -1814      * </pre>
    -1815      * Result of this method can be passed to
    -1816      * {@link KJUR.asn1.x509.PolicyInformation} constructor.
    -1817      * @example
    -1818      * x = new X509();
    -1819      * x.getPolicyInformation("30...") →
    -1820      * {
    -1821      *     policyoid: "2.16.840.1.114412.2.1",
    -1822      *     array: [{cps: "https://www.digicert.com/CPS"}]
    -1823      * }
    -1824      */
    -1825     this.getPolicyInformation = function(h) {
    -1826 	var result = {};
    -1827 
    -1828 	var hPOLICYOID = _getVbyList(h, 0, [0], "06");
    -1829 	result.policyoid = _oidname(hPOLICYOID);
    -1830 	
    -1831 	var idxPQSEQ = _getIdxbyListEx(h, 0, [1], "30");
    -1832 	if (idxPQSEQ != -1) {
    -1833 	    result.array = [];
    -1834 	    var aIdx = _getChildIdx(h, idxPQSEQ);
    -1835 	    for (var j = 0; j < aIdx.length; j++) {
    -1836 		var hPQI = _getTLV(h, aIdx[j]);
    -1837 		var pqinfo = this.getPolicyQualifierInfo(hPQI);
    -1838 		result.array.push(pqinfo);
    -1839 	    }
    -1840 	}
    -1841 
    -1842 	return result;
    -1843     };
    -1844 
    -1845     /**
    -1846      * getOtherName ASN.1 structure parameter as JSON object<br/>
    -1847      * @name getOtherName
    -1848      * @memberOf X509#
    -1849      * @param {String} h hexadecimal string of GeneralName
    -1850      * @return {Array} associative array of OtherName
    -1851      * @since jsrsasign 10.5.3 x509 2.0.12
    -1852      * @see KJUR.asn1.x509.GeneralNames
    -1853      * @see KJUR.asn1.x509.GeneralName
    -1854      * @see KJUR.asn1.x509.OtherName
    -1855      * @see X509#getGeneralName
    -1856      * @see ASN1HEX#parse
    -1857      *
    -1858      * @description
    -1859      * This method will get OtherName parameters defined in
    -1860      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    -1861      * RFC 5280 4.2.1.6</a>.
    -1862      * <pre>
    -1863      * OtherName ::= SEQUENCE {
    -1864      *    type-id    OBJECT IDENTIFIER,
    -1865      *    value      [0] EXPLICIT ANY DEFINED BY type-id }
    -1866      * </pre>
    -1867      * The value of member "other" is converted by 
    -1868      * {@link ASN1HEX#parse}.
    -1869      *
    -1870      * @example
    -1871      * x = new X509();
    -1872      * x.getOtherName("30...") →
    -1873      * { oid: "1.2.3.4",
    -1874      *   other: {utf8str: {str: "aaa"}} }
    -1875      */
    -1876     this.getOtherName = function(h) {
    -1877         var result = {};
    +1559 	    var hTLV = _getTLV(hExtV, a[i]);
    +1560 	    result.array.push(this.getDistributionPoint(hTLV));
    +1561 	}
    +1562 
    +1563 	return result;
    +1564     };
    +1565 
    +1566     /**
    +1567      * get DistributionPoint ASN.1 structure parameter as JSON object
    +1568      * @name getDistributionPoint
    +1569      * @memberOf X509#
    +1570      * @function
    +1571      * @param {String} h hexadecimal string of DistributionPoint
    +1572      * @return {Object} JSON object of DistributionPoint parameters
    +1573      * @since jsrsasign 9.0.0 x509 2.0.0
    +1574      * @see X509#getExtCRLDistributionPoints
    +1575      * @see X509#getDistributionPointName
    +1576      * @see X509#getGeneralNames
    +1577      * @see X509#getGeneralName
    +1578      * @description
    +1579      * This method will get DistributionPoint parameters.
    +1580      * Result of this method can be passed to
    +1581      * {@link KJUR.asn1.x509.DistributionPoint} constructor.
    +1582      * <br/>
    +1583      * NOTE: reasons[1] and CRLIssuer[2] field not supported
    +1584      * @example
    +1585      * x = new X509();
    +1586      * x.getDistributionPoint("30...") →
    +1587      * {dpname: {full: [{uri: "http://aaa.com/"}]}}
    +1588      */
    +1589     this.getDistributionPoint = function(h) {
    +1590 	var result = {};
    +1591 	var a = _getChildIdx(h, 0);
    +1592 	for (var i = 0; i < a.length; i++) {
    +1593 	    var tag = h.substr(a[i], 2);
    +1594 	    var hTLV = _getTLV(h, a[i]);
    +1595 	    if (tag == "a0") {
    +1596 		result.dpname = this.getDistributionPointName(hTLV);
    +1597 	    }
    +1598 	}
    +1599 	return result;
    +1600     };
    +1601 
    +1602     /**
    +1603      * get DistributionPointName ASN.1 structure parameter as JSON object
    +1604      * @name getDistributionPointName
    +1605      * @memberOf X509#
    +1606      * @function
    +1607      * @param {String} h hexadecimal string of DistributionPointName
    +1608      * @return {Object} JSON object of DistributionPointName parameters
    +1609      * @since jsrsasign 9.0.0 x509 2.0.0
    +1610      * @see X509#getExtCRLDistributionPoints
    +1611      * @see X509#getDistributionPoint
    +1612      * @see X509#getGeneralNames
    +1613      * @see X509#getGeneralName
    +1614      * @description
    +1615      * This method will get DistributionPointName parameters.
    +1616      * Result of this method can be passed to
    +1617      * {@link KJUR.asn1.x509.DistributionPointName} constructor.
    +1618      * <br/>
    +1619      * NOTE: nameRelativeToCRLIssuer[1] not supported
    +1620      * @example
    +1621      * x = new X509();
    +1622      * x.getDistributionPointName("a0...") →
    +1623      * {full: [{uri: "http://aaa.com/"}]}
    +1624      */
    +1625     this.getDistributionPointName = function(h) {
    +1626 	var result = {};
    +1627 	var a = _getChildIdx(h, 0);
    +1628 	for (var i = 0; i < a.length; i++) {
    +1629 	    var tag = h.substr(a[i], 2);
    +1630 	    var hTLV = _getTLV(h, a[i]);
    +1631 	    if (tag == "a0") {
    +1632 		result.full = this.getGeneralNames(hTLV);
    +1633 	    }
    +1634 	}
    +1635 	return result;
    +1636     };
    +1637 
    +1638     /**
    +1639      * get array of string for fullName URIs in cRLDistributionPoints(CDP) in the certificate (DEPRECATED)
    +1640      * @name getExtCRLDistributionPointsURI
    +1641      * @memberOf X509#
    +1642      * @function
    +1643      * @return {Object} array of fullName URIs of CDP of the certificate
    +1644      * @since jsrsasign 7.2.0 x509 1.1.14
    +1645      * @description
    +1646      * This method will get all fullName URIs of cRLDistributionPoints extension
    +1647      * in the certificate as array of URI string.
    +1648      * If there is this in the certificate, it returns undefined;
    +1649      * <br>
    +1650      * NOTE: Currently this method supports only fullName URI so that
    +1651      * other parameters will not be returned.
    +1652      * @example
    +1653      * x = new X509();
    +1654      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1655      * x.getExtCRLDistributionPointsURI() →
    +1656      * ["http://example.com/aaa.crl", "http://example.org/aaa.crl"]
    +1657      */
    +1658     this.getExtCRLDistributionPointsURI = function() {
    +1659 	var p = this.getExtCRLDistributionPoints();
    +1660 	if (p == undefined) return p;
    +1661 	var a = p.array;
    +1662 	var result = [];
    +1663 	for (var i = 0; i < a.length; i++) {
    +1664 	    try {
    +1665 		if (a[i].dpname.full[0].uri != undefined) {
    +1666 		    result.push(a[i].dpname.full[0].uri);
    +1667 		}
    +1668 	    } catch(ex) {}
    +1669 	}
    +1670 	return result;
    +1671     };
    +1672 
    +1673     /**
    +1674      * get AuthorityInfoAccess extension value in the certificate as associative array
    +1675      * @name getExtAIAInfo
    +1676      * @memberOf X509#
    +1677      * @function
    +1678      * @return {Object} associative array of AIA extension properties
    +1679      * @since jsrsasign 7.2.0 x509 1.1.14
    +1680      * @description
    +1681      * This method will get authority info access value
    +1682      * as associate array which has following properties:
    +1683      * <ul>
    +1684      * <li>ocsp - array of string for OCSP responder URL</li>
    +1685      * <li>caissuer - array of string for caIssuer value (i.e. CA certificates URL)</li>
    +1686      * </ul>
    +1687      * If there is this in the certificate, it returns undefined;
    +1688      * @example
    +1689      * x = new X509();
    +1690      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1691      * x.getExtAIAInfo(hCert) → 
    +1692      * { ocsp:     ["http://ocsp.foo.com"],
    +1693      *   caissuer: ["http://rep.foo.com/aaa.p8m"] }
    +1694      */
    +1695     this.getExtAIAInfo = function() {
    +1696 	var info = this.getExtInfo("authorityInfoAccess");
    +1697 	if (info === undefined) return info;
    +1698 
    +1699 	var result = { ocsp: [], caissuer: [] };
    +1700 	var a = _getChildIdx(this.hex, info.vidx);
    +1701 	for (var i = 0; i < a.length; i++) {
    +1702 	    var hOID = _getVbyList(this.hex, a[i], [0], "06");
    +1703 	    var hName = _getVbyList(this.hex, a[i], [1], "86");
    +1704 	    if (hOID === "2b06010505073001") {
    +1705 		result.ocsp.push(hextoutf8(hName));
    +1706 	    }
    +1707 	    if (hOID === "2b06010505073002") {
    +1708 		result.caissuer.push(hextoutf8(hName));
    +1709 	    }
    +1710 	}
    +1711 
    +1712 	return result;
    +1713     };
    +1714 
    +1715     /**
    +1716      * get AuthorityInfoAccess extension value as JSON object
    +1717      * @name getExtAuthorityInfoAccess
    +1718      * @memberOf X509#
    +1719      * @function
    +1720      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1721      * @param {Boolean} critical flag (OPTIONAL)
    +1722      * @return {Array} JSON object of AuthorityInfoAccess parameters or undefined
    +1723      * @since jsrsasign 9.0.0 x509 2.0.0
    +1724      * @see KJUR.asn1.x509.AuthorityInfoAccess
    +1725      * @description
    +1726      * This method parse authorityInfoAccess extension. When arguments are
    +1727      * not specified, its extension in X509 object will be parsed.
    +1728      * Result of this method can be passed to 
    +1729      * {@link KJUR.asn1.x509.AuthorityInfoAccess} constructor.
    +1730      * <br>
    +1731      * When hExtV and critical specified as arguments, return value
    +1732      * will be generated from them.
    +1733      * @example
    +1734      * x = new X509();
    +1735      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1736      * x.getExtAuthorityInfoAccess() →
    +1737      * {
    +1738      *   critial: true, // 
    +1739      *   array: [{ocsp: http://ocsp.example.com/},
    +1740      *           {caissuer: https://repository.example.com/}]
    +1741      * }
    +1742      *
    +1743      * x = new X509();
    +1744      * x.getExtAuthorityInfoAccesss("306230...") 
    +1745      * x.getExtAuthorityInfoAccesss("306230...", true) 
    +1746      */
    +1747     this.getExtAuthorityInfoAccess = function(hExtV, critical) {
    +1748 	if (hExtV === undefined && critical === undefined) {
    +1749 	    var info = this.getExtInfo("authorityInfoAccess");
    +1750 	    if (info === undefined) return undefined;
    +1751 	    hExtV = _getTLV(this.hex, info.vidx);
    +1752 	    critical = info.critical;
    +1753 	}
    +1754 
    +1755 	var result = {extname:"authorityInfoAccess",array:[]};
    +1756 	if (critical) result.critical = true;
    +1757 
    +1758 	var a = _getChildIdx(hExtV, 0);
    +1759 	for (var i = 0; i < a.length; i++) {
    +1760 	    var hMethod = _getVbyListEx(hExtV, a[i], [0], "06");
    +1761 	    var hLoc = _getVbyList(hExtV, a[i], [1], "86");
    +1762 	    var sLoc = hextoutf8(hLoc);
    +1763 	    if (hMethod == "2b06010505073001") {
    +1764 		result.array.push({ocsp: sLoc});
    +1765 	    } else if (hMethod == "2b06010505073002") {
    +1766 		result.array.push({caissuer: sLoc});
    +1767 	    } else {
    +1768 		throw new Error("unknown method: " + hMethod);
    +1769 	    }
    +1770 	}
    +1771 
    +1772 	return result;
    +1773     }
    +1774 
    +1775     /**
    +1776      * get CertificatePolicies extension value as JSON object
    +1777      * @name getExtCertificatePolicies
    +1778      * @memberOf X509#
    +1779      * @function
    +1780      * @param {String} hExtV hexadecimal string of extension value (OPTIONAL)
    +1781      * @param {Boolean} critical flag (OPTIONAL)
    +1782      * @return {Object} JSON object of CertificatePolicies parameters or undefined
    +1783      * @since jsrsasign 7.2.0 x509 1.1.14
    +1784      * @description
    +1785      * This method will get certificate policies value
    +1786      * as an array of JSON object which has properties defined
    +1787      * in {@link KJUR.asn1.x509.CertificatePolicies}.
    +1788      * Result of this method can be passed to 
    +1789      * {@link KJUR.asn1.x509.CertificatePolicies} constructor.
    +1790      * If there is no this extension in the certificate,
    +1791      * it returns undefined.
    +1792      * <br>
    +1793      * CAUTION: return value of JSON object format have been changed
    +1794      * from jsrsasign 9.0.0 without backword compatibility.
    +1795      * <br>
    +1796      * When hExtV and critical specified as arguments, return value
    +1797      * will be generated from them.
    +1798      * @example
    +1799      * x = new X509();
    +1800      * x.readCertPEM(sCertPEM); // parseExt() will also be called internally.
    +1801      * x.getExtCertificatePolicies() → 
    +1802      * { array: [
    +1803      *   { policyoid: "1.2.3.4" }
    +1804      *   { policyoid: "1.2.3.5",
    +1805      *     array: [
    +1806      *       { cps: "https://example.com/" },
    +1807      *       { unotice: { exptext: { type: "bmp", str: "sample text" } } }
    +1808      *     ] 
    +1809      *   }
    +1810      * ]}
    +1811      */
    +1812     this.getExtCertificatePolicies = function(hExtV, critical) {
    +1813 	if (hExtV === undefined && critical === undefined) {
    +1814 	    var info = this.getExtInfo("certificatePolicies");
    +1815 	    if (info === undefined) return undefined;
    +1816 	    hExtV = _getTLV(this.hex, info.vidx);
    +1817 	    critical = info.critical;
    +1818 	}
    +1819 	var result = {extname:"certificatePolicies",array:[]};
    +1820 	if (critical) result.critical = true;
    +1821 
    +1822 	var aIdxPI = _getChildIdx(hExtV, 0); // PolicyInformation list index
    +1823 	for (var i = 0; i < aIdxPI.length; i++) {
    +1824 	    var hPolicyInformation = _getTLV(hExtV, aIdxPI[i]);
    +1825 	    var polinfo = this.getPolicyInformation(hPolicyInformation);
    +1826 	    result.array.push(polinfo);
    +1827 	}
    +1828 	return result;
    +1829     }
    +1830 
    +1831     /**
    +1832      * get PolicyInformation ASN.1 structure parameter as JSON object
    +1833      * @name getPolicyInformation
    +1834      * @memberOf X509#
    +1835      * @function
    +1836      * @param {String} h hexadecimal string of PolicyInformation
    +1837      * @return {Object} JSON object of PolicyInformation parameters
    +1838      * @since jsrsasign 9.0.0 x509 2.0.0
    +1839      * @description
    +1840      * This method will get PolicyInformation parameters defined in
    +1841      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    +1842      * RFC 5280 4.2.1.4</a>.
    +1843      * <pre>
    +1844      * PolicyInformation ::= SEQUENCE {
    +1845      *      policyIdentifier   CertPolicyId,
    +1846      *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
    +1847      *                              PolicyQualifierInfo OPTIONAL }
    +1848      * </pre>
    +1849      * Result of this method can be passed to
    +1850      * {@link KJUR.asn1.x509.PolicyInformation} constructor.
    +1851      * @example
    +1852      * x = new X509();
    +1853      * x.getPolicyInformation("30...") →
    +1854      * {
    +1855      *     policyoid: "2.16.840.1.114412.2.1",
    +1856      *     array: [{cps: "https://www.digicert.com/CPS"}]
    +1857      * }
    +1858      */
    +1859     this.getPolicyInformation = function(h) {
    +1860 	var result = {};
    +1861 
    +1862 	var hPOLICYOID = _getVbyList(h, 0, [0], "06");
    +1863 	result.policyoid = _oidname(hPOLICYOID);
    +1864 	
    +1865 	var idxPQSEQ = _getIdxbyListEx(h, 0, [1], "30");
    +1866 	if (idxPQSEQ != -1) {
    +1867 	    result.array = [];
    +1868 	    var aIdx = _getChildIdx(h, idxPQSEQ);
    +1869 	    for (var j = 0; j < aIdx.length; j++) {
    +1870 		var hPQI = _getTLV(h, aIdx[j]);
    +1871 		var pqinfo = this.getPolicyQualifierInfo(hPQI);
    +1872 		result.array.push(pqinfo);
    +1873 	    }
    +1874 	}
    +1875 
    +1876 	return result;
    +1877     };
     1878 
    -1879         var a = _getChildIdx(h, 0);
    -1880         var hOID = _getVbyList(h, a[0], [], "06");
    -1881         var hValue = _getVbyList(h, a[1], []);
    -1882         result.oid = KJUR.asn1.ASN1Util.oidHexToInt(hOID);
    -1883         result.obj = _ASN1HEX_parse(hValue);
    -1884         return result;
    -1885     };
    -1886 
    -1887     /**
    -1888      * get PolicyQualifierInfo ASN.1 structure parameter as JSON object
    -1889      * @name getPolicyQualifierInfo
    -1890      * @memberOf X509#
    -1891      * @function
    -1892      * @param {String} h hexadecimal string of PolicyQualifierInfo
    -1893      * @return {Object} JSON object of PolicyQualifierInfo parameters
    -1894      * @since jsrsasign 9.0.0 x509 2.0.0
    -1895      * @see X509#getExtCertificatePolicies
    -1896      * @see X509#getPolicyInformation
    -1897      * @description
    -1898      * This method will get 
    -1899      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    -1900      * PolicyQualifierInfo</a> parameters.
    -1901      * <pre>
    -1902      * PolicyQualifierInfo ::= SEQUENCE {
    -1903      *      policyQualifierId  PolicyQualifierId,
    -1904      *      qualifier          ANY DEFINED BY policyQualifierId }
    -1905      * id-qt          OBJECT IDENTIFIER ::=  { id-pkix 2 }
    -1906      * id-qt-cps      OBJECT IDENTIFIER ::=  { id-qt 1 }
    -1907      * id-qt-unotice  OBJECT IDENTIFIER ::=  { id-qt 2 }
    -1908      * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
    -1909      * Qualifier ::= CHOICE {
    -1910      *      cPSuri           CPSuri,
    -1911      *      userNotice       UserNotice }
    -1912      * CPSuri ::= IA5String
    -1913      * </pre>
    -1914      * Result of this method can be passed to 
    -1915      * {@link KJUR.asn1.x509.PolicyQualifierInfo} constructor.
    -1916      * @example
    -1917      * x = new X509();
    -1918      * x.getPolicyQualifierInfo("30...") 
    -1919      * → {unotice: {exptext: {type: 'utf8', str: 'aaa'}}}
    -1920      * x.getPolicyQualifierInfo("30...") 
    -1921      * → {cps: "https://repository.example.com/"}
    -1922      */
    -1923     this.getPolicyQualifierInfo = function(h) {
    -1924 	var result = {};
    -1925 	var hPQOID = _getVbyList(h, 0, [0], "06");
    -1926 	if (hPQOID === "2b06010505070201") { // cps
    -1927 	    var hCPSURI = _getVbyListEx(h, 0, [1], "16");
    -1928 	    result.cps = hextorstr(hCPSURI);
    -1929 	} else if (hPQOID === "2b06010505070202") { // unotice
    -1930 	    var hUserNotice = _getTLVbyList(h, 0, [1], "30");
    -1931 	    result.unotice = this.getUserNotice(hUserNotice);
    -1932 	}
    -1933 	return result;
    -1934     };
    -1935 
    -1936     /**
    -1937      * get UserNotice ASN.1 structure parameter as JSON object
    -1938      * @name getUserNotice
    -1939      * @memberOf X509#
    -1940      * @function
    -1941      * @param {String} h hexadecimal string of UserNotice
    -1942      * @return {Object} JSON object of UserNotice parameters
    -1943      * @since jsrsasign 9.0.0 x509 2.0.0
    -1944      * @see X509#getExtCertificatePolicies
    -1945      * @see X509#getPolicyInformation
    -1946      * @see X509#getPolicyQualifierInfo
    -1947      * @description
    -1948      * This method will get 
    -1949      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    -1950      * UserNotice</a> parameters.
    -1951      * <pre>
    -1952      * UserNotice ::= SEQUENCE {
    -1953      *      noticeRef        NoticeReference OPTIONAL,
    -1954      *      explicitText     DisplayText OPTIONAL }
    -1955      * </pre>
    -1956      * Result of this method can be passed to 
    -1957      * {@link KJUR.asn1.x509.NoticeReference} constructor.
    -1958      * <br/>
    -1959      * NOTE: NoticeReference parsing is currently not supported and
    -1960      * it will be ignored.
    -1961      * @example
    -1962      * x = new X509();
    -1963      * x.getUserNotice("30...") → {exptext: {type: 'utf8', str: 'aaa'}}
    -1964      */
    -1965     this.getUserNotice = function(h) {
    -1966 	var result = {};
    -1967 	var a = _getChildIdx(h, 0);
    -1968 	for (var i = 0; i < a.length; i++) {
    -1969 	    var hItem = _getTLV(h, a[i]);
    -1970 	    if (hItem.substr(0, 2) != "30") {
    -1971 		result.exptext = this.getDisplayText(hItem);
    -1972 	    }
    -1973 	}
    -1974 	return result;
    -1975     };
    -1976 
    -1977     /**
    -1978      * get DisplayText ASN.1 structure parameter as JSON object
    -1979      * @name getDisplayText
    -1980      * @memberOf X509#
    -1981      * @function
    -1982      * @param {String} h hexadecimal string of DisplayText
    -1983      * @return {Object} JSON object of DisplayText parameters
    -1984      * @since jsrsasign 9.0.0 x509 2.0.0
    -1985      * @see X509#getExtCertificatePolicies
    -1986      * @see X509#getPolicyInformation
    -1987      * @description
    -1988      * This method will get 
    -1989      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    -1990      * DisplayText</a> parameters.
    -1991      * <pre>
    -1992      * DisplayText ::= CHOICE {
    -1993      *      ia5String        IA5String      (SIZE (1..200)),
    -1994      *      visibleString    VisibleString  (SIZE (1..200)),
    -1995      *      bmpString        BMPString      (SIZE (1..200)),
    -1996      *      utf8String       UTF8String     (SIZE (1..200)) }     
    -1997      * </pre>
    -1998      * Result of this method can be passed to 
    -1999      * {@link KJUR.asn1.x509.DisplayText} constructor.
    -2000      * @example
    -2001      * x = new X509();
    -2002      * x.getDisplayText("0c03616161") &rarr {type: 'utf8', str: 'aaa'}
    -2003      * x.getDisplayText("1e03616161") &rarr {type: 'bmp',  str: 'aaa'}
    -2004      */
    -2005     this.getDisplayText = function(h) {
    -2006 	var _DISPLAYTEXTTAG = {"0c": "utf8", "16": "ia5", "1a": "vis" , "1e": "bmp"};
    -2007 	var result = {};
    -2008 	result.type = _DISPLAYTEXTTAG[h.substr(0, 2)];
    -2009 	result.str = hextorstr(_getV(h, 0));
    -2010 	return result;
    -2011     };
    -2012 
    -2013     /**
    -2014      * parse cRLNumber CRL extension as JSON object<br/>
    -2015      * @name getExtCRLNumber
    -2016      * @memberOf X509#
    -2017      * @function
    -2018      * @param {String} hExtV hexadecimal string of extension value
    -2019      * @param {Boolean} critical flag
    -2020      * @since jsrsasign 9.1.1 x509 2.0.1
    -2021      * @see KJUR.asn1.x509.CRLNumber
    -2022      * @see X509#getExtParamArray
    -2023      * @description
    -2024      * This method parses
    -2025      * CRLNumber CRL extension value defined in
    -2026      * <a href="https://tools.ietf.org/html/rfc5280#section-5.2.3">
    -2027      * RFC 5280 5.2.3</a> as JSON object.
    -2028      * <pre>
    -2029      * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
    -2030      * CRLNumber ::= INTEGER (0..MAX)
    -2031      * </pre>
    -2032      * <br/>
    -2033      * Result of this method can be passed to 
    -2034      * {@link KJUR.asn1.x509.CRLNumber} constructor.
    -2035      * @example
    -2036      * crl = X509CRL("-----BEGIN X509 CRL...");
    -2037      * ... get hExtV and critical flag ...
    -2038      * crl.getExtCRLNumber("02...", false) →
    -2039      * {extname: "cRLNumber", num: {hex: "12af"}}
    -2040      */
    -2041     this.getExtCRLNumber = function(hExtV, critical) {
    -2042 	var result = {extname:"cRLNumber"};
    -2043 	if (critical) result.critical = true;
    -2044 
    -2045 	if (hExtV.substr(0, 2) == "02") {
    -2046 	    result.num = {hex: _getV(hExtV, 0)};
    -2047 	    return result;
    -2048 	}
    -2049 	throw new Error("hExtV parse error: " + hExtV);
    -2050     };
    -2051 
    -2052     /**
    -2053      * parse cRLReason CRL entry extension as JSON object<br/>
    -2054      * @name getExtCRLReason
    -2055      * @memberOf X509#
    -2056      * @function
    -2057      * @param {String} hExtV hexadecimal string of extension value
    -2058      * @param {Boolean} critical flag
    -2059      * @since jsrsasign 9.1.1 x509 2.0.1
    -2060      * @see KJUR.asn1.x509.CRLReason
    -2061      * @see X509#getExtParamArray
    -2062      * @description
    -2063      * This method parses
    -2064      * CRLReason CRL entry extension value defined in
    -2065      * <a href="https://tools.ietf.org/html/rfc5280#section-5.3.1">
    -2066      * RFC 5280 5.3.1</a> as JSON object.
    -2067      * <pre>
    -2068      * id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 }
    -2069      * -- reasonCode ::= { CRLReason }
    -2070      * CRLReason ::= ENUMERATED {
    -2071      *      unspecified             (0),
    -2072      *      keyCompromise           (1),
    -2073      *      cACompromise            (2),
    -2074      *      affiliationChanged      (3),
    -2075      *      superseded              (4),
    -2076      *      cessationOfOperation    (5),
    -2077      *      certificateHold         (6),
    -2078      *      removeFromCRL           (8),
    -2079      *      privilegeWithdrawn      (9),
    -2080      *      aACompromise           (10) }
    -2081      * </pre>
    -2082      * <br/>
    -2083      * Result of this method can be passed to 
    -2084      * {@link KJUR.asn1.x509.CRLReason} constructor.
    -2085      * @example
    -2086      * crl = X509CRL("-----BEGIN X509 CRL...");
    -2087      * ... get hExtV and critical flag ...
    -2088      * crl.getExtCRLReason("02...", false) →
    -2089      * {extname: "cRLReason", code: 3}
    -2090      */
    -2091     this.getExtCRLReason = function(hExtV, critical) {
    -2092 	var result = {extname:"cRLReason"};
    -2093 	if (critical) result.critical = true;
    -2094 
    -2095 	if (hExtV.substr(0, 2) == "0a") {
    -2096 	    result.code = parseInt(_getV(hExtV, 0), 16);
    -2097 	    return result;
    -2098 	}
    -2099 	throw new Error("hExtV parse error: " + hExtV);
    -2100     };
    -2101 
    -2102     /**
    -2103      * parse OCSPNonce OCSP extension as JSON object<br/>
    -2104      * @name getExtOcspNonce
    -2105      * @memberOf X509#
    -2106      * @function
    -2107      * @param {String} hExtV hexadecimal string of extension value
    -2108      * @param {Boolean} critical flag
    -2109      * @return {Array} JSON object of parsed OCSPNonce extension
    -2110      * @since jsrsasign 9.1.6 x509 2.0.3
    -2111      * @see KJUR.asn1.x509.OCSPNonce
    -2112      * @see X509#getExtParamArray
    -2113      * @see X509#getExtParam
    -2114      * @description
    -2115      * This method parses
    -2116      * Nonce OCSP extension value defined in
    -2117      * <a href="https://tools.ietf.org/html/rfc6960#section-4.4.1">
    -2118      * RFC 6960 4.4.1</a> as JSON object.
    -2119      * <pre>
    -2120      * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
    -2121      * id-pkix-ocsp-nonce     OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
    -2122      * Nonce ::= OCTET STRING
    -2123      * </pre>
    -2124      * <br/>
    -2125      * Result of this method can be passed to 
    -2126      * {@link KJUR.asn1.x509.OCSPNonce} constructor.
    -2127      * @example
    -2128      * x = new X509();
    -2129      * x.getExtOcspNonce(<<extn hex value >>) →
    -2130      * { extname: "ocspNonce", hex: "1a2b..." }
    -2131      */
    -2132     this.getExtOcspNonce = function(hExtV, critical) {
    -2133 	var result = {extname:"ocspNonce"};
    -2134 	if (critical) result.critical = true;
    -2135 
    -2136 	var hNonce = _getV(hExtV, 0);
    -2137 	result.hex = hNonce;
    -2138 
    -2139 	return result;
    -2140     };
    -2141 
    -2142     /**
    -2143      * parse OCSPNoCheck OCSP extension as JSON object<br/>
    -2144      * @name getExtOcspNoCheck
    -2145      * @memberOf X509#
    -2146      * @function
    -2147      * @param {String} hExtV hexadecimal string of extension value
    -2148      * @param {Boolean} critical flag
    -2149      * @return {Array} JSON object of parsed OCSPNoCheck extension
    -2150      * @since jsrsasign 9.1.6 x509 2.0.3
    -2151      * @see KJUR.asn1.x509.OCSPNoCheck
    -2152      * @see X509#getExtParamArray
    -2153      * @see X509#getExtParam
    -2154      * @description
    -2155      * This method parses
    -2156      * OCSPNoCheck extension value defined in
    -2157      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.2.2.1">
    -2158      * RFC 6960 4.2.2.2.1</a> as JSON object.
    -2159      * <pre>
    -2160      * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
    -2161      * </pre>
    -2162      * <br/>
    -2163      * Result of this method can be passed to 
    -2164      * {@link KJUR.asn1.x509.OCSPNoCheck} constructor.
    -2165      * @example
    -2166      * x = new X509();
    -2167      * x.getExtOcspNoCheck(<<extn hex value >>) →
    -2168      * { extname: "ocspNoCheck" }
    -2169      */
    -2170     this.getExtOcspNoCheck = function(hExtV, critical) {
    -2171 	var result = {extname:"ocspNoCheck"};
    -2172 	if (critical) result.critical = true;
    -2173 
    -2174 	return result;
    -2175     };
    -2176 
    -2177     /**
    -2178      * parse AdobeTimeStamp extension as JSON object<br/>
    -2179      * @name getExtAdobeTimeStamp
    -2180      * @memberOf X509#
    -2181      * @function
    -2182      * @param {String} hExtV hexadecimal string of extension value
    -2183      * @param {Boolean} critical flag
    -2184      * @return {Array} JSON object of parsed AdobeTimeStamp extension
    -2185      * @since jsrsasign 10.0.1 x509 2.0.5
    -2186      * @see KJUR.asn1.x509.AdobeTimeStamp
    -2187      * @see X509#getExtParamArray
    -2188      * @see X509#getExtParam
    -2189      * @description
    -2190      * This method parses
    -2191      * X.509v3 AdobeTimeStamp private extension value defined in the
    -2192      * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSigDC/oids.html">
    -2193      * Adobe site</a> as JSON object.
    -2194      * This extension provides the URL location for time stamp service.
    -2195      * <pre>
    -2196      * adbe- OBJECT IDENTIFIER ::=  { adbe(1.2.840.113583) acrobat(1) security(1) x509Ext(9) 1 }
    -2197      *  ::= SEQUENCE {
    -2198      *     version INTEGER  { v1(1) }, -- extension version
    -2199      *     location GeneralName (In v1 GeneralName can be only uniformResourceIdentifier)
    -2200      *     requiresAuth        boolean (default false), OPTIONAL }
    -2201      * </pre>
    -2202      * <br/>
    -2203      * Result of this method can be passed to 
    -2204      * {@link KJUR.asn1.x509.AdobeTimeStamp} constructor.
    -2205      * <br/>
    -2206      * NOTE: This extesion doesn't seem to have official name. This may be called as "pdfTimeStamp".
    -2207      * @example
    -2208      * x.getExtAdobeTimeStamp(<<extn hex value >>) →
    -2209      * { extname: "adobeTimeStamp", uri: "http://tsa.example.com/" reqauth: true }
    -2210      */
    -2211     this.getExtAdobeTimeStamp = function(hExtV, critical) {
    -2212 	if (hExtV === undefined && critical === undefined) {
    -2213 	    var info = this.getExtInfo("adobeTimeStamp");
    -2214 	    if (info === undefined) return undefined;
    -2215 	    hExtV = _getTLV(this.hex, info.vidx);
    -2216 	    critical = info.critical;
    -2217 	}
    -2218 
    -2219 	var result = {extname:"adobeTimeStamp"};
    -2220 	if (critical) result.critical = true;
    -2221 
    -2222 	var a = _getChildIdx(hExtV, 0);
    -2223 	if (a.length > 1) {
    -2224 	    var hGN = _getTLV(hExtV, a[1])
    -2225 	    var gnParam = this.getGeneralName(hGN);
    -2226 	    if (gnParam.uri != undefined) {
    -2227 		result.uri = gnParam.uri;
    -2228 	    }
    -2229 	}
    -2230 	if (a.length > 2) {
    -2231 	    var hBool = _getTLV(hExtV, a[2]);
    -2232 	    if (hBool == "0101ff") result.reqauth = true;
    -2233 	    if (hBool == "010100") result.reqauth = false;
    -2234 	}
    -2235 
    -2236 	return result;
    -2237     };
    -2238 
    -2239     // ===== BEGIN X500Name related =====================================
    -2240     /*
    -2241      * convert ASN.1 parsed object to attrTypeAndValue assoc array<br/>
    -2242      * @name _convATV
    -2243      * @param p associative array of parsed attrTypeAndValue object
    -2244      * @return attrTypeAndValue associative array
    -2245      * @since jsrsasign 10.5.12 x509 2.0.14
    -2246      * @example
    -2247      * _convATV({seq: [...]} &rarr: {type:"C",value:"JP",ds:"prn"}
    -2248      */
    -2249     var _convATV = function(p) {
    -2250 	var result = {};
    -2251 	try {
    -2252 	    var name = p.seq[0].oid;
    -2253 	    var oid = KJUR.asn1.x509.OID.name2oid(name);
    -2254 	    result.type = KJUR.asn1.x509.OID.oid2atype(oid);
    -2255 	    var item1 = p.seq[1];
    -2256 	    if (item1.utf8str != undefined) {
    -2257 		result.ds = "utf8";
    -2258 		result.value = item1.utf8str.str;
    -2259 	    } else if (item1.numstr != undefined) {
    -2260 		result.ds = "num";
    -2261 		result.value = item1.numstr.str;
    -2262 	    } else if (item1.telstr != undefined) {
    -2263 		result.ds = "tel";
    -2264 		result.value = item1.telstr.str;
    -2265 	    } else if (item1.prnstr != undefined) {
    -2266 		result.ds = "prn";
    -2267 		result.value = item1.prnstr.str;
    -2268 	    } else if (item1.ia5str != undefined) {
    -2269 		result.ds = "ia5";
    -2270 		result.value = item1.ia5str.str;
    -2271 	    } else if (item1.visstr != undefined) {
    -2272 		result.ds = "vis";
    -2273 		result.value = item1.visstr.str;
    -2274 	    } else if (item1.bmpstr != undefined) {
    -2275 		result.ds = "bmp";
    -2276 		result.value = item1.bmpstr.str;
    -2277 	    } else {
    -2278 		throw "error";
    -2279 	    }
    -2280 	    return result;
    -2281 	} catch(ex) {
    -2282 	    throw new Erorr("improper ASN.1 parsed AttrTypeAndValue");
    -2283 	}
    -2284     };
    -2285 
    -2286     /*
    -2287      * convert ASN.1 parsed object to RDN array<br/>
    -2288      * @name _convRDN
    -2289      * @param p associative array of parsed RDN object
    -2290      * @return RDN array
    -2291      * @since jsrsasign 10.5.12 x509 2.0.14
    -2292      * @example
    -2293      * _convRDN({set: [...]} &rarr: [{type:"C",value:"JP",ds:"prn"}]
    -2294      */
    -2295     var _convRDN = function(p) {
    -2296 	try {
    -2297 	    return p.set.map(function(pATV){return _convATV(pATV)});
    -2298 	} catch(ex) {
    -2299 	    throw new Error("improper ASN.1 parsed RDN: " + ex);
    -2300 	}
    -2301     };
    -2302 
    -2303     /*
    -2304      * convert ASN.1 parsed object to X500Name array<br/>
    -2305      * @name _convX500Name
    -2306      * @param p associative array of parsed X500Name array object
    -2307      * @return RDN array
    -2308      * @since jsrsasign 10.5.12 x509 2.0.14
    -2309      * @example
    -2310      * _convX500Name({seq: [...]} &rarr: [[{type:"C",value:"JP",ds:"prn"}]]
    -2311      */
    -2312     var _convX500Name = function(p) {
    -2313 	try {
    -2314 	    return p.seq.map(function(pRDN){return _convRDN(pRDN)});
    -2315 	} catch(ex) {
    -2316 	    throw new Error("improper ASN.1 parsed X500Name: " + ex);
    -2317 	}
    -2318     };
    -2319 
    -2320     this.getX500NameRule = function(aDN) {
    -2321 	var isPRNRule = true;
    -2322 	var isUTF8Rule = true;
    -2323 	var isMixedRule = false;
    -2324 	var logfull = "";
    -2325 	var logcheck = "";
    -2326 	var lasttag = null;
    -2327 
    -2328 	var a = [];
    -2329 	for (var i = 0; i < aDN.length; i++) {
    -2330 	    var aRDN = aDN[i];
    -2331 	    for (var j = 0; j < aRDN.length; j++) {
    -2332 		a.push(aRDN[j]);
    -2333 	    }
    -2334 	}
    +1879     /**
    +1880      * getOtherName ASN.1 structure parameter as JSON object<br/>
    +1881      * @name getOtherName
    +1882      * @memberOf X509#
    +1883      * @param {String} h hexadecimal string of GeneralName
    +1884      * @return {Array} associative array of OtherName
    +1885      * @since jsrsasign 10.5.3 x509 2.0.12
    +1886      * @see KJUR.asn1.x509.GeneralNames
    +1887      * @see KJUR.asn1.x509.GeneralName
    +1888      * @see KJUR.asn1.x509.OtherName
    +1889      * @see X509#getGeneralName
    +1890      * @see ASN1HEX#parse
    +1891      *
    +1892      * @description
    +1893      * This method will get OtherName parameters defined in
    +1894      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.6">
    +1895      * RFC 5280 4.2.1.6</a>.
    +1896      * <pre>
    +1897      * OtherName ::= SEQUENCE {
    +1898      *    type-id    OBJECT IDENTIFIER,
    +1899      *    value      [0] EXPLICIT ANY DEFINED BY type-id }
    +1900      * </pre>
    +1901      * The value of member "other" is converted by 
    +1902      * {@link ASN1HEX#parse}.
    +1903      *
    +1904      * @example
    +1905      * x = new X509();
    +1906      * x.getOtherName("30...") →
    +1907      * { oid: "1.2.3.4",
    +1908      *   value: {utf8str: {str: "aaa"}} }
    +1909      */
    +1910     this.getOtherName = function(h) {
    +1911         var result = {};
    +1912         var a = _getChildIdx(h, 0);
    +1913         var hOID = _getVbyList(h, a[0], [], "06");
    +1914         var hValue = _getVbyList(h, a[1], []);
    +1915 	result.oid = _oidname(hOID);
    +1916 	result.value = _ASN1HEX_parse(hValue);
    +1917         return result;
    +1918     };
    +1919 
    +1920     /**
    +1921      * get PolicyQualifierInfo ASN.1 structure parameter as JSON object
    +1922      * @name getPolicyQualifierInfo
    +1923      * @memberOf X509#
    +1924      * @function
    +1925      * @param {String} h hexadecimal string of PolicyQualifierInfo
    +1926      * @return {Object} JSON object of PolicyQualifierInfo parameters
    +1927      * @since jsrsasign 9.0.0 x509 2.0.0
    +1928      * @see X509#getExtCertificatePolicies
    +1929      * @see X509#getPolicyInformation
    +1930      * @description
    +1931      * This method will get 
    +1932      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    +1933      * PolicyQualifierInfo</a> parameters.
    +1934      * <pre>
    +1935      * PolicyQualifierInfo ::= SEQUENCE {
    +1936      *      policyQualifierId  PolicyQualifierId,
    +1937      *      qualifier          ANY DEFINED BY policyQualifierId }
    +1938      * id-qt          OBJECT IDENTIFIER ::=  { id-pkix 2 }
    +1939      * id-qt-cps      OBJECT IDENTIFIER ::=  { id-qt 1 }
    +1940      * id-qt-unotice  OBJECT IDENTIFIER ::=  { id-qt 2 }
    +1941      * PolicyQualifierId ::= OBJECT IDENTIFIER ( id-qt-cps | id-qt-unotice )
    +1942      * Qualifier ::= CHOICE {
    +1943      *      cPSuri           CPSuri,
    +1944      *      userNotice       UserNotice }
    +1945      * CPSuri ::= IA5String
    +1946      * </pre>
    +1947      * Result of this method can be passed to 
    +1948      * {@link KJUR.asn1.x509.PolicyQualifierInfo} constructor.
    +1949      * @example
    +1950      * x = new X509();
    +1951      * x.getPolicyQualifierInfo("30...") 
    +1952      * → {unotice: {exptext: {type: 'utf8', str: 'aaa'}}}
    +1953      * x.getPolicyQualifierInfo("30...") 
    +1954      * → {cps: "https://repository.example.com/"}
    +1955      */
    +1956     this.getPolicyQualifierInfo = function(h) {
    +1957 	var result = {};
    +1958 	var hPQOID = _getVbyList(h, 0, [0], "06");
    +1959 	if (hPQOID === "2b06010505070201") { // cps
    +1960 	    var hCPSURI = _getVbyListEx(h, 0, [1], "16");
    +1961 	    result.cps = hextorstr(hCPSURI);
    +1962 	} else if (hPQOID === "2b06010505070202") { // unotice
    +1963 	    var hUserNotice = _getTLVbyList(h, 0, [1], "30");
    +1964 	    result.unotice = this.getUserNotice(hUserNotice);
    +1965 	}
    +1966 	return result;
    +1967     };
    +1968 
    +1969     /**
    +1970      * get UserNotice ASN.1 structure parameter as JSON object
    +1971      * @name getUserNotice
    +1972      * @memberOf X509#
    +1973      * @function
    +1974      * @param {String} h hexadecimal string of UserNotice
    +1975      * @return {Object} JSON object of UserNotice parameters
    +1976      * @since jsrsasign 9.0.0 x509 2.0.0
    +1977      * @see X509#getExtCertificatePolicies
    +1978      * @see X509#getPolicyInformation
    +1979      * @see X509#getPolicyQualifierInfo
    +1980      * @description
    +1981      * This method will get 
    +1982      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    +1983      * UserNotice</a> parameters.
    +1984      * <pre>
    +1985      * UserNotice ::= SEQUENCE {
    +1986      *      noticeRef        NoticeReference OPTIONAL,
    +1987      *      explicitText     DisplayText OPTIONAL }
    +1988      * </pre>
    +1989      * Result of this method can be passed to 
    +1990      * {@link KJUR.asn1.x509.NoticeReference} constructor.
    +1991      * <br/>
    +1992      * NOTE: NoticeReference parsing is currently not supported and
    +1993      * it will be ignored.
    +1994      * @example
    +1995      * x = new X509();
    +1996      * x.getUserNotice("30...") → {exptext: {type: 'utf8', str: 'aaa'}}
    +1997      */
    +1998     this.getUserNotice = function(h) {
    +1999 	var result = {};
    +2000 	var a = _getChildIdx(h, 0);
    +2001 	for (var i = 0; i < a.length; i++) {
    +2002 	    var hItem = _getTLV(h, a[i]);
    +2003 	    if (hItem.substr(0, 2) != "30") {
    +2004 		result.exptext = this.getDisplayText(hItem);
    +2005 	    }
    +2006 	}
    +2007 	return result;
    +2008     };
    +2009 
    +2010     /**
    +2011      * get DisplayText ASN.1 structure parameter as JSON object
    +2012      * @name getDisplayText
    +2013      * @memberOf X509#
    +2014      * @function
    +2015      * @param {String} h hexadecimal string of DisplayText
    +2016      * @return {Object} JSON object of DisplayText parameters
    +2017      * @since jsrsasign 9.0.0 x509 2.0.0
    +2018      * @see X509#getExtCertificatePolicies
    +2019      * @see X509#getPolicyInformation
    +2020      * @description
    +2021      * This method will get 
    +2022      * <a href="https://tools.ietf.org/html/rfc5280#section-4.2.1.4">
    +2023      * DisplayText</a> parameters.
    +2024      * <pre>
    +2025      * DisplayText ::= CHOICE {
    +2026      *      ia5String        IA5String      (SIZE (1..200)),
    +2027      *      visibleString    VisibleString  (SIZE (1..200)),
    +2028      *      bmpString        BMPString      (SIZE (1..200)),
    +2029      *      utf8String       UTF8String     (SIZE (1..200)) }     
    +2030      * </pre>
    +2031      * Result of this method can be passed to 
    +2032      * {@link KJUR.asn1.x509.DisplayText} constructor.
    +2033      * @example
    +2034      * x = new X509();
    +2035      * x.getDisplayText("0c03616161") &rarr {type: 'utf8', str: 'aaa'}
    +2036      * x.getDisplayText("1e03616161") &rarr {type: 'bmp',  str: 'aaa'}
    +2037      */
    +2038     this.getDisplayText = function(h) {
    +2039 	var _DISPLAYTEXTTAG = {"0c": "utf8", "16": "ia5", "1a": "vis" , "1e": "bmp"};
    +2040 	var result = {};
    +2041 	result.type = _DISPLAYTEXTTAG[h.substr(0, 2)];
    +2042 	result.str = hextorstr(_getV(h, 0));
    +2043 	return result;
    +2044     };
    +2045 
    +2046     /**
    +2047      * parse cRLNumber CRL extension as JSON object<br/>
    +2048      * @name getExtCRLNumber
    +2049      * @memberOf X509#
    +2050      * @function
    +2051      * @param {String} hExtV hexadecimal string of extension value
    +2052      * @param {Boolean} critical flag
    +2053      * @since jsrsasign 9.1.1 x509 2.0.1
    +2054      * @see KJUR.asn1.x509.CRLNumber
    +2055      * @see X509#getExtParamArray
    +2056      * @description
    +2057      * This method parses
    +2058      * CRLNumber CRL extension value defined in
    +2059      * <a href="https://tools.ietf.org/html/rfc5280#section-5.2.3">
    +2060      * RFC 5280 5.2.3</a> as JSON object.
    +2061      * <pre>
    +2062      * id-ce-cRLNumber OBJECT IDENTIFIER ::= { id-ce 20 }
    +2063      * CRLNumber ::= INTEGER (0..MAX)
    +2064      * </pre>
    +2065      * <br/>
    +2066      * Result of this method can be passed to 
    +2067      * {@link KJUR.asn1.x509.CRLNumber} constructor.
    +2068      * @example
    +2069      * crl = X509CRL("-----BEGIN X509 CRL...");
    +2070      * ... get hExtV and critical flag ...
    +2071      * crl.getExtCRLNumber("02...", false) →
    +2072      * {extname: "cRLNumber", num: {hex: "12af"}}
    +2073      */
    +2074     this.getExtCRLNumber = function(hExtV, critical) {
    +2075 	var result = {extname:"cRLNumber"};
    +2076 	if (critical) result.critical = true;
    +2077 
    +2078 	if (hExtV.substr(0, 2) == "02") {
    +2079 	    result.num = {hex: _getV(hExtV, 0)};
    +2080 	    return result;
    +2081 	}
    +2082 	throw new Error("hExtV parse error: " + hExtV);
    +2083     };
    +2084 
    +2085     /**
    +2086      * parse cRLReason CRL entry extension as JSON object<br/>
    +2087      * @name getExtCRLReason
    +2088      * @memberOf X509#
    +2089      * @function
    +2090      * @param {String} hExtV hexadecimal string of extension value
    +2091      * @param {Boolean} critical flag
    +2092      * @since jsrsasign 9.1.1 x509 2.0.1
    +2093      * @see KJUR.asn1.x509.CRLReason
    +2094      * @see X509#getExtParamArray
    +2095      * @description
    +2096      * This method parses
    +2097      * CRLReason CRL entry extension value defined in
    +2098      * <a href="https://tools.ietf.org/html/rfc5280#section-5.3.1">
    +2099      * RFC 5280 5.3.1</a> as JSON object.
    +2100      * <pre>
    +2101      * id-ce-cRLReasons OBJECT IDENTIFIER ::= { id-ce 21 }
    +2102      * -- reasonCode ::= { CRLReason }
    +2103      * CRLReason ::= ENUMERATED {
    +2104      *      unspecified             (0),
    +2105      *      keyCompromise           (1),
    +2106      *      cACompromise            (2),
    +2107      *      affiliationChanged      (3),
    +2108      *      superseded              (4),
    +2109      *      cessationOfOperation    (5),
    +2110      *      certificateHold         (6),
    +2111      *      removeFromCRL           (8),
    +2112      *      privilegeWithdrawn      (9),
    +2113      *      aACompromise           (10) }
    +2114      * </pre>
    +2115      * <br/>
    +2116      * Result of this method can be passed to 
    +2117      * {@link KJUR.asn1.x509.CRLReason} constructor.
    +2118      * @example
    +2119      * crl = X509CRL("-----BEGIN X509 CRL...");
    +2120      * ... get hExtV and critical flag ...
    +2121      * crl.getExtCRLReason("02...", false) →
    +2122      * {extname: "cRLReason", code: 3}
    +2123      */
    +2124     this.getExtCRLReason = function(hExtV, critical) {
    +2125 	var result = {extname:"cRLReason"};
    +2126 	if (critical) result.critical = true;
    +2127 
    +2128 	if (hExtV.substr(0, 2) == "0a") {
    +2129 	    result.code = parseInt(_getV(hExtV, 0), 16);
    +2130 	    return result;
    +2131 	}
    +2132 	throw new Error("hExtV parse error: " + hExtV);
    +2133     };
    +2134 
    +2135     /**
    +2136      * parse OCSPNonce OCSP extension as JSON object<br/>
    +2137      * @name getExtOcspNonce
    +2138      * @memberOf X509#
    +2139      * @function
    +2140      * @param {String} hExtV hexadecimal string of extension value
    +2141      * @param {Boolean} critical flag
    +2142      * @return {Array} JSON object of parsed OCSPNonce extension
    +2143      * @since jsrsasign 9.1.6 x509 2.0.3
    +2144      * @see KJUR.asn1.x509.OCSPNonce
    +2145      * @see X509#getExtParamArray
    +2146      * @see X509#getExtParam
    +2147      * @description
    +2148      * This method parses
    +2149      * Nonce OCSP extension value defined in
    +2150      * <a href="https://tools.ietf.org/html/rfc6960#section-4.4.1">
    +2151      * RFC 6960 4.4.1</a> as JSON object.
    +2152      * <pre>
    +2153      * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
    +2154      * id-pkix-ocsp-nonce     OBJECT IDENTIFIER ::= { id-pkix-ocsp 2 }
    +2155      * Nonce ::= OCTET STRING
    +2156      * </pre>
    +2157      * <br/>
    +2158      * Result of this method can be passed to 
    +2159      * {@link KJUR.asn1.x509.OCSPNonce} constructor.
    +2160      * @example
    +2161      * x = new X509();
    +2162      * x.getExtOcspNonce(<<extn hex value >>) →
    +2163      * { extname: "ocspNonce", hex: "1a2b..." }
    +2164      */
    +2165     this.getExtOcspNonce = function(hExtV, critical) {
    +2166 	var result = {extname:"ocspNonce"};
    +2167 	if (critical) result.critical = true;
    +2168 
    +2169 	var hNonce = _getV(hExtV, 0);
    +2170 	result.hex = hNonce;
    +2171 
    +2172 	return result;
    +2173     };
    +2174 
    +2175     /**
    +2176      * parse OCSPNoCheck OCSP extension as JSON object<br/>
    +2177      * @name getExtOcspNoCheck
    +2178      * @memberOf X509#
    +2179      * @function
    +2180      * @param {String} hExtV hexadecimal string of extension value
    +2181      * @param {Boolean} critical flag
    +2182      * @return {Array} JSON object of parsed OCSPNoCheck extension
    +2183      * @since jsrsasign 9.1.6 x509 2.0.3
    +2184      * @see KJUR.asn1.x509.OCSPNoCheck
    +2185      * @see X509#getExtParamArray
    +2186      * @see X509#getExtParam
    +2187      * @description
    +2188      * This method parses
    +2189      * OCSPNoCheck extension value defined in
    +2190      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.2.2.1">
    +2191      * RFC 6960 4.2.2.2.1</a> as JSON object.
    +2192      * <pre>
    +2193      * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
    +2194      * </pre>
    +2195      * <br/>
    +2196      * Result of this method can be passed to 
    +2197      * {@link KJUR.asn1.x509.OCSPNoCheck} constructor.
    +2198      * @example
    +2199      * x = new X509();
    +2200      * x.getExtOcspNoCheck(<<extn hex value >>) →
    +2201      * { extname: "ocspNoCheck" }
    +2202      */
    +2203     this.getExtOcspNoCheck = function(hExtV, critical) {
    +2204 	var result = {extname:"ocspNoCheck"};
    +2205 	if (critical) result.critical = true;
    +2206 
    +2207 	return result;
    +2208     };
    +2209 
    +2210     /**
    +2211      * parse AdobeTimeStamp extension as JSON object<br/>
    +2212      * @name getExtAdobeTimeStamp
    +2213      * @memberOf X509#
    +2214      * @function
    +2215      * @param {String} hExtV hexadecimal string of extension value
    +2216      * @param {Boolean} critical flag
    +2217      * @return {Array} JSON object of parsed AdobeTimeStamp extension
    +2218      * @since jsrsasign 10.0.1 x509 2.0.5
    +2219      * @see KJUR.asn1.x509.AdobeTimeStamp
    +2220      * @see X509#getExtParamArray
    +2221      * @see X509#getExtParam
    +2222      * @description
    +2223      * This method parses
    +2224      * X.509v3 AdobeTimeStamp private extension value defined in the
    +2225      * <a href="https://www.adobe.com/devnet-docs/acrobatetk/tools/DigSigDC/oids.html">
    +2226      * Adobe site</a> as JSON object.
    +2227      * This extension provides the URL location for time stamp service.
    +2228      * <pre>
    +2229      * adbe- OBJECT IDENTIFIER ::=  { adbe(1.2.840.113583) acrobat(1) security(1) x509Ext(9) 1 }
    +2230      *  ::= SEQUENCE {
    +2231      *     version INTEGER  { v1(1) }, -- extension version
    +2232      *     location GeneralName (In v1 GeneralName can be only uniformResourceIdentifier)
    +2233      *     requiresAuth        boolean (default false), OPTIONAL }
    +2234      * </pre>
    +2235      * <br/>
    +2236      * Result of this method can be passed to 
    +2237      * {@link KJUR.asn1.x509.AdobeTimeStamp} constructor.
    +2238      * <br/>
    +2239      * NOTE: This extesion doesn't seem to have official name. This may be called as "pdfTimeStamp".
    +2240      * @example
    +2241      * x.getExtAdobeTimeStamp(<<extn hex value >>) →
    +2242      * { extname: "adobeTimeStamp", uri: "http://tsa.example.com/" reqauth: true }
    +2243      */
    +2244     this.getExtAdobeTimeStamp = function(hExtV, critical) {
    +2245 	if (hExtV === undefined && critical === undefined) {
    +2246 	    var info = this.getExtInfo("adobeTimeStamp");
    +2247 	    if (info === undefined) return undefined;
    +2248 	    hExtV = _getTLV(this.hex, info.vidx);
    +2249 	    critical = info.critical;
    +2250 	}
    +2251 
    +2252 	var result = {extname:"adobeTimeStamp"};
    +2253 	if (critical) result.critical = true;
    +2254 
    +2255 	var a = _getChildIdx(hExtV, 0);
    +2256 	if (a.length > 1) {
    +2257 	    var hGN = _getTLV(hExtV, a[1])
    +2258 	    var gnParam = this.getGeneralName(hGN);
    +2259 	    if (gnParam.uri != undefined) {
    +2260 		result.uri = gnParam.uri;
    +2261 	    }
    +2262 	}
    +2263 	if (a.length > 2) {
    +2264 	    var hBool = _getTLV(hExtV, a[2]);
    +2265 	    if (hBool == "0101ff") result.reqauth = true;
    +2266 	    if (hBool == "010100") result.reqauth = false;
    +2267 	}
    +2268 
    +2269 	return result;
    +2270     };
    +2271 
    +2272     // ===== BEGIN X500Name related =====================================
    +2273     /*
    +2274      * convert ASN.1 parsed object to attrTypeAndValue assoc array<br/>
    +2275      * @name _convATV
    +2276      * @param p associative array of parsed attrTypeAndValue object
    +2277      * @return attrTypeAndValue associative array
    +2278      * @since jsrsasign 10.5.12 x509 2.0.14
    +2279      * @example
    +2280      * _convATV({seq: [...]} &rarr: {type:"C",value:"JP",ds:"prn"}
    +2281      */
    +2282     var _convATV = function(p) {
    +2283 	var result = {};
    +2284 	try {
    +2285 	    var name = p.seq[0].oid;
    +2286 	    var oid = KJUR.asn1.x509.OID.name2oid(name);
    +2287 	    result.type = KJUR.asn1.x509.OID.oid2atype(oid);
    +2288 	    var item1 = p.seq[1];
    +2289 	    if (item1.utf8str != undefined) {
    +2290 		result.ds = "utf8";
    +2291 		result.value = item1.utf8str.str;
    +2292 	    } else if (item1.numstr != undefined) {
    +2293 		result.ds = "num";
    +2294 		result.value = item1.numstr.str;
    +2295 	    } else if (item1.telstr != undefined) {
    +2296 		result.ds = "tel";
    +2297 		result.value = item1.telstr.str;
    +2298 	    } else if (item1.prnstr != undefined) {
    +2299 		result.ds = "prn";
    +2300 		result.value = item1.prnstr.str;
    +2301 	    } else if (item1.ia5str != undefined) {
    +2302 		result.ds = "ia5";
    +2303 		result.value = item1.ia5str.str;
    +2304 	    } else if (item1.visstr != undefined) {
    +2305 		result.ds = "vis";
    +2306 		result.value = item1.visstr.str;
    +2307 	    } else if (item1.bmpstr != undefined) {
    +2308 		result.ds = "bmp";
    +2309 		result.value = item1.bmpstr.str;
    +2310 	    } else {
    +2311 		throw "error";
    +2312 	    }
    +2313 	    return result;
    +2314 	} catch(ex) {
    +2315 	    throw new Erorr("improper ASN.1 parsed AttrTypeAndValue");
    +2316 	}
    +2317     };
    +2318 
    +2319     /*
    +2320      * convert ASN.1 parsed object to RDN array<br/>
    +2321      * @name _convRDN
    +2322      * @param p associative array of parsed RDN object
    +2323      * @return RDN array
    +2324      * @since jsrsasign 10.5.12 x509 2.0.14
    +2325      * @example
    +2326      * _convRDN({set: [...]} &rarr: [{type:"C",value:"JP",ds:"prn"}]
    +2327      */
    +2328     var _convRDN = function(p) {
    +2329 	try {
    +2330 	    return p.set.map(function(pATV){return _convATV(pATV)});
    +2331 	} catch(ex) {
    +2332 	    throw new Error("improper ASN.1 parsed RDN: " + ex);
    +2333 	}
    +2334     };
     2335 
    -2336 	for (var i = 0; i < a.length; i++) {
    -2337 	    var item = a[i];
    -2338 	    var tag = item.ds;
    -2339 	    var value = item.value;
    -2340 	    var type = item.type;
    -2341 	    logfull += ":" + tag;
    -2342 	    
    -2343 	    if (tag != "prn" && tag != "utf8" && tag != "ia5") {
    -2344 		return "mixed";
    -2345 	    }
    -2346 	    if (tag == "ia5") {
    -2347 		if (type != "CN") {
    -2348 		    return "mixed";
    -2349 		} else {
    -2350 		    if (! KJUR.lang.String.isMail(value)) {
    -2351 			return "mixed";
    -2352 		    } else {
    -2353 			continue;
    -2354 		    }
    -2355 		}
    -2356 	    }
    -2357 	    if (type == "C") {
    -2358 		if (tag == "prn") {
    -2359 		    continue;
    -2360 		} else {
    -2361 		    return "mixed";
    -2362 		}
    -2363 	    }
    -2364 	    logcheck += ":" + tag;
    -2365 	    if (lasttag == null) {
    -2366 		lasttag = tag;
    -2367 	    } else {
    -2368 		if (lasttag !== tag) return "mixed";
    -2369 	    }
    -2370 	}
    -2371 	if (lasttag == null) {
    -2372 	    return "prn";
    -2373 	} else {
    -2374 	    return lasttag;
    -2375 	}
    -2376     };
    -2377 
    -2378     /**
    -2379      * get AttributeTypeAndValue ASN.1 structure parameter as JSON object<br/>
    -2380      * @name getAttrTypeAndValue
    -2381      * @memberOf X509#
    -2382      * @function
    -2383      * @param {String} h hexadecimal string of AttributeTypeAndValue
    -2384      * @return {Object} JSON object of AttributeTypeAndValue parameters
    -2385      * @since jsrsasign 9.0.0 x509 2.0.0
    -2386      * @see X509#getX500Name
    -2387      * @see X509#getRDN
    -2388      * @description
    -2389      * This method will get AttributeTypeAndValue parameters defined in
    -2390      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    -2391      * RFC 5280 4.1.2.4</a>.
    -2392      * <pre>
    -2393      * AttributeTypeAndValue ::= SEQUENCE {
    -2394      *   type     AttributeType,
    -2395      *   value    AttributeValue }
    -2396      * AttributeType ::= OBJECT IDENTIFIER
    -2397      * AttributeValue ::= ANY -- DEFINED BY AttributeType
    -2398      * </pre>
    -2399      * <ul>
    -2400      * <li>{String}type - AttributeType name or OID(ex. C,O,CN)</li>
    -2401      * <li>{String}value - raw string of ASN.1 value of AttributeValue</li>
    -2402      * <li>{String}ds - DirectoryString type of AttributeValue</li>
    -2403      * </ul>
    -2404      * "ds" has one of following value:
    -2405      * <ul>
    -2406      * <li>utf8 - (0x0c) UTF8String</li>
    -2407      * <li>num  - (0x12) NumericString</li>
    -2408      * <li>prn  - (0x13) PrintableString</li>
    -2409      * <li>tel  - (0x14) TeletexString</li>
    -2410      * <li>ia5  - (0x16) IA5String</li>
    -2411      * <li>vis  - (0x1a) VisibleString</li>
    -2412      * <li>bmp  - (0x1e) BMPString</li>
    -2413      * </ul>
    -2414      * @example
    -2415      * x = new X509();
    -2416      * x.getAttrTypeAndValue("30...") →
    -2417      * {type:"CN",value:"john.smith@example.com",ds:"ia5"} or
    -2418      * {type:"O",value:"Sample Corp.",ds:"prn"}
    -2419      */
    -2420     // unv  - (0x1c??) UniversalString ... for future
    -2421     this.getAttrTypeAndValue = function(h) {
    -2422 	var p = _ASN1HEX_parse(h);
    -2423 	return _convATV(p);
    -2424     };
    -2425 
    -2426     /**
    -2427      * get RelativeDistinguishedName ASN.1 structure parameter array<br/>
    -2428      * @name getRDN
    -2429      * @memberOf X509#
    -2430      * @function
    -2431      * @param {String} h hexadecimal string of RDN
    -2432      * @return {Array} array of AttrTypeAndValue parameters
    -2433      * @since jsrsasign 9.0.0 x509 2.0.0
    -2434      * @see X509#getX500Name
    -2435      * @see X509#getRDN
    -2436      * @see X509#getAttrTypeAndValue
    -2437      * @description
    -2438      * This method will get RelativeDistinguishedName parameters defined in
    -2439      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    -2440      * RFC 5280 4.1.2.4</a>.
    -2441      * <pre>
    -2442      * RelativeDistinguishedName ::=
    -2443      *   SET SIZE (1..MAX) OF AttributeTypeAndValue
    -2444      * </pre>
    -2445      * @example
    -2446      * x = new X509();
    -2447      * x.getRDN("31...") →
    -2448      * [{type:"C",value:"US",ds:"prn"}] or
    -2449      * [{type:"O",value:"Sample Corp.",ds:"prn"}] or
    -2450      * [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]
    -2451      */
    -2452     this.getRDN = function(h) {
    -2453 	var p = _ASN1HEX_parse(h);
    -2454 	return _convRDN(p);
    -2455     };
    -2456 
    -2457     /**
    -2458      * get X.500 Name ASN.1 structure parameter array<br/>
    -2459      * @name getX500NameArray
    -2460      * @memberOf X509#
    -2461      * @function
    -2462      * @param {String} h hexadecimal string of Name
    -2463      * @return {Array} array of RDN parameter array
    -2464      * @since jsrsasign 10.0.6 x509 2.0.9
    -2465      * @see X509#getX500Name
    -2466      * @see X509#getRDN
    -2467      * @see X509#getAttrTypeAndValue
    -2468      * @description
    -2469      * This method will get Name parameter defined in
    -2470      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    -2471      * RFC 5280 4.1.2.4</a>.
    -2472      * <pre>
    -2473      * Name ::= CHOICE { -- only one possibility for now --
    -2474      *   rdnSequence  RDNSequence }
    -2475      * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
    -2476      * </pre>
    -2477      * @example
    -2478      * x = new X509();
    -2479      * x.getX500NameArray("30...") →
    -2480      * [[{type:"C",value:"US",ds:"prn"}],
    -2481      *  [{type:"O",value:"Sample Corp.",ds:"utf8"}],
    -2482      *  [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]]
    -2483      */
    -2484     this.getX500NameArray = function(h) {
    -2485 	var p = _ASN1HEX_parse(h);
    -2486 	return _convX500Name(p);
    -2487     };
    -2488 
    -2489     /**
    -2490      * get Name ASN.1 structure parameter array<br/>
    -2491      * @name getX500Name
    -2492      * @memberOf X509#
    -2493      * @function
    -2494      * @param {String} h hexadecimal string of Name
    -2495      * @return {Array} array of RDN parameter array
    -2496      * @since jsrsasign 9.0.0 x509 2.0.0
    -2497      * @see X509#getX500NameArray
    -2498      * @see X509#getRDN
    -2499      * @see X509#getAttrTypeAndValue
    -2500      * @see KJUR.asn1.x509.X500Name
    -2501      * @see KJUR.asn1.x509.GeneralName
    -2502      * @see KJUR.asn1.x509.GeneralNames
    -2503      * @description
    -2504      * This method will get Name parameter defined in
    -2505      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    -2506      * RFC 5280 4.1.2.4</a>.
    -2507      * <pre>
    -2508      * Name ::= CHOICE { -- only one possibility for now --
    -2509      *   rdnSequence  RDNSequence }
    -2510      * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
    -2511      * </pre>
    -2512      * @example
    -2513      * x = new X509();
    -2514      * x.getX500Name("30...") →
    -2515      * { array: [
    -2516      *     [{type:"C",value:"US",ds:"prn"}],
    -2517      *     [{type:"O",value:"Sample Corp.",ds:"utf8"}],
    -2518      *     [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]
    -2519      *   ],
    -2520      *   str: "/C=US/O=Sample Corp./CN=john.smith@example.com",
    -2521      *   hex: "30..."
    -2522      * }
    -2523      */
    -2524     this.getX500Name = function(h) {
    -2525 	var a = this.getX500NameArray(h);
    -2526 	var s = this.dnarraytostr(a);
    -2527 	return { array: a, str: s };
    -2528     };
    -2529 
    -2530     // ===== END X500Name related =====================================
    -2531 
    -2532     // ===== BEGIN read certificate =====================================
    -2533     /**
    -2534      * read PEM formatted X.509 certificate from string.<br/>
    -2535      * @name readCertPEM
    -2536      * @memberOf X509#
    -2537      * @function
    -2538      * @param {String} sCertPEM string for PEM formatted X.509 certificate
    -2539      * @example
    -2540      * x = new X509();
    -2541      * x.readCertPEM(sCertPEM); // read certificate
    -2542      */
    -2543     this.readCertPEM = function(sCertPEM) {
    -2544         this.readCertHex(_pemtohex(sCertPEM));
    -2545     };
    -2546 
    -2547     /**
    -2548      * read a hexadecimal string of X.509 certificate<br/>
    -2549      * @name readCertHex
    -2550      * @memberOf X509#
    -2551      * @function
    -2552      * @param {String} sCertHex hexadecimal string of X.509 certificate
    -2553      * @since jsrsasign 7.1.4 x509 1.1.13
    -2554      * @description
    -2555      * NOTE: {@link X509#parseExt} will called internally since jsrsasign 7.2.0.
    -2556      * @example
    -2557      * x = new X509();
    -2558      * x.readCertHex("3082..."); // read certificate
    -2559      */
    -2560     this.readCertHex = function(sCertHex) {
    -2561         this.hex = sCertHex;
    -2562 	this.getVersion(); // set version parameter
    -2563 
    -2564 	try {
    -2565 	    _getIdxbyList(this.hex, 0, [0, 7], "a3"); // has [3] v3ext
    -2566 	    this.parseExt();
    -2567 	} catch(ex) {};
    -2568     };
    -2569 
    -2570     // ===== END read certificate =====================================
    -2571 
    -2572     /**
    -2573      * get JSON object of certificate parameters<br/>
    -2574      * @name getParam
    -2575      * @memberOf X509#
    -2576      * @function
    -2577      * @param {Object} option optional setting for return object
    -2578      * @return {Object} JSON object of certificate parameters
    -2579      * @since jsrsasign 9.0.0 x509 2.0.0
    -2580      * @see KJUR.asn1.x509.X509Util.newCertPEM
    -2581      *
    -2582      * @description
    -2583      * This method returns a JSON object of the certificate
    -2584      * parameters. Return value can be passed to
    -2585      * {@link KJUR.asn1.x509.X509Util.newCertPEM}.
    -2586      * <br>
    -2587      * NOTE1: From jsrsasign 10.5.16, optional argument can be applied.
    -2588      * It can have following members:
    -2589      * <ul>
    -2590      * <li>tbshex - if this is true, tbshex member with hex value of
    -2591      * tbsCertificate will be added</li>
    -2592      * <li>nodnarray - if this is true, array member for subject and
    -2593      * issuer will be deleted to simplify it<li>
    -2594      * </ul>
    -2595      *
    -2596      * @example
    -2597      * x = new X509();
    -2598      * x.readCertPEM("-----BEGIN CERTIFICATE...");
    -2599      * x.getParam() →
    -2600      * {version:3,
    -2601      *  serial:{hex:"12ab"},
    -2602      *  sigalg:"SHA256withRSA",
    -2603      *  issuer: {array:[[{type:'CN',value:'CA1',ds:'prn'}]],str:"/O=CA1"},
    -2604      *  notbefore:"160403023700Z",
    -2605      *  notafter:"160702023700Z",
    -2606      *  subject: {array:[[{type:'CN',value:'Test1',ds:'prn'}]],str:"/CN=Test1"},
    -2607      *  sbjpubkey:"-----BEGIN PUBLIC KEY...",
    -2608      *  ext:[
    -2609      *   {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    -2610      *   {extname:"basicConstraints",critical:true},
    -2611      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    -2612      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2613      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    -2614      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}
    -2615      *  ],
    -2616      *  sighex:"0b76...8"
    -2617      * };
    -2618      *
    -2619      * x.getParam({tbshex: true}) → { ... , tbshex: "30..." }
    -2620      * x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...}
    -2621      */
    -2622     this.getParam = function(option) {
    -2623 	var result = {};
    -2624 	result.version = this.getVersion();
    -2625 	result.serial = {hex: this.getSerialNumberHex()};
    -2626 	result.sigalg = this.getSignatureAlgorithmField();
    -2627 	result.issuer = this.getIssuer();
    -2628 	result.notbefore = this.getNotBefore();
    -2629 	result.notafter = this.getNotAfter();
    -2630 	result.subject = this.getSubject();
    -2631 	result.sbjpubkey = hextopem(this.getPublicKeyHex(), "PUBLIC KEY");
    -2632 	if (this.aExtInfo != undefined &&
    -2633 	    this.aExtInfo.length > 0) {
    -2634 	    result.ext = this.getExtParamArray();
    -2635 	}
    -2636 	result.sighex = this.getSignatureValueHex();
    -2637 
    -2638 	// for options
    -2639 	if (typeof option == "object") {
    -2640 	    if (option.tbshex == true) {
    -2641 		result.tbshex = _getTLVbyList(this.hex, 0, [0]);
    -2642 	    }
    -2643 	    if (option.nodnarray == true) {
    -2644 		delete result.issuer.array;
    -2645 		delete result.subject.array;
    -2646 	    }
    -2647 	}
    -2648 	return result;
    -2649     };
    -2650 
    -2651     /** 
    -2652      * get array of certificate extension parameter JSON object<br/>
    -2653      * @name getExtParamArray
    -2654      * @memberOf X509#
    -2655      * @function
    -2656      * @param {String} hExtSeq hexadecimal string of SEQUENCE of Extension
    -2657      * @return {Array} array of certificate extension parameter JSON object
    -2658      * @since jsrsasign 9.0.0 x509 2.0.0
    -2659      * @see KJUR.asn1.x509.X509Util.newCertPEM
    -2660      * @see X509#getParam
    -2661      * @see X509#getExtParam
    -2662      * @see X509CRL#getParam
    -2663      * @see KJUR.asn1.csr.CSRUtil.getParam
    -2664      *
    -2665      * @description
    -2666      * This method returns an array of certificate extension
    -2667      * parameters. 
    -2668      * <br/>
    -2669      * NOTE: Argument "hExtSeq" have been supported since jsrsasign 9.1.1.
    -2670      *
    -2671      * @example
    -2672      * x = new X509();
    -2673      * x.readCertPEM("-----BEGIN CERTIFICATE...");
    -2674      * x.getExtParamArray() →
    -2675      * [ {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    -2676      *   {extname:"basicConstraints",critical:true},
    -2677      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    -2678      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2679      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    -2680      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}]
    -2681      */
    -2682     this.getExtParamArray = function(hExtSeq) {
    -2683 	if (hExtSeq == undefined) {
    -2684 	    // for X.509v3 certificate
    -2685 	    var idx1 = _getIdxbyListEx(this.hex, 0, [0, "[3]"]);
    -2686 	    if (idx1 != -1) {
    -2687 		hExtSeq = _getTLVbyListEx(this.hex, 0, [0, "[3]", 0], "30");
    -2688 	    }
    -2689 	}
    -2690 	var result = [];
    -2691 	var aIdx = _getChildIdx(hExtSeq, 0);
    -2692 
    -2693 	for (var i = 0; i < aIdx.length; i++) {
    -2694 	    var hExt = _getTLV(hExtSeq, aIdx[i]);
    -2695 	    var extParam = this.getExtParam(hExt);
    -2696 	    if (extParam != null) result.push(extParam);
    -2697 	}
    -2698 
    -2699 	return result;
    -2700     };
    -2701 
    -2702     /** 
    -2703      * get a extension parameter JSON object<br/>
    -2704      * @name getExtParam
    -2705      * @memberOf X509#
    -2706      * @function
    -2707      * @param {String} hExt hexadecimal string of Extension
    -2708      * @return {Array} Extension parameter JSON object
    -2709      * @since jsrsasign 9.1.1 x509 2.0.1
    -2710      * @see KJUR.asn1.x509.X509Util.newCertPEM
    -2711      * @see X509#getParam
    -2712      * @see X509#getExtParamArray
    -2713      * @see X509CRL#getParam
    -2714      * @see KJUR.asn1.csr.CSRUtil.getParam
    -2715      *
    -2716      * @description
    -2717      * This method returns a extension parameters as JSON object. 
    -2718      *
    -2719      * @example
    -2720      * x = new X509();
    -2721      * ...
    -2722      * x.getExtParam("30...") →
    -2723      * {extname:"keyUsage",critical:true,names:["digitalSignature"]}
    -2724      */
    -2725     this.getExtParam = function(hExt) {
    -2726 	var result = {};
    -2727 	var aIdx = _getChildIdx(hExt, 0);
    -2728 	var aIdxLen = aIdx.length;
    -2729 	if (aIdxLen != 2 && aIdxLen != 3)
    -2730 	    throw new Error("wrong number elements in Extension: " + 
    -2731 			    aIdxLen + " " + hExt);
    -2732 
    -2733 	var oid = _hextooidstr(_getVbyList(hExt, 0, [0], "06"));
    -2734 
    -2735 	var critical = false;
    -2736 	if (aIdxLen == 3 && _getTLVbyList(hExt, 0, [1]) == "0101ff")
    -2737 	    critical = true;
    -2738 
    -2739 	var hExtV = _getTLVbyList(hExt, 0, [aIdxLen - 1, 0]);
    -2740 
    -2741 	var extParam = undefined;
    -2742 	if (oid == "2.5.29.14") {
    -2743 	    extParam = this.getExtSubjectKeyIdentifier(hExtV, critical);
    -2744 	} else if (oid == "2.5.29.15") {
    -2745 	    extParam = this.getExtKeyUsage(hExtV, critical);
    -2746 	} else if (oid == "2.5.29.17") {
    -2747 	    extParam = this.getExtSubjectAltName(hExtV, critical);
    -2748 	} else if (oid == "2.5.29.18") {
    -2749 	    extParam = this.getExtIssuerAltName(hExtV, critical);
    -2750 	} else if (oid == "2.5.29.19") {
    -2751 	    extParam = this.getExtBasicConstraints(hExtV, critical);
    -2752 	} else if (oid == "2.5.29.30") {
    -2753 	    extParam = this.getExtNameConstraints(hExtV, critical);
    -2754 	} else if (oid == "2.5.29.31") {
    -2755 	    extParam = this.getExtCRLDistributionPoints(hExtV, critical);
    -2756 	} else if (oid == "2.5.29.32") {
    -2757 	    extParam = this.getExtCertificatePolicies(hExtV, critical);
    -2758 	} else if (oid == "2.5.29.35") {
    -2759 	    extParam = this.getExtAuthorityKeyIdentifier(hExtV, critical);
    -2760 	} else if (oid == "2.5.29.37") {
    -2761 	    extParam = this.getExtExtKeyUsage(hExtV, critical);
    -2762 	} else if (oid == "1.3.6.1.5.5.7.1.1") {
    -2763 	    extParam = this.getExtAuthorityInfoAccess(hExtV, critical);
    -2764 	} else if (oid == "2.5.29.20") {
    -2765 	    extParam = this.getExtCRLNumber(hExtV, critical);
    -2766 	} else if (oid == "2.5.29.21") {
    -2767 	    extParam = this.getExtCRLReason(hExtV, critical);
    -2768 	} else if (oid == "1.3.6.1.5.5.7.48.1.2") {
    -2769 	    extParam = this.getExtOcspNonce(hExtV, critical);
    -2770 	} else if (oid == "1.3.6.1.5.5.7.48.1.5") {
    -2771 	    extParam = this.getExtOcspNoCheck(hExtV, critical);
    -2772 	} else if (oid == "1.2.840.113583.1.1.9.1") {
    -2773 	    extParam = this.getExtAdobeTimeStamp(hExtV, critical);
    -2774 	}
    -2775 	if (extParam != undefined) return extParam;
    -2776 
    -2777 	var privateParam = { extname: oid, extn: hExtV };
    -2778 	if (critical) privateParam.critical = true;
    -2779 	return privateParam;
    -2780     };
    -2781 
    -2782     /**
    -2783      * find extension parameter in array<br/>
    -2784      * @name findExt
    -2785      * @memberOf X509#
    -2786      * @function
    -2787      * @param {Array} aExt array of extension parameters
    -2788      * @param {String} extname extension name
    -2789      * @return {Array} extension parameter in the array or null
    -2790      * @since jsrsasign 10.0.3 x509 2.0.7
    -2791      * @see X509#getParam
    -2792      *
    -2793      * @description
    -2794      * This method returns an extension parameter for
    -2795      * specified extension name in the array.
    -2796      * This method is useful to update extension parameter value.
    -2797      * When there is no such extension with the extname,
    -2798      * this returns "null".
    -2799      *
    -2800      * @example
    -2801      * // (1) 
    -2802      * x = new X509(CERTPEM);
    -2803      * params = x.getParam();
    -2804      * pSKID = x.findExt(params.ext, "subjectKeyIdentifier");
    -2805      * pSKID.kid = "1234abced..."; // skid in the params is updated.
    -2806      *   // then params was updated
    -2807      *
    -2808      * // (2) another example
    -2809      * aExt = [
    -2810      *   {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    -2811      *   {extname:"basicConstraints",critical:true},
    -2812      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    -2813      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2814      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    -2815      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}
    -2816      * ];
    -2817      * var x = new X509();
    -2818      * x.findExt(aExt, "authorityKeyInfoAccess").array[0].ocsp = "http://aaa.com";
    -2819      * pKU = x.findExt(aExt, "keyUsage");
    -2820      * delete pKU["critical"]; // clear criticla flag
    -2821      * pKU.names = ["keyCertSign", "cRLSign"];
    -2822      *   // then aExt was updated
    -2823      */
    -2824     this.findExt = function(aExt, extname) {
    -2825 	for (var i = 0; i < aExt.length; i++) {
    -2826 	    if (aExt[i].extname == extname) return aExt[i];
    -2827 	}
    -2828 	return null;
    -2829 
    -2830     };
    -2831 
    -2832     /**
    -2833      * update CRLDistributionPoints Full URI in parameter<br/>
    -2834      * @name updateCDPFullURI
    -2835      * @memberOf X509#
    -2836      * @function
    -2837      * @param {Array} aExt array of extension parameters
    -2838      * @param {String} newURI string of new uri
    -2839      * @since jsrsasign 10.0.4 x509 2.0.8
    -2840      * @see X509#findExt
    -2841      * @see KJUR.asn1.x509.CRLDistributionPoints
    -2842      *
    -2843      * @description
    -2844      * This method updates Full URI of CRLDistributionPoints extension
    -2845      * in the extension parameter array if it exists.
    -2846      *
    -2847      * @example
    -2848      * aExt = [
    -2849      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2850      *   {extname:"cRLDistributionPoints",
    -2851      *    array:[{dpname:{full:[{uri:"http://example.com/a.crl"}]}}]},
    -2852      * ];
    -2853      * x = new X509();
    -2854      * x.updateCDPFullURI(aExt, "http://crl2.example.new/b.crl");
    -2855      */
    -2856     this.updateExtCDPFullURI = function(aExt, newURI) {
    -2857 	var pExt = this.findExt(aExt, "cRLDistributionPoints");
    -2858 	if (pExt == null) return;
    -2859 	if (pExt.array == undefined) return;
    -2860 	var aDP = pExt.array;
    -2861 	for (var i = 0; i < aDP.length; i++) {
    -2862 	    if (aDP[i].dpname == undefined) continue;
    -2863 	    if (aDP[i].dpname.full == undefined) continue;
    -2864 	    var aURI = aDP[i].dpname.full;
    -2865 	    for (var j = 0; j < aURI.length; j++) {
    -2866 		var pURI = aURI[i];
    -2867 		if (pURI.uri == undefined) continue;
    -2868 		pURI.uri = newURI;
    -2869 	    }
    -2870 	}
    -2871     };
    -2872 
    -2873     /**
    -2874      * update authorityInfoAccess ocsp in parameter<br/>
    -2875      * @name updateAIAOCSP
    -2876      * @memberOf X509#
    -2877      * @function
    -2878      * @param {Array} aExt array of extension parameters
    -2879      * @param {String} newURI string of new uri
    -2880      * @since jsrsasign 10.0.4 x509 2.0.8
    -2881      * @see X509#findExt
    -2882      * @see KJUR.asn1.x509.AuthorityInfoAccess
    -2883      *
    -2884      * @description
    -2885      * This method updates "ocsp" accessMethod URI of 
    -2886      * AuthorityInfoAccess extension
    -2887      * in the extension parameter array if it exists.
    -2888      *
    -2889      * @example
    -2890      * aExt = [
    -2891      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2892      *   {extname:"authoriyInfoAccess",
    -2893      *    array:[
    -2894      *      {ocsp: "http://ocsp1.example.com"},
    -2895      *      {caissuer: "http://example.com/a.crt"}
    -2896      *    ]}
    -2897      * ];
    -2898      * x = new X509();
    -2899      * x.updateAIAOCSP(aExt, "http://ocsp2.example.net");
    -2900      */
    -2901     this.updateExtAIAOCSP = function(aExt, newURI) {
    -2902 	var pExt = this.findExt(aExt, "authorityInfoAccess");
    -2903 	if (pExt == null) return;
    -2904 	if (pExt.array == undefined) return;
    -2905 	var a = pExt.array;
    -2906 	for (var i = 0; i < a.length; i++) {
    -2907 	    if (a[i].ocsp != undefined) a[i].ocsp = newURI;
    -2908 	}
    -2909     };
    -2910 
    -2911     /**
    -2912      * update authorityInfoAccess caIssuer in parameter<br/>
    -2913      * @name updateAIACAIssuer
    -2914      * @memberOf X509#
    -2915      * @function
    -2916      * @param {Array} aExt array of extension parameters
    -2917      * @param {String} newURI string of new uri
    -2918      * @since jsrsasign 10.0.4 x509 2.0.8
    -2919      * @see X509#findExt
    -2920      * @see KJUR.asn1.x509.AuthorityInfoAccess
    -2921      *
    -2922      * @description
    -2923      * This method updates "caIssuer" accessMethod URI of 
    -2924      * AuthorityInfoAccess extension
    -2925      * in the extension parameter array if it exists.
    -2926      *
    -2927      * @example
    -2928      * aExt = [
    -2929      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    -2930      *   {extname:"authoriyInfoAccess",
    -2931      *    array:[
    -2932      *      {ocsp: "http://ocsp1.example.com"},
    -2933      *      {caissuer: "http://example.com/a.crt"}
    -2934      *    ]}
    -2935      * ];
    -2936      * x = new X509();
    -2937      * x.updateAIACAIssuer(aExt, "http://example.net/b.crt");
    -2938      */
    -2939     this.updateExtAIACAIssuer = function(aExt, newURI) {
    -2940 	var pExt = this.findExt(aExt, "authorityInfoAccess");
    -2941 	if (pExt == null) return;
    -2942 	if (pExt.array == undefined) return;
    -2943 	var a = pExt.array;
    -2944 	for (var i = 0; i < a.length; i++) {
    -2945 	    if (a[i].caissuer != undefined) a[i].caissuer = newURI;
    -2946 	}
    -2947     };
    -2948 
    -2949     /**
    -2950      * convert array for X500 distinguish name to distinguish name string<br/>
    -2951      * @name dnarraytostr
    -2952      * @memberOf X509#
    -2953      * @function
    -2954      * @param {Array} aDN array for X500 distinguish name
    -2955      * @return {String} distinguish name
    -2956      * @since jsrsasign 10.0.6 x509 2.0.8
    -2957      * @see X509#getX500Name
    -2958      * @see X509#getX500NameArray
    -2959      * @see KJUR.asn1.x509.X500Name
    -2960      *
    -2961      * @description
    -2962      * This method converts from an array representation of 
    -2963      * X.500 distinguished name to X.500 name string.
    -2964      * This supports multi-valued RDN.
    -2965      * 
    -2966      * @example
    -2967      * var x = new X509();
    -2968      * x.dnarraytostr(
    -2969      *   [[{type:"C",value:"JP",ds:"prn"}],
    -2970      *   [{type:"O",value:"T1",ds:"prn"}]]) → "/C=JP/O=T1"
    -2971      * x.dnarraytostr(
    -2972      *   [[{type:"C",value:"JP",ds:"prn"}],
    -2973      *   [{type:"O",value:"T1",ds:"prn"}
    -2974      *    {type:"CN",value:"Bob",ds:"prn"}]]) → "/C=JP/O=T1+CN=Bob"
    -2975      */
    -2976     this.dnarraytostr = function(aDN) {
    -2977 	function rdnarraytostr(aRDN) {
    -2978 	    return aRDN.map(function(x){return atvtostr(x).replace(/\+/,"\\+");}).join("+");
    -2979 	};
    -2980 
    -2981 	function atvtostr(pATV) {
    -2982 	    return pATV.type + "=" + pATV.value;
    -2983 	};
    -2984 
    -2985 	return "/" + aDN.map(function(x){return rdnarraytostr(x).replace(/\//, "\\/");}).join("/");
    -2986     };
    -2987 
    -2988     /**
    -2989      * get certificate information as string.<br/>
    -2990      * @name getInfo
    -2991      * @memberOf X509#
    -2992      * @function
    -2993      * @return {String} certificate information string
    -2994      * @since jsrsasign 5.0.10 x509 1.1.8
    -2995      * @example
    -2996      * x = new X509();
    -2997      * x.readCertPEM(certPEM);
    -2998      * console.log(x.getInfo());
    -2999      * // this shows as following
    -3000      * Basic Fields
    -3001      *   serial number: 02ac5c266a0b409b8f0b79f2ae462577
    -3002      *   signature algorithm: SHA1withRSA
    -3003      *   issuer: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
    -3004      *   notBefore: 061110000000Z
    -3005      *   notAfter: 311110000000Z
    -3006      *   subject: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA
    -3007      *   subject public key info:
    -3008      *     key algorithm: RSA
    -3009      *     n=c6cce573e6fbd4bb...
    -3010      *     e=10001
    -3011      * X509v3 Extensions:
    -3012      *   keyUsage CRITICAL:
    -3013      *     digitalSignature,keyCertSign,cRLSign
    -3014      *   basicConstraints CRITICAL:
    -3015      *     cA=true
    -3016      *   subjectKeyIdentifier :
    -3017      *     b13ec36903f8bf4701d498261a0802ef63642bc3
    -3018      *   authorityKeyIdentifier :
    -3019      *     kid=b13ec36903f8bf4701d498261a0802ef63642bc3
    -3020      * signature algorithm: SHA1withRSA
    -3021      * signature: 1c1a0697dcd79c9f...
    -3022      */
    -3023     this.getInfo = function() {
    -3024 	var _getSubjectAltNameStr = function(params) {
    -3025 	    var s = JSON.stringify(params.array).replace(/[\[\]\{\}\"]/g, '');
    -3026 	    return s;
    -3027 	};
    -3028 	var _getCertificatePoliciesStr = function(params) {
    -3029 	    var s = "";
    -3030 	    var a = params.array;
    -3031 	    for (var i = 0; i < a.length; i++) {
    -3032 		var pi = a[i];
    -3033 		s += "    policy oid: " + pi.policyoid + "\n";
    -3034 		if (pi.array === undefined) continue;
    -3035 		for (var j = 0; j < pi.array.length; j++) {
    -3036 		    var pqi = pi.array[j];
    -3037 		    if (pqi.cps !== undefined) {
    -3038 			s += "    cps: " + pqi.cps + "\n";
    -3039 		    }
    -3040 		}
    -3041 	    }
    -3042 	    return s;
    +2336     /*
    +2337      * convert ASN.1 parsed object to X500Name array<br/>
    +2338      * @name _convX500Name
    +2339      * @param p associative array of parsed X500Name array object
    +2340      * @return RDN array
    +2341      * @since jsrsasign 10.5.12 x509 2.0.14
    +2342      * @example
    +2343      * _convX500Name({seq: [...]} &rarr: [[{type:"C",value:"JP",ds:"prn"}]]
    +2344      */
    +2345     var _convX500Name = function(p) {
    +2346 	try {
    +2347 	    return p.seq.map(function(pRDN){return _convRDN(pRDN)});
    +2348 	} catch(ex) {
    +2349 	    throw new Error("improper ASN.1 parsed X500Name: " + ex);
    +2350 	}
    +2351     };
    +2352 
    +2353     this.getX500NameRule = function(aDN) {
    +2354 	var isPRNRule = true;
    +2355 	var isUTF8Rule = true;
    +2356 	var isMixedRule = false;
    +2357 	var logfull = "";
    +2358 	var logcheck = "";
    +2359 	var lasttag = null;
    +2360 
    +2361 	var a = [];
    +2362 	for (var i = 0; i < aDN.length; i++) {
    +2363 	    var aRDN = aDN[i];
    +2364 	    for (var j = 0; j < aRDN.length; j++) {
    +2365 		a.push(aRDN[j]);
    +2366 	    }
    +2367 	}
    +2368 
    +2369 	for (var i = 0; i < a.length; i++) {
    +2370 	    var item = a[i];
    +2371 	    var tag = item.ds;
    +2372 	    var value = item.value;
    +2373 	    var type = item.type;
    +2374 	    logfull += ":" + tag;
    +2375 	    
    +2376 	    if (tag != "prn" && tag != "utf8" && tag != "ia5") {
    +2377 		return "mixed";
    +2378 	    }
    +2379 	    if (tag == "ia5") {
    +2380 		if (type != "CN") {
    +2381 		    return "mixed";
    +2382 		} else {
    +2383 		    if (! KJUR.lang.String.isMail(value)) {
    +2384 			return "mixed";
    +2385 		    } else {
    +2386 			continue;
    +2387 		    }
    +2388 		}
    +2389 	    }
    +2390 	    if (type == "C") {
    +2391 		if (tag == "prn") {
    +2392 		    continue;
    +2393 		} else {
    +2394 		    return "mixed";
    +2395 		}
    +2396 	    }
    +2397 	    logcheck += ":" + tag;
    +2398 	    if (lasttag == null) {
    +2399 		lasttag = tag;
    +2400 	    } else {
    +2401 		if (lasttag !== tag) return "mixed";
    +2402 	    }
    +2403 	}
    +2404 	if (lasttag == null) {
    +2405 	    return "prn";
    +2406 	} else {
    +2407 	    return lasttag;
    +2408 	}
    +2409     };
    +2410 
    +2411     /**
    +2412      * get AttributeTypeAndValue ASN.1 structure parameter as JSON object<br/>
    +2413      * @name getAttrTypeAndValue
    +2414      * @memberOf X509#
    +2415      * @function
    +2416      * @param {String} h hexadecimal string of AttributeTypeAndValue
    +2417      * @return {Object} JSON object of AttributeTypeAndValue parameters
    +2418      * @since jsrsasign 9.0.0 x509 2.0.0
    +2419      * @see X509#getX500Name
    +2420      * @see X509#getRDN
    +2421      * @description
    +2422      * This method will get AttributeTypeAndValue parameters defined in
    +2423      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    +2424      * RFC 5280 4.1.2.4</a>.
    +2425      * <pre>
    +2426      * AttributeTypeAndValue ::= SEQUENCE {
    +2427      *   type     AttributeType,
    +2428      *   value    AttributeValue }
    +2429      * AttributeType ::= OBJECT IDENTIFIER
    +2430      * AttributeValue ::= ANY -- DEFINED BY AttributeType
    +2431      * </pre>
    +2432      * <ul>
    +2433      * <li>{String}type - AttributeType name or OID(ex. C,O,CN)</li>
    +2434      * <li>{String}value - raw string of ASN.1 value of AttributeValue</li>
    +2435      * <li>{String}ds - DirectoryString type of AttributeValue</li>
    +2436      * </ul>
    +2437      * "ds" has one of following value:
    +2438      * <ul>
    +2439      * <li>utf8 - (0x0c) UTF8String</li>
    +2440      * <li>num  - (0x12) NumericString</li>
    +2441      * <li>prn  - (0x13) PrintableString</li>
    +2442      * <li>tel  - (0x14) TeletexString</li>
    +2443      * <li>ia5  - (0x16) IA5String</li>
    +2444      * <li>vis  - (0x1a) VisibleString</li>
    +2445      * <li>bmp  - (0x1e) BMPString</li>
    +2446      * </ul>
    +2447      * @example
    +2448      * x = new X509();
    +2449      * x.getAttrTypeAndValue("30...") →
    +2450      * {type:"CN",value:"john.smith@example.com",ds:"ia5"} or
    +2451      * {type:"O",value:"Sample Corp.",ds:"prn"}
    +2452      */
    +2453     // unv  - (0x1c??) UniversalString ... for future
    +2454     this.getAttrTypeAndValue = function(h) {
    +2455 	var p = _ASN1HEX_parse(h);
    +2456 	return _convATV(p);
    +2457     };
    +2458 
    +2459     /**
    +2460      * get RelativeDistinguishedName ASN.1 structure parameter array<br/>
    +2461      * @name getRDN
    +2462      * @memberOf X509#
    +2463      * @function
    +2464      * @param {String} h hexadecimal string of RDN
    +2465      * @return {Array} array of AttrTypeAndValue parameters
    +2466      * @since jsrsasign 9.0.0 x509 2.0.0
    +2467      * @see X509#getX500Name
    +2468      * @see X509#getRDN
    +2469      * @see X509#getAttrTypeAndValue
    +2470      * @description
    +2471      * This method will get RelativeDistinguishedName parameters defined in
    +2472      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    +2473      * RFC 5280 4.1.2.4</a>.
    +2474      * <pre>
    +2475      * RelativeDistinguishedName ::=
    +2476      *   SET SIZE (1..MAX) OF AttributeTypeAndValue
    +2477      * </pre>
    +2478      * @example
    +2479      * x = new X509();
    +2480      * x.getRDN("31...") →
    +2481      * [{type:"C",value:"US",ds:"prn"}] or
    +2482      * [{type:"O",value:"Sample Corp.",ds:"prn"}] or
    +2483      * [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]
    +2484      */
    +2485     this.getRDN = function(h) {
    +2486 	var p = _ASN1HEX_parse(h);
    +2487 	return _convRDN(p);
    +2488     };
    +2489 
    +2490     /**
    +2491      * get X.500 Name ASN.1 structure parameter array<br/>
    +2492      * @name getX500NameArray
    +2493      * @memberOf X509#
    +2494      * @function
    +2495      * @param {String} h hexadecimal string of Name
    +2496      * @return {Array} array of RDN parameter array
    +2497      * @since jsrsasign 10.0.6 x509 2.0.9
    +2498      * @see X509#getX500Name
    +2499      * @see X509#getRDN
    +2500      * @see X509#getAttrTypeAndValue
    +2501      * @description
    +2502      * This method will get Name parameter defined in
    +2503      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    +2504      * RFC 5280 4.1.2.4</a>.
    +2505      * <pre>
    +2506      * Name ::= CHOICE { -- only one possibility for now --
    +2507      *   rdnSequence  RDNSequence }
    +2508      * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
    +2509      * </pre>
    +2510      * @example
    +2511      * x = new X509();
    +2512      * x.getX500NameArray("30...") →
    +2513      * [[{type:"C",value:"US",ds:"prn"}],
    +2514      *  [{type:"O",value:"Sample Corp.",ds:"utf8"}],
    +2515      *  [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]]
    +2516      */
    +2517     this.getX500NameArray = function(h) {
    +2518 	var p = _ASN1HEX_parse(h);
    +2519 	return _convX500Name(p);
    +2520     };
    +2521 
    +2522     /**
    +2523      * get Name ASN.1 structure parameter array<br/>
    +2524      * @name getX500Name
    +2525      * @memberOf X509#
    +2526      * @function
    +2527      * @param {String} h hexadecimal string of Name
    +2528      * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false)
    +2529      * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false)
    +2530      * @return {Array} array of RDN parameter array
    +2531      * @since jsrsasign 9.0.0 x509 2.0.0
    +2532      * @see X509#getX500NameArray
    +2533      * @see X509#getRDN
    +2534      * @see X509#getAttrTypeAndValue
    +2535      * @see X509#c14nRDNArray
    +2536      * @see KJUR.asn1.x509.X500Name
    +2537      * @see KJUR.asn1.x509.GeneralName
    +2538      * @see KJUR.asn1.x509.GeneralNames
    +2539      *
    +2540      * @description
    +2541      * This method will get Name parameter defined in
    +2542      * <a href="https://tools.ietf.org/html/rfc5280#section-4.1.2.4">
    +2543      * RFC 5280 4.1.2.4</a>.
    +2544      * <pre>
    +2545      * Name ::= CHOICE { -- only one possibility for now --
    +2546      *   rdnSequence  RDNSequence }
    +2547      * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName
    +2548      * </pre>
    +2549      * <br>
    +2550      * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been 
    +2551      * supported to conclude a canonicalized name for caseIgnoreMatch
    +2552      * desribed in <a href="https://tools.ietf.org/html/rfc4518">
    +2553      * RFC 4518</a>.
    +2554      *
    +2555      * @example
    +2556      * x = new X509();
    +2557      * x.getX500Name("30...") →
    +2558      * { array: [
    +2559      *     [{type:"C",value:"US",ds:"prn"}],
    +2560      *     [{type:"O",value:"Sample Corp.",ds:"utf8"}],
    +2561      *     [{type:"CN",value:"john.smith@example.com",ds:"ia5"}]
    +2562      *   ],
    +2563      *   str: "/C=US/O=Sample Corp./CN=john.smith@example.com",
    +2564      *   hex: "30..." }
    +2565      *
    +2566      * x.getX500Name("30...", true) →
    +2567      * { array: [
    +2568      *     [{type:"C",value:"US",ds:"prn"}],
    +2569      *     [{type:"O",value:"Sample    Corp.",ds:"utf8"}]
    +2570      *   ],
    +2571      *   str: "/C=US/O=Sample    Corp.",
    +2572      *   canon: "/c=us/o=sample corp.",
    +2573      *   hex: "30..." }
    +2574      */
    +2575     this.getX500Name = function(h, flagCanon, flagHex) {
    +2576 	var a = this.getX500NameArray(h);
    +2577 	var s = this.dnarraytostr(a);
    +2578 	var result = { str: s };
    +2579 
    +2580 	result.array = a;
    +2581 	if (flagHex == true) result.hex = h;
    +2582 	if (flagCanon == true) result.canon = this.c14nRDNArray(a);
    +2583 	return result;
    +2584     };
    +2585 
    +2586     // ===== END X500Name related =====================================
    +2587 
    +2588     // ===== BEGIN read certificate =====================================
    +2589     /**
    +2590      * read PEM formatted X.509 certificate from string.<br/>
    +2591      * @name readCertPEM
    +2592      * @memberOf X509#
    +2593      * @function
    +2594      * @param {String} sCertPEM string for PEM formatted X.509 certificate
    +2595      * @example
    +2596      * x = new X509();
    +2597      * x.readCertPEM(sCertPEM); // read certificate
    +2598      */
    +2599     this.readCertPEM = function(sCertPEM) {
    +2600         this.readCertHex(_pemtohex(sCertPEM));
    +2601     };
    +2602 
    +2603     /**
    +2604      * read a hexadecimal string of X.509 certificate<br/>
    +2605      * @name readCertHex
    +2606      * @memberOf X509#
    +2607      * @function
    +2608      * @param {String} sCertHex hexadecimal string of X.509 certificate
    +2609      * @since jsrsasign 7.1.4 x509 1.1.13
    +2610      * @description
    +2611      * NOTE: {@link X509#parseExt} will called internally since jsrsasign 7.2.0.
    +2612      * @example
    +2613      * x = new X509();
    +2614      * x.readCertHex("3082..."); // read certificate
    +2615      */
    +2616     this.readCertHex = function(sCertHex) {
    +2617         this.hex = sCertHex;
    +2618 	this.getVersion(); // set version parameter
    +2619 
    +2620 	try {
    +2621 	    _getIdxbyList(this.hex, 0, [0, 7], "a3"); // has [3] v3ext
    +2622 	    this.parseExt();
    +2623 	} catch(ex) {};
    +2624     };
    +2625 
    +2626     // ===== END read certificate =====================================
    +2627 
    +2628     /**
    +2629      * get JSON object of certificate parameters<br/>
    +2630      * @name getParam
    +2631      * @memberOf X509#
    +2632      * @function
    +2633      * @param {Object} option optional setting for return object
    +2634      * @return {Object} JSON object of certificate parameters
    +2635      * @since jsrsasign 9.0.0 x509 2.0.0
    +2636      * @see KJUR.asn1.x509.X509Util.newCertPEM
    +2637      *
    +2638      * @description
    +2639      * This method returns a JSON object of the certificate
    +2640      * parameters. Return value can be passed to
    +2641      * {@link KJUR.asn1.x509.X509Util.newCertPEM}.
    +2642      * <br/>
    +2643      * NOTE1: From jsrsasign 10.5.16, optional argument can be applied.
    +2644      * It can have following members:
    +2645      * <ul>
    +2646      * <li>tbshex - (boolean) tbshex member with hex value of 
    +2647      * tbsCertificate will be added if true (DEFAULT undefined)</li>
    +2648      * <li>nodnarray - (boolean) array member for subject and
    +2649      * issuer will be deleted to simplify it if true (DEFAULT undefined)<li>
    +2650      * <li>dncanon - (boolean) add canon member to subject and issuer for DN StringPrep if true(DEFAULT undefined)</li>
    +2651      * <li>dnhex - (boolean) add hex member to subject and issuer if true(DEFAULT undefined)</li>
    +2652      * </ul>
    +2653      * <br/>
    +2654      * NOTE2: From jsrsasign 10.6.0, member "dncanon" and "dnhex" supported
    +2655      * in the "option" argument.
    +2656      *
    +2657      * @example
    +2658      * x = new X509();
    +2659      * x.readCertPEM("-----BEGIN CERTIFICATE...");
    +2660      * x.getParam() →
    +2661      * {version:3,
    +2662      *  serial:{hex:"12ab"},
    +2663      *  sigalg:"SHA256withRSA",
    +2664      *  issuer: {array:[[{type:'CN',value:'CA1',ds:'prn'}]],str:"/O=CA1"},
    +2665      *  notbefore:"160403023700Z",
    +2666      *  notafter:"160702023700Z",
    +2667      *  subject: {array:[[{type:'CN',value:'Test1',ds:'prn'}]],str:"/CN=Test1"},
    +2668      *  sbjpubkey:"-----BEGIN PUBLIC KEY...",
    +2669      *  ext:[
    +2670      *   {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    +2671      *   {extname:"basicConstraints",critical:true},
    +2672      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    +2673      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2674      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    +2675      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}
    +2676      *  ],
    +2677      *  sighex:"0b76...8"
    +2678      * };
    +2679      *
    +2680      * x.getParam({tbshex: true}) → { ... , tbshex: "30..." }
    +2681      * x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...}
    +2682      * x.getParam({dncanon: true}) → {... {issuer: {canon: "/c=jp/o=..."} ...} ...}
    +2683      * x.getParam({dnhex: true}) → {... {issuer: {hex: "30..."} ...} ...}
    +2684      */
    +2685     this.getParam = function(option) {
    +2686 	var result = {};
    +2687 	if (option == undefined) option = {};
    +2688 
    +2689 	result.version = this.getVersion();
    +2690 	result.serial = {hex: this.getSerialNumberHex()};
    +2691 	result.sigalg = this.getSignatureAlgorithmField();
    +2692 	result.issuer = this.getIssuer(option.dncanon, option.dnhex);
    +2693 	result.notbefore = this.getNotBefore();
    +2694 	result.notafter = this.getNotAfter();
    +2695 	result.subject = this.getSubject(option.dncanon, option.dnhex);
    +2696 	result.sbjpubkey = hextopem(this.getPublicKeyHex(), "PUBLIC KEY");
    +2697 	if (this.aExtInfo != undefined &&
    +2698 	    this.aExtInfo.length > 0) {
    +2699 	    result.ext = this.getExtParamArray();
    +2700 	}
    +2701 	result.sighex = this.getSignatureValueHex();
    +2702 
    +2703 	// for options
    +2704 	if (option.tbshex == true) {
    +2705 	    result.tbshex = _getTLVbyList(this.hex, 0, [0]);
    +2706 	}
    +2707 	if (option.nodnarray == true) {
    +2708 	    delete result.issuer.array;
    +2709 	    delete result.subject.array;
    +2710 	}
    +2711 
    +2712 	return result;
    +2713     };
    +2714 
    +2715     /** 
    +2716      * get array of certificate extension parameter JSON object<br/>
    +2717      * @name getExtParamArray
    +2718      * @memberOf X509#
    +2719      * @function
    +2720      * @param {String} hExtSeq hexadecimal string of SEQUENCE of Extension
    +2721      * @return {Array} array of certificate extension parameter JSON object
    +2722      * @since jsrsasign 9.0.0 x509 2.0.0
    +2723      * @see KJUR.asn1.x509.X509Util.newCertPEM
    +2724      * @see X509#getParam
    +2725      * @see X509#getExtParam
    +2726      * @see X509CRL#getParam
    +2727      * @see KJUR.asn1.csr.CSRUtil.getParam
    +2728      *
    +2729      * @description
    +2730      * This method returns an array of certificate extension
    +2731      * parameters. 
    +2732      * <br/>
    +2733      * NOTE: Argument "hExtSeq" have been supported since jsrsasign 9.1.1.
    +2734      *
    +2735      * @example
    +2736      * x = new X509();
    +2737      * x.readCertPEM("-----BEGIN CERTIFICATE...");
    +2738      * x.getExtParamArray() →
    +2739      * [ {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    +2740      *   {extname:"basicConstraints",critical:true},
    +2741      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    +2742      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2743      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    +2744      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}]
    +2745      */
    +2746     this.getExtParamArray = function(hExtSeq) {
    +2747 	if (hExtSeq == undefined) {
    +2748 	    // for X.509v3 certificate
    +2749 	    var idx1 = _getIdxbyListEx(this.hex, 0, [0, "[3]"]);
    +2750 	    if (idx1 != -1) {
    +2751 		hExtSeq = _getTLVbyListEx(this.hex, 0, [0, "[3]", 0], "30");
    +2752 	    }
    +2753 	}
    +2754 	var result = [];
    +2755 	var aIdx = _getChildIdx(hExtSeq, 0);
    +2756 
    +2757 	for (var i = 0; i < aIdx.length; i++) {
    +2758 	    var hExt = _getTLV(hExtSeq, aIdx[i]);
    +2759 	    var extParam = this.getExtParam(hExt);
    +2760 	    if (extParam != null) result.push(extParam);
    +2761 	}
    +2762 
    +2763 	return result;
    +2764     };
    +2765 
    +2766     /** 
    +2767      * get a extension parameter JSON object<br/>
    +2768      * @name getExtParam
    +2769      * @memberOf X509#
    +2770      * @function
    +2771      * @param {String} hExt hexadecimal string of Extension
    +2772      * @return {Array} Extension parameter JSON object
    +2773      * @since jsrsasign 9.1.1 x509 2.0.1
    +2774      * @see KJUR.asn1.x509.X509Util.newCertPEM
    +2775      * @see X509#getParam
    +2776      * @see X509#getExtParamArray
    +2777      * @see X509CRL#getParam
    +2778      * @see KJUR.asn1.csr.CSRUtil.getParam
    +2779      *
    +2780      * @description
    +2781      * This method returns a extension parameters as JSON object. 
    +2782      *
    +2783      * @example
    +2784      * x = new X509();
    +2785      * ...
    +2786      * x.getExtParam("30...") →
    +2787      * {extname:"keyUsage",critical:true,names:["digitalSignature"]}
    +2788      */
    +2789     this.getExtParam = function(hExt) {
    +2790 	var result = {};
    +2791 	var aIdx = _getChildIdx(hExt, 0);
    +2792 	var aIdxLen = aIdx.length;
    +2793 	if (aIdxLen != 2 && aIdxLen != 3)
    +2794 	    throw new Error("wrong number elements in Extension: " + 
    +2795 			    aIdxLen + " " + hExt);
    +2796 
    +2797 	var oid = _hextooidstr(_getVbyList(hExt, 0, [0], "06"));
    +2798 
    +2799 	var critical = false;
    +2800 	if (aIdxLen == 3 && _getTLVbyList(hExt, 0, [1]) == "0101ff")
    +2801 	    critical = true;
    +2802 
    +2803 	var hExtV = _getTLVbyList(hExt, 0, [aIdxLen - 1, 0]);
    +2804 
    +2805 	var extParam = undefined;
    +2806 	if (oid == "2.5.29.14") {
    +2807 	    extParam = this.getExtSubjectKeyIdentifier(hExtV, critical);
    +2808 	} else if (oid == "2.5.29.15") {
    +2809 	    extParam = this.getExtKeyUsage(hExtV, critical);
    +2810 	} else if (oid == "2.5.29.17") {
    +2811 	    extParam = this.getExtSubjectAltName(hExtV, critical);
    +2812 	} else if (oid == "2.5.29.18") {
    +2813 	    extParam = this.getExtIssuerAltName(hExtV, critical);
    +2814 	} else if (oid == "2.5.29.19") {
    +2815 	    extParam = this.getExtBasicConstraints(hExtV, critical);
    +2816 	} else if (oid == "2.5.29.30") {
    +2817 	    extParam = this.getExtNameConstraints(hExtV, critical);
    +2818 	} else if (oid == "2.5.29.31") {
    +2819 	    extParam = this.getExtCRLDistributionPoints(hExtV, critical);
    +2820 	} else if (oid == "2.5.29.32") {
    +2821 	    extParam = this.getExtCertificatePolicies(hExtV, critical);
    +2822 	} else if (oid == "2.5.29.35") {
    +2823 	    extParam = this.getExtAuthorityKeyIdentifier(hExtV, critical);
    +2824 	} else if (oid == "2.5.29.37") {
    +2825 	    extParam = this.getExtExtKeyUsage(hExtV, critical);
    +2826 	} else if (oid == "1.3.6.1.5.5.7.1.1") {
    +2827 	    extParam = this.getExtAuthorityInfoAccess(hExtV, critical);
    +2828 	} else if (oid == "2.5.29.20") {
    +2829 	    extParam = this.getExtCRLNumber(hExtV, critical);
    +2830 	} else if (oid == "2.5.29.21") {
    +2831 	    extParam = this.getExtCRLReason(hExtV, critical);
    +2832 	} else if (oid == "1.3.6.1.5.5.7.48.1.2") {
    +2833 	    extParam = this.getExtOcspNonce(hExtV, critical);
    +2834 	} else if (oid == "1.3.6.1.5.5.7.48.1.5") {
    +2835 	    extParam = this.getExtOcspNoCheck(hExtV, critical);
    +2836 	} else if (oid == "1.2.840.113583.1.1.9.1") {
    +2837 	    extParam = this.getExtAdobeTimeStamp(hExtV, critical);
    +2838 	}
    +2839 	if (extParam != undefined) return extParam;
    +2840 
    +2841 	var privateParam = { extname: oid, extn: hExtV };
    +2842 	if (critical) privateParam.critical = true;
    +2843 	return privateParam;
    +2844     };
    +2845 
    +2846     /**
    +2847      * find extension parameter in array<br/>
    +2848      * @name findExt
    +2849      * @memberOf X509#
    +2850      * @function
    +2851      * @param {Array} aExt array of extension parameters
    +2852      * @param {String} extname extension name
    +2853      * @return {Array} extension parameter in the array or null
    +2854      * @since jsrsasign 10.0.3 x509 2.0.7
    +2855      * @see X509#getParam
    +2856      *
    +2857      * @description
    +2858      * This method returns an extension parameter for
    +2859      * specified extension name in the array.
    +2860      * This method is useful to update extension parameter value.
    +2861      * When there is no such extension with the extname,
    +2862      * this returns "null".
    +2863      *
    +2864      * @example
    +2865      * // (1) 
    +2866      * x = new X509(CERTPEM);
    +2867      * params = x.getParam();
    +2868      * pSKID = x.findExt(params.ext, "subjectKeyIdentifier");
    +2869      * pSKID.kid = "1234abced..."; // skid in the params is updated.
    +2870      *   // then params was updated
    +2871      *
    +2872      * // (2) another example
    +2873      * aExt = [
    +2874      *   {extname:"keyUsage",critical:true,names:["digitalSignature"]},
    +2875      *   {extname:"basicConstraints",critical:true},
    +2876      *   {extname:"subjectKeyIdentifier",kid:{hex:"f2eb..."}},
    +2877      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2878      *   {extname:"authorityInfoAccess",array:[{ocsp:"http://ocsp.example.com/"}]},
    +2879      *   {extname:"certificatePolicies",array:[{policyoid:"2.23.140.1.2.1"}]}
    +2880      * ];
    +2881      * var x = new X509();
    +2882      * x.findExt(aExt, "authorityKeyInfoAccess").array[0].ocsp = "http://aaa.com";
    +2883      * pKU = x.findExt(aExt, "keyUsage");
    +2884      * delete pKU["critical"]; // clear criticla flag
    +2885      * pKU.names = ["keyCertSign", "cRLSign"];
    +2886      *   // then aExt was updated
    +2887      */
    +2888     this.findExt = function(aExt, extname) {
    +2889 	for (var i = 0; i < aExt.length; i++) {
    +2890 	    if (aExt[i].extname == extname) return aExt[i];
    +2891 	}
    +2892 	return null;
    +2893 
    +2894     };
    +2895 
    +2896     /**
    +2897      * update CRLDistributionPoints Full URI in parameter<br/>
    +2898      * @name updateCDPFullURI
    +2899      * @memberOf X509#
    +2900      * @function
    +2901      * @param {Array} aExt array of extension parameters
    +2902      * @param {String} newURI string of new uri
    +2903      * @since jsrsasign 10.0.4 x509 2.0.8
    +2904      * @see X509#findExt
    +2905      * @see KJUR.asn1.x509.CRLDistributionPoints
    +2906      *
    +2907      * @description
    +2908      * This method updates Full URI of CRLDistributionPoints extension
    +2909      * in the extension parameter array if it exists.
    +2910      *
    +2911      * @example
    +2912      * aExt = [
    +2913      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2914      *   {extname:"cRLDistributionPoints",
    +2915      *    array:[{dpname:{full:[{uri:"http://example.com/a.crl"}]}}]},
    +2916      * ];
    +2917      * x = new X509();
    +2918      * x.updateCDPFullURI(aExt, "http://crl2.example.new/b.crl");
    +2919      */
    +2920     this.updateExtCDPFullURI = function(aExt, newURI) {
    +2921 	var pExt = this.findExt(aExt, "cRLDistributionPoints");
    +2922 	if (pExt == null) return;
    +2923 	if (pExt.array == undefined) return;
    +2924 	var aDP = pExt.array;
    +2925 	for (var i = 0; i < aDP.length; i++) {
    +2926 	    if (aDP[i].dpname == undefined) continue;
    +2927 	    if (aDP[i].dpname.full == undefined) continue;
    +2928 	    var aURI = aDP[i].dpname.full;
    +2929 	    for (var j = 0; j < aURI.length; j++) {
    +2930 		var pURI = aURI[i];
    +2931 		if (pURI.uri == undefined) continue;
    +2932 		pURI.uri = newURI;
    +2933 	    }
    +2934 	}
    +2935     };
    +2936 
    +2937     /**
    +2938      * update authorityInfoAccess ocsp in parameter<br/>
    +2939      * @name updateAIAOCSP
    +2940      * @memberOf X509#
    +2941      * @function
    +2942      * @param {Array} aExt array of extension parameters
    +2943      * @param {String} newURI string of new uri
    +2944      * @since jsrsasign 10.0.4 x509 2.0.8
    +2945      * @see X509#findExt
    +2946      * @see KJUR.asn1.x509.AuthorityInfoAccess
    +2947      *
    +2948      * @description
    +2949      * This method updates "ocsp" accessMethod URI of 
    +2950      * AuthorityInfoAccess extension
    +2951      * in the extension parameter array if it exists.
    +2952      *
    +2953      * @example
    +2954      * aExt = [
    +2955      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2956      *   {extname:"authoriyInfoAccess",
    +2957      *    array:[
    +2958      *      {ocsp: "http://ocsp1.example.com"},
    +2959      *      {caissuer: "http://example.com/a.crt"}
    +2960      *    ]}
    +2961      * ];
    +2962      * x = new X509();
    +2963      * x.updateAIAOCSP(aExt, "http://ocsp2.example.net");
    +2964      */
    +2965     this.updateExtAIAOCSP = function(aExt, newURI) {
    +2966 	var pExt = this.findExt(aExt, "authorityInfoAccess");
    +2967 	if (pExt == null) return;
    +2968 	if (pExt.array == undefined) return;
    +2969 	var a = pExt.array;
    +2970 	for (var i = 0; i < a.length; i++) {
    +2971 	    if (a[i].ocsp != undefined) a[i].ocsp = newURI;
    +2972 	}
    +2973     };
    +2974 
    +2975     /**
    +2976      * update authorityInfoAccess caIssuer in parameter<br/>
    +2977      * @name updateAIACAIssuer
    +2978      * @memberOf X509#
    +2979      * @function
    +2980      * @param {Array} aExt array of extension parameters
    +2981      * @param {String} newURI string of new uri
    +2982      * @since jsrsasign 10.0.4 x509 2.0.8
    +2983      * @see X509#findExt
    +2984      * @see KJUR.asn1.x509.AuthorityInfoAccess
    +2985      *
    +2986      * @description
    +2987      * This method updates "caIssuer" accessMethod URI of 
    +2988      * AuthorityInfoAccess extension
    +2989      * in the extension parameter array if it exists.
    +2990      *
    +2991      * @example
    +2992      * aExt = [
    +2993      *   {extname:"authorityKeyIdentifier",kid:{hex:"12ab..."}},
    +2994      *   {extname:"authoriyInfoAccess",
    +2995      *    array:[
    +2996      *      {ocsp: "http://ocsp1.example.com"},
    +2997      *      {caissuer: "http://example.com/a.crt"}
    +2998      *    ]}
    +2999      * ];
    +3000      * x = new X509();
    +3001      * x.updateAIACAIssuer(aExt, "http://example.net/b.crt");
    +3002      */
    +3003     this.updateExtAIACAIssuer = function(aExt, newURI) {
    +3004 	var pExt = this.findExt(aExt, "authorityInfoAccess");
    +3005 	if (pExt == null) return;
    +3006 	if (pExt.array == undefined) return;
    +3007 	var a = pExt.array;
    +3008 	for (var i = 0; i < a.length; i++) {
    +3009 	    if (a[i].caissuer != undefined) a[i].caissuer = newURI;
    +3010 	}
    +3011     };
    +3012 
    +3013     /**
    +3014      * convert array for X500 distinguish name to distinguish name string<br/>
    +3015      * @name dnarraytostr
    +3016      * @memberOf X509#
    +3017      * @function
    +3018      * @param {Array} aDN array for X500 distinguish name
    +3019      * @return {String} distinguish name
    +3020      * @since jsrsasign 10.0.6 x509 2.0.8
    +3021      * @see X509#getX500Name
    +3022      * @see X509#getX500NameArray
    +3023      * @see KJUR.asn1.x509.X500Name
    +3024      *
    +3025      * @description
    +3026      * This method converts from an array representation of 
    +3027      * X.500 distinguished name to X.500 name string.
    +3028      * This supports multi-valued RDN.
    +3029      * 
    +3030      * @example
    +3031      * var x = new X509();
    +3032      * x.dnarraytostr(
    +3033      *   [[{type:"C",value:"JP",ds:"prn"}],
    +3034      *   [{type:"O",value:"T1",ds:"prn"}]]) → "/C=JP/O=T1"
    +3035      * x.dnarraytostr(
    +3036      *   [[{type:"C",value:"JP",ds:"prn"}],
    +3037      *   [{type:"O",value:"T1",ds:"prn"}
    +3038      *    {type:"CN",value:"Bob",ds:"prn"}]]) → "/C=JP/O=T1+CN=Bob"
    +3039      */
    +3040     this.dnarraytostr = function(aDN) {
    +3041 	function rdnarraytostr(aRDN) {
    +3042 	    return aRDN.map(function(x){return atvtostr(x).replace(/\+/,"\\+");}).join("+");
     3043 	};
    -3044 	var _getCRLDistributionPointsStr = function(params) {
    -3045 	    var s = "";
    -3046 	    var a = params.array;
    -3047 	    for (var i = 0; i < a.length; i++) {
    -3048 		var dp = a[i];
    -3049 		try {
    -3050 		    if (dp.dpname.full[0].uri !== undefined)
    -3051 			s += "    " + dp.dpname.full[0].uri + "\n";
    -3052 		} catch(ex) {};
    -3053 		try {
    -3054 		    if (dp.dname.full[0].dn.hex !== undefined)
    -3055 			s += "    " + X509.hex2dn(dp.dpname.full[0].dn.hex) + "\n";
    -3056 		} catch(ex) {};
    -3057 	    }
    -3058 	    return s;
    -3059 	}
    -3060 	var _getAuthorityInfoAccessStr = function(params) {
    -3061 	    var s = "";
    -3062 	    var a = params.array;
    -3063 	    for (var i = 0; i < a.length; i++) {
    -3064 		var ad = a[i];
    -3065 
    -3066 		if (ad.caissuer !== undefined)
    -3067 		    s += "    caissuer: " + ad.caissuer + "\n";
    -3068 		if (ad.ocsp !== undefined)
    -3069 		    s += "    ocsp: " + ad.ocsp + "\n";
    -3070 	    }
    -3071 	    return s;
    -3072 	};
    -3073 	var _X509 = X509;
    -3074 	var s, pubkey, aExt;
    -3075 	s  = "Basic Fields\n";
    -3076         s += "  serial number: " + this.getSerialNumberHex() + "\n";
    -3077 	s += "  signature algorithm: " + this.getSignatureAlgorithmField() + "\n";
    -3078 	s += "  issuer: " + this.getIssuerString() + "\n";
    -3079 	s += "  notBefore: " + this.getNotBefore() + "\n";
    -3080 	s += "  notAfter: " + this.getNotAfter() + "\n";
    -3081 	s += "  subject: " + this.getSubjectString() + "\n";
    -3082 	s += "  subject public key info: " + "\n";
    -3083 
    -3084 	// subject public key info
    -3085 	pubkey = this.getPublicKey();
    -3086 	s += "    key algorithm: " + pubkey.type + "\n";
    -3087 
    -3088 	if (pubkey.type === "RSA") {
    -3089 	    s += "    n=" + hextoposhex(pubkey.n.toString(16)).substr(0, 16) + "...\n";
    -3090 	    s += "    e=" + hextoposhex(pubkey.e.toString(16)) + "\n";
    -3091 	}
    -3092 
    -3093 	// X.509v3 Extensions
    -3094         aExt = this.aExtInfo;
    -3095 
    -3096 	if (aExt !== undefined && aExt !== null) {
    -3097             s += "X509v3 Extensions:\n";
    -3098 	    
    -3099             for (var i = 0; i < aExt.length; i++) {
    -3100 		var info = aExt[i];
    -3101 
    -3102 		// show extension name and critical flag
    -3103 		var extName = KJUR.asn1.x509.OID.oid2name(info["oid"]);
    -3104 		if (extName === '') extName = info["oid"];
    -3105 
    -3106 		var critical = '';
    -3107 		if (info["critical"] === true) critical = "CRITICAL";
    -3108 
    -3109 		s += "  " + extName + " " + critical + ":\n";
    -3110 
    -3111 		// show extension value if supported
    -3112 		if (extName === "basicConstraints") {
    -3113 		    var bc = this.getExtBasicConstraints();
    -3114 		    if (bc.cA === undefined) {
    -3115 			s += "    {}\n";
    -3116 		    } else {
    -3117 			s += "    cA=true";
    -3118 			if (bc.pathLen !== undefined)
    -3119 			    s += ", pathLen=" + bc.pathLen;
    -3120 			s += "\n";
    -3121 		    }
    -3122 		} else if (extName === "keyUsage") {
    -3123 		    s += "    " + this.getExtKeyUsageString() + "\n";
    -3124 		} else if (extName === "subjectKeyIdentifier") {
    -3125 		    s += "    " + this.getExtSubjectKeyIdentifier().kid.hex + "\n";
    -3126 		} else if (extName === "authorityKeyIdentifier") {
    -3127 		    var akid = this.getExtAuthorityKeyIdentifier();
    -3128 		    if (akid.kid !== undefined)
    -3129 			s += "    kid=" + akid.kid.hex + "\n";
    -3130 		} else if (extName === "extKeyUsage") {
    -3131 		    var eku = this.getExtExtKeyUsage().array;
    -3132 		    s += "    " + eku.join(", ") + "\n";
    -3133 		} else if (extName === "subjectAltName") {
    -3134 		    var san = _getSubjectAltNameStr(this.getExtSubjectAltName());
    -3135 		    s += "    " + san + "\n";
    -3136 		} else if (extName === "cRLDistributionPoints") {
    -3137 		    var cdp = this.getExtCRLDistributionPoints();
    -3138 		    s += _getCRLDistributionPointsStr(cdp);
    -3139 		} else if (extName === "authorityInfoAccess") {
    -3140 		    var aia = this.getExtAuthorityInfoAccess();
    -3141 		    s += _getAuthorityInfoAccessStr(aia);
    -3142 		} else if (extName === "certificatePolicies") {
    -3143 		    s += _getCertificatePoliciesStr(this.getExtCertificatePolicies());
    -3144 		}
    -3145 	    }
    -3146         }
    -3147 
    -3148 	s += "signature algorithm: " + this.getSignatureAlgorithmName() + "\n";
    -3149 	s += "signature: " + this.getSignatureValueHex().substr(0, 16) + "...\n";
    -3150 	return s;
    -3151     };
    -3152 
    -3153     if (typeof params == "string") {
    -3154 	if (params.indexOf("-----BEGIN") != -1) {
    -3155 	    this.readCertPEM(params);
    -3156 	} else if (KJUR.lang.String.isHex(params)) {
    -3157 	    this.readCertHex(params);
    -3158 	}
    -3159     }
    -3160 };
    -3161 // ----- END of X509 class -----
    -3162 
    -3163 /**
    -3164  * get distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER X.500 name<br/>
    -3165  * @name hex2dn
    -3166  * @memberOf X509
    -3167  * @function
    -3168  * @param {String} hex hexadecimal string of ASN.1 DER distinguished name
    -3169  * @param {Integer} idx index of hexadecimal string (DEFAULT=0)
    -3170  * @return {String} OpenSSL online format distinguished name
    -3171  * @description
    -3172  * This static method converts from a hexadecimal string of 
    -3173  * distinguished name (DN)
    -3174  * specified by 'hex' and 'idx' to OpenSSL oneline string representation (ex. /C=US/O=a).
    -3175  * @example
    -3176  * X509.hex2dn("3031310b3...") → /C=US/O=a/CN=b2+OU=b1
    -3177  */
    -3178 X509.hex2dn = function(hex, idx) {
    -3179     if (idx === undefined) idx = 0;
    -3180     var x = new X509();
    -3181     var hDN = ASN1HEX.getTLV(hex, idx);
    -3182     var pDN = x.getX500Name(hex);
    -3183     return pDN.str;
    -3184 };
    -3185 
    -3186 /**
    -3187  * get relative distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER RDN<br/>
    -3188  * @name hex2rdn
    -3189  * @memberOf X509
    -3190  * @function
    -3191  * @param {String} hex hexadecimal string of ASN.1 DER concludes relative distinguished name
    -3192  * @param {Integer} idx index of hexadecimal string (DEFAULT=0)
    -3193  * @return {String} OpenSSL online format relative distinguished name
    -3194  * @description
    -3195  * This static method converts from a hexadecimal string of 
    -3196  * relative distinguished name (RDN)
    -3197  * specified by 'hex' and 'idx' to LDAP string representation (ex. O=test+CN=test).<br/>
    -3198  * NOTE: Multi-valued RDN is supported since jsnrsasign 6.2.2 x509 1.1.10.
    -3199  * @example
    -3200  * X509.hex2rdn("310a3008060355040a0c0161") → O=a
    -3201  * X509.hex2rdn("31143008060355040a0c01613008060355040a0c0162") → O=a+O=b
    -3202  */
    -3203 X509.hex2rdn = function(hex, idx) {
    -3204     if (idx === undefined) idx = 0;
    -3205     if (hex.substr(idx, 2) !== "31") throw new Error("malformed RDN");
    -3206 
    -3207     var a = new Array();
    -3208 
    -3209     var aIdx = ASN1HEX.getChildIdx(hex, idx);
    -3210     for (var i = 0; i < aIdx.length; i++) {
    -3211 	a.push(X509.hex2attrTypeValue(hex, aIdx[i]));
    -3212     }
    -3213 
    -3214     a = a.map(function(s) { return s.replace("+", "\\+"); });
    -3215     return a.join("+");
    -3216 };
    -3217 
    -3218 /**
    -3219  * get string from hexadecimal string of ASN.1 DER AttributeTypeAndValue<br/>
    -3220  * @name hex2attrTypeValue
    -3221  * @memberOf X509
    -3222  * @function
    -3223  * @param {String} hex hexadecimal string of ASN.1 DER concludes AttributeTypeAndValue
    -3224  * @param {Integer} idx index of hexadecimal string (DEFAULT=0)
    -3225  * @return {String} string representation of AttributeTypeAndValue (ex. C=US)
    -3226  * @description
    -3227  * This static method converts from a hexadecimal string of AttributeTypeAndValue
    -3228  * specified by 'hex' and 'idx' to LDAP string representation (ex. C=US).
    -3229  * @example
    -3230  * X509.hex2attrTypeValue("3008060355040a0c0161") → O=a
    -3231  * X509.hex2attrTypeValue("300806035504060c0161") → C=a
    -3232  * X509.hex2attrTypeValue("...3008060355040a0c0161...", 128) → O=a
    -3233  */
    -3234 X509.hex2attrTypeValue = function(hex, idx) {
    -3235     var _ASN1HEX = ASN1HEX;
    -3236     var _getV = _ASN1HEX.getV;
    -3237 
    -3238     if (idx === undefined) idx = 0;
    -3239     if (hex.substr(idx, 2) !== "30") 
    -3240 	throw new Error("malformed attribute type and value");
    -3241 
    -3242     var aIdx = _ASN1HEX.getChildIdx(hex, idx);
    -3243     if (aIdx.length !== 2 || hex.substr(aIdx[0], 2) !== "06")
    -3244 	"malformed attribute type and value";
    -3245 
    -3246     var oidHex = _getV(hex, aIdx[0]);
    -3247     var oidInt = KJUR.asn1.ASN1Util.oidHexToInt(oidHex);
    -3248     var atype = KJUR.asn1.x509.OID.oid2atype(oidInt);
    -3249 
    -3250     var hV = _getV(hex, aIdx[1]);
    -3251     var rawV = hextorstr(hV);
    -3252 
    -3253     return atype + "=" + rawV;
    -3254 };
    -3255 
    -3256 /**
    -3257  * get RSA/DSA/ECDSA public key object from X.509 certificate hexadecimal string<br/>
    -3258  * @name getPublicKeyFromCertHex
    -3259  * @memberOf X509
    -3260  * @function
    -3261  * @param {String} h hexadecimal string of X.509 certificate for RSA/ECDSA/DSA public key
    -3262  * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key
    -3263  * @since jsrasign 7.1.0 x509 1.1.11
    -3264  */
    -3265 X509.getPublicKeyFromCertHex = function(h) {
    -3266     var x = new X509();
    -3267     x.readCertHex(h);
    -3268     return x.getPublicKey();
    -3269 };
    -3270 
    -3271 /**
    -3272  * get RSA/DSA/ECDSA public key object from PEM certificate string
    -3273  * @name getPublicKeyFromCertPEM
    -3274  * @memberOf X509
    -3275  * @function
    -3276  * @param {String} sCertPEM PEM formatted RSA/ECDSA/DSA X.509 certificate
    -3277  * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key
    -3278  * @since x509 1.1.1
    -3279  * @description
    -3280  * NOTE: DSA is also supported since x509 1.1.2.
    -3281  */
    -3282 X509.getPublicKeyFromCertPEM = function(sCertPEM) {
    -3283     var x = new X509();
    -3284     x.readCertPEM(sCertPEM);
    -3285     return x.getPublicKey();
    -3286 };
    -3287 
    -3288 /**
    -3289  * get public key information from PEM certificate
    -3290  * @name getPublicKeyInfoPropOfCertPEM
    -3291  * @memberOf X509
    -3292  * @function
    -3293  * @param {String} sCertPEM string of PEM formatted certificate
    -3294  * @return {Hash} hash of information for public key
    -3295  * @since x509 1.1.1
    -3296  * @description
    -3297  * Resulted associative array has following properties:<br/>
    -3298  * <ul>
    -3299  * <li>algoid - hexadecimal string of OID of asymmetric key algorithm</li>
    -3300  * <li>algparam - hexadecimal string of OID of ECC curve name or null</li>
    -3301  * <li>keyhex - hexadecimal string of key in the certificate</li>
    -3302  * </ul>
    -3303  * NOTE: X509v1 certificate is also supported since x509.js 1.1.9.
    -3304  */
    -3305 X509.getPublicKeyInfoPropOfCertPEM = function(sCertPEM) {
    -3306     var _ASN1HEX = ASN1HEX;
    -3307     var _getVbyList = _ASN1HEX.getVbyList;
    -3308 
    -3309     var result = {};
    -3310     var x, hSPKI, pubkey;
    -3311     result.algparam = null;
    -3312 
    -3313     x = new X509();
    -3314     x.readCertPEM(sCertPEM);
    -3315 
    -3316     hSPKI = x.getPublicKeyHex();
    -3317     result.keyhex = _getVbyList(hSPKI, 0, [1], "03").substr(2);
    -3318     result.algoid = _getVbyList(hSPKI, 0, [0, 0], "06");
    -3319 
    -3320     if (result.algoid === "2a8648ce3d0201") { // ecPublicKey
    -3321 	result.algparam = _getVbyList(hSPKI, 0, [0, 1], "06");
    -3322     };
    -3323 
    -3324     return result;
    -3325 };
    -3326 
    -3327 /* ======================================================================
    -3328  *   Specific V3 Extensions
    -3329  * ====================================================================== */
    -3330 
    -3331 X509.KEYUSAGE_NAME = [
    -3332     "digitalSignature",
    -3333     "nonRepudiation",
    -3334     "keyEncipherment",
    -3335     "dataEncipherment",
    -3336     "keyAgreement",
    -3337     "keyCertSign",
    -3338     "cRLSign",
    -3339     "encipherOnly",
    -3340     "decipherOnly"
    -3341 ];
    -3342 
    \ No newline at end of file +3044 +3045
    function atvtostr(pATV) { +3046 return pATV.type + "=" + pATV.value; +3047 }; +3048 +3049 return "/" + aDN.map(function(x){return rdnarraytostr(x).replace(/\//, "\\/");}).join("/"); +3050 }; +3051 +3052 /** +3053 * set canonicalized DN to a DN parameter<br/> +3054 * @name setCanonicalizedDN +3055 * @memberOf X509# +3056 * @function +3057 * @param {object} pDN DN parameter associative array +3058 * @since jsrsasign 10.6.0 x509 2.1.0 +3059 * +3060 * @description +3061 * This method canonicalizes a DN string as following: +3062 * <ul> +3063 * <li>convert to lower case</li> +3064 * <li>convert from all multiple spaces to a space</li> +3065 * </ul> +3066 * +3067 * @example +3068 * var x = new X509(); +3069 * var pDN = { +3070 * array: [ +3071 * [{type:'C',value:'JP',ds:'prn'}], +3072 * [{type:'O',value:'Test 1',ds:'prn'}] ], +3073 * str: "/C=JP/O=Test 1" }; +3074 * x.setCanonicalizedDN(pDN); +3075 +3076 * // pDN will become following +3077 * pDN = { +3078 * array: [ +3079 * [{type:'C',value:'JP',ds:'prn'}], +3080 * [{type:'O',value:'Test 1',ds:'prn'}] ], +3081 * str: "/C=JP/O=Test 1", +3082 * canon: "/c=jp/o=test 1" }; +3083 */ +3084 this.setCanonicalizedDN = function(pDN) { +3085 var aRDN; +3086 if (pDN.str != undefined && pDN.array == undefined) { +3087 var dDN = new KJUR.asn1.x509.X500Name({str: pDN.str}); +3088 var hDN = dDN.tohex(); +3089 aRDN = this.getX500NameArray(hDN); +3090 } else { +3091 aRDN = pDN.array; +3092 } +3093 if (pDN.canon == undefined) { +3094 pDN.canon = this.c14nRDNArray(aRDN); +3095 } +3096 }; +3097 +3098 /** +3099 * simple canonicalization(c14n) for RDN array<br/> +3100 * @name c14nRDNArray +3101 * @memberOf X509# +3102 * @function +3103 * @param {array} aRDN array of RDN parameters +3104 * @return {string} canonicalized distinguish name (ex. "/c=jp/o=test ca") +3105 * @since jsrsasign 10.6.0 x509 2.1.0 +3106 * +3107 * @description +3108 * This method canonicalizes a DN string according to +3109 * <a href="https://datatracker.ietf.org/doc/html/rfc4518#appendix-B"> +3110 * "RFC 4518 StringPrep Appendix B Substring Matching"</a> as following: +3111 * <ul> +3112 * <li>convert to lower case</li> +3113 * <li>convert from all sequence of spaces to a space</li> +3114 * <li>remove leading and trailing spaces</li> +3115 * </ul> +3116 * +3117 * @example +3118 * var x = new X509(); +3119 * x.c14nRDNArray([ +3120 * [{type:"C", value:"JP", ds: "prn"}], +3121 * [{type:"O", value:" Test 1234 ", ds: "utf8"}], +3122 * [{type:"OU", value:"HR 45", ds: "utf8"}] +3123 * ]) → "/c=jp/o=test 1234/ou=hr 45" +3124 */ +3125 this.c14nRDNArray = function(aRDN) { +3126 var a = []; +3127 for (var i = 0; i < aRDN.length; i++) { +3128 var aAVA = aRDN[i]; +3129 var a2 = []; +3130 for (var j = 0; j < aAVA.length; j++) { +3131 var pAVA = aAVA[j]; +3132 var value = pAVA.value; +3133 value = value.replace(/^\s*/, ''); +3134 value = value.replace(/\s*$/, ''); +3135 value = value.replace(/\s+/g, ' '); +3136 value = value.toLowerCase(); +3137 a2.push(pAVA.type.toLowerCase() + "=" + value); +3138 } +3139 a.push(a2.join("+")); +3140 } +3141 return "/" + a.join("/"); +3142 }; +3143 +3144 /** +3145 * get certificate information as string.<br/> +3146 * @name getInfo +3147 * @memberOf X509# +3148 * @function +3149 * @return {String} certificate information string +3150 * @since jsrsasign 5.0.10 x509 1.1.8 +3151 * @example +3152 * x = new X509(); +3153 * x.readCertPEM(certPEM); +3154 * console.log(x.getInfo()); +3155 * // this shows as following +3156 * Basic Fields +3157 * serial number: 02ac5c266a0b409b8f0b79f2ae462577 +3158 * signature algorithm: SHA1withRSA +3159 * issuer: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA +3160 * notBefore: 061110000000Z +3161 * notAfter: 311110000000Z +3162 * subject: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA +3163 * subject public key info: +3164 * key algorithm: RSA +3165 * n=c6cce573e6fbd4bb... +3166 * e=10001 +3167 * X509v3 Extensions: +3168 * keyUsage CRITICAL: +3169 * digitalSignature,keyCertSign,cRLSign +3170 * basicConstraints CRITICAL: +3171 * cA=true +3172 * subjectKeyIdentifier : +3173 * b13ec36903f8bf4701d498261a0802ef63642bc3 +3174 * authorityKeyIdentifier : +3175 * kid=b13ec36903f8bf4701d498261a0802ef63642bc3 +3176 * signature algorithm: SHA1withRSA +3177 * signature: 1c1a0697dcd79c9f... +3178 */ +3179 this.getInfo = function() { +3180 var _getSubjectAltNameStr = function(params) { +3181 var s = ""; +3182 var indent = " "; +3183 var NL = "\n"; +3184 var a = params.array; +3185 for (var i = 0; i < a.length; i++) { +3186 var pGN = a[i]; +3187 if (pGN.dn != undefined) s += indent + "dn: " + pGN.dn.str + NL; +3188 if (pGN.ip != undefined) s += indent + "ip: " + pGN.ip + NL; +3189 if (pGN.rfc822 != undefined) s += indent + "rfc822: " + pGN.rfc822 + NL; +3190 if (pGN.dns != undefined) s += indent + "dns: " + pGN.dns + NL; +3191 if (pGN.uri != undefined) s += indent + "uri: " + pGN.uri + NL; +3192 if (pGN.other != undefined) { +3193 var oidname = pGN.other.oid; +3194 var value = JSON.stringify(pGN.other.value).replace(/\"/g, ''); +3195 s += indent + "other: " + oidname + "=" + value + NL; +3196 } +3197 } +3198 s = s.replace(/\n$/, ''); +3199 return s; +3200 }; +3201 var _getCertificatePoliciesStr = function(params) { +3202 var s = ""; +3203 var a = params.array; +3204 for (var i = 0; i < a.length; i++) { +3205 var pi = a[i]; +3206 s += " policy oid: " + pi.policyoid + "\n"; +3207 if (pi.array === undefined) continue; +3208 for (var j = 0; j < pi.array.length; j++) { +3209 var pqi = pi.array[j]; +3210 if (pqi.cps !== undefined) { +3211 s += " cps: " + pqi.cps + "\n"; +3212 } +3213 } +3214 } +3215 return s; +3216 }; +3217 var _getCRLDistributionPointsStr = function(params) { +3218 var s = ""; +3219 var a = params.array; +3220 for (var i = 0; i < a.length; i++) { +3221 var dp = a[i]; +3222 try { +3223 if (dp.dpname.full[0].uri !== undefined) +3224 s += " " + dp.dpname.full[0].uri + "\n"; +3225 } catch(ex) {}; +3226 try { +3227 if (dp.dname.full[0].dn.hex !== undefined) +3228 s += " " + X509.hex2dn(dp.dpname.full[0].dn.hex) + "\n"; +3229 } catch(ex) {}; +3230 } +3231 return s; +3232 } +3233 var _getAuthorityInfoAccessStr = function(params) { +3234 var s = ""; +3235 var a = params.array; +3236 for (var i = 0; i < a.length; i++) { +3237 var ad = a[i]; +3238 +3239 if (ad.caissuer !== undefined) +3240 s += " caissuer: " + ad.caissuer + "\n"; +3241 if (ad.ocsp !== undefined) +3242 s += " ocsp: " + ad.ocsp + "\n"; +3243 } +3244 return s; +3245 }; +3246 var _X509 = X509; +3247 var s, pubkey, aExt; +3248 s = "Basic Fields\n"; +3249 s += " serial number: " + this.getSerialNumberHex() + "\n"; +3250 s += " signature algorithm: " + this.getSignatureAlgorithmField() + "\n"; +3251 s += " issuer: " + this.getIssuerString() + "\n"; +3252 s += " notBefore: " + this.getNotBefore() + "\n"; +3253 s += " notAfter: " + this.getNotAfter() + "\n"; +3254 s += " subject: " + this.getSubjectString() + "\n"; +3255 s += " subject public key info: " + "\n"; +3256 +3257 // subject public key info +3258 pubkey = this.getPublicKey(); +3259 s += " key algorithm: " + pubkey.type + "\n"; +3260 +3261 if (pubkey.type === "RSA") { +3262 s += " n=" + hextoposhex(pubkey.n.toString(16)).substr(0, 16) + "...\n"; +3263 s += " e=" + hextoposhex(pubkey.e.toString(16)) + "\n"; +3264 } +3265 +3266 // X.509v3 Extensions +3267 aExt = this.aExtInfo; +3268 +3269 if (aExt !== undefined && aExt !== null) { +3270 s += "X509v3 Extensions:\n"; +3271 +3272 for (var i = 0; i < aExt.length; i++) { +3273 var info = aExt[i]; +3274 +3275 // show extension name and critical flag +3276 var extName = KJUR.asn1.x509.OID.oid2name(info["oid"]); +3277 if (extName === '') extName = info["oid"]; +3278 +3279 var critical = ''; +3280 if (info["critical"] === true) critical = "CRITICAL"; +3281 +3282 s += " " + extName + " " + critical + ":\n"; +3283 +3284 // show extension value if supported +3285 if (extName === "basicConstraints") { +3286 var bc = this.getExtBasicConstraints(); +3287 if (bc.cA === undefined) { +3288 s += " {}\n"; +3289 } else { +3290 s += " cA=true"; +3291 if (bc.pathLen !== undefined) +3292 s += ", pathLen=" + bc.pathLen; +3293 s += "\n"; +3294 } +3295 } else if (extName === "keyUsage") { +3296 s += " " + this.getExtKeyUsageString() + "\n"; +3297 } else if (extName === "subjectKeyIdentifier") { +3298 s += " " + this.getExtSubjectKeyIdentifier().kid.hex + "\n"; +3299 } else if (extName === "authorityKeyIdentifier") { +3300 var akid = this.getExtAuthorityKeyIdentifier(); +3301 if (akid.kid !== undefined) +3302 s += " kid=" + akid.kid.hex + "\n"; +3303 } else if (extName === "extKeyUsage") { +3304 var eku = this.getExtExtKeyUsage().array; +3305 s += " " + eku.join(", ") + "\n"; +3306 } else if (extName === "subjectAltName") { +3307 var san = _getSubjectAltNameStr(this.getExtSubjectAltName()); +3308 s += san + "\n"; +3309 } else if (extName === "cRLDistributionPoints") { +3310 var cdp = this.getExtCRLDistributionPoints(); +3311 s += _getCRLDistributionPointsStr(cdp); +3312 } else if (extName === "authorityInfoAccess") { +3313 var aia = this.getExtAuthorityInfoAccess(); +3314 s += _getAuthorityInfoAccessStr(aia); +3315 } else if (extName === "certificatePolicies") { +3316 s += _getCertificatePoliciesStr(this.getExtCertificatePolicies()); +3317 } +3318 } +3319 } +3320 +3321 s += "signature algorithm: " + this.getSignatureAlgorithmName() + "\n"; +3322 s += "signature: " + this.getSignatureValueHex().substr(0, 16) + "...\n"; +3323 return s; +3324 }; +3325 +3326 if (typeof params == "string") { +3327 if (params.indexOf("-----BEGIN") != -1) { +3328 this.readCertPEM(params); +3329 } else if (KJUR.lang.String.isHex(params)) { +3330 this.readCertHex(params); +3331 } +3332 } +3333 }; +3334 // ----- END of X509 class ----- +3335 +3336 /** +3337 * get distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER X.500 name<br/> +3338 * @name hex2dn +3339 * @memberOf X509 +3340 * @function +3341 * @param {String} hex hexadecimal string of ASN.1 DER distinguished name +3342 * @param {Integer} idx index of hexadecimal string (DEFAULT=0) +3343 * @return {String} OpenSSL online format distinguished name +3344 * @description +3345 * This static method converts from a hexadecimal string of +3346 * distinguished name (DN) +3347 * specified by 'hex' and 'idx' to OpenSSL oneline string representation (ex. /C=US/O=a). +3348 * @example +3349 * X509.hex2dn("3031310b3...") → /C=US/O=a/CN=b2+OU=b1 +3350 */ +3351 X509.hex2dn = function(hex, idx) { +3352 if (idx === undefined) idx = 0; +3353 var x = new X509(); +3354 var hDN = ASN1HEX.getTLV(hex, idx); +3355 var pDN = x.getX500Name(hex); +3356 return pDN.str; +3357 }; +3358 +3359 /** +3360 * get relative distinguished name string in OpenSSL online format from hexadecimal string of ASN.1 DER RDN<br/> +3361 * @name hex2rdn +3362 * @memberOf X509 +3363 * @function +3364 * @param {String} hex hexadecimal string of ASN.1 DER concludes relative distinguished name +3365 * @param {Integer} idx index of hexadecimal string (DEFAULT=0) +3366 * @return {String} OpenSSL online format relative distinguished name +3367 * @description +3368 * This static method converts from a hexadecimal string of +3369 * relative distinguished name (RDN) +3370 * specified by 'hex' and 'idx' to LDAP string representation (ex. O=test+CN=test).<br/> +3371 * NOTE: Multi-valued RDN is supported since jsnrsasign 6.2.2 x509 1.1.10. +3372 * @example +3373 * X509.hex2rdn("310a3008060355040a0c0161") → O=a +3374 * X509.hex2rdn("31143008060355040a0c01613008060355040a0c0162") → O=a+O=b +3375 */ +3376 X509.hex2rdn = function(hex, idx) { +3377 if (idx === undefined) idx = 0; +3378 if (hex.substr(idx, 2) !== "31") throw new Error("malformed RDN"); +3379 +3380 var a = new Array(); +3381 +3382 var aIdx = ASN1HEX.getChildIdx(hex, idx); +3383 for (var i = 0; i < aIdx.length; i++) { +3384 a.push(X509.hex2attrTypeValue(hex, aIdx[i])); +3385 } +3386 +3387 a = a.map(function(s) { return s.replace("+", "\\+"); }); +3388 return a.join("+"); +3389 }; +3390 +3391 /** +3392 * get string from hexadecimal string of ASN.1 DER AttributeTypeAndValue<br/> +3393 * @name hex2attrTypeValue +3394 * @memberOf X509 +3395 * @function +3396 * @param {String} hex hexadecimal string of ASN.1 DER concludes AttributeTypeAndValue +3397 * @param {Integer} idx index of hexadecimal string (DEFAULT=0) +3398 * @return {String} string representation of AttributeTypeAndValue (ex. C=US) +3399 * @description +3400 * This static method converts from a hexadecimal string of AttributeTypeAndValue +3401 * specified by 'hex' and 'idx' to LDAP string representation (ex. C=US). +3402 * @example +3403 * X509.hex2attrTypeValue("3008060355040a0c0161") → O=a +3404 * X509.hex2attrTypeValue("300806035504060c0161") → C=a +3405 * X509.hex2attrTypeValue("...3008060355040a0c0161...", 128) → O=a +3406 */ +3407 X509.hex2attrTypeValue = function(hex, idx) { +3408 var _ASN1HEX = ASN1HEX; +3409 var _getV = _ASN1HEX.getV; +3410 +3411 if (idx === undefined) idx = 0; +3412 if (hex.substr(idx, 2) !== "30") +3413 throw new Error("malformed attribute type and value"); +3414 +3415 var aIdx = _ASN1HEX.getChildIdx(hex, idx); +3416 if (aIdx.length !== 2 || hex.substr(aIdx[0], 2) !== "06") +3417 "malformed attribute type and value"; +3418 +3419 var oidHex = _getV(hex, aIdx[0]); +3420 var oidInt = KJUR.asn1.ASN1Util.oidHexToInt(oidHex); +3421 var atype = KJUR.asn1.x509.OID.oid2atype(oidInt); +3422 +3423 var hV = _getV(hex, aIdx[1]); +3424 var rawV = hextorstr(hV); +3425 +3426 return atype + "=" + rawV; +3427 }; +3428 +3429 /** +3430 * get RSA/DSA/ECDSA public key object from X.509 certificate hexadecimal string<br/> +3431 * @name getPublicKeyFromCertHex +3432 * @memberOf X509 +3433 * @function +3434 * @param {String} h hexadecimal string of X.509 certificate for RSA/ECDSA/DSA public key +3435 * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key +3436 * @since jsrasign 7.1.0 x509 1.1.11 +3437 */ +3438 X509.getPublicKeyFromCertHex = function(h) { +3439 var x = new X509(); +3440 x.readCertHex(h); +3441 return x.getPublicKey(); +3442 }; +3443 +3444 /** +3445 * get RSA/DSA/ECDSA public key object from PEM certificate string +3446 * @name getPublicKeyFromCertPEM +3447 * @memberOf X509 +3448 * @function +3449 * @param {String} sCertPEM PEM formatted RSA/ECDSA/DSA X.509 certificate +3450 * @return returns RSAKey/KJUR.crypto.{ECDSA,DSA} object of public key +3451 * @since x509 1.1.1 +3452 * @description +3453 * NOTE: DSA is also supported since x509 1.1.2. +3454 */ +3455 X509.getPublicKeyFromCertPEM = function(sCertPEM) { +3456 var x = new X509(); +3457 x.readCertPEM(sCertPEM); +3458 return x.getPublicKey(); +3459 }; +3460 +3461 /** +3462 * get public key information from PEM certificate +3463 * @name getPublicKeyInfoPropOfCertPEM +3464 * @memberOf X509 +3465 * @function +3466 * @param {String} sCertPEM string of PEM formatted certificate +3467 * @return {Hash} hash of information for public key +3468 * @since x509 1.1.1 +3469 * @description +3470 * Resulted associative array has following properties:<br/> +3471 * <ul> +3472 * <li>algoid - hexadecimal string of OID of asymmetric key algorithm</li> +3473 * <li>algparam - hexadecimal string of OID of ECC curve name or null</li> +3474 * <li>keyhex - hexadecimal string of key in the certificate</li> +3475 * </ul> +3476 * NOTE: X509v1 certificate is also supported since x509.js 1.1.9. +3477 */ +3478 X509.getPublicKeyInfoPropOfCertPEM = function(sCertPEM) { +3479 var _ASN1HEX = ASN1HEX; +3480 var _getVbyList = _ASN1HEX.getVbyList; +3481 +3482 var result = {}; +3483 var x, hSPKI, pubkey; +3484 result.algparam = null; +3485 +3486 x = new X509(); +3487 x.readCertPEM(sCertPEM); +3488 +3489 hSPKI = x.getPublicKeyHex(); +3490 result.keyhex = _getVbyList(hSPKI, 0, [1], "03").substr(2); +3491 result.algoid = _getVbyList(hSPKI, 0, [0, 0], "06"); +3492 +3493 if (result.algoid === "2a8648ce3d0201") { // ecPublicKey +3494 result.algparam = _getVbyList(hSPKI, 0, [0, 1], "06"); +3495 }; +3496 +3497 return result; +3498 }; +3499 +3500 /* ====================================================================== +3501 * Specific V3 Extensions +3502 * ====================================================================== */ +3503 +3504 X509.KEYUSAGE_NAME = [ +3505 "digitalSignature", +3506 "nonRepudiation", +3507 "keyEncipherment", +3508 "dataEncipherment", +3509 "keyAgreement", +3510 "keyCertSign", +3511 "cRLSign", +3512 "encipherOnly", +3513 "decipherOnly" +3514 ]; +3515
    \ No newline at end of file diff --git a/bower.json b/bower.json index 08132934..6499ff09 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "kjur-jsrsasign", - "version": "10.5.27", + "version": "10.6.0", "main": "jsrsasign-all-min.js", "description": "The 'jsrsasign' (RSA-Sign JavaScript Library) is an opensource free cryptography library supporting RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp, CAdES, JWS and JWT in pure JavaScript.", "license": "MIT", diff --git a/jsrsasign-all-min.js b/jsrsasign-all-min.js index 004b6276..28e4e525 100644 --- a/jsrsasign-all-min.js +++ b/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -219,7 +219,7 @@ ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBi var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)";var j='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:"'+j+'*")';var d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+i+")","g");var k=new RegExp("\\\\(?:([^u])|u(.{4}))","g");var g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String("");var a="\\";var f={"{":Object,"[":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if("{"===v){x={}}else{if("["===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=u*2){break}}var z={};z.keyhex=x.substr(0,i[q]["keylen"]*2);z.ivhex=x.substr(i[q]["keylen"]*2,i[q]["ivlen"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v]["proc"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s]["eproc"];var t=r(p,q,u);return t};return{version:"1.0.0",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p="";if(typeof t=="undefined"||t==null){t="AES-256-CBC"}if(typeof i[t]=="undefined"){throw new Error("KEYUTIL unsupported algorithm: "+t)}if(typeof r=="undefined"||r==null){var v=i[t]["ivlen"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,"$1\r\n");var p="-----BEGIN "+x+" PRIVATE KEY-----\r\n";p+="Proc-Type: 4,ENCRYPTED\r\n";p+="DEK-Info: "+t+","+r+"\r\n";p+="\r\n";p+=q;p+="\r\n-----END "+x+" PRIVATE KEY-----\r\n";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw new Error("malformed format: SEQUENCE(0).items != 2: "+r.length)}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+A.length)}if(w(y,A[0])!="2a864886f70d01050d"){throw new Error("this only supports pkcs5PBES2")}var p=z(y,A[1]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+p.length)}var q=z(y,p[1]);if(q.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+q.length)}if(w(y,q[0])!="2a864886f70d0307"){throw"this only supports TripleDES"}t.encryptionSchemeAlg="TripleDES";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+s.length)}if(w(y,s[0])!="2a864886f70d01050c"){throw new Error("this only supports pkcs5PBKDF2")}var x=z(y,s[1]);if(x.length<2){throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+x.length)}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw new Error("malformed format pbkdf2Iter: "+u)}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,"ENCRYPTED PRIVATE KEY");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!="30"){throw new Error("malformed plain PKCS8 private key(code:001)")}var r=u(s,0);if(r.length<3){throw new Error("malformed plain PKCS8 private key(code:002)")}if(s.substr(r[1],2)!="30"){throw new Error("malformed PKCS8 private key(code:003)")}var p=u(s,r[1]);if(p.length!=2){throw new Error("malformed PKCS8 private key(code:004)")}if(s.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 private key(code:005)")}q.algoid=t(s,p[0]);if(s.substr(p[1],2)=="06"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!="04"){throw new Error("malformed PKCS8 private key(code:006)")}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,"PRIVATE KEY");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid=="2a864886f70d010101"){r=new RSAKey()}else{if(q.algoid=="2a8648ce380401"){r=new KJUR.crypto.DSA()}else{if(q.algoid=="2a8648ce3d0201"){r=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported private key algorithm")}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],"06");if(r==="2a864886f70d010101"){p=new RSAKey()}else{if(r==="2a8648ce380401"){p=new KJUR.crypto.DSA()}else{if(r==="2a8648ce3d0201"){p=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported PKCS#8 public key hex")}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!="30"){throw new Error("malformed RSA key(code:001)")}var q=t(r,0);if(q.length!=2){throw new Error("malformed RSA key(code:002)")}if(r.substr(q[0],2)!="02"){throw new Error("malformed RSA key(code:003)")}p.n=s(r,q[0]);if(r.substr(q[1],2)!="02"){throw new Error("malformed RSA key(code:004)")}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw new Error("outer DERSequence shall have 2 elements: "+r.length)}var w=r[0];if(t.substr(w,2)!="30"){throw new Error("malformed PKCS8 public key(code:001)")}var p=u(t,w);if(p.length!=2){throw new Error("malformed PKCS8 public key(code:002)")}if(t.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 public key(code:003)")}q.algoid=s(t,p[0]);if(t.substr(p[1],2)=="06"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)=="30"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],"02");q.algparam.q=v.getVbyList(t,p[1],[1],"02");q.algparam.g=v.getVbyList(t,p[1],[2],"02")}}if(t.substr(r[1],2)!="03"){throw new Error("malformed PKCS8 public key(code:004)")}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!="undefined"&&l instanceof w){return l}if(typeof i!="undefined"&&l instanceof i){return l}if(typeof C!="undefined"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;j.setPublicKeyHex(u);return j}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;var b=("0000000000"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n==="pkcs5prv"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)==="04"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw new Error("unsupported PKCS#1/5 hexadecimal key")}}}return P}if(n==="pkcs8prv"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n==="pkcs8pub"){return F._getKeyFromPublicPKCS8Hex(l)}if(n==="x509pub"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf("-END CERTIFICATE-",0)!=-1||l.indexOf("-END X509 CERTIFICATE-",0)!=-1||l.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf("-END PUBLIC KEY-")!=-1){var O=pemtohex(l,"PUBLIC KEY");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"RSA PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var I=M(l,"DSA PRIVATE KEY");var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"EC PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END PRIVATE KEY-")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],"04");var f=d(I,0,[2,0],"06");var A=d(I,0,[3,0],"03").substr(2);var e="";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+f)}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw new Error("not supported argument")};KEYUTIL.generateKeypair=function(a,c){if(a=="RSA"){var b=c;var h=new RSAKey();h.generate(b,"10001");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a=="EC"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw new Error("unknown algorithm: "+a)}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var H=l({seq:[{"int":0},{"int":{bigint:s.n}},{"int":s.e},{"int":{bigint:s.d}},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.dmp1}},{"int":{bigint:s.dmq1}},{"int":{bigint:s.coeff}}]});return H}function B(H){var s=l({seq:[{"int":1},{octstr:{hex:H.prvKeyHex}},{tag:["a0",true,{oid:{name:H.curveName}}]},{tag:["a1",true,{bitstr:{hex:"00"+H.pubKeyHex}}]}]});return s}function x(s){var H=l({seq:[{"int":0},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.g}},{"int":{bigint:s.y}},{"int":{bigint:s.x}}]});return H}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D=="PKCS8PUB")){var E=new C(b);var w=E.tohex();return hextopem(w,"PUBLIC KEY")}if(D=="PKCS1PRV"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();return hextopem(w,"RSA PRIVATE KEY")}if(D=="PKCS1PRV"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.tohex();var h=B(b);var t=h.tohex();var p="";p+=hextopem(v,"EC PARAMETERS");p+=hextopem(t,"EC PRIVATE KEY");return p}if(D=="PKCS1PRV"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();return hextopem(w,"DSA PRIVATE KEY")}if(D=="PKCS5PRV"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,y,m,j)}if(D=="PKCS5PRV"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,y,m,j)}if(D=="PKCS5PRV"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,y,m,j)}var o=function(H,s){var J=c(H,s);var I=new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:J.pbkdf2Salt}},{"int":J.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:J.encryptionSchemeIV}}]}]}]},{octstr:{hex:J.ciphertext}}]});return I.tohex()};var c=function(O,P){var I=100;var N=CryptoJS.lib.WordArray.random(8);var M="DES-EDE3-CBC";var s=CryptoJS.lib.WordArray.random(8);var J=CryptoJS.PBKDF2(P,N,{keySize:192/32,iterations:I});var K=CryptoJS.enc.Hex.parse(O);var L=CryptoJS.TripleDES.encrypt(K,J,{iv:s})+"";var H={};H.ciphertext=L;H.pbkdf2Salt=CryptoJS.enc.Hex.stringify(N);H.pbkdf2Iter=I;H.encryptionSchemeAlg=M;H.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return H};if(D=="PKCS8PRV"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"rsaEncryption"}},{"null":true}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var G={seq:[{"int":1},{octstr:{hex:b.prvKeyHex}}]};if(typeof b.pubKeyHex=="string"){G.seq.push({tag:["a1",true,{bitstr:{hex:"00"+b.pubKeyHex}}]})}var g=new l(G);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"dsa"}},{seq:[{"int":{bigint:b.p}},{"int":{bigint:b.q}},{"int":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}throw new Error("unsupported object nor format")};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,"CERTIFICATE REQUEST");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,"pkcs8pub");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!="30"){throw new Error("malformed CSR(code:001)")}var e=f(g,0);if(e.length<1){throw new Error("malformed CSR(code:002)")}if(g.substr(e[0],2)!="30"){throw new Error("malformed CSR(code:003)")}var a=f(g,e[0]);if(a.length<3){throw new Error("malformed CSR(code:004)")}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getKeyID=function(f){var c=KEYUTIL;var e=ASN1HEX;if(typeof f==="string"&&f.indexOf("BEGIN ")!=-1){f=c.getKey(f)}var d=pemtohex(c.getPEM(f));var b=e.getIdxbyList(d,0,[1]);var a=e.getV(d,b).substring(2);return KJUR.crypto.Util.hashHex(a,"sha1")};KEYUTIL.getJWK=function(d,h,g,b,f){var i;var k={};var e;var c=KJUR.crypto.Util.hashHex;if(typeof d=="string"){i=KEYUTIL.getKey(d);if(d.indexOf("CERTIFICATE")!=-1){e=pemtohex(d)}}else{if(typeof d=="object"){if(d instanceof X509){i=d.getPublicKey();e=d.hex}else{i=d}}else{throw new Error("unsupported keyinfo type")}}if(i instanceof RSAKey&&i.isPrivate){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16));k.d=hextob64u(i.d.toString(16));k.p=hextob64u(i.p.toString(16));k.q=hextob64u(i.q.toString(16));k.dp=hextob64u(i.dmp1.toString(16));k.dq=hextob64u(i.dmq1.toString(16));k.qi=hextob64u(i.coeff.toString(16))}else{if(i instanceof RSAKey&&i.isPublic){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16))}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPrivate){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y);k.d=hextob64u(i.prvKeyHex)}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPublic){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y)}}}}if(k.kty==undefined){throw new Error("unsupported keyinfo")}if((!i.isPrivate)&&h!=true){k.kid=KJUR.jws.JWS.getJWKthumbprint(k)}if(e!=undefined&&g!=true){k.x5c=[hex2b64(e)]}if(e!=undefined&&b!=true){k.x5t=b64tob64u(hex2b64(c(e,"sha1")))}if(e!=undefined&&f!=true){k["x5t#S256"]=b64tob64u(hex2b64(c(e,"sha256")))}return k};KEYUTIL.getJWKFromKey=function(a){return KEYUTIL.getJWK(a,true,true,true,true)}; RSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,i,k,b,a,f,d,j;var m=ASN1HEX;var l=m.getVbyListEx;if(m.isASN1HEX(e)===false){throw new Error("not ASN.1 hex string")}try{c=l(e,0,[2,0,1],"02");i=l(e,0,[2,0,2],"02");k=l(e,0,[2,0,3],"02");b=l(e,0,[2,0,4],"02");a=l(e,0,[2,0,5],"02");f=l(e,0,[2,0,6],"02");d=l(e,0,[2,0,7],"02");j=l(e,0,[2,0,8],"02")}catch(g){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(c,i,k,b,a,f,d,j)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw new Error("keyHex is not ASN.1 hex string")}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!=="02"||c.substr(a[1],2)!=="02"){throw new Error("wrong hex for PKCS#5 public key")}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw new Error("not ASN.1 hex string")}if(c.getTLVbyListEx(b,0,[0,0])!=="06092a864886f70d010101"){throw new Error("not PKCS8 RSA public key")}var a=c.getTLVbyListEx(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)}; var _RE_HEXDECONLY=new RegExp("[^0-9a-f]","gi");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c="";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw new Error("invalid salt length")}}}if(c<(g+k+2)){throw new Error("data too long")}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dk){return false}var j=this.doPublic(b);var i=j.toString(16);if(i.length+3!=k/4){return false}var e=i.replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(m){return KJUR.crypto.Util.hashString(m,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){if(a.length!=Math.ceil(this.n.bitLength()/4)){return false}var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){if(s.length!=Math.ceil(this.n.bitLength()/4)){return false}var k=new BigInteger(s,16);var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw new Error("invalid salt length")}}}if(m<(h+c+2)){throw new Error("data too long")}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw new Error("bits beyond keysize not zero")}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(typeof z=="object"){if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C0){var b=":"+n.join(":")+":";if(b.indexOf(":"+k+":")==-1){throw"algorithm '"+k+"' not accepted in the list"}}if(k!="none"&&B===null){throw"key shall be specified to verify."}if(typeof B=="string"&&B.indexOf("-----BEGIN ")!=-1){B=KEYUTIL.getKey(B)}if(z=="RS"||z=="PS"){if(!(B instanceof m)){throw"key shall be a RSAKey obj for RS* and PS* algs"}}if(z=="ES"){if(!(B instanceof p)){throw"key shall be a ECDSA obj for ES* algs"}}if(k=="none"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw"unsupported alg name: "+k}else{u=t.jwsalg2sigalg[k]}if(u=="none"){throw"not supported"}else{if(u.substr(0,4)=="Hmac"){var o=null;if(B===undefined){throw"hexadecimal key shall be specified for HMAC"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf("withECDSA")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(".");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw"malformed sJWS: wrong number of '.' splitted elements"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null," ");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null," ")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;if(!isBase64URLDot(e)){return false}var k=e.split(".");if(k.length!=3){return false}var c=k[0];var i=k[1];var q=c+"."+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw"acceptField.alg shall be specified"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss==="object"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub==="object"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud==="object"){if(typeof g.aud=="string"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud=="object"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt==="number"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!=="number"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp=="number"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw"addSignature failed: "+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw"malformed header"}if(typeof g.payload==="string"){this.sPayload=g.payload}else{throw"malformed signatures"}if(g.signatures.length>0){this.aSignature=g.signatures}else{throw"malformed signatures"}}catch(e){throw"malformed JWS-JS JSON object: "+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}}; diff --git a/jsrsasign-jwths-min.js b/jsrsasign-jwths-min.js index 819cf98c..6fff29fe 100644 --- a/jsrsasign-jwths-min.js +++ b/jsrsasign-jwths-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(jwths) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(jwths) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js diff --git a/jsrsasign-rsa-min.js b/jsrsasign-rsa-min.js index 409fef33..871ae541 100644 --- a/jsrsasign-rsa-min.js +++ b/jsrsasign-rsa-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(rsa) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(rsa) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js diff --git a/min/asn1x509-1.0.min.js b/min/asn1x509-1.0.min.js index 99019337..84f2dde1 100644 --- a/min/asn1x509-1.0.min.js +++ b/min/asn1x509-1.0.min.js @@ -1 +1 @@ -if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}if(typeof KJUR.asn1.x509=="undefined"||!KJUR.asn1.x509){KJUR.asn1.x509={}}KJUR.asn1.x509.Certificate=function(h){KJUR.asn1.x509.Certificate.superclass.constructor.call(this);var d=KJUR,c=d.asn1,f=c.DERBitString,b=c.DERSequence,g=c.x509,a=g.TBSCertificate,e=g.AlgorithmIdentifier;this.params=undefined;this.setByParam=function(i){this.params=i};this.sign=function(){var l=this.params;var k=l.sigalg;if(l.sigalg.name!=undefined){k=l.sigalg.name}var i=l.tbsobj.tohex();var j=new KJUR.crypto.Signature({alg:k});j.init(l.cakey);j.updateHex(i);l.sighex=j.sign()};this.getPEM=function(){return hextopem(this.tohex(),"CERTIFICATE")};this.tohex=function(){var k=this.params;if(k.tbsobj==undefined||k.tbsobj==null){k.tbsobj=new a(k)}if(k.sighex==undefined&&k.cakey!=undefined){this.sign()}if(k.sighex==undefined){throw new Error("sighex or cakey parameter not defined")}var i=[];i.push(k.tbsobj);i.push(new e({name:k.sigalg}));i.push(new f({hex:"00"+k.sighex}));var j=new b({array:i});return j.tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.params=h}};extendClass(KJUR.asn1.x509.Certificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.TBSCertificate=function(f){KJUR.asn1.x509.TBSCertificate.superclass.constructor.call(this);var b=KJUR,i=b.asn1,d=i.x509,c=i.DERTaggedObject,h=i.DERInteger,g=i.DERSequence,l=d.AlgorithmIdentifier,e=d.Time,a=d.X500Name,j=d.Extensions,k=d.SubjectPublicKeyInfo;this.params=null;this.setByParam=function(m){this.params=m};this.tohex=function(){var n=[];var q=this.params;if(q.version!=undefined||q.version!=1){var m=2;if(q.version!=undefined){m=q.version-1}var p=new c({obj:new h({"int":m})});n.push(p)}n.push(new h(q.serial));n.push(new l({name:q.sigalg}));n.push(new a(q.issuer));n.push(new g({array:[new e(q.notbefore),new e(q.notafter)]}));n.push(new a(q.subject));n.push(new k(KEYUTIL.getKey(q.sbjpubkey)));if(q.ext!==undefined&&q.ext.length>0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(typeof z=="object"){if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=u*2){break}}var z={};z.keyhex=x.substr(0,i[q]["keylen"]*2);z.ivhex=x.substr(i[q]["keylen"]*2,i[q]["ivlen"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v]["proc"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s]["eproc"];var t=r(p,q,u);return t};return{version:"1.0.0",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p="";if(typeof t=="undefined"||t==null){t="AES-256-CBC"}if(typeof i[t]=="undefined"){throw new Error("KEYUTIL unsupported algorithm: "+t)}if(typeof r=="undefined"||r==null){var v=i[t]["ivlen"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,"$1\r\n");var p="-----BEGIN "+x+" PRIVATE KEY-----\r\n";p+="Proc-Type: 4,ENCRYPTED\r\n";p+="DEK-Info: "+t+","+r+"\r\n";p+="\r\n";p+=q;p+="\r\n-----END "+x+" PRIVATE KEY-----\r\n";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw new Error("malformed format: SEQUENCE(0).items != 2: "+r.length)}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+A.length)}if(w(y,A[0])!="2a864886f70d01050d"){throw new Error("this only supports pkcs5PBES2")}var p=z(y,A[1]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+p.length)}var q=z(y,p[1]);if(q.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+q.length)}if(w(y,q[0])!="2a864886f70d0307"){throw"this only supports TripleDES"}t.encryptionSchemeAlg="TripleDES";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+s.length)}if(w(y,s[0])!="2a864886f70d01050c"){throw new Error("this only supports pkcs5PBKDF2")}var x=z(y,s[1]);if(x.length<2){throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+x.length)}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw new Error("malformed format pbkdf2Iter: "+u)}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,"ENCRYPTED PRIVATE KEY");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!="30"){throw new Error("malformed plain PKCS8 private key(code:001)")}var r=u(s,0);if(r.length<3){throw new Error("malformed plain PKCS8 private key(code:002)")}if(s.substr(r[1],2)!="30"){throw new Error("malformed PKCS8 private key(code:003)")}var p=u(s,r[1]);if(p.length!=2){throw new Error("malformed PKCS8 private key(code:004)")}if(s.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 private key(code:005)")}q.algoid=t(s,p[0]);if(s.substr(p[1],2)=="06"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!="04"){throw new Error("malformed PKCS8 private key(code:006)")}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,"PRIVATE KEY");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid=="2a864886f70d010101"){r=new RSAKey()}else{if(q.algoid=="2a8648ce380401"){r=new KJUR.crypto.DSA()}else{if(q.algoid=="2a8648ce3d0201"){r=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported private key algorithm")}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],"06");if(r==="2a864886f70d010101"){p=new RSAKey()}else{if(r==="2a8648ce380401"){p=new KJUR.crypto.DSA()}else{if(r==="2a8648ce3d0201"){p=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported PKCS#8 public key hex")}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!="30"){throw new Error("malformed RSA key(code:001)")}var q=t(r,0);if(q.length!=2){throw new Error("malformed RSA key(code:002)")}if(r.substr(q[0],2)!="02"){throw new Error("malformed RSA key(code:003)")}p.n=s(r,q[0]);if(r.substr(q[1],2)!="02"){throw new Error("malformed RSA key(code:004)")}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw new Error("outer DERSequence shall have 2 elements: "+r.length)}var w=r[0];if(t.substr(w,2)!="30"){throw new Error("malformed PKCS8 public key(code:001)")}var p=u(t,w);if(p.length!=2){throw new Error("malformed PKCS8 public key(code:002)")}if(t.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 public key(code:003)")}q.algoid=s(t,p[0]);if(t.substr(p[1],2)=="06"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)=="30"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],"02");q.algparam.q=v.getVbyList(t,p[1],[1],"02");q.algparam.g=v.getVbyList(t,p[1],[2],"02")}}if(t.substr(r[1],2)!="03"){throw new Error("malformed PKCS8 public key(code:004)")}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!="undefined"&&l instanceof w){return l}if(typeof i!="undefined"&&l instanceof i){return l}if(typeof C!="undefined"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;j.setPublicKeyHex(u);return j}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;var b=("0000000000"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n==="pkcs5prv"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)==="04"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw new Error("unsupported PKCS#1/5 hexadecimal key")}}}return P}if(n==="pkcs8prv"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n==="pkcs8pub"){return F._getKeyFromPublicPKCS8Hex(l)}if(n==="x509pub"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf("-END CERTIFICATE-",0)!=-1||l.indexOf("-END X509 CERTIFICATE-",0)!=-1||l.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf("-END PUBLIC KEY-")!=-1){var O=pemtohex(l,"PUBLIC KEY");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"RSA PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var I=M(l,"DSA PRIVATE KEY");var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"EC PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END PRIVATE KEY-")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],"04");var f=d(I,0,[2,0],"06");var A=d(I,0,[3,0],"03").substr(2);var e="";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+f)}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw new Error("not supported argument")};KEYUTIL.generateKeypair=function(a,c){if(a=="RSA"){var b=c;var h=new RSAKey();h.generate(b,"10001");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a=="EC"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw new Error("unknown algorithm: "+a)}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var H=l({seq:[{"int":0},{"int":{bigint:s.n}},{"int":s.e},{"int":{bigint:s.d}},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.dmp1}},{"int":{bigint:s.dmq1}},{"int":{bigint:s.coeff}}]});return H}function B(H){var s=l({seq:[{"int":1},{octstr:{hex:H.prvKeyHex}},{tag:["a0",true,{oid:{name:H.curveName}}]},{tag:["a1",true,{bitstr:{hex:"00"+H.pubKeyHex}}]}]});return s}function x(s){var H=l({seq:[{"int":0},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.g}},{"int":{bigint:s.y}},{"int":{bigint:s.x}}]});return H}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D=="PKCS8PUB")){var E=new C(b);var w=E.tohex();return hextopem(w,"PUBLIC KEY")}if(D=="PKCS1PRV"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();return hextopem(w,"RSA PRIVATE KEY")}if(D=="PKCS1PRV"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.tohex();var h=B(b);var t=h.tohex();var p="";p+=hextopem(v,"EC PARAMETERS");p+=hextopem(t,"EC PRIVATE KEY");return p}if(D=="PKCS1PRV"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();return hextopem(w,"DSA PRIVATE KEY")}if(D=="PKCS5PRV"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,y,m,j)}if(D=="PKCS5PRV"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,y,m,j)}if(D=="PKCS5PRV"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,y,m,j)}var o=function(H,s){var J=c(H,s);var I=new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:J.pbkdf2Salt}},{"int":J.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:J.encryptionSchemeIV}}]}]}]},{octstr:{hex:J.ciphertext}}]});return I.tohex()};var c=function(O,P){var I=100;var N=CryptoJS.lib.WordArray.random(8);var M="DES-EDE3-CBC";var s=CryptoJS.lib.WordArray.random(8);var J=CryptoJS.PBKDF2(P,N,{keySize:192/32,iterations:I});var K=CryptoJS.enc.Hex.parse(O);var L=CryptoJS.TripleDES.encrypt(K,J,{iv:s})+"";var H={};H.ciphertext=L;H.pbkdf2Salt=CryptoJS.enc.Hex.stringify(N);H.pbkdf2Iter=I;H.encryptionSchemeAlg=M;H.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return H};if(D=="PKCS8PRV"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"rsaEncryption"}},{"null":true}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var G={seq:[{"int":1},{octstr:{hex:b.prvKeyHex}}]};if(typeof b.pubKeyHex=="string"){G.seq.push({tag:["a1",true,{bitstr:{hex:"00"+b.pubKeyHex}}]})}var g=new l(G);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"dsa"}},{seq:[{"int":{bigint:b.p}},{"int":{bigint:b.q}},{"int":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}throw new Error("unsupported object nor format")};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,"CERTIFICATE REQUEST");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,"pkcs8pub");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!="30"){throw new Error("malformed CSR(code:001)")}var e=f(g,0);if(e.length<1){throw new Error("malformed CSR(code:002)")}if(g.substr(e[0],2)!="30"){throw new Error("malformed CSR(code:003)")}var a=f(g,e[0]);if(a.length<3){throw new Error("malformed CSR(code:004)")}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getKeyID=function(f){var c=KEYUTIL;var e=ASN1HEX;if(typeof f==="string"&&f.indexOf("BEGIN ")!=-1){f=c.getKey(f)}var d=pemtohex(c.getPEM(f));var b=e.getIdxbyList(d,0,[1]);var a=e.getV(d,b).substring(2);return KJUR.crypto.Util.hashHex(a,"sha1")};KEYUTIL.getJWK=function(d,h,g,b,f){var i;var k={};var e;var c=KJUR.crypto.Util.hashHex;if(typeof d=="string"){i=KEYUTIL.getKey(d);if(d.indexOf("CERTIFICATE")!=-1){e=pemtohex(d)}}else{if(typeof d=="object"){if(d instanceof X509){i=d.getPublicKey();e=d.hex}else{i=d}}else{throw new Error("unsupported keyinfo type")}}if(i instanceof RSAKey&&i.isPrivate){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16));k.d=hextob64u(i.d.toString(16));k.p=hextob64u(i.p.toString(16));k.q=hextob64u(i.q.toString(16));k.dp=hextob64u(i.dmp1.toString(16));k.dq=hextob64u(i.dmq1.toString(16));k.qi=hextob64u(i.coeff.toString(16))}else{if(i instanceof RSAKey&&i.isPublic){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16))}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPrivate){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y);k.d=hextob64u(i.prvKeyHex)}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPublic){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y)}}}}if(k.kty==undefined){throw new Error("unsupported keyinfo")}if((!i.isPrivate)&&h!=true){k.kid=KJUR.jws.JWS.getJWKthumbprint(k)}if(e!=undefined&&g!=true){k.x5c=[hex2b64(e)]}if(e!=undefined&&b!=true){k.x5t=b64tob64u(hex2b64(c(e,"sha1")))}if(e!=undefined&&f!=true){k["x5t#S256"]=b64tob64u(hex2b64(c(e,"sha256")))}return k};KEYUTIL.getJWKFromKey=function(a){return KEYUTIL.getJWK(a,true,true,true,true)}; RSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,i,k,b,a,f,d,j;var m=ASN1HEX;var l=m.getVbyListEx;if(m.isASN1HEX(e)===false){throw new Error("not ASN.1 hex string")}try{c=l(e,0,[2,0,1],"02");i=l(e,0,[2,0,2],"02");k=l(e,0,[2,0,3],"02");b=l(e,0,[2,0,4],"02");a=l(e,0,[2,0,5],"02");f=l(e,0,[2,0,6],"02");d=l(e,0,[2,0,7],"02");j=l(e,0,[2,0,8],"02")}catch(g){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(c,i,k,b,a,f,d,j)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw new Error("keyHex is not ASN.1 hex string")}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!=="02"||c.substr(a[1],2)!=="02"){throw new Error("wrong hex for PKCS#5 public key")}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw new Error("not ASN.1 hex string")}if(c.getTLVbyListEx(b,0,[0,0])!=="06092a864886f70d010101"){throw new Error("not PKCS8 RSA public key")}var a=c.getTLVbyListEx(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)}; var _RE_HEXDECONLY=new RegExp("[^0-9a-f]","gi");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c="";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw new Error("invalid salt length")}}}if(c<(g+k+2)){throw new Error("data too long")}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dk){return false}var j=this.doPublic(b);var i=j.toString(16);if(i.length+3!=k/4){return false}var e=i.replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(m){return KJUR.crypto.Util.hashString(m,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){if(a.length!=Math.ceil(this.n.bitLength()/4)){return false}var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){if(s.length!=Math.ceil(this.n.bitLength()/4)){return false}var k=new BigInteger(s,16);var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw new Error("invalid salt length")}}}if(m<(h+c+2)){throw new Error("data too long")}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw new Error("bits beyond keysize not zero")}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(typeof z=="object"){if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C0){var b=":"+n.join(":")+":";if(b.indexOf(":"+k+":")==-1){throw"algorithm '"+k+"' not accepted in the list"}}if(k!="none"&&B===null){throw"key shall be specified to verify."}if(typeof B=="string"&&B.indexOf("-----BEGIN ")!=-1){B=KEYUTIL.getKey(B)}if(z=="RS"||z=="PS"){if(!(B instanceof m)){throw"key shall be a RSAKey obj for RS* and PS* algs"}}if(z=="ES"){if(!(B instanceof p)){throw"key shall be a ECDSA obj for ES* algs"}}if(k=="none"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw"unsupported alg name: "+k}else{u=t.jwsalg2sigalg[k]}if(u=="none"){throw"not supported"}else{if(u.substr(0,4)=="Hmac"){var o=null;if(B===undefined){throw"hexadecimal key shall be specified for HMAC"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf("withECDSA")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(".");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw"malformed sJWS: wrong number of '.' splitted elements"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null," ");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null," ")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;if(!isBase64URLDot(e)){return false}var k=e.split(".");if(k.length!=3){return false}var c=k[0];var i=k[1];var q=c+"."+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw"acceptField.alg shall be specified"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss==="object"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub==="object"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud==="object"){if(typeof g.aud=="string"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud=="object"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt==="number"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!=="number"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp=="number"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw"addSignature failed: "+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw"malformed header"}if(typeof g.payload==="string"){this.sPayload=g.payload}else{throw"malformed signatures"}if(g.signatures.length>0){this.aSignature=g.signatures}else{throw"malformed signatures"}}catch(e){throw"malformed JWS-JS JSON object: "+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}}; diff --git a/npm/lib/jsrsasign-jwths-min.js b/npm/lib/jsrsasign-jwths-min.js index 819cf98c..6fff29fe 100644 --- a/npm/lib/jsrsasign-jwths-min.js +++ b/npm/lib/jsrsasign-jwths-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(jwths) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(jwths) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js diff --git a/npm/lib/jsrsasign-rsa-min.js b/npm/lib/jsrsasign-rsa-min.js index 409fef33..871ae541 100644 --- a/npm/lib/jsrsasign-rsa-min.js +++ b/npm/lib/jsrsasign-rsa-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(rsa) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(rsa) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js diff --git a/npm/lib/jsrsasign.js b/npm/lib/jsrsasign.js index 92d40eaa..e9c7e93f 100755 --- a/npm/lib/jsrsasign.js +++ b/npm/lib/jsrsasign.js @@ -4,7 +4,7 @@ navigator.userAgent = false; var window = {}; /* - * jsrsasign(all) 10.5.27 (2022-08-19) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.6.0 (2022-11-04) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -224,7 +224,7 @@ ECFieldElementFp.prototype.getByteLength=function(){return Math.floor((this.toBi var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)";var j='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))';var i='(?:"'+j+'*")';var d=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+i+")","g");var k=new RegExp("\\\\(?:([^u])|u(.{4}))","g");var g={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function h(l,m,n){return m?g[m]:String.fromCharCode(parseInt(n,16))}var c=new String("");var a="\\";var f={"{":Object,"[":Array};var b=Object.hasOwnProperty;return function(u,q){var p=u.match(d);var x;var v=p[0];var l=false;if("{"===v){x={}}else{if("["===v){x=[]}else{x=[];l=true}}var t;var r=[x];for(var o=1-l,m=p.length;o=0;){delete D[n[A]]}}}return q.call(C,B,D)};x=s({"":x},"")}return x}})(); if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw new Error("ASN.1 length too long to represent by 8x: n = "+j.toString(16))}var g=128+h;return g.toString(16)+i}};this.tohex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.getValueHex=function(){this.tohex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};extendClass(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.setByParam=function(d){this.hV=null;this.hTLV=null;this.params=d};this.getString=function(){return undefined};this.setString=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.str=d};this.setByDate=function(d){this.hTLV=null;this.isModified=true;if(this.params==undefined){this.params={}}this.params.date=d};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};extendClass(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};extendClass(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};extendClass(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};extendClass(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.tohex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(e,b,f){if(f==undefined){f=-1}try{var c=e.substr(b,2);if(c!="02"&&c!="03"){return f}var a=ASN1HEX.getV(e,b);if(c=="02"){return parseInt(a,16)}else{return bitstrtoint(a)}}catch(d){return f}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.getString=function(d,b,e){if(e==undefined){e=null}try{var a=ASN1HEX.getV(d,b);return hextorstr(a)}catch(c){return e}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.tohex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+ucs2hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u4){return{"enum":{hex:p}}}else{return{"enum":parseInt(p,16)}}}else{if(C=="30"||C=="31"){j[c[C]]=u(x);return j}else{if(C=="14"){var o=q(p);j[c[C]]={str:o};return j}else{if(C=="1e"){var o=n(p);j[c[C]]={str:o};return j}else{if(":0c:12:13:16:17:18:1a:".indexOf(C)!=-1){var o=k(p);j[c[C]]={str:o};return j}else{if(C.match(/^8[0-9]$/)){var o=k(p);if(o==null|o==""){return{tag:{tag:C,explicit:false,hex:p}}}else{if(o.match(/[\x00-\x1F\x7F-\x9F]/)!=null||o.match(/[\u0000-\u001F\u0080–\u009F]/)!=null){return{tag:{tag:C,explicit:false,hex:p}}}else{return{tag:{tag:C,explicit:false,str:o}}}}}else{if(C.match(/^a[0-9]$/)){try{if(!a(p)){throw new Error("not encap")}return{tag:{tag:C,explicit:true,obj:f(p)}}}catch(z){return{tag:{tag:C,explicit:true,hex:p}}}}else{var A=new KJUR.asn1.ASN1Object();A.hV=p;var w=A.getLengthHexFromValue();return{asn1:{tlv:C+w+p}}}}}}}}}}}}}}}};ASN1HEX.isContextTag=function(c,b){c=c.toLowerCase();var f,e;try{f=parseInt(c,16)}catch(d){return -1}if(b===undefined){if((f&192)==128){return true}else{return false}}try{var a=b.match(/^\[[0-9]+\]$/);if(a==null){return false}e=parseInt(b.substr(1,b.length-1),10);if(e>31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.tohex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.tohex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};extendClass(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!==undefined){this.params=d}};extendClass(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.tohex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.tohex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.tohex()}};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.tohex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.tohex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.tohex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(c!==undefined){this.setByParam(c)}};extendClass(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.tohex=function(){var p=this.getASN1Object();this.hTLV=p.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.tohex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.tohex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};extendClass(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.params=null;this.type=null;this.setTimeParams=function(h){this.timeParams=h};this.setByParam=function(h){this.params=h};this.getType=function(h){if(h.match(/^[0-9]{12}Z$/)){return"utc"}if(h.match(/^[0-9]{14}Z$/)){return"gen"}if(h.match(/^[0-9]{12}\.[0-9]+Z$/)){return"utc"}if(h.match(/^[0-9]{14}\.[0-9]+Z$/)){return"gen"}return null};this.tohex=function(){var i=this.params;var h=null;if(typeof i=="string"){i={str:i}}if(i!=null&&i.str&&(i.type==null||i.type==undefined)){i.type=this.getType(i.str)}if(i!=null&&i.str){if(i.type=="utc"){h=new b(i.str)}if(i.type=="gen"){h=new g(i.str)}}else{if(this.type=="gen"){h=new g()}else{h=new b()}}if(h==null){throw new Error("wrong setting for Time")}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};if(f!=undefined){this.setByParam(f)}};KJUR.asn1.x509.Time_bak=function(f){KJUR.asn1.x509.Time_bak.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.tohex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.tohex();return this.TLV};this.getEncodedHex=function(){return this.tohex()};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};extendClass(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};extendClass(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(f){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var l={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},b=KJUR,h=b.asn1,d=h.x509,a=d.X500Name,g=d.OtherName,e=h.DERIA5String,i=h.DERPrintableString,k=h.DEROctetString,c=h.DERTaggedObject,m=h.ASN1Object,j=Error;this.params=null;this.setByParam=function(n){this.params=n};this.tohex=function(){var p=this.params;var A,y,q;var y=false;if(p.other!==undefined){A="a0",q=new g(p.other)}else{if(p.rfc822!==undefined){A="81";q=new e({str:p.rfc822})}else{if(p.dns!==undefined){A="82";q=new e({str:p.dns})}else{if(p.dn!==undefined){A="a4";y=true;if(typeof p.dn==="string"){q=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){q=p.dn}else{q=new a(p.dn)}}}else{if(p.ldapdn!==undefined){A="a4";y=true;q=new a({ldapstr:p.ldapdn})}else{if(p.certissuer!==undefined||p.certsubj!==undefined){A="a4";y=true;var n,o;var z=null;if(p.certsubj!==undefined){n=false;o=p.certsubj}else{n=true;o=p.certissuer}if(o.match(/^[0-9A-Fa-f]+$/)){z==o}if(o.indexOf("-----BEGIN ")!=-1){z=pemtohex(o)}if(z==null){throw new Error("certsubj/certissuer not cert")}var w=new X509();w.hex=z;var s;if(n){s=w.getIssuerHex()}else{s=w.getSubjectHex()}q=new m();q.hTLV=s}else{if(p.uri!==undefined){A="86";q=new e({str:p.uri})}else{if(p.ip!==undefined){A="87";var v;var t=p.ip;try{if(t.match(/^[0-9a-f]+$/)){var r=t.length;if(r==8||r==16||r==32||r==64){v=t}else{throw"err"}}else{v=iptohex(t)}}catch(u){throw new j("malformed IP address: "+p.ip+":"+u.message)}q=new k({hex:v})}else{throw new j("improper params")}}}}}}}}var B=new c({tag:A,explicit:y,obj:q});return B.tohex()};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){this.setByParam(f)}};extendClass(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSignaturePolicyIdentifier=function(s){var q=j(s.valhex,0);if(q.length>0){var r=l.getOID(s.valhex,q[0]);s.oid=r}if(q.length>1){var m=new a();var t=j(s.valhex,q[1]);var p=b(s.valhex,t[0]);var o=m.getAlgorithmIdentifierName(p);s.alg=o;var n=i(s.valhex,t[1]);s.hash=n}delete s.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o=0;j--){l+=k[j]}return l}else{if(typeof n=="string"&&a[n]!=undefined){return namearraytobinstr([n],a)}else{if(typeof n=="object"&&n.length!=undefined){return namearraytobinstr(n,a)}else{throw new f("wrong params")}}}return};this.tohex=function(){var j=this.params;var i=this.getBinValue();return(new g({bin:i})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(h!=undefined){this.setByParam(h)}};extendClass(KJUR.asn1.tsp.PKIFailureInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.AbstractTSAAdapter=function(a){this.getTSTHex=function(c,b){throw"not implemented yet"}};KJUR.asn1.tsp.SimpleTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.SimpleTSAAdapter.superclass.constructor.call(this);this.params=null;this.serial=0;this.getTSTHex=function(g,f){var i=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:i};this.params.econtent.content.serial={"int":this.serial++};var h=Math.floor(Math.random()*1000000000);this.params.econtent.content.nonce={"int":h};var j=new a.TimeStampToken(this.params);return j.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.SimpleTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.FixedTSAAdapter=function(e){var d=KJUR,c=d.asn1,a=c.tsp,b=d.crypto.Util.hashHex;a.FixedTSAAdapter.superclass.constructor.call(this);this.params=null;this.getTSTHex=function(g,f){var h=b(g,f);this.params.econtent.content.messageImprint={alg:f,hash:h};var i=new a.TimeStampToken(this.params);return i.getContentInfoEncodedHex()};if(e!==undefined){this.params=e}};extendClass(KJUR.asn1.tsp.FixedTSAAdapter,KJUR.asn1.tsp.AbstractTSAAdapter);KJUR.asn1.tsp.TSPUtil=new function(){};KJUR.asn1.tsp.TSPUtil.newTimeStampToken=function(a){return new KJUR.asn1.tsp.TimeStampToken(a)};KJUR.asn1.tsp.TSPUtil.parseTimeStampReq=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getTimeStampReq(a)};KJUR.asn1.tsp.TSPUtil.parseMessageImprint=function(a){var b=new KJUR.asn1.tsp.TSPParser();return b.getMessageImprint(a)};KJUR.asn1.tsp.TSPParser=function(){var e=Error,a=X509,f=new a(),k=ASN1HEX,g=k.getV,b=k.getTLV,d=k.getIdxbyList,c=k.getTLVbyListEx,i=k.getChildIdx;var j=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"];var h={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(n){var l=i(n,0);if(l.length==1){return this.getPKIStatusInfo(b(n,l[0]))}else{if(l.length>1){var o=this.getPKIStatusInfo(b(n,l[0]));var m=b(n,l[1]);var p=this.getToken(m);p.statusinfo=o;return p}}};this.getToken=function(m){var l=new KJUR.asn1.cms.CMSParser;var n=l.getCMSSignedData(m);this.setTSTInfo(n);return n};this.setTSTInfo=function(l){var o=l.econtent;if(o.type=="tstinfo"){var n=o.content.hex;var m=this.getTSTInfo(n);o.content=m}};this.getTSTInfo=function(r){var x={};var s=i(r,0);var p=g(r,s[1]);x.policy=hextooid(p);var o=b(r,s[2]);x.messageImprint=this.getMessageImprint(o);var u=g(r,s[3]);x.serial={hex:u};var y=g(r,s[4]);x.genTime={str:hextoutf8(y)};var q=0;if(s.length>5&&r.substr(s[5],2)=="30"){var v=b(r,s[5]);x.accuracy=this.getAccuracy(v);q++}if(s.length>5+q&&r.substr(s[5+q],2)=="01"){var z=g(r,s[5+q]);if(z=="ff"){x.ordering=true}q++}if(s.length>5+q&&r.substr(s[5+q],2)=="02"){var n=g(r,s[5+q]);x.nonce={hex:n};q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a0"){var m=b(r,s[5+q]);m="30"+m.substr(2);pGeneralNames=f.getGeneralNames(m);var t=pGeneralNames[0].dn;x.tsa=t;q++}if(s.length>5+q&&r.substr(s[5+q],2)=="a1"){var l=b(r,s[5+q]);l="30"+l.substr(2);var w=f.getExtParamArray(l);x.ext=w;q++}return x};this.getAccuracy=function(q){var r={};var o=i(q,0);for(var p=0;p1&&o.substr(r[1],2)=="30"){var m=b(o,r[1]);t.statusstr=this.getPKIFreeText(m);n++}if(r.length>n&&o.substr(r[1+n],2)=="03"){var q=b(o,r[1+n]);t.failinfo=this.getPKIFailureInfo(q)}return t};this.getPKIFreeText=function(n){var o=[];var l=i(n,0);for(var m=0;m=u*2){break}}var z={};z.keyhex=x.substr(0,i[q]["keylen"]*2);z.ivhex=x.substr(i[q]["keylen"]*2,i[q]["ivlen"]*2);return z};var b=function(p,v,r,w){var s=CryptoJS.enc.Base64.parse(p);var q=CryptoJS.enc.Hex.stringify(s);var u=i[v]["proc"];var t=u(q,r,w);return t};var h=function(p,s,q,u){var r=i[s]["eproc"];var t=r(p,q,u);return t};return{version:"1.0.0",parsePKCS5PEM:function(p){return n(p)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(q,p,r){return j(q,p,r)},decryptKeyB64:function(p,r,q,s){return b(p,r,q,s)},getDecryptedKeyHex:function(y,x){var q=n(y);var t=q.type;var r=q.cipher;var p=q.ivsalt;var s=q.data;var w=j(r,x,p);var v=w.keyhex;var u=b(s,r,v,p);return u},getEncryptedPKCS5PEMFromPrvKeyHex:function(x,s,A,t,r){var p="";if(typeof t=="undefined"||t==null){t="AES-256-CBC"}if(typeof i[t]=="undefined"){throw new Error("KEYUTIL unsupported algorithm: "+t)}if(typeof r=="undefined"||r==null){var v=i[t]["ivlen"];var u=m(v);r=u.toUpperCase()}var z=j(t,A,r);var y=z.keyhex;var w=h(s,t,y,r);var q=w.replace(/(.{64})/g,"$1\r\n");var p="-----BEGIN "+x+" PRIVATE KEY-----\r\n";p+="Proc-Type: 4,ENCRYPTED\r\n";p+="DEK-Info: "+t+","+r+"\r\n";p+="\r\n";p+=q;p+="\r\n-----END "+x+" PRIVATE KEY-----\r\n";return p},parseHexOfEncryptedPKCS8:function(y){var B=ASN1HEX;var z=B.getChildIdx;var w=B.getV;var t={};var r=z(y,0);if(r.length!=2){throw new Error("malformed format: SEQUENCE(0).items != 2: "+r.length)}t.ciphertext=w(y,r[1]);var A=z(y,r[0]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+A.length)}if(w(y,A[0])!="2a864886f70d01050d"){throw new Error("this only supports pkcs5PBES2")}var p=z(y,A[1]);if(A.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+p.length)}var q=z(y,p[1]);if(q.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+q.length)}if(w(y,q[0])!="2a864886f70d0307"){throw"this only supports TripleDES"}t.encryptionSchemeAlg="TripleDES";t.encryptionSchemeIV=w(y,q[1]);var s=z(y,p[0]);if(s.length!=2){throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+s.length)}if(w(y,s[0])!="2a864886f70d01050c"){throw new Error("this only supports pkcs5PBKDF2")}var x=z(y,s[1]);if(x.length<2){throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+x.length)}t.pbkdf2Salt=w(y,x[0]);var u=w(y,x[1]);try{t.pbkdf2Iter=parseInt(u,16)}catch(v){throw new Error("malformed format pbkdf2Iter: "+u)}return t},getPBKDF2KeyHexFromParam:function(u,p){var t=CryptoJS.enc.Hex.parse(u.pbkdf2Salt);var q=u.pbkdf2Iter;var s=CryptoJS.PBKDF2(p,t,{keySize:192/32,iterations:q});var r=CryptoJS.enc.Hex.stringify(s);return r},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(x,y){var r=pemtohex(x,"ENCRYPTED PRIVATE KEY");var p=this.parseHexOfEncryptedPKCS8(r);var u=KEYUTIL.getPBKDF2KeyHexFromParam(p,y);var v={};v.ciphertext=CryptoJS.enc.Hex.parse(p.ciphertext);var t=CryptoJS.enc.Hex.parse(u);var s=CryptoJS.enc.Hex.parse(p.encryptionSchemeIV);var w=CryptoJS.TripleDES.decrypt(v,t,{iv:s});var q=CryptoJS.enc.Hex.stringify(w);return q},getKeyFromEncryptedPKCS8PEM:function(s,q){var p=this._getPlainPKCS8HexFromEncryptedPKCS8PEM(s,q);var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},parsePlainPrivatePKCS8Hex:function(s){var v=ASN1HEX;var u=v.getChildIdx;var t=v.getV;var q={};q.algparam=null;if(s.substr(0,2)!="30"){throw new Error("malformed plain PKCS8 private key(code:001)")}var r=u(s,0);if(r.length<3){throw new Error("malformed plain PKCS8 private key(code:002)")}if(s.substr(r[1],2)!="30"){throw new Error("malformed PKCS8 private key(code:003)")}var p=u(s,r[1]);if(p.length!=2){throw new Error("malformed PKCS8 private key(code:004)")}if(s.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 private key(code:005)")}q.algoid=t(s,p[0]);if(s.substr(p[1],2)=="06"){q.algparam=t(s,p[1])}if(s.substr(r[2],2)!="04"){throw new Error("malformed PKCS8 private key(code:006)")}q.keyidx=v.getVidx(s,r[2]);return q},getKeyFromPlainPrivatePKCS8PEM:function(q){var p=pemtohex(q,"PRIVATE KEY");var r=this.getKeyFromPlainPrivatePKCS8Hex(p);return r},getKeyFromPlainPrivatePKCS8Hex:function(p){var q=this.parsePlainPrivatePKCS8Hex(p);var r;if(q.algoid=="2a864886f70d010101"){r=new RSAKey()}else{if(q.algoid=="2a8648ce380401"){r=new KJUR.crypto.DSA()}else{if(q.algoid=="2a8648ce3d0201"){r=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported private key algorithm")}}}r.readPKCS8PrvKeyHex(p);return r},_getKeyFromPublicPKCS8Hex:function(q){var p;var r=ASN1HEX.getVbyList(q,0,[0,0],"06");if(r==="2a864886f70d010101"){p=new RSAKey()}else{if(r==="2a8648ce380401"){p=new KJUR.crypto.DSA()}else{if(r==="2a8648ce3d0201"){p=new KJUR.crypto.ECDSA()}else{throw new Error("unsupported PKCS#8 public key hex")}}}p.readPKCS8PubKeyHex(q);return p},parsePublicRawRSAKeyHex:function(r){var u=ASN1HEX;var t=u.getChildIdx;var s=u.getV;var p={};if(r.substr(0,2)!="30"){throw new Error("malformed RSA key(code:001)")}var q=t(r,0);if(q.length!=2){throw new Error("malformed RSA key(code:002)")}if(r.substr(q[0],2)!="02"){throw new Error("malformed RSA key(code:003)")}p.n=s(r,q[0]);if(r.substr(q[1],2)!="02"){throw new Error("malformed RSA key(code:004)")}p.e=s(r,q[1]);return p},parsePublicPKCS8Hex:function(t){var v=ASN1HEX;var u=v.getChildIdx;var s=v.getV;var q={};q.algparam=null;var r=u(t,0);if(r.length!=2){throw new Error("outer DERSequence shall have 2 elements: "+r.length)}var w=r[0];if(t.substr(w,2)!="30"){throw new Error("malformed PKCS8 public key(code:001)")}var p=u(t,w);if(p.length!=2){throw new Error("malformed PKCS8 public key(code:002)")}if(t.substr(p[0],2)!="06"){throw new Error("malformed PKCS8 public key(code:003)")}q.algoid=s(t,p[0]);if(t.substr(p[1],2)=="06"){q.algparam=s(t,p[1])}else{if(t.substr(p[1],2)=="30"){q.algparam={};q.algparam.p=v.getVbyList(t,p[1],[0],"02");q.algparam.q=v.getVbyList(t,p[1],[1],"02");q.algparam.g=v.getVbyList(t,p[1],[2],"02")}}if(t.substr(r[1],2)!="03"){throw new Error("malformed PKCS8 public key(code:004)")}q.key=s(t,r[1]).substr(2);return q},}}();KEYUTIL.getKey=function(l,k,n){var G=ASN1HEX,L=G.getChildIdx,v=G.getV,d=G.getVbyList,c=KJUR.crypto,i=c.ECDSA,C=c.DSA,w=RSAKey,M=pemtohex,F=KEYUTIL;if(typeof w!="undefined"&&l instanceof w){return l}if(typeof i!="undefined"&&l instanceof i){return l}if(typeof C!="undefined"&&l instanceof C){return l}if(l.curve!==undefined&&l.xy!==undefined&&l.d===undefined){return new i({pub:l.xy,curve:l.curve})}if(l.curve!==undefined&&l.d!==undefined){return new i({prv:l.d,curve:l.curve})}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(l.n,l.e);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.co!==undefined&&l.qi===undefined){var P=new w();P.setPrivateEx(l.n,l.e,l.d,l.p,l.q,l.dp,l.dq,l.co);return P}if(l.kty===undefined&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p===undefined){var P=new w();P.setPrivate(l.n,l.e,l.d);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x===undefined){var P=new C();P.setPublic(l.p,l.q,l.g,l.y);return P}if(l.p!==undefined&&l.q!==undefined&&l.g!==undefined&&l.y!==undefined&&l.x!==undefined){var P=new C();P.setPrivate(l.p,l.q,l.g,l.y,l.x);return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d===undefined){var P=new w();P.setPublic(b64utohex(l.n),b64utohex(l.e));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined&&l.p!==undefined&&l.q!==undefined&&l.dp!==undefined&&l.dq!==undefined&&l.qi!==undefined){var P=new w();P.setPrivateEx(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d),b64utohex(l.p),b64utohex(l.q),b64utohex(l.dp),b64utohex(l.dq),b64utohex(l.qi));return P}if(l.kty==="RSA"&&l.n!==undefined&&l.e!==undefined&&l.d!==undefined){var P=new w();P.setPrivate(b64utohex(l.n),b64utohex(l.e),b64utohex(l.d));return P}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d===undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;j.setPublicKeyHex(u);return j}if(l.kty==="EC"&&l.crv!==undefined&&l.x!==undefined&&l.y!==undefined&&l.d!==undefined){var j=new i({curve:l.crv});var t=j.ecparams.keycharlen;var B=("0000000000"+b64utohex(l.x)).slice(-t);var z=("0000000000"+b64utohex(l.y)).slice(-t);var u="04"+B+z;var b=("0000000000"+b64utohex(l.d)).slice(-t);j.setPublicKeyHex(u);j.setPrivateKeyHex(b);return j}if(n==="pkcs5prv"){var J=l,G=ASN1HEX,N,P;N=L(J,0);if(N.length===9){P=new w();P.readPKCS5PrvKeyHex(J)}else{if(N.length===6){P=new C();P.readPKCS5PrvKeyHex(J)}else{if(N.length>2&&J.substr(N[1],2)==="04"){P=new i();P.readPKCS5PrvKeyHex(J)}else{throw new Error("unsupported PKCS#1/5 hexadecimal key")}}}return P}if(n==="pkcs8prv"){var P=F.getKeyFromPlainPrivatePKCS8Hex(l);return P}if(n==="pkcs8pub"){return F._getKeyFromPublicPKCS8Hex(l)}if(n==="x509pub"){return X509.getPublicKeyFromCertHex(l)}if(l.indexOf("-END CERTIFICATE-",0)!=-1||l.indexOf("-END X509 CERTIFICATE-",0)!=-1||l.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1){return X509.getPublicKeyFromCertPEM(l)}if(l.indexOf("-END PUBLIC KEY-")!=-1){var O=pemtohex(l,"PUBLIC KEY");return F._getKeyFromPublicPKCS8Hex(O)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"RSA PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var I=M(l,"DSA PRIVATE KEY");var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")==-1){var m=M(l,"EC PRIVATE KEY");return F.getKey(m,null,"pkcs5prv")}if(l.indexOf("-END PRIVATE KEY-")!=-1){return F.getKeyFromPlainPrivatePKCS8PEM(l)}if(l.indexOf("-END RSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var o=F.getDecryptedKeyHex(l,k);var H=new RSAKey();H.readPKCS5PrvKeyHex(o);return H}if(l.indexOf("-END EC PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var P=d(I,0,[1],"04");var f=d(I,0,[2,0],"06");var A=d(I,0,[3,0],"03").substr(2);var e="";if(KJUR.crypto.OID.oidhex2name[f]!==undefined){e=KJUR.crypto.OID.oidhex2name[f]}else{throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+f)}var j=new i({curve:e});j.setPublicKeyHex(A);j.setPrivateKeyHex(P);j.isPublic=false;return j}if(l.indexOf("-END DSA PRIVATE KEY-")!=-1&&l.indexOf("4,ENCRYPTED")!=-1){var I=F.getDecryptedKeyHex(l,k);var E=d(I,0,[1],"02");var D=d(I,0,[2],"02");var K=d(I,0,[3],"02");var r=d(I,0,[4],"02");var s=d(I,0,[5],"02");var P=new C();P.setPrivate(new BigInteger(E,16),new BigInteger(D,16),new BigInteger(K,16),new BigInteger(r,16),new BigInteger(s,16));return P}if(l.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1){return F.getKeyFromEncryptedPKCS8PEM(l,k)}throw new Error("not supported argument")};KEYUTIL.generateKeypair=function(a,c){if(a=="RSA"){var b=c;var h=new RSAKey();h.generate(b,"10001");h.isPrivate=true;h.isPublic=true;var f=new RSAKey();var e=h.n.toString(16);var i=h.e.toString(16);f.setPublic(e,i);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{if(a=="EC"){var d=c;var g=new KJUR.crypto.ECDSA({curve:d});var j=g.generateKeyPairHex();var h=new KJUR.crypto.ECDSA({curve:d});h.setPublicKeyHex(j.ecpubhex);h.setPrivateKeyHex(j.ecprvhex);h.isPrivate=true;h.isPublic=false;var f=new KJUR.crypto.ECDSA({curve:d});f.setPublicKeyHex(j.ecpubhex);f.isPrivate=false;f.isPublic=true;var k={};k.prvKeyObj=h;k.pubKeyObj=f;return k}else{throw new Error("unknown algorithm: "+a)}}};KEYUTIL.getPEM=function(b,D,y,m,q,j){var F=KJUR,k=F.asn1,z=k.DERObjectIdentifier,f=k.DERInteger,l=k.ASN1Util.newObject,a=k.x509,C=a.SubjectPublicKeyInfo,e=F.crypto,u=e.DSA,r=e.ECDSA,n=RSAKey;function A(s){var H=l({seq:[{"int":0},{"int":{bigint:s.n}},{"int":s.e},{"int":{bigint:s.d}},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.dmp1}},{"int":{bigint:s.dmq1}},{"int":{bigint:s.coeff}}]});return H}function B(H){var s=l({seq:[{"int":1},{octstr:{hex:H.prvKeyHex}},{tag:["a0",true,{oid:{name:H.curveName}}]},{tag:["a1",true,{bitstr:{hex:"00"+H.pubKeyHex}}]}]});return s}function x(s){var H=l({seq:[{"int":0},{"int":{bigint:s.p}},{"int":{bigint:s.q}},{"int":{bigint:s.g}},{"int":{bigint:s.y}},{"int":{bigint:s.x}}]});return H}if(((n!==undefined&&b instanceof n)||(u!==undefined&&b instanceof u)||(r!==undefined&&b instanceof r))&&b.isPublic==true&&(D===undefined||D=="PKCS8PUB")){var E=new C(b);var w=E.tohex();return hextopem(w,"PUBLIC KEY")}if(D=="PKCS1PRV"&&n!==undefined&&b instanceof n&&(y===undefined||y==null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();return hextopem(w,"RSA PRIVATE KEY")}if(D=="PKCS1PRV"&&r!==undefined&&b instanceof r&&(y===undefined||y==null)&&b.isPrivate==true){var i=new z({name:b.curveName});var v=i.tohex();var h=B(b);var t=h.tohex();var p="";p+=hextopem(v,"EC PARAMETERS");p+=hextopem(t,"EC PRIVATE KEY");return p}if(D=="PKCS1PRV"&&u!==undefined&&b instanceof u&&(y===undefined||y==null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();return hextopem(w,"DSA PRIVATE KEY")}if(D=="PKCS5PRV"&&n!==undefined&&b instanceof n&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=A(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,y,m,j)}if(D=="PKCS5PRV"&&r!==undefined&&b instanceof r&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=B(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,y,m,j)}if(D=="PKCS5PRV"&&u!==undefined&&b instanceof u&&(y!==undefined&&y!=null)&&b.isPrivate==true){var E=x(b);var w=E.tohex();if(m===undefined){m="DES-EDE3-CBC"}return this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,y,m,j)}var o=function(H,s){var J=c(H,s);var I=new l({seq:[{seq:[{oid:{name:"pkcs5PBES2"}},{seq:[{seq:[{oid:{name:"pkcs5PBKDF2"}},{seq:[{octstr:{hex:J.pbkdf2Salt}},{"int":J.pbkdf2Iter}]}]},{seq:[{oid:{name:"des-EDE3-CBC"}},{octstr:{hex:J.encryptionSchemeIV}}]}]}]},{octstr:{hex:J.ciphertext}}]});return I.tohex()};var c=function(O,P){var I=100;var N=CryptoJS.lib.WordArray.random(8);var M="DES-EDE3-CBC";var s=CryptoJS.lib.WordArray.random(8);var J=CryptoJS.PBKDF2(P,N,{keySize:192/32,iterations:I});var K=CryptoJS.enc.Hex.parse(O);var L=CryptoJS.TripleDES.encrypt(K,J,{iv:s})+"";var H={};H.ciphertext=L;H.pbkdf2Salt=CryptoJS.enc.Hex.stringify(N);H.pbkdf2Iter=I;H.encryptionSchemeAlg=M;H.encryptionSchemeIV=CryptoJS.enc.Hex.stringify(s);return H};if(D=="PKCS8PRV"&&n!=undefined&&b instanceof n&&b.isPrivate==true){var g=A(b);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"rsaEncryption"}},{"null":true}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&r!==undefined&&b instanceof r&&b.isPrivate==true){var G={seq:[{"int":1},{octstr:{hex:b.prvKeyHex}}]};if(typeof b.pubKeyHex=="string"){G.seq.push({tag:["a1",true,{bitstr:{hex:"00"+b.pubKeyHex}}]})}var g=new l(G);var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:b.curveName}}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}if(D=="PKCS8PRV"&&u!==undefined&&b instanceof u&&b.isPrivate==true){var g=new f({bigint:b.x});var d=g.tohex();var E=l({seq:[{"int":0},{seq:[{oid:{name:"dsa"}},{seq:[{"int":{bigint:b.p}},{"int":{bigint:b.q}},{"int":{bigint:b.g}}]}]},{octstr:{hex:d}}]});var w=E.tohex();if(y===undefined||y==null){return hextopem(w,"PRIVATE KEY")}else{var t=o(w,y);return hextopem(t,"ENCRYPTED PRIVATE KEY")}}throw new Error("unsupported object nor format")};KEYUTIL.getKeyFromCSRPEM=function(b){var a=pemtohex(b,"CERTIFICATE REQUEST");var c=KEYUTIL.getKeyFromCSRHex(a);return c};KEYUTIL.getKeyFromCSRHex=function(a){var c=KEYUTIL.parseCSRHex(a);var b=KEYUTIL.getKey(c.p8pubkeyhex,null,"pkcs8pub");return b};KEYUTIL.parseCSRHex=function(d){var i=ASN1HEX;var f=i.getChildIdx;var c=i.getTLV;var b={};var g=d;if(g.substr(0,2)!="30"){throw new Error("malformed CSR(code:001)")}var e=f(g,0);if(e.length<1){throw new Error("malformed CSR(code:002)")}if(g.substr(e[0],2)!="30"){throw new Error("malformed CSR(code:003)")}var a=f(g,e[0]);if(a.length<3){throw new Error("malformed CSR(code:004)")}b.p8pubkeyhex=c(g,a[2]);return b};KEYUTIL.getKeyID=function(f){var c=KEYUTIL;var e=ASN1HEX;if(typeof f==="string"&&f.indexOf("BEGIN ")!=-1){f=c.getKey(f)}var d=pemtohex(c.getPEM(f));var b=e.getIdxbyList(d,0,[1]);var a=e.getV(d,b).substring(2);return KJUR.crypto.Util.hashHex(a,"sha1")};KEYUTIL.getJWK=function(d,h,g,b,f){var i;var k={};var e;var c=KJUR.crypto.Util.hashHex;if(typeof d=="string"){i=KEYUTIL.getKey(d);if(d.indexOf("CERTIFICATE")!=-1){e=pemtohex(d)}}else{if(typeof d=="object"){if(d instanceof X509){i=d.getPublicKey();e=d.hex}else{i=d}}else{throw new Error("unsupported keyinfo type")}}if(i instanceof RSAKey&&i.isPrivate){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16));k.d=hextob64u(i.d.toString(16));k.p=hextob64u(i.p.toString(16));k.q=hextob64u(i.q.toString(16));k.dp=hextob64u(i.dmp1.toString(16));k.dq=hextob64u(i.dmq1.toString(16));k.qi=hextob64u(i.coeff.toString(16))}else{if(i instanceof RSAKey&&i.isPublic){k.kty="RSA";k.n=hextob64u(i.n.toString(16));k.e=hextob64u(i.e.toString(16))}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPrivate){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y);k.d=hextob64u(i.prvKeyHex)}else{if(i instanceof KJUR.crypto.ECDSA&&i.isPublic){var a=i.getShortNISTPCurveName();if(a!=="P-256"&&a!=="P-384"&&a!=="P-521"){throw new Error("unsupported curve name for JWT: "+a)}var j=i.getPublicKeyXYHex();k.kty="EC";k.crv=a;k.x=hextob64u(j.x);k.y=hextob64u(j.y)}}}}if(k.kty==undefined){throw new Error("unsupported keyinfo")}if((!i.isPrivate)&&h!=true){k.kid=KJUR.jws.JWS.getJWKthumbprint(k)}if(e!=undefined&&g!=true){k.x5c=[hex2b64(e)]}if(e!=undefined&&b!=true){k.x5t=b64tob64u(hex2b64(c(e,"sha1")))}if(e!=undefined&&f!=true){k["x5t#S256"]=b64tob64u(hex2b64(c(e,"sha256")))}return k};KEYUTIL.getJWKFromKey=function(a){return KEYUTIL.getJWK(a,true,true,true,true)}; RSAKey.getPosArrayOfChildrenFromHex=function(a){return ASN1HEX.getChildIdx(a,0)};RSAKey.getHexValueArrayOfChildrenFromHex=function(f){var n=ASN1HEX;var i=n.getV;var k=RSAKey.getPosArrayOfChildrenFromHex(f);var e=i(f,k[0]);var j=i(f,k[1]);var b=i(f,k[2]);var c=i(f,k[3]);var h=i(f,k[4]);var g=i(f,k[5]);var m=i(f,k[6]);var l=i(f,k[7]);var d=i(f,k[8]);var k=new Array();k.push(e,j,b,c,h,g,m,l,d);return k};RSAKey.prototype.readPrivateKeyFromPEMString=function(d){var c=pemtohex(d);var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS5PrvKeyHex=function(c){var b=RSAKey.getHexValueArrayOfChildrenFromHex(c);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])};RSAKey.prototype.readPKCS8PrvKeyHex=function(e){var c,i,k,b,a,f,d,j;var m=ASN1HEX;var l=m.getVbyListEx;if(m.isASN1HEX(e)===false){throw new Error("not ASN.1 hex string")}try{c=l(e,0,[2,0,1],"02");i=l(e,0,[2,0,2],"02");k=l(e,0,[2,0,3],"02");b=l(e,0,[2,0,4],"02");a=l(e,0,[2,0,5],"02");f=l(e,0,[2,0,6],"02");d=l(e,0,[2,0,7],"02");j=l(e,0,[2,0,8],"02")}catch(g){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(c,i,k,b,a,f,d,j)};RSAKey.prototype.readPKCS5PubKeyHex=function(c){var e=ASN1HEX;var b=e.getV;if(e.isASN1HEX(c)===false){throw new Error("keyHex is not ASN.1 hex string")}var a=e.getChildIdx(c,0);if(a.length!==2||c.substr(a[0],2)!=="02"||c.substr(a[1],2)!=="02"){throw new Error("wrong hex for PKCS#5 public key")}var f=b(c,a[0]);var d=b(c,a[1]);this.setPublic(f,d)};RSAKey.prototype.readPKCS8PubKeyHex=function(b){var c=ASN1HEX;if(c.isASN1HEX(b)===false){throw new Error("not ASN.1 hex string")}if(c.getTLVbyListEx(b,0,[0,0])!=="06092a864886f70d010101"){throw new Error("not PKCS8 RSA public key")}var a=c.getTLVbyListEx(b,0,[1,0]);this.readPKCS5PubKeyHex(a)};RSAKey.prototype.readCertPubKeyHex=function(b,d){var a,c;a=new X509();a.readCertHex(b);c=a.getPublicKeyHex();this.readPKCS8PubKeyHex(c)}; var _RE_HEXDECONLY=new RegExp("[^0-9a-f]","gi");function _rsasign_getHexPaddedDigestInfoForString(d,e,a){var b=function(f){return KJUR.crypto.Util.hashString(f,a)};var c=b(d);return KJUR.crypto.Util.getPaddedDigestInfoHex(c,a,e)}function _zeroPaddingOfSignature(e,d){var c="";var a=d/4-e.length;for(var b=0;b>24,(d&16711680)>>16,(d&65280)>>8,d&255]))));d+=1}return b}RSAKey.prototype.signPSS=function(e,a,d){var c=function(f){return KJUR.crypto.Util.hashHex(f,a)};var b=c(rstrtohex(e));if(d===undefined){d=-1}return this.signWithMessageHashPSS(b,a,d)};RSAKey.prototype.signWithMessageHashPSS=function(l,a,k){var b=hextorstr(l);var g=b.length;var m=this.n.bitLength()-1;var c=Math.ceil(m/8);var d;var o=function(i){return KJUR.crypto.Util.hashHex(i,a)};if(k===-1||k===undefined){k=g}else{if(k===-2){k=c-g-2}else{if(k<-2){throw new Error("invalid salt length")}}}if(c<(g+k+2)){throw new Error("data too long")}var f="";if(k>0){f=new Array(k);new SecureRandom().nextBytes(f);f=String.fromCharCode.apply(String,f)}var n=hextorstr(o(rstrtohex("\x00\x00\x00\x00\x00\x00\x00\x00"+b+f)));var j=[];for(d=0;d>(8*c-m))&255;q[0]&=~p;for(d=0;dk){return false}var j=this.doPublic(b);var i=j.toString(16);if(i.length+3!=k/4){return false}var e=i.replace(/^1f+00/,"");var g=_rsasign_getAlgNameAndHashFromHexDisgestInfo(e);if(g.length==0){return false}var d=g[0];var h=g[1];var a=function(m){return KJUR.crypto.Util.hashString(m,d)};var c=a(f);return(h==c)};RSAKey.prototype.verifyWithMessageHash=function(e,a){if(a.length!=Math.ceil(this.n.bitLength()/4)){return false}var b=parseBigInt(a,16);if(b.bitLength()>this.n.bitLength()){return 0}var h=this.doPublic(b);var g=h.toString(16).replace(/^1f+00/,"");var c=_rsasign_getAlgNameAndHashFromHexDisgestInfo(g);if(c.length==0){return false}var d=c[0];var f=c[1];return(f==e)};RSAKey.prototype.verifyPSS=function(c,b,a,f){var e=function(g){return KJUR.crypto.Util.hashHex(g,a)};var d=e(rstrtohex(c));if(f===undefined){f=-1}return this.verifyWithMessageHashPSS(d,b,a,f)};RSAKey.prototype.verifyWithMessageHashPSS=function(f,s,l,c){if(s.length!=Math.ceil(this.n.bitLength()/4)){return false}var k=new BigInteger(s,16);var r=function(i){return KJUR.crypto.Util.hashHex(i,l)};var j=hextorstr(f);var h=j.length;var g=this.n.bitLength()-1;var m=Math.ceil(g/8);var q;if(c===-1||c===undefined){c=h}else{if(c===-2){c=m-h-2}else{if(c<-2){throw new Error("invalid salt length")}}}if(m<(h+c+2)){throw new Error("data too long")}var a=this.doPublic(k).toByteArray();for(q=0;q>(8*m-g))&255;if((d.charCodeAt(0)&p)!==0){throw new Error("bits beyond keysize not zero")}var n=pss_mgf1_str(e,d.length,r);var o=[];for(q=0;q1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(typeof z=="object"){if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C1){var F=b(B,A[1]);var z=this.getGeneralName(F);if(z.uri!=undefined){y.uri=z.uri}}if(A.length>2){var C=b(B,A[2]);if(C=="0101ff"){y.reqauth=true}if(C=="010100"){y.reqauth=false}}return y};var e=function(D){var y={};try{var A=D.seq[0].oid;var C=KJUR.asn1.x509.OID.name2oid(A);y.type=KJUR.asn1.x509.OID.oid2atype(C);var z=D.seq[1];if(z.utf8str!=undefined){y.ds="utf8";y.value=z.utf8str.str}else{if(z.numstr!=undefined){y.ds="num";y.value=z.numstr.str}else{if(z.telstr!=undefined){y.ds="tel";y.value=z.telstr.str}else{if(z.prnstr!=undefined){y.ds="prn";y.value=z.prnstr.str}else{if(z.ia5str!=undefined){y.ds="ia5";y.value=z.ia5str.str}else{if(z.visstr!=undefined){y.ds="vis";y.value=z.visstr.str}else{if(z.bmpstr!=undefined){y.ds="bmp";y.value=z.bmpstr.str}else{throw"error"}}}}}}}return y}catch(B){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}};var i=function(z){try{return z.set.map(function(A){return e(A)})}catch(y){throw new Error("improper ASN.1 parsed RDN: "+y)}};var h=function(z){try{return z.seq.map(function(A){return i(A)})}catch(y){throw new Error("improper ASN.1 parsed X500Name: "+y)}};this.getX500NameRule=function(y){var F=true;var J=true;var I=false;var z="";var C="";var L=null;var G=[];for(var B=0;B0){y.ext=this.getExtParamArray()}y.sighex=this.getSignatureValueHex();if(z.tbshex==true){y.tbshex=a(this.hex,0,[0])}if(z.nodnarray==true){delete y.issuer.array;delete y.subject.array}return y};this.getExtParamArray=function(z){if(z==undefined){var B=f(this.hex,0,[0,"[3]"]);if(B!=-1){z=p(this.hex,0,[0,"[3]",0],"30")}}var y=[];var A=r(z,0);for(var C=0;C0){var b=":"+n.join(":")+":";if(b.indexOf(":"+k+":")==-1){throw"algorithm '"+k+"' not accepted in the list"}}if(k!="none"&&B===null){throw"key shall be specified to verify."}if(typeof B=="string"&&B.indexOf("-----BEGIN ")!=-1){B=KEYUTIL.getKey(B)}if(z=="RS"||z=="PS"){if(!(B instanceof m)){throw"key shall be a RSAKey obj for RS* and PS* algs"}}if(z=="ES"){if(!(B instanceof p)){throw"key shall be a ECDSA obj for ES* algs"}}if(k=="none"){}var u=null;if(t.jwsalg2sigalg[l.alg]===undefined){throw"unsupported alg name: "+k}else{u=t.jwsalg2sigalg[k]}if(u=="none"){throw"not supported"}else{if(u.substr(0,4)=="Hmac"){var o=null;if(B===undefined){throw"hexadecimal key shall be specified for HMAC"}var j=new s({alg:u,pass:B});j.updateString(c);o=j.doFinal();return A==o}else{if(u.indexOf("withECDSA")!=-1){var h=null;try{h=p.concatSigToASN1Sig(A)}catch(v){return false}var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(h)}else{var g=new d({alg:u});g.init(B);g.updateString(c);return g.verify(A)}}}};KJUR.jws.JWS.parse=function(g){var c=g.split(".");var b={};var f,e,d;if(c.length!=2&&c.length!=3){throw"malformed sJWS: wrong number of '.' splitted elements"}f=c[0];e=c[1];if(c.length==3){d=c[2]}b.headerObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(f));b.payloadObj=KJUR.jws.JWS.readSafeJSONString(b64utoutf8(e));b.headerPP=JSON.stringify(b.headerObj,null," ");if(b.payloadObj==null){b.payloadPP=b64utoutf8(e)}else{b.payloadPP=JSON.stringify(b.payloadObj,null," ")}if(d!==undefined){b.sigHex=b64utohex(d)}return b};KJUR.jws.JWS.verifyJWT=function(e,l,r){var d=KJUR,j=d.jws,o=j.JWS,n=o.readSafeJSONString,p=o.inArray,f=o.includedArray;if(!isBase64URLDot(e)){return false}var k=e.split(".");if(k.length!=3){return false}var c=k[0];var i=k[1];var q=c+"."+i;var m=b64utohex(k[2]);var h=n(b64utoutf8(c));var g=n(b64utoutf8(i));if(h.alg===undefined){return false}if(r.alg===undefined){throw"acceptField.alg shall be specified"}if(!p(h.alg,r.alg)){return false}if(g.iss!==undefined&&typeof r.iss==="object"){if(!p(g.iss,r.iss)){return false}}if(g.sub!==undefined&&typeof r.sub==="object"){if(!p(g.sub,r.sub)){return false}}if(g.aud!==undefined&&typeof r.aud==="object"){if(typeof g.aud=="string"){if(!p(g.aud,r.aud)){return false}}else{if(typeof g.aud=="object"){if(!f(g.aud,r.aud)){return false}}}}var b=j.IntDate.getNow();if(r.verifyAt!==undefined&&typeof r.verifyAt==="number"){b=r.verifyAt}if(r.gracePeriod===undefined||typeof r.gracePeriod!=="number"){r.gracePeriod=0}if(g.exp!==undefined&&typeof g.exp=="number"){if(g.exp+r.gracePeriodl){this.aHeader.pop()}if(this.aSignature.length>l){this.aSignature.pop()}throw"addSignature failed: "+i}};this.verifyAll=function(h){if(this.aHeader.length!==h.length||this.aSignature.length!==h.length){return false}for(var g=0;g0){this.aHeader=g.headers}else{throw"malformed header"}if(typeof g.payload==="string"){this.sPayload=g.payload}else{throw"malformed signatures"}if(g.signatures.length>0){this.aSignature=g.signatures}else{throw"malformed signatures"}}catch(e){throw"malformed JWS-JS JSON object: "+e}}};this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}};this.isEmpty=function(){if(this.aHeader.length==0){return 1}return 0}}; diff --git a/npm/package.json b/npm/package.json index e1e2844d..51a11c2a 100755 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "jsrsasign", - "version": "10.5.27", + "version": "10.6.0", "description": "opensource free pure JavaScript cryptographic library supports RSA/RSAPSS/ECDSA/DSA signing/validation, ASN.1, PKCS#1/5/8 private/public key, X.509 certificate, CRL, OCSP, CMS SignedData, TimeStamp and CAdES and JSON Web Signature(JWS)/Token(JWT)/Key(JWK).", "main": "lib/jsrsasign.js", "scripts": { diff --git a/src/asn1-1.0.js b/src/asn1-1.0.js index 9f8da6b4..3a46ae75 100644 --- a/src/asn1-1.0.js +++ b/src/asn1-1.0.js @@ -1724,6 +1724,7 @@ extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured); * @name KJUR.asn1.DERTaggedObject * @class class for ASN.1 DER TaggedObject * @extends KJUR.asn1.ASN1Object + * @see KJUR_asn1.ASN1Util.newObject * * @description *
    @@ -1737,12 +1738,20 @@ extendClass(KJUR.asn1.DERSet, KJUR.asn1.DERAbstractStructured); *
  • tag - specify tag (default is 'a0' which means [0])
  • *
  • explicit - specify true if this is explicit tag otherwise false * (default is 'true').
  • - *
  • obj - specify ASN1Object which is tagged
  • + *
  • obj - specify ASN1Object or JSON object which will be tagged
  • *
  • tage - specify tag with explicit
  • *
  • tagi - specify tag with implicit
  • * + * As for the member "obj" value of JSON object, + * {@link KJUR_asn1.ASN1Util.newObject} is used to generate. * * @example + * // by JSON + * new KJUR.asn1.DERTaggedObject({ + * tag:'a0', explicit: true, obj: { "prnstr": { "str": "aaa" } } + * }).tohex() + * + * // by ASN1Object object * new KJUR.asn1.DERTaggedObject({ * tage:'a0', obj: new KJUR.asn1.DERInteger({int: 3}) // explicit * }) diff --git a/src/asn1x509-1.0.js b/src/asn1x509-1.0.js index aba18d8f..af71f187 100644 --- a/src/asn1x509-1.0.js +++ b/src/asn1x509-1.0.js @@ -1,4 +1,4 @@ -/* asn1x509-2.1.16.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +/* asn1x509-2.1.17.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /* * asn1x509.js - ASN.1 DER encoder classes for X.509 certificate @@ -16,7 +16,7 @@ * @fileOverview * @name asn1x509-1.0.js * @author Kenji Urushima kenji.urushima@gmail.com - * @version jsrsasign 10.5.22 asn1x509 2.1.16 (2022-May-24) + * @version jsrsasign 10.6.0 asn1x509 2.1.17 (2022-Nov-04) * @since jsrsasign 2.1 * @license MIT License */ @@ -4008,7 +4008,7 @@ KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV = { * gn = new KJUR.asn1.x509.GeneralName({uri: 'http://aaa.com/'}); * gn = new KJUR.asn1.x509.GeneralName({other: { * oid: "1.2.3.4", - * value: {utf8: "example"} // any ASN.1 which passed to ASN1Util.newObject + * value: {utf8str: "example"} // any ASN.1 which passed to ASN1Util.newObject * }}); * * gn = new KJUR.asn1.x509.GeneralName({ldapdn: 'O=Test,C=US'}); // DEPRECATED @@ -4200,7 +4200,7 @@ extendClass(KJUR.asn1.x509.GeneralNames, KJUR.asn1.ASN1Object); * Constructor has two members: *
      *
    • oid - oid string (ex. "1.2.3.4")
    • - *
    • value - associative array passed to ASN1Util.newObject
    • + *
    • value - JSON object passed to ASN1Util.newObject or ASN1Object object
    • *
    * *
    @@ -4379,6 +4379,9 @@ KJUR.asn1.x509.OID = new function() {
             'timeStamping':         '1.3.6.1.5.5.7.3.8',
             'ocspSigning':          '1.3.6.1.5.5.7.3.9',
     
    +	// 'otherNameForms':	'1.3.6.1.5.5.7.8',
    +	'smtpUTF8Mailbox':	'1.3.6.1.5.5.7.8.9',
    +
             'dateOfBirth':          '1.3.6.1.5.5.7.9.1',
             'placeOfBirth':         '1.3.6.1.5.5.7.9.2',
             'gender':               '1.3.6.1.5.5.7.9.3',
    diff --git a/src/x509-1.1.js b/src/x509-1.1.js
    index 2c178416..06dd81a8 100644
    --- a/src/x509-1.1.js
    +++ b/src/x509-1.1.js
    @@ -1,4 +1,4 @@
    -/* x509-2.0.17.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
    +/* x509-2.1.0.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
      */
     /*
      * x509.js - X509 class to read subject public key from certificate.
    @@ -16,7 +16,7 @@
      * @fileOverview
      * @name x509-1.1.js
      * @author Kenji Urushima kenji.urushima@gmail.com
    - * @version jsrsasign 10.5.24 x509 2.0.17 (2022-Jun-04)
    + * @version jsrsasign 10.6.0 x509 2.1.0 (2022-Nov-04)
      * @since jsrsasign 1.x.x
      * @license MIT License
      */
    @@ -239,18 +239,35 @@ function X509(params) {
          * @name getIssuer
          * @memberOf X509#
          * @function
    +     * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false)
    +     * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false)
          * @return {Array} JSON object of issuer field
          * @since jsrsasign 9.0.0 x509 2.0.0
          * @see X509#getX500Name
    +     *
          * @description
    +     * Get a JSON object of an issuer field.
    +     * 
    + * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been + * supported to conclude a canonicalized name for caseIgnoreMatch + * desribed in + * RFC 4518. + * * @example * var x = new X509(sCertPEM); * x.getIssuer() → * { array: [[{type:'C',value:'JP',ds:'prn'}],...], * str: "/C=JP/..." } + * + * // with flags + * x.getIssuer(true, true) → + * { array: ..., + * str: "/C=JP/O= Test 123 ", + * canon: "/c=jp/o=test 123", + * hex: "30..." } */ - this.getIssuer = function() { - return this.getX500Name(this.getIssuerHex()) + this.getIssuer = function(flagCanon, flagHex) { + return this.getX500Name(this.getIssuerHex(), flagCanon, flagHex); }; /** @@ -291,18 +308,35 @@ function X509(params) { * @name getSubject * @memberOf X509# * @function - * @return {Array} JSON object of subject field + * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false) + * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false) + * @return {object} JSON object of subject field * @since jsrsasign 9.0.0 x509 2.0.0 * @see X509#getX500Name + * * @description + * Get a JSON object of a subject field. + *
    + * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been + * supported to conclude a canonicalized name for caseIgnoreMatch + * desribed in + * RFC 4518. + * * @example * var x = new X509(sCertPEM); * x.getSubject() → * { array: [[{type:'C',value:'JP',ds:'prn'}],...], * str: "/C=JP/..." } + * + * // with flags + * x.getSubject(true, true) → + * { array: ..., + * str: "/C=JP/O= Test 123 ", + * canon: "/c=jp/o=test 123", + * hex: "30..." } */ - this.getSubject = function() { - return this.getX500Name(this.getSubjectHex()); + this.getSubject = function(flagCanon, flagHex) { + return this.getX500Name(this.getSubjectHex(), flagCanon, flagHex); }; /** @@ -1871,16 +1905,15 @@ function X509(params) { * x = new X509(); * x.getOtherName("30...") → * { oid: "1.2.3.4", - * other: {utf8str: {str: "aaa"}} } + * value: {utf8str: {str: "aaa"}} } */ this.getOtherName = function(h) { var result = {}; - var a = _getChildIdx(h, 0); var hOID = _getVbyList(h, a[0], [], "06"); var hValue = _getVbyList(h, a[1], []); - result.oid = KJUR.asn1.ASN1Util.oidHexToInt(hOID); - result.obj = _ASN1HEX_parse(hValue); + result.oid = _oidname(hOID); + result.value = _ASN1HEX_parse(hValue); return result; }; @@ -2492,14 +2525,18 @@ function X509(params) { * @memberOf X509# * @function * @param {String} h hexadecimal string of Name + * @param {boolean} flagCanon flag to conclude canonicalized name (DEFAULT false) + * @param {boolean} flagHex flag to conclude hexadecimal string (DEFAULT false) * @return {Array} array of RDN parameter array * @since jsrsasign 9.0.0 x509 2.0.0 * @see X509#getX500NameArray * @see X509#getRDN * @see X509#getAttrTypeAndValue + * @see X509#c14nRDNArray * @see KJUR.asn1.x509.X500Name * @see KJUR.asn1.x509.GeneralName * @see KJUR.asn1.x509.GeneralNames + * * @description * This method will get Name parameter defined in * @@ -2509,6 +2546,12 @@ function X509(params) { * rdnSequence RDNSequence } * RDNSequence ::= SEQUENCE OF RelativeDistinguishedName *
    + *
    + * NOTE: From jsrsasign 10.6.0, flagHex and flagCanon has been + * supported to conclude a canonicalized name for caseIgnoreMatch + * desribed in
    + * RFC 4518. + * * @example * x = new X509(); * x.getX500Name("30...") → @@ -2518,13 +2561,26 @@ function X509(params) { * [{type:"CN",value:"john.smith@example.com",ds:"ia5"}] * ], * str: "/C=US/O=Sample Corp./CN=john.smith@example.com", - * hex: "30..." - * } + * hex: "30..." } + * + * x.getX500Name("30...", true) → + * { array: [ + * [{type:"C",value:"US",ds:"prn"}], + * [{type:"O",value:"Sample Corp.",ds:"utf8"}] + * ], + * str: "/C=US/O=Sample Corp.", + * canon: "/c=us/o=sample corp.", + * hex: "30..." } */ - this.getX500Name = function(h) { + this.getX500Name = function(h, flagCanon, flagHex) { var a = this.getX500NameArray(h); var s = this.dnarraytostr(a); - return { array: a, str: s }; + var result = { str: s }; + + result.array = a; + if (flagHex == true) result.hex = h; + if (flagCanon == true) result.canon = this.c14nRDNArray(a); + return result; }; // ===== END X500Name related ===================================== @@ -2583,15 +2639,20 @@ function X509(params) { * This method returns a JSON object of the certificate * parameters. Return value can be passed to * {@link KJUR.asn1.x509.X509Util.newCertPEM}. - *
    + *
    * NOTE1: From jsrsasign 10.5.16, optional argument can be applied. * It can have following members: *
      - *
    • tbshex - if this is true, tbshex member with hex value of - * tbsCertificate will be added
    • - *
    • nodnarray - if this is true, array member for subject and - * issuer will be deleted to simplify it
    • + *
    • tbshex - (boolean) tbshex member with hex value of + * tbsCertificate will be added if true (DEFAULT undefined)
    • + *
    • nodnarray - (boolean) array member for subject and + * issuer will be deleted to simplify it if true (DEFAULT undefined)
    • + *
    • dncanon - (boolean) add canon member to subject and issuer for DN StringPrep if true(DEFAULT undefined)
    • + *
    • dnhex - (boolean) add hex member to subject and issuer if true(DEFAULT undefined)
    • *
    + *
    + * NOTE2: From jsrsasign 10.6.0, member "dncanon" and "dnhex" supported + * in the "option" argument. * * @example * x = new X509(); @@ -2618,16 +2679,20 @@ function X509(params) { * * x.getParam({tbshex: true}) → { ... , tbshex: "30..." } * x.getParam({nodnarray: true}) → {issuer: {str: "/C=JP"}, ...} + * x.getParam({dncanon: true}) → {... {issuer: {canon: "/c=jp/o=..."} ...} ...} + * x.getParam({dnhex: true}) → {... {issuer: {hex: "30..."} ...} ...} */ this.getParam = function(option) { var result = {}; + if (option == undefined) option = {}; + result.version = this.getVersion(); result.serial = {hex: this.getSerialNumberHex()}; result.sigalg = this.getSignatureAlgorithmField(); - result.issuer = this.getIssuer(); + result.issuer = this.getIssuer(option.dncanon, option.dnhex); result.notbefore = this.getNotBefore(); result.notafter = this.getNotAfter(); - result.subject = this.getSubject(); + result.subject = this.getSubject(option.dncanon, option.dnhex); result.sbjpubkey = hextopem(this.getPublicKeyHex(), "PUBLIC KEY"); if (this.aExtInfo != undefined && this.aExtInfo.length > 0) { @@ -2636,15 +2701,14 @@ function X509(params) { result.sighex = this.getSignatureValueHex(); // for options - if (typeof option == "object") { - if (option.tbshex == true) { - result.tbshex = _getTLVbyList(this.hex, 0, [0]); - } - if (option.nodnarray == true) { - delete result.issuer.array; - delete result.subject.array; - } + if (option.tbshex == true) { + result.tbshex = _getTLVbyList(this.hex, 0, [0]); + } + if (option.nodnarray == true) { + delete result.issuer.array; + delete result.subject.array; } + return result; }; @@ -2985,6 +3049,98 @@ function X509(params) { return "/" + aDN.map(function(x){return rdnarraytostr(x).replace(/\//, "\\/");}).join("/"); }; + /** + * set canonicalized DN to a DN parameter
    + * @name setCanonicalizedDN + * @memberOf X509# + * @function + * @param {object} pDN DN parameter associative array + * @since jsrsasign 10.6.0 x509 2.1.0 + * + * @description + * This method canonicalizes a DN string as following: + *
      + *
    • convert to lower case
    • + *
    • convert from all multiple spaces to a space
    • + *
    + * + * @example + * var x = new X509(); + * var pDN = { + * array: [ + * [{type:'C',value:'JP',ds:'prn'}], + * [{type:'O',value:'Test 1',ds:'prn'}] ], + * str: "/C=JP/O=Test 1" }; + * x.setCanonicalizedDN(pDN); + + * // pDN will become following + * pDN = { + * array: [ + * [{type:'C',value:'JP',ds:'prn'}], + * [{type:'O',value:'Test 1',ds:'prn'}] ], + * str: "/C=JP/O=Test 1", + * canon: "/c=jp/o=test 1" }; + */ + this.setCanonicalizedDN = function(pDN) { + var aRDN; + if (pDN.str != undefined && pDN.array == undefined) { + var dDN = new KJUR.asn1.x509.X500Name({str: pDN.str}); + var hDN = dDN.tohex(); + aRDN = this.getX500NameArray(hDN); + } else { + aRDN = pDN.array; + } + if (pDN.canon == undefined) { + pDN.canon = this.c14nRDNArray(aRDN); + } + }; + + /** + * simple canonicalization(c14n) for RDN array
    + * @name c14nRDNArray + * @memberOf X509# + * @function + * @param {array} aRDN array of RDN parameters + * @return {string} canonicalized distinguish name (ex. "/c=jp/o=test ca") + * @since jsrsasign 10.6.0 x509 2.1.0 + * + * @description + * This method canonicalizes a DN string according to + * + * "RFC 4518 StringPrep Appendix B Substring Matching" as following: + *
      + *
    • convert to lower case
    • + *
    • convert from all sequence of spaces to a space
    • + *
    • remove leading and trailing spaces
    • + *
    + * + * @example + * var x = new X509(); + * x.c14nRDNArray([ + * [{type:"C", value:"JP", ds: "prn"}], + * [{type:"O", value:" Test 1234 ", ds: "utf8"}], + * [{type:"OU", value:"HR 45", ds: "utf8"}] + * ]) → "/c=jp/o=test 1234/ou=hr 45" + */ + this.c14nRDNArray = function(aRDN) { + var a = []; + for (var i = 0; i < aRDN.length; i++) { + var aAVA = aRDN[i]; + var a2 = []; + for (var j = 0; j < aAVA.length; j++) { + var pAVA = aAVA[j]; + var value = pAVA.value; + value = value.replace(/^\s*/, ''); + value = value.replace(/\s*$/, ''); + value = value.replace(/\s+/g, ' '); + value = value.toLowerCase(); + a2.push(pAVA.type.toLowerCase() + "=" + value); + } + a.push(a2.join("+")); + } + return "/" + a.join("/"); + }; + /** * get certificate information as string.
    * @name getInfo @@ -3022,7 +3178,24 @@ function X509(params) { */ this.getInfo = function() { var _getSubjectAltNameStr = function(params) { - var s = JSON.stringify(params.array).replace(/[\[\]\{\}\"]/g, ''); + var s = ""; + var indent = " "; + var NL = "\n"; + var a = params.array; + for (var i = 0; i < a.length; i++) { + var pGN = a[i]; + if (pGN.dn != undefined) s += indent + "dn: " + pGN.dn.str + NL; + if (pGN.ip != undefined) s += indent + "ip: " + pGN.ip + NL; + if (pGN.rfc822 != undefined) s += indent + "rfc822: " + pGN.rfc822 + NL; + if (pGN.dns != undefined) s += indent + "dns: " + pGN.dns + NL; + if (pGN.uri != undefined) s += indent + "uri: " + pGN.uri + NL; + if (pGN.other != undefined) { + var oidname = pGN.other.oid; + var value = JSON.stringify(pGN.other.value).replace(/\"/g, ''); + s += indent + "other: " + oidname + "=" + value + NL; + } + } + s = s.replace(/\n$/, ''); return s; }; var _getCertificatePoliciesStr = function(params) { @@ -3132,7 +3305,7 @@ function X509(params) { s += " " + eku.join(", ") + "\n"; } else if (extName === "subjectAltName") { var san = _getSubjectAltNameStr(this.getExtSubjectAltName()); - s += " " + san + "\n"; + s += san + "\n"; } else if (extName === "cRLDistributionPoints") { var cdp = this.getExtCRLDistributionPoints(); s += _getCRLDistributionPointsStr(cdp); diff --git a/test/qunit-do-asn1x509.html b/test/qunit-do-asn1x509.html index 39a57b74..e990e58f 100755 --- a/test/qunit-do-asn1x509.html +++ b/test/qunit-do-asn1x509.html @@ -915,12 +915,36 @@ // SubjectAltName test("SubjectAltName", function() { - var o1 = new KJUR.asn1.x509.SubjectAltName({ - critical: true, - array: [{uri: 'http://a.com'}, {uri: 'http://b.com'}] - }); - equal(o1.getExtnValueHex(), "301c860c687474703a2f2f612e636f6d860c687474703a2f2f622e636f6d", "URIs critical"); - equal(o1.getEncodedHex(), "30280603551d110101ff041e301c860c687474703a2f2f612e636f6d860c687474703a2f2f622e636f6d", "ext hex"); +var _SAN = KJUR.asn1.x509.SubjectAltName; +var o, hExpect1, hExpect2; + +o = new _SAN({ + critical: true, + array: [{uri: 'http://a.com'}, {uri: 'http://b.com'}] +}); +hExpect1 = "301c860c687474703a2f2f612e636f6d860c687474703a2f2f622e636f6d"; +hExpect2 = "30280603551d110101ff041e301c860c687474703a2f2f612e636f6d860c687474703a2f2f622e636f6d"; +equal(o.getExtnValueHex(), hExpect1, "URI[2] critical"); +equal(o.tohex(), hExpect2, "URI[2] ext hex"); + +o = new _SAN({array: [{rfc822: "aaa@a.com"}]}); +hExpect1 = "300b810961616140612e636f6d"; +hExpect2 = "30140603551d11040d300b810961616140612e636f6d"; +equal(o.getExtnValueHex(), hExpect1, "RFC822=aaa@a.com extnValue"); +equal(o.tohex(), hExpect2, "RFC822=aaa@a.com ext hex"); + +o = new _SAN({array: [{ip: "192.168.1.5"}]}); +hExpect1 = "30068704c0a80105"; +hExpect2 = "300f0603551d11040830068704c0a80105"; +equal(o.getExtnValueHex(), hExpect1, "IP=192.168.1.5 extnValue"); +equal(o.tohex(), hExpect2, "IP=192.168.1.5 ext hex"); + +o = new _SAN({array: [{other: {oid: "smtpUTF8Mailbox", value: {utf8str: {str: "a@a.com"}}}}]}); +hExpect1 = "3017a01506082b06010505070809a0090c076140612e636f6d"; +hExpect2 = "30200603551d1104193017a01506082b06010505070809a0090c076140612e636f6d"; +equal(o.getExtnValueHex(), hExpect1, "other smtpUTF8Mbox=a@a.com extnValue"); +equal(o.tohex(), hExpect2, "other smtpUTF8Mbox=a@a.com ext hex"); + }); test("IssuerAltName", function() { diff --git a/test/qunit-do-x509-ext.html b/test/qunit-do-x509-ext.html index 2f1c3e7b..5521066b 100755 --- a/test/qunit-do-x509-ext.html +++ b/test/qunit-do-x509-ext.html @@ -904,7 +904,7 @@ pExpect = { other: { oid: "2.16.76.1.3.1", - obj: {prnstr: {str: '260619863371256782000000000000000000000000000'}} + value: {prnstr: {str: '260619863371256782000000000000000000000000000'}} } }; deepEqual(x.getGeneralName(hIn), pExpect, "other brazil"); @@ -913,7 +913,7 @@ pExpect = { other: { oid: "1.2.392.200149.8.5.5.1", - obj: {utf8str: {str: '山田 太郎'}} + value: {utf8str: {str: '山田 太郎'}} } }; deepEqual(x.getGeneralName(hIn), pExpect, "other jpki cn"); diff --git a/test/qunit-do-x509-getinfo.html b/test/qunit-do-x509-getinfo.html index f9487d54..e3d243c0 100644 --- a/test/qunit-do-x509-getinfo.html +++ b/test/qunit-do-x509-getinfo.html @@ -185,6 +185,23 @@ B9LZ8g== */}).toString().match(/\/\*([^]*)\*\//)[1]; +// _test/??? +var san1PEM = (function() {/* +-----BEGIN CERTIFICATE----- +MIICCjCCAXOgAwIBAgIBATANBgkqhkiG9w0BAQsFADAeMQswCQYDVQQGEwJKUDEP +MA0GA1UECgwGVGVzdENBMB4XDTIyMTAyODE0MDAwM1oXDTIzMTAyODE0MDAwM1ow +EDEOMAwGA1UEAwwFYS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALDi +kFExZMEW5bwsj9DckEA+Ai7jYe7+In5UHpsqCaqXlPlJQFpziDWDHp1IlWI6r+nZ +/7AJhS3y6wbVrF8IN4ohKaga1LIL3RDfnGbm4QcF06rrE0vHkMALUu0o/7zmR0qU +geNnRhd21J/+5vt9nzbaigklghW3DKYCaZN/n3CbAgMBAAGjZjBkMGIGA1UdEQRb +MFmkHDAaMQswCQYDVQQGEwJKUDELMAkGA1UECgwCTzGHBMCoAQWBB2FAYS5jb22G +DGh0dHA6Ly9hLmNvbYIFYS5jb22gFQYIKwYBBQUHCAmgCQwHYUBhLmNvbTANBgkq +hkiG9w0BAQsFAAOBgQATHBsnLqNsnH+3xH+tj8u1HXrQb3Z3AmPQ/W++kvlOMi1i +o/WbHGa3lrJCYomw7O1U36HkCedSCPbv2zoof0MYVLa4XyWt8DuL9GT/WTO9vHzv +Y0OgvwaSbp0daCfOHdXDGb8E2qJXutdNgAvXl/gprZ6dM0c8d0kLUs+hTuAHpw== +-----END CERTIFICATE----- +*/}).toString().match(/\/\*([^]*)\*\//)[1]; + // _test/0cert/digicertevroot.cer var certDigicertOUT = (function() {/*Basic Fields serial number: 02ac5c266a0b409b8f0b79f2ae462577 @@ -237,7 +254,9 @@ ocsp: http://ocsp.int-x3.letsencrypt.org/ caissuer: http://cert.int-x3.letsencrypt.org/ subjectAltName : - dns:https.cio.gov,dns:pulse.cio.gov,dns:staging.pulse.cio.gov + dns: https.cio.gov + dns: pulse.cio.gov + dns: staging.pulse.cio.gov certificatePolicies : policy oid: 2.23.140.1.2.1 policy oid: 1.3.6.1.4.1.44947.1.1.1 @@ -264,7 +283,8 @@ subjectKeyIdentifier : 6a43907d3b98147252953aaa280a43f8517ed3a6 subjectAltName : - dns:github.com,dns:www.github.com + dns: github.com + dns: www.github.com keyUsage CRITICAL: digitalSignature,keyEncipherment extKeyUsage : @@ -306,7 +326,7 @@ policy oid: 1.2.208.169.1.1.1.3.4 cps: http://www.trust2408.com/repository subjectAltName : - rfc822:apotekerforeningen@apotekerforeningen.dk + rfc822: apotekerforeningen@apotekerforeningen.dk cRLDistributionPoints : http://crl.ica02.trust2408.com/ica02.crl authorityKeyIdentifier : @@ -319,31 +339,55 @@ signature: 5a0323b8bc53d46b... */}).toString().match(/\/\*([^]*)\*\//)[1]; +// _test/??? +var san1OUT = (function() {/*Basic Fields + serial number: 01 + signature algorithm: SHA256withRSA + issuer: /C=JP/O=TestCA + notBefore: 221028140003Z + notAfter: 231028140003Z + subject: /CN=a.com + subject public key info: + key algorithm: RSA + n=00b0e290513164c1... + e=010001 +X509v3 Extensions: + subjectAltName : + dn: /C=JP/O=O1 + ip: 192.168.1.5 + rfc822: a@a.com + uri: http://a.com + dns: a.com + other: smtpUTF8Mailbox={utf8str:{str:a@a.com}} +signature algorithm: SHA256withRSA +signature: 131c1b272ea36c9c... +*/}).toString().match(/\/\*([^]*)\*\//)[1]; + test("X509.getInfo() DigiCert EV Root", function() { - var c = new X509(); - c.readCertPEM(certDigicertPEM); - //c.readCertPEM(certGithubPEM); - equal(c.getInfo(), certDigicertOUT, certDigicertOUT); +var c = new X509(certDigicertPEM); +equal(c.getInfo(), certDigicertOUT, certDigicertOUT); }); test("X509.getInfo() pulse.cio.gov SSL cert", function() { - var c = new X509(); - c.readCertPEM(certCioGovPEM); - equal(c.getInfo(), certCioGovOUT, certCioGovOUT); +var c = new X509(certCioGovPEM); +equal(c.getInfo(), certCioGovOUT, certCioGovOUT); }); test("X509.getInfo() github.com SSL cert", function() { - var c = new X509(); - c.readCertPEM(certGithubPEM); - equal(c.getInfo(), certGithubOUT, certGithubOUT); +var c = new X509(certGithubPEM); +equal(c.getInfo(), certGithubOUT, certGithubOUT); }); test("X509.getInfo() danmarks user cert", function() { -var x = new X509(); -x.readCertPEM(danmarksUser1PEM); +var x = new X509(danmarksUser1PEM); //deepEqual(x.getExtCertificatePolicies(),{},"cp"); //deepEqual(x.getExtCRLDistributionPoints(),{},"cdp"); -equal(x.getInfo(), danmarksUser1OUT, "danmarksUser1"); +equal(x.getInfo(), danmarksUser1OUT, danmarksUser1OUT); +}); + +test("X509.getInfo() various SAN", function() { +var x = new X509(san1PEM); +equal(x.getInfo(), san1OUT, san1OUT); }); }); @@ -366,7 +410,5 @@

    -

    © 2016-2017 Kenji Urushima

    +

    © 2016-2022 Kenji Urushima

    - - diff --git a/test/qunit-do-x509-param.html b/test/qunit-do-x509-param.html index 96967fed..953f52b2 100755 --- a/test/qunit-do-x509-param.html +++ b/test/qunit-do-x509-param.html @@ -298,6 +298,23 @@ -----END CERTIFICATE----- */}).toString().match(/\/\*([^]*)\*\//)[1]; +// for getParam({dncanon:true,dnhex:true}) test +var dn1PEM = (function() {/* +-----BEGIN CERTIFICATE----- +MIIB3zCCAUigAwIBAgIBATANBgkqhkiG9w0BAQsFADAeMQswCQYDVQQGEwJKUDEP +MA0GA1UECgwGVGVzdENBMB4XDTIyMTAyODE0MDAwM1oXDTIzMTAyODE0MDAwM1ow +PjELMAkGA1UEBhMCSlAxHzAdBgNVBAoMFiAgICBUZXN0ICAgICBPcmcxICAgICAx +DjAMBgNVBAMMBVVzZXIxMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw4pBR +MWTBFuW8LI/Q3JBAPgIu42Hu/iJ+VB6bKgmql5T5SUBac4g1gx6dSJViOq/p2f+w +CYUt8usG1axfCDeKISmoGtSyC90Q35xm5uEHBdOq6xNLx5DAC1LtKP+85kdKlIHj +Z0YXdtSf/ub7fZ822ooJJYIVtwymAmmTf59wmwIDAQABow0wCzAJBgNVHRMEAjAA +MA0GCSqGSIb3DQEBCwUAA4GBACX9Y1l8dkxrwxDjobQvFzgc6u5DLFQsXoyCoJDb +9QCtZR7g6VLBRMOld0u0nAxaD87N11hWask7O3pe7QyQ45ooCjk+D41jOlW5ymIE +BS6CWMFShsDGV5im/cF5ipyZ2m24eX926OPNEypAMwNnescJaxUcP8AvVCE6xAPh +U5z/ +-----END CERTIFICATE----- +*/}).toString().match(/\/\*([^]*)\*\//)[1]; + // _gitpg/jsrsasign/test/eckey/k1.self.cer var k1CertPEM = "" + "-----BEGIN CERTIFICATE-----\n" + @@ -642,6 +659,40 @@ deepEqual(pIn, pExpected, "NIST PKITS nameConstraints Test01 ICA"); }); +test("getParam canonicalized DN and hex test", function() { +var pIn = new X509(dn1PEM).getParam({dncanon: true, dnhex: true}); +var pExpected = { + version: 3, + serial: {hex: "01"}, + sigalg: "SHA256withRSA", + issuer: { + array: [ + [{ds:"prn",type: "C",value: "JP"}], + [{ds:"utf8",type: "O",value: "TestCA"}] + ], + canon: "/c=jp/o=testca", + hex: "301e310b3009060355040613024a50310f300d060355040a0c06546573744341", + str: "/C=JP/O=TestCA" + }, + notafter: "231028140003Z", + notbefore: "221028140003Z", + subject: { + array: [ + [{ds:"prn",type: "C",value: "JP"}], + [{ds:"utf8",type: "O",value: " Test Org1 "}], + [{ds:"utf8",type: "CN",value: "User1"}] + ], + canon: "/c=jp/o=test org1/cn=user1", + hex: "303e310b3009060355040613024a50311f301d060355040a0c16202020205465737420202020204f7267312020202020310e300c06035504030c055573657231", + str: "/C=JP/O= Test Org1 /CN=User1" + }, + sbjpubkey: "-----BEGIN PUBLIC KEY-----\r\nMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCw4pBRMWTBFuW8LI/Q3JBAPgIu\r\n42Hu/iJ+VB6bKgmql5T5SUBac4g1gx6dSJViOq/p2f+wCYUt8usG1axfCDeKISmo\r\nGtSyC90Q35xm5uEHBdOq6xNLx5DAC1LtKP+85kdKlIHjZ0YXdtSf/ub7fZ822ooJ\r\nJYIVtwymAmmTf59wmwIDAQAB\r\n-----END PUBLIC KEY-----\r\n", + ext: [{extname: "basicConstraints"}], + sighex: "25fd63597c764c6bc310e3a1b42f17381ceaee432c542c5e8c82a090dbf500ad651ee0e952c144c3a5774bb49c0c5a0fcecdd758566ac93b3b7a5eed0c90e39a280a393e0f8d633a55b9ca6204052e8258c15286c0c65798a6fdc1798a9c99da6db8797f76e8e3cd132a403303677ac7096b151c3fc02f54213ac403e1539cff" +}; +deepEqual(pIn, pExpected, JSON.stringify(pExpected)); +}); + test("findParam test", function() { var x = new X509(); var aExt = [{ diff --git a/test/qunit-do-x509.html b/test/qunit-do-x509.html index e4aca938..6ead556f 100755 --- a/test/qunit-do-x509.html +++ b/test/qunit-do-x509.html @@ -412,18 +412,89 @@ equal(key.verify("aab", Z4SHA1AAASIG), false, "check sig is invalid."); }); -test("new X509(PEM).get{Version,SerialNumber,Issuer,Subject,NotBefore,NotAfter} test", function() { - var c = new X509(); - c.readCertPEM(sCer1PEM); - equal(c.getVersion(), 3, "version=3"); - equal(c.getSerialNumberHex(), "009e775e7d9f43abc9", "sn = 02"); - equal(c.getIssuerHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "issuer"); - equal(c.getSubjectHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "subject"); - equal(c.getNotBefore(), "100531061756Z", "notbefore"); - equal(c.getNotAfter(), "200528061756Z", "notafter"); - equal(X509.hex2dn(c.getSubjectHex()), "/C=JP/O=z2", "subjecthex2str"); - equal(c.getIssuerString(), "/C=JP/O=z2", "issuer str"); - equal(c.getSubjectString(), "/C=JP/O=z2", "subject str"); +test("new X509(PEM).get{Version,SerialNumber,IssuerHex,SubjectHex,NotBefore,NotAfter} test", function() { +var c = new X509(sCer1PEM); +equal(c.getVersion(), 3, "version=3"); +equal(c.getSerialNumberHex(), "009e775e7d9f43abc9", "sn = 02"); +equal(c.getIssuerHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "issuer"); +equal(c.getSubjectHex(), "301a310b3009060355040613024a50310b3009060355040a13027a32", "subject"); +equal(c.getNotBefore(), "100531061756Z", "notbefore"); +equal(c.getNotAfter(), "200528061756Z", "notafter"); +equal(X509.hex2dn(c.getSubjectHex()), "/C=JP/O=z2", "subjecthex2str"); +equal(c.getIssuerString(), "/C=JP/O=z2", "issuer str"); +equal(c.getSubjectString(), "/C=JP/O=z2", "subject str"); +}); + +test("getSubject", function() { +var x = new X509(sCer1PEM); +var pExpect; + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2" +}; +deepEqual(x.getSubject(), pExpect, "getSubject /C=JP/O=z2"); + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2", + canon: "/c=jp/o=z2" +}; +deepEqual(x.getSubject(true), pExpect, "getSubject(true) /C=JP/O=z2"); + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2", + canon: "/c=jp/o=z2", + hex: "301a310b3009060355040613024a50310b3009060355040a13027a32" +}; +deepEqual(x.getSubject(true,true), pExpect, "getSubject(true,true) /C=JP/O=z2"); + +}); + +test("getIssuer", function() { +var x = new X509(sCer1PEM); +var pExpect; + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2" +}; +deepEqual(x.getIssuer(), pExpect, "getIssuer /C=JP/O=z2"); + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2", + canon: "/c=jp/o=z2" +}; +deepEqual(x.getIssuer(true), pExpect, "getIssuer(true) /C=JP/O=z2"); + +pExpect = { + array: [ + [{type:"C", value:"JP", ds:"prn"}], + [{type:"O", value:"z2", ds:"prn"}] + ], + str: "/C=JP/O=z2", + canon: "/c=jp/o=z2", + hex: "301a310b3009060355040613024a50310b3009060355040a13027a32" +}; +deepEqual(x.getIssuer(true,true), pExpect, "getIssuer(true,true) /C=JP/O=z2"); + }); /* @@ -568,6 +639,36 @@ equal(x.verifySignature(pubkey), false, "false"); }); +test("setCanonicalizedDN", function() { +var x = new X509(); +var p, pOrg, pExpect; + +p = { str: "/C=JP/O=Test 1234/OU=HR 45" }; +pExpect = { + str: "/C=JP/O=Test 1234/OU=HR 45", + canon: "/c=jp/o=test 1234/ou=hr 45" +}; +x.setCanonicalizedDN(p); +deepEqual(p, pExpect, "hoge"); + +p = {array: [ + [{type:"C", value:"JP", ds: "prn"}], + [{type:"O", value:"Test 1234", ds: "utf8"}], + [{type:"OU", value:"HR 45", ds: "utf8"}] +]}; +pExpect = { +array: [ + [{type:"C", value:"JP", ds: "prn"}], + [{type:"O", value:"Test 1234", ds: "utf8"}], + [{type:"OU", value:"HR 45", ds: "utf8"}] +], +canon: "/c=jp/o=test 1234/ou=hr 45" +}; +x.setCanonicalizedDN(p); +deepEqual(p, pExpect, "hoge2"); + +}); + });