diff --git a/ChangeLog.txt b/ChangeLog.txt index 0e9973d5..048dfdc5 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,14 @@ ChangeLog for jsrsasign +CSRUtil class enhancement +* Changes from 10.5.25 to 10.5.26 (2022-Jul-14) + - src/asn1csr.js + - CSRUtil.verifySignature method added + - CSRUtil.getParam enhanced to support optional argument flagTBS + - test/qunit-do-asn1csr.html + - update some test cases for above + CVE-2022-25898 Security fix in JWS and JWT validation * Changes from 10.5.24 to 10.5.25 (2022-Jun-23) - src/jws.js diff --git a/README.md b/README.md index d53f8f3c..2fc229d4 100755 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ HIGHLIGHTS - no dependency to other library - no dependency to [W3C Web Cryptography API](https://www.w3.org/TR/WebCryptoAPI/) nor [OpenSSL](https://www.openssl.org/) - no dependency on newer ECMAScirpt function. So old browsers also supported. -- very popular crypto library with [0.6M+ npm downloads/month](https://npm-stat.com/charts.html?package=jsrsasign&from=2016-05-01&to=2022-06-20) +- very popular crypto library with [0.6M+ npm downloads/month](https://npm-stat.com/charts.html?package=jsrsasign&from=2016-05-01&to=2022-07-07) INSTALL ------- diff --git a/api/files.html b/api/files.html index 43075a73..545d93c3 100644 --- a/api/files.html +++ b/api/files.html @@ -586,7 +586,7 @@
KJUR.asn1.csr.CSRUtil.verifySignatrue("-----BEGIN CERTIFICATE REQUEST...") → true or false + +p = KJUR.asn1.csr.CSRUtil.getParam("-----BEGIN CERTIFICATE REQUEST-----", true); // with tbs +KJUR.asn1.csr.CSRUtil.verifySignatrue(p) → true or false+ + + + +
1 /* asn1csr-2.0.5.js (c) 2015-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +1 /* asn1csr-2.0.6.js (c) 2015-2022 Kenji Urushima | kjur.github.io/jsrsasign/license 2 */ 3 /* 4 * asn1csr.js - ASN.1 DER encoder classes for PKCS#10 CSR 5 * - 6 * Copyright (c) 2015-2020 Kenji Urushima (kenji.urushima@gmail.com) + 6 * Copyright (c) 2015-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 asn1csr-1.0.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 10.5.16 asn1csr 2.0.5 (2022-Apr-08) + 19 * @version jsrsasign 10.5.26 asn1csr 2.0.6 (2022-Jul-14) 20 * @since jsrsasign 4.9.0 21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 22 */ @@ -390,104 +390,164 @@ 383 * @name getParam 384 * @memberOf KJUR.asn1.csr.CSRUtil 385 * @function -386 * @param {String} sPEM PEM string of CSR/PKCS#10 -387 * @returns {Array} JSON object with parsed parameters such as name or public key -388 * @since jsrsasign 9.0.0 asn1csr 2.0.0 -389 * @see KJUR.asn1.csr.CertificationRequest -390 * @see KJUR.asn1.x509.X500Name -391 * @see X509#getExtParamArray -392 * @description -393 * This method parses PEM CSR/PKCS#1 string and retrieves -394 * fields such as subject name and public key. -395 * Following parameters are available in the -396 * resulted JSON object. -397 * <ul> -398 * <li>{X500Name}subject - subject name parameters </li> -399 * <li>{String}sbjpubkey - PEM string of subject public key</li> -400 * <li>{Array}extreq - array of extensionRequest parameters</li> -401 * <li>{String}sigalg - name of signature algorithm field</li> -402 * <li>{String}sighex - hexadecimal string of signature value</li> -403 * </ul> -404 * Returned JSON object can be passed to -405 * {@link KJUR.asn1.csr.CertificationRequest} class constructor. -406 * <br/> -407 * CAUTION: -408 * Returned JSON value format have been changed without -409 * backward compatibility since jsrsasign 9.0.0 asn1csr 2.0.0. -410 * -411 * @example -412 * KJUR.asn1.csr.CSRUtil.getParam("-----BEGIN CERTIFICATE REQUEST...") → -413 * { -414 * subject: { array:[[{type:"C",value:"JP",ds:"prn"}],...], -415 * str: "/C=JP/O=Test"}, -416 * sbjpubkey: "-----BEGIN PUBLIC KEY...", -417 * extreq: [{extname:"subjectAltName",array:[{dns:"example.com"}]}] -418 * sigalg: "SHA256withRSA", -419 * sighex: "1ab3df.." -420 * } -421 */ -422 KJUR.asn1.csr.CSRUtil.getParam = function(sPEM) { -423 var _ASN1HEX = ASN1HEX, -424 _getV = _ASN1HEX.getV, -425 _getIdxbyList = _ASN1HEX.getIdxbyList, -426 _getTLVbyList = _ASN1HEX.getTLVbyList, -427 _getTLVbyListEx = _ASN1HEX.getTLVbyListEx, -428 _getVbyListEx = _ASN1HEX.getVbyListEx; -429 -430 /* -431 * get a hexadecimal string of sequence of extension request attribute value -432 * @param {String} h hexadecimal string of whole CSR -433 * @return {String} hexadecimal string of SEQUENCE of extension request attribute value -434 */ -435 var _getExtReqSeqHex = function(h) { -436 var idx1 = _getIdxbyList(h, 0, [0, 3, 0, 0], "06"); // extreq attr OID idx -437 if (_getV(h, idx1) != "2a864886f70d01090e") { -438 return null; -439 } -440 -441 return _getTLVbyList(h, 0, [0, 3, 0, 1, 0], "30"); // ext seq idx -442 }; -443 -444 var result = {}; -445 -446 if (sPEM.indexOf("-----BEGIN CERTIFICATE REQUEST") == -1) -447 throw new Error("argument is not PEM file"); -448 -449 var hex = pemtohex(sPEM, "CERTIFICATE REQUEST"); -450 -451 try { -452 var hSubject = _getTLVbyListEx(hex, 0, [0, 1]); -453 if (hSubject == "3000") { -454 result.subject = {}; -455 } else { -456 var x = new X509(); -457 result.subject = x.getX500Name(hSubject); -458 } -459 } catch (ex) {}; -460 -461 var hPubKey = _getTLVbyListEx(hex, 0, [0, 2]); -462 var pubkeyobj = KEYUTIL.getKey(hPubKey, null, "pkcs8pub"); -463 result.sbjpubkey = KEYUTIL.getPEM(pubkeyobj, "PKCS8PUB"); -464 -465 var hExtReqSeq = _getExtReqSeqHex(hex); -466 var x = new X509(); -467 if (hExtReqSeq != null) { -468 result.extreq = x.getExtParamArray(hExtReqSeq); -469 } -470 -471 try { -472 var hSigAlg = _getTLVbyListEx(hex, 0, [1], "30"); -473 var x = new X509(); -474 result.sigalg = x.getAlgorithmIdentifierName(hSigAlg); -475 } catch (ex) {}; -476 -477 try { -478 var hSig = _getVbyListEx(hex, 0, [2]); -479 result.sighex = hSig; -480 } catch (ex) {}; -481 -482 return result; -483 }; -484 -485 -486