diff --git a/ChangeLog.txt b/ChangeLog.txt index 30718283..43d447cc 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,18 @@ ChangeLog for jsrsasign +BitString parsing bug fix +* Changes from 10.5.22 to 10.5.23 (2022-May-27) + - src/base64x.js + - bitstrtobinstr bugfix fix + - src/asn1hex.js + - ASN1HEX.parse change for bin string range + - npm/lib/footers.js + - add missed exports (bitstrtobinstr, binstrtobitstr, + namearraytobinstr, extendClass) + - test/qunit-do-{asn1hex-parse,base64x}.html + - add and fix some test cases for above + DERBitString, KeyUsage and tsp PKIFailureInfo critical bug fix * Changes from 10.5.21 to 10.5.22 (2022-May-24) - src/asn1.js diff --git a/api/files.html b/api/files.html index c2bc008e..383d35ca 100644 --- a/api/files.html +++ b/api/files.html @@ -605,7 +605,7 @@
binstrtobitstr("101") → "05a0" +binstrtobitstr("001") → "0520" binstrtobitstr("11001") → "03c8" binstrtobitstr("101000001") → "07a080" binstrtobitstr(101) → null // not number @@ -1856,9 +1857,10 @@diff --git a/api/symbols/src/asn1hex-1.1.js.html b/api/symbols/src/asn1hex-1.1.js.html index 128f781c..a0b45cf9 100644 --- a/api/symbols/src/asn1hex-1.1.js.html +++ b/api/symbols/src/asn1hex-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;} -
bitstrtobinstr("05a0") → "101" +bitstrtobinstr("0520") → "001" bitstrtobinstr("07a080") → "101000001" -bitstrtoint(502) → null // non ASN.1 BitString value -bitstrtoint("ff00") → -1 // for improper BitString value+bitstrtobinstr(502) → null // non ASN.1 BitString value +bitstrtobinstr("ff00") → null // for improper BitString value
1 /* asn1hex-1.2.14.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +1 /* asn1hex-1.2.15.js (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license 2 */ 3 /* 4 * asn1hex.js - Hexadecimal represented ASN.1 string library @@ -23,7 +23,7 @@ 16 * @fileOverview 17 * @name asn1hex-1.1.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 10.5.16 asn1hex 1.2.14 (2022-Apr-08) + 19 * @version jsrsasign 10.5.23 asn1hex 1.2.15 (2022-May-27) 20 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 21 */ 22 @@ -1076,7 +1076,7 @@ 1069 return {bitstr: {obj: _parse(hV1)}}; 1070 } catch(ex) { 1071 var bV = null; -1072 if (hV.length <= 6) bV = bitstrtobinstr(hV); +1072 if (hV.length <= 10) bV = bitstrtobinstr(hV); 1073 if (bV == null) { 1074 return {bitstr: {hex: hV}}; 1075 } else { diff --git a/api/symbols/src/base64x-1.1.js.html b/api/symbols/src/base64x-1.1.js.html index 2cc4f1a2..00cac176 100644 --- a/api/symbols/src/base64x-1.1.js.html +++ b/api/symbols/src/base64x-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 /* base64x-1.1.28 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +1 /* base64x-1.1.29 (c) 2012-2022 Kenji Urushima | kjur.github.io/jsrsasign/license 2 */ 3 /* 4 * base64x.js - Base64url and supplementary functions for Tom Wu's base64.js library @@ -23,7 +23,7 @@ 16 * @fileOverview 17 * @name base64x-1.1.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 10.5.22 base64x 1.1.28 (2022-May-24) + 19 * @version jsrsasign 10.5.23 base64x 1.1.29 (2022-May-27) 20 * @since jsrsasign 2.1 21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 22 */ @@ -1741,123 +1741,141 @@ 1734 * 1735 * @example 1736 * bitstrtobinstr("05a0") → "101" -1737 * bitstrtobinstr("07a080") → "101000001" -1738 * bitstrtoint(502) → null // non ASN.1 BitString value -1739 * bitstrtoint("ff00") → -1 // for improper BitString value -1740 */ -1741 function bitstrtobinstr(h) { -1742 var n = bitstrtoint(h); -1743 if (n == -1) return null; -1744 return n.toString(2); -1745 } -1746 -1747 /** -1748 * convert from binary string to hexadecimal string of ASN.1 BitString value with unused bit<br/> -1749 * @name binstrtobitstr -1750 * @function -1751 * @param {string} s binary string (ex. "101") -1752 * @return {string} hexadecimal string of ASN.1 BitString value with unused bit -1753 * @since jsrsasign 10.5.4 base64x 1.1.21 -1754 * @see bitstrtobinstr -1755 * @see inttobitstr -1756 * @see KJUR.asn1.DERBitString -1757 * -1758 * @description -1759 * This function converts from an binary string (ex. "101") to -1760 * hexadecimal string of ASN.1 BitString value -1761 * with unused bit (ex. "05a0"). <br/> -1762 * When "s" is not binary string, this returns null. -1763 * -1764 * @example -1765 * binstrtobitstr("101") → "05a0" -1766 * binstrtobitstr("11001") → "03c8" -1767 * binstrtobitstr("101000001") → "07a080" -1768 * binstrtobitstr(101) → null // not number -1769 * binstrtobitstr("xyz") → null // not binary string -1770 */ -1771 function binstrtobitstr(s) { -1772 if (typeof s != "string") return null; -1773 if (s.match(/^[01]+$/) == null) return null; -1774 try { -1775 var n = parseInt(s, 2); -1776 return inttobitstr(n); -1777 } catch(ex) { -1778 return null; -1779 } -1780 } -1781 -1782 // ======================================================= -1783 /** -1784 * convert array of names to bit string<br/> -1785 * @name namearraytobinstr -1786 * @function -1787 * @param {array} namearray array of name string -1788 * @param {object} namedb associative array of name and value -1789 * @return {string} binary string (ex. "110001") -1790 * @since jsrsasign 10.5.21 base64x 1.1.27 -1791 * @see KJUR.asn1.x509.KeyUsage -1792 * @see KJUR.asn1.tsp.PKIFailureInfo -1793 * -1794 * @description -1795 * This function converts from an array of names to -1796 * a binary string. DB value bit will be set. -1797 * Note that ordering of namearray items -1798 * will be ignored. -1799 * -1800 * @example -1801 * db = { a: 0, b: 3, c: 8, d: 9, e: 17, f: 19 }; -1802 * namearraytobinstr(['a', 'c', 'd'], db) &rarr: '1000000011' -1803 * namearraytobinstr(['c', 'b'], db) &rarr: '000100001' -1804 */ -1805 function namearraytobinstr (namearray, namedb) { -1806 var d = 0; -1807 for (var i = 0; i < namearray.length; i++) { -1808 d |= 1 << namedb[namearray[i]]; -1809 } -1810 -1811 var s = d.toString(2); -1812 var r = ""; -1813 for (var i = s.length - 1; i >=0; i--) { -1814 r += s[i]; -1815 } -1816 return r; -1817 } -1818 -1819 // ======================================================= -1820 /** -1821 * set class inheritance<br/> -1822 * @name extendClass -1823 * @function -1824 * @param {Function} subClass sub class to set inheritance -1825 * @param {Function} superClass super class to inherit -1826 * @since jsrsasign 10.3.0 base64x 1.1.21 -1827 * -1828 * @description -1829 * This function extends a class and set an inheritance -1830 * for member variables and methods. -1831 * -1832 * @example -1833 * var Animal = function() { -1834 * this.hello = function(){console.log("Hello")}; -1835 * this.name="Ani"; -1836 * }; -1837 * var Dog = function() { -1838 * Dog.superclass.constructor.call(this); -1839 * this.vow = function(){console.log("Vow wow")}; -1840 * this.tail=true; -1841 * }; -1842 * extendClass(Dog, Animal); -1843 */ -1844 function extendClass(subClass, superClass) { -1845 var F = function() {}; -1846 F.prototype = superClass.prototype; -1847 subClass.prototype = new F(); -1848 subClass.prototype.constructor = subClass; -1849 subClass.superclass = superClass.prototype; -1850 -1851 if (superClass.prototype.constructor == Object.prototype.constructor) { -1852 superClass.prototype.constructor = superClass; -1853 } -1854 }; -1855 -1856