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 @@
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 @@+
+
+ 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 @@- See:
+ +- KJUR_asn1.ASN1Util.newObject
+ +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 @@
@@ -1275,10 +1292,10 @@ -
@@ -1325,7 +1342,7 @@ - getSubject() +getSubject(flagCanon, flagHex)get JSON object of subject field+Get a JSON object of a subject field.
-
+ - 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 @@
+ ++ + +setCanonicalizedDN(pDN) ++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 @@@@ -4793,7 +4924,9 @@
{Array} - getIssuer() + getIssuer(flagCanon, flagHex)get JSON object of issuer field@@ -4549,11 +4651,35 @@
- +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.
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.}; 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@@ -5732,11 +5870,35 @@
- +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.
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 @@
@@ -6055,6 +6242,8 @@
@@ -5983,7 +6145,7 @@
- Returns:
-- {Array} JSON object of subject field
+- {object} JSON object of subject field
{Array} - getX500Name(h) + getX500Name(h, flagCanon, flagHex)@@ -5996,6 +6158,11 @@@@ -6010,8 +6177,16 @@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.[{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)
+
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: ++
+ + +- convert to lower case
+- convert from all multiple spaces to a space
+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