diff --git a/ChangeLog.txt b/ChangeLog.txt index 7baa3f9c..5c4d5b65 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,33 @@ ChangeLog for jsrsasign +ASN.1 parser update and fix +* Changes from 10.5.3 to 10.5.4 (2022-Feb-15) + - src/asn1.js + - DERTaggedObject + - refactoring + - add {tag: xx, str:"aaa"} parameter support + - add {tag: xx, hex:"616161"} parameter support + - setASN1Object method now *deprecated*. Please use setByParam + - src/asn1hex.js + - ASN1HEX.parse + - add encapsulated OctetString, BitString support + - add encapsulated structured TaggedObject support + - changed to return binary string for 3byte or less BitString value + - ObjectIdentifier fix when undefined OID name + - src/base64x.js + - added bitstrtobinstr/binstrtobitstr + - utf8tohex fix for lower case hexadecimal string + - hextoutf8 fix for improper hexadecimal string for UTF-8 + - bitstrtoint/inttobitstr fix for error case return + - test/qunit-do-asn1.html + - TaggedObject test case update + - test/qunit-do-asn1hex-parse.html + - BitString, TaggedObject test case update + - test/qunit-do-base64x.html + - hextoutf8/utf8tohex testcase update + - bitstrtobinstr/binstrtobitstr testcase added + add OtherName support in GeneralName * Changes from 10.5.2 to 10.5.3 (2022-Feb-10) - add otherName support in GeneralName by PR diff --git a/api/files.html b/api/files.html index d3f3cf6b..da45c0e0 100644 --- a/api/files.html +++ b/api/files.html @@ -525,7 +525,7 @@
o = new KJUR.asn1.DERBitString(); -o.setByBooleanArray("01011");+o.setByBinaryString("01011"); diff --git a/api/symbols/KJUR.asn1.DERTaggedObject.html b/api/symbols/KJUR.asn1.DERTaggedObject.html index 4dcea0c1..82f3da45 100644 --- a/api/symbols/KJUR.asn1.DERTaggedObject.html +++ b/api/symbols/KJUR.asn1.DERTaggedObject.html @@ -722,6 +722,13 @@
binstrtobitstr("101") → "05a0" +binstrtobitstr("11001") → "03c8" +binstrtobitstr("101000001") → "07a080" +binstrtobitstr(101) → null // not number +binstrtobitstr("xyz") → null // not binary string+ + + + +
bitstrtobinstr("05a0") → "101" +bitstrtobinstr("07a080") → "101000001" +bitstrtoint(502) → null // non ASN.1 BitString value +bitstrtoint("ff00") → -1 // for improper BitString value+ + + + +
// 25 → 11001b → 11001000b unusedbit=03 → 0xc8 unusedbit=03 → "03c8" -inttobitstr(25) → "03c8"+inttobitstr(25) → "03c8" +inttobitstr(-3) → null +inttobitstr("abc") → null +inttobitstr(parseInt("11001", 2)) → "03c8" +inttobitstr(parseInt("101", 2)) → "05a0" +inttobitstr(parseInt("101000001", 2)) → "07a080" diff --git a/api/symbols/src/asn1-1.0.js.html b/api/symbols/src/asn1-1.0.js.html index 0a9d2d2d..0256dd45 100644 --- a/api/symbols/src/asn1-1.0.js.html +++ b/api/symbols/src/asn1-1.0.js.html @@ -5,12 +5,12 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
1 /* asn1-1.0.22.js (c) 2013-2021 Kenji Urushima | kjur.github.io/jsrsasign/license +1 /* asn1-1.0.23.js (c) 2013-2022 Kenji Urushima | kjur.github.io/jsrsasign/license 2 */ 3 /* 4 * asn1.js - ASN.1 DER encoder classes 5 * - 6 * Copyright (c) 2013-2020 Kenji Urushima (kenji.urushima@gmail.com) + 6 * Copyright (c) 2013-2022 Kenji Urushima (kenji.urushima@gmail.com) 7 * 8 * This software is licensed under the terms of the MIT License. 9 * https://kjur.github.io/jsrsasign/license @@ -23,7 +23,7 @@ 16 * @fileOverview 17 * @name asn1-1.0.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 10.4.1 asn1 1.0.22 (2021-Sep-30) + 19 * @version jsrsasign 10.5.4 asn1 1.0.23 (2022-Feb-14) 20 * @since jsrsasign 2.1 21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 22 */ @@ -1048,7 +1048,7 @@ 1041 * NOTE: Trailing zeros '0' will be ignored. 1042 * @example 1043 * o = new KJUR.asn1.DERBitString(); -1044 * o.setByBooleanArray("01011"); +1044 * o.setByBinaryString("01011"); 1045 */ 1046 this.setByBinaryString = function(binaryString) { 1047 binaryString = binaryString.replace(/0+$/, ''); @@ -1763,69 +1763,81 @@ 1756 KJUR.asn1.DERTaggedObject = function(params) { 1757 KJUR.asn1.DERTaggedObject.superclass.constructor.call(this); 1758 -1759 var _KJUR_asn1 = KJUR.asn1; -1760 -1761 this.hT = "a0"; -1762 this.hV = ''; -1763 this.isExplicit = true; -1764 this.asn1Object = null; -1765 -1766 /** -1767 * set value by an ASN1Object -1768 * @name setString -1769 * @memberOf KJUR.asn1.DERTaggedObject# -1770 * @function -1771 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag -1772 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag -1773 * @param {ASN1Object} asn1Object ASN.1 to encapsulate -1774 */ -1775 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) { -1776 this.hT = tagNoHex; -1777 this.isExplicit = isExplicitFlag; -1778 this.asn1Object = asn1Object; -1779 if (this.isExplicit) { -1780 this.hV = this.asn1Object.getEncodedHex(); -1781 this.hTLV = null; -1782 this.isModified = true; -1783 } else { -1784 this.hV = null; -1785 this.hTLV = asn1Object.getEncodedHex(); -1786 this.hTLV = this.hTLV.replace(/^../, tagNoHex); -1787 this.isModified = false; -1788 } -1789 }; -1790 -1791 this.getFreshValueHex = function() { -1792 return this.hV; -1793 }; -1794 -1795 this.setByParam = function(params) { -1796 if (params.tag != undefined) { -1797 this.hT = params.tag; -1798 } -1799 if (params.explicit != undefined) { -1800 this.isExplicit = params.explicit; -1801 } -1802 if (params.tage != undefined) { -1803 this.hT = params.tage; -1804 this.isExplicit = true; -1805 } -1806 if (params.tagi != undefined) { -1807 this.hT = params.tagi; -1808 this.isExplicit = false; -1809 } -1810 if (params.obj != undefined) { -1811 if (params.obj instanceof _KJUR_asn1.ASN1Object) { -1812 this.asn1Object = params.obj; -1813 this.setASN1Object(this.isExplicit, this.hT, this.asn1Object); -1814 } else if (typeof params.obj == "object") { -1815 this.asn1Object = _KJUR_asn1.ASN1Util.newObject(params.obj); -1816 this.setASN1Object(this.isExplicit, this.hT, this.asn1Object); -1817 } -1818 } -1819 }; +1759 var _KJUR_asn1 = KJUR.asn1, +1760 _ASN1HEX = ASN1HEX, +1761 _getV = _ASN1HEX.getV, +1762 _isASN1HEX = _ASN1HEX.isASN1HEX, +1763 _newObject = _KJUR_asn1.ASN1Util.newObject; +1764 +1765 this.hT = "a0"; +1766 this.hV = ''; +1767 this.isExplicit = true; +1768 this.asn1Object = null; +1769 this.params = {tag: "a0", explicit: true}; //"tag": "a0, "explicit": true}; +1770 +1771 /** +1772 * set value by an ASN1Object +1773 * @name setString +1774 * @memberOf KJUR.asn1.DERTaggedObject# +1775 * @function +1776 * @param {Boolean} isExplicitFlag flag for explicit/implicit tag +1777 * @param {Integer} tagNoHex hexadecimal string of ASN.1 tag +1778 * @param {ASN1Object} asn1Object ASN.1 to encapsulate +1779 * @deprecated since jsrsasign 10.5.4 please use setByParam instead +1780 */ +1781 this.setASN1Object = function(isExplicitFlag, tagNoHex, asn1Object) { +1782 this.params = {tag: tagNoHex, +1783 explicit: isExplicitFlag, +1784 obj: asn1Object}; +1785 }; +1786 +1787 this.getFreshValueHex = function() { +1788 var params = this.params; +1789 +1790 if (params.explicit == undefined) params.explicit = true; +1791 +1792 if (params.tage != undefined) { +1793 params.tag = params.tage; +1794 params.explicit = true; +1795 } +1796 if (params.tagi != undefined) { +1797 params.tag = params.tagi; +1798 params.explicit = false; +1799 } +1800 +1801 if (params.str != undefined) { +1802 this.hV = utf8tohex(params.str); +1803 } else if (params.hex != undefined) { +1804 this.hV = params.hex; +1805 } else if (params.obj != undefined) { +1806 var hV1; +1807 if (params.obj instanceof _KJUR_asn1.ASN1Object) { +1808 hV1 = params.obj.getEncodedHex(); +1809 } else if (typeof params.obj == "object") { +1810 hV1 = _newObject(params.obj).getEncodedHex(); +1811 } +1812 if (params.explicit) { +1813 this.hV = hV1; +1814 } else { +1815 this.hV = _getV(hV1, 0); +1816 } +1817 } else { +1818 throw new Error("str, hex nor obj not specified"); +1819 } 1820 -1821 if (params != undefined) this.setByParam(params); -1822 }; -1823 extendClass(KJUR.asn1.DERTaggedObject, KJUR.asn1.ASN1Object); -1824