diff --git a/ChangeLog.txt b/ChangeLog.txt index e1602f4c..2a7f5f76 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,15 @@ ChangeLog for jsrsasign +OCSP ResponderID object udpate +* Changes from 10.5.19 to 10.5.20 (2022-Apr-25) + - src/asn1ocsp.js + - ResponderID class now also supports PEM certificate or + X509 object for key and name field. + - test/qunit-do-asn1ocsp.html + - add some test cases and fix for above + - remove silver sponsor + Time stamp package update * Changes from 10.5.18 to 10.5.19 (2022-Apr-23) - src/asn1tsp.js diff --git a/README.md b/README.md index 420454d2..d4c698ec 100755 --- a/README.md +++ b/README.md @@ -99,9 +99,4 @@ You can donate cryptocurrency to jsrsasign using the following addresses: - Litecoin(LTC): [LPf3VDJVamwPcNJNjjVtrUQuJQ17ZyWzeU](https://en.cryptobadges.io/donate/LPf3VDJVamwPcNJNjjVtrUQuJQ17ZyWzeU) - Bitcoin Cash(BCH): bitcoincash:pq3hy08pc9vm57q6ddgsc06cqdffmfzwwqxd9yejyf -## SPONSORS -

-Silver Sponsors
- -

diff --git a/api/files.html b/api/files.html index 9349d23e..0786d65e 100644 --- a/api/files.html +++ b/api/files.html @@ -624,7 +624,7 @@

asn1ocsp-1.0.js

Version:
-
jsrsasign 10.5.16 asn1ocsp 1.1.7 (2022-Apr-08)
+
jsrsasign 10.5.20 asn1ocsp 1.1.8 (2022-Apr-25)
diff --git a/api/symbols/KJUR.asn1.ocsp.ResponderID.html b/api/symbols/KJUR.asn1.ocsp.ResponderID.html index 9186dc6b..bf319f59 100644 --- a/api/symbols/KJUR.asn1.ocsp.ResponderID.html +++ b/api/symbols/KJUR.asn1.ocsp.ResponderID.html @@ -617,18 +617,31 @@

Following properties are available: +
+NOTE: From jsrsasign 10.5.20, "name" and "key" member values can be +specified by PEM string of X.509 certificate or {@link X509 object}. +For "name", subject field of the certificate will be used and +for "key", subjectKeyIdentifier extension value of the certificate will be used +respectively. -
new KJUR.asn1.ocsp.ResponderID({name: {str: "/C=JP/O=Resp"}})
+				
new KJUR.asn1.ocsp.ResponderID({key: "12ab..."})
+new KJUR.asn1.ocsp.ResponderID({name: {str: "/C=JP/O=Resp"}})
 new KJUR.asn1.ocsp.ResponderID({name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}})
-new KJUR.asn1.ocsp.ResponderID({key: "12ab..."})
+// by certificate +new KJUR.asn1.ocsp.ResponderID({key: "-----BEGIN CERTIFICATE..."}) +new KJUR.asn1.ocsp.ResponderID({name: "-----BEGIN CERTIFICATE..."}) +// by X509 object +new KJUR.asn1.ocsp.ResponderID({key: new X509(...)}) +new KJUR.asn1.ocsp.ResponderID({name: new X509(...)})
@@ -667,6 +680,10 @@

KJUR.asn1.ocsp.ResponseData
+
X509#getSubject
+ +
X509#getExtSubjectKeyIdentifier
+ diff --git a/api/symbols/src/asn1ocsp-1.0.js.html b/api/symbols/src/asn1ocsp-1.0.js.html index 10d95268..b6a39b60 100644 --- a/api/symbols/src/asn1ocsp-1.0.js.html +++ b/api/symbols/src/asn1ocsp-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 /* asn1ocsp-1.1.7.js (c) 2016-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* asn1ocsp-1.1.8.js (c) 2016-2022 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * asn1ocsp.js - ASN.1 DER encoder classes for OCSP protocol
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name asn1ocsp-1.0.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.5.16 asn1ocsp 1.1.7 (2022-Apr-08)
+ 19  * @version jsrsasign 10.5.20 asn1ocsp 1.1.8 (2022-Apr-25)
  20  * @since jsrsasign 6.1.0
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -488,1296 +488,1296 @@
 481  * @see KJUR.asn1.ocsp.ResponseBytes
 482  * @see KJUR.asn1.ocsp.BasicOCSPResponse
 483  * @see KJUR.asn1.ocsp.ResponseData
-484  *
-485  * @description
-486  * ResponderID ASN.1 class is defined in 
-487  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-488  * <pre>
-489  * ResponderID ::= CHOICE {
-490  *    byName               [1] Name,
-491  *    byKey                [2] KeyHash }
-492  * KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key
-493  *                             (excluding the tag and length fields)
-494  * </pre>
-495  * Following properties are available:
-496  * <ul>
-497  * <li>{Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter
-498  * for "byName"</li>
-499  * <li>{String}key (OPTION) - hexadecimal string of KeyHash value</li>
-500  * </ul>
-501  *
-502  * @example
-503  * new KJUR.asn1.ocsp.ResponderID({name: {str: "/C=JP/O=Resp"}})
-504  * new KJUR.asn1.ocsp.ResponderID({name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}})
-505  * new KJUR.asn1.ocsp.ResponderID({key: "12ab..."})
-506  */
-507 KJUR.asn1.ocsp.ResponderID = function(params) {
-508     KJUR.asn1.ocsp.ResponderID.superclass.constructor.call(this);
-509     var _KJUR_asn1 = KJUR.asn1,
-510 	_newObject = _KJUR_asn1.ASN1Util.newObject,
-511 	_X500Name = _KJUR_asn1.x509.X500Name;
-512     
-513     this.params = null;
-514     
-515     this.tohex = function() {
-516 	var params = this.params;
-517 	if (params.key != undefined) {
-518 	    var dTag = _newObject({tag: {tag:"a2",
-519 					 explicit:true,
-520 					 obj:{octstr:{hex:params.key}}}});
-521 	    return dTag.tohex();
-522 	} else if (params.name != undefined) {
-523 	    var dTag = _newObject({tag: {tag:"a1",
-524 					 explicit:true,
-525 					 obj:new _X500Name(params.name)}});
-526 	    return dTag.tohex();
-527 	}
-528 	throw new Error("key or name not specified");
-529     };
-530     this.getEncodedHex = function() { return this.tohex(); };
-531 
-532     this.setByParam = function(params) {
-533 	this.params = params;
-534     };
-535 
-536     if (params !== undefined) this.setByParam(params);
-537 };
-538 extendClass(KJUR.asn1.ocsp.ResponderID, KJUR.asn1.ASN1Object);
-539 
-540 /**
-541  * ASN.1 class encoder for SEQUENCE OF SingleResponse<br/>
-542  * @name KJUR.asn1.ocsp.SingleResponseList
-543  * @class ASN.1 class encoder for SEQUENCE OF SingleResponse
-544  * @param {Array} params array of JSON object for SingleResponse parameters
-545  * @extends KJUR.asn1.ASN1Object
-546  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-547  * @see KJUR.asn1.ocsp.OCSPResponse
-548  * @see KJUR.asn1.ocsp.ResponseBytes
-549  * @see KJUR.asn1.ocsp.BasicOCSPResponse
-550  * @see KJUR.asn1.ocsp.ResponseData
-551  * @see KJUR.asn1.ocsp.SingleResponse
-552  *
-553  * @description
-554  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
-555  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-556  * <pre>
-557  * ResponseData ::= SEQUENCE {
-558  *    version              [0] EXPLICIT Version DEFAULT v1,
-559  *    responderID              ResponderID,
-560  *    producedAt               GeneralizedTime,
-561  *    responses                SEQUENCE OF SingleResponse,
-562  *    responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
-563  * SingleResponse ::= SEQUENCE {
-564  *    certID                       CertID,
-565  *    certStatus                   CertStatus,
-566  *    thisUpdate                   GeneralizedTime,
-567  *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
-568  *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
-569  * </pre>
-570  * Following properties are available:
-571  * <ul>
-572  * <li>{Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter
-573  * for "byName"</li>
-574  * <li>{String}key (OPTION) - hexadecimal string of KeyHash value</li>
-575  * </ul>
-576  *
-577  * @example
-578  * new KJUR.asn1.ocsp.SingleResponseList([{
-579  *   certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
-580  *   status: {status: "good"},
-581  *   thisupdate: "20200903235959Z"
-582  * },{
-583  *   certid: {alg:"sha1",issname:"24ab",isskey:"24ab",sbjsn:"24ab"},
-584  *   status: {status: "good"},
-585  *   thisupdate: "20200904235959Z"
-586  * ])
-587  */
-588 KJUR.asn1.ocsp.SingleResponseList = function(params) {
-589     KJUR.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);
-590 
-591     var _KJUR_asn1 = KJUR.asn1,
-592 	_DERSequence = _KJUR_asn1.DERSequence,
-593 	_SingleResponse = _KJUR_asn1.ocsp.SingleResponse;
-594 
-595     this.params = null;
-596     
-597     this.tohex = function() {
-598 	var params = this.params;
-599 
-600 	if (typeof params != "object" || params.length == undefined) {
-601 	    throw new Error("params not specified properly");
-602 	}
-603 
-604 	var a = [];
-605 	for (var i = 0; i < params.length; i++) {
-606 	    a.push(new _SingleResponse(params[i]));
-607 	}
-608 
-609 	var seq = new _DERSequence({array: a});
-610 	return seq.tohex();
-611     };
-612     this.getEncodedHex = function() { return this.tohex(); };
-613 
-614     this.setByParam = function(params) {
-615 	this.params = params;
-616     };
-617 
-618     if (params !== undefined) this.setByParam(params);
-619 };
-620 extendClass(KJUR.asn1.ocsp.SingleResponseList, KJUR.asn1.ASN1Object);
-621 
-622 /**
-623  * SingleResponse ASN.1 class encoder<br/>
-624  * @name KJUR.asn1.ocsp.SingleResponse
-625  * @class SingleResponse ASN.1 class encoder
-626  * @param {Array} params JSON object for SingleResponse parameter
-627  * @extends KJUR.asn1.ASN1Object
-628  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-629  * @see KJUR.asn1.ocsp.OCSPResponse
-630  * @see KJUR.asn1.ocsp.ResponseBytes
-631  * @see KJUR.asn1.ocsp.BasicOCSPResponse
-632  * @see KJUR.asn1.ocsp.ResponseData
-633  * @see KJUR.asn1.ocsp.SingleResponse
-634  * @see KJUR.asn1.ocsp.CertID
-635  * @see KJUR.asn1.ocsp.CertStatus
-636  *
-637  * @description
-638  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
-639  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-640  * <pre>
-641  * SingleResponse ::= SEQUENCE {
-642  *    certID                       CertID,
-643  *    certStatus                   CertStatus,
-644  *    thisUpdate                   GeneralizedTime,
-645  *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
-646  *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
-647  * </pre>
-648  * Following properties are available:
-649  * <ul>
-650  * <li>{Array}certid - JSON object of {@link KJUR.asn1.ocsp.CertID} parameter</li>
-651  * <li>{Array}status - JSON object of {@link KJUR.asn1.ocsp.CertStatus} parameter</li>
-652  * <li>{Object}thisupdate - {@link KJUR.asn1.DERGeneralizedTime} parameter
-653  * for "thisUpdate"</li>
-654  * <li>{Object}nextupdate (OPTION) - {@link KJUR.asn1.DERGeneralizedTime} parameter
-655  * for "nextUpdate"</li>
-656  * <li>{Array}ext (OPTION) - array of JSON object 
-657  * {@link KJUR.asn1.x509.Extension} sub class parameter for
-658  * "singleExtensions"</li>
-659  * </ul>
-660  *
-661  * @example
-662  * new KJUR.asn1.ocsp.SingleResponse({
-663  *   certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
-664  *   status: {status: "good"},
-665  *   thisupdate: "20200903235959Z",
-666  *   nextupdate: "20200913235959Z",
-667  *   ext: [<<Extension parameters>>...]
-668  * })
-669  */
-670 KJUR.asn1.ocsp.SingleResponse = function(params) {
-671     var _Error = Error,
-672 	_KJUR = KJUR,
-673 	_KJUR_asn1 = _KJUR.asn1,
-674 	_DERSequence = _KJUR_asn1.DERSequence,
-675 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime,
-676 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
-677 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp,
-678 	_CertID = _KJUR_asn1_ocsp.CertID,
-679 	_CertStatus = _KJUR_asn1_ocsp.CertStatus,
-680 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-681 	_Extensions = _KJUR_asn1_x509.Extensions;
-682 
-683     _KJUR_asn1_ocsp.SingleResponse.superclass.constructor.call(this);
-684 
-685     this.params = null;
-686     
-687     this.tohex = function() {
-688 	var params = this.params;
-689 	var a = [];
-690 
-691 	if (params.certid == undefined) throw new _Error("certid unspecified");
-692 	if (params.status == undefined) throw new _Error("status unspecified");
-693 	if (params.thisupdate == undefined) throw new _Error("thisupdate unspecified");
-694 
-695 	a.push(new _CertID(params.certid));
-696 	a.push(new _CertStatus(params.status));
-697 	a.push(new _DERGeneralizedTime(params.thisupdate));
-698 
-699 	if (params.nextupdate != undefined) {
-700 	    var dTime = new _DERGeneralizedTime(params.nextupdate);
-701 	    a.push(new _DERTaggedObject({tag:'a0', explicit:true, obj:dTime}));
-702 	}
-703 
-704 	if (params.ext != undefined) {
-705 	    var dExt = new _Extensions(params.ext);
-706 	    a.push(new _DERTaggedObject({tag:'a1', explicit:true, obj:dExt}));
-707 	}
-708 
-709 	var seq = new _DERSequence({array: a});
-710 	return seq.tohex();
-711     };
-712     this.getEncodedHex = function() { return this.tohex(); };
-713 
-714     this.setByParam = function(params) {
-715 	this.params = params;
-716     };
-717 
-718     if (params !== undefined) this.setByParam(params);
-719 };
-720 extendClass(KJUR.asn1.ocsp.SingleResponse, KJUR.asn1.ASN1Object);
-721 
-722 /**
-723  * ASN.1 CertID class for OCSP<br/>
-724  * @name KJUR.asn1.ocsp.CertID
-725  * @class ASN.1 CertID class for OCSP
-726  * @param {Array} params JSON object of parameters
-727  * @extends KJUR.asn1.ASN1Object
-728  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-729  * @see KJUR.asn1.ocsp.SingleResponse
-730  * @see KJUR.asn1.x509.AlgorithmIdentifier
-731  *
-732  * @description
-733  * CertID ASN.1 class is defined in 
-734  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-735  * <pre>
-736  * CertID ::= SEQUENCE {
-737  *   hashAlgorithm   AlgorithmIdentifier,
-738  *   issuerNameHash  OCTET STRING, -- Hash of issuer's DN
-739  *   issuerKeyHash   OCTET STRING, -- Hash of issuer's public key
-740  *   serialNumber    CertificateSerialNumber }
-741  * </pre>
-742  * Following properties are available in "params" of the constructor:
-743  * <ul>
-744  * <li>{String}alg (OPTION) - hash algorithm name. Default is "sha1" (ex, "sha1")</li>
-745  * <li>{String}issname (OPTION) - hexadecimal string of issuerNameHash</li>
-746  * <li>{String}isskey (OPTION) - hexadecimal string of issuerKeyHash</li>
-747  * <li>{String}sbjsn (OPTION) - hexadecimal string of serial number of subject certificate</li>
-748  * <li>{String}issuerCert (OPTION) - PEM string of issuer certificate.
-749  * Property "issname" and "isskey" will be set by "issuerCert".</li>
-750  * <li>{String}subjectCert (OPTION) - PEM string of issuer certificate.
-751  * Property "sbjsn" will be set by "subjectCert".</li>
-752  * </ul>
-753  * <br/>
-754  * NOTE: Properties "namehash", "keyhash" and "serial" are
-755  * changed to "issname", "isskey", and "sbjsn" respectively
-756  * since jsrsasign 9.1.6 asn1ocsp 1.1.0.
-757  *
-758  * @example
-759  * // constructor with explicit values (changed since jsrsasign 9.1.6)
-760  * new KJUR.asn1.ocsp.CertID({issname: "1a...", isskey: "ad...", sbjsn: "1234", alg: "sha256"});
-761  *
-762  * // constructor with certs (sha1 is used by default)
-763  * o = new KJUR.asn1.ocsp.CertID({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN..."});
-764  *
-765  * // constructor with certs and sha256
-766  * o = new KJUR.asn1.ocsp.CertID({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"});
-767  */
-768 KJUR.asn1.ocsp.CertID = function(params) {
-769     var _KJUR = KJUR,
-770 	_KJUR_asn1 = _KJUR.asn1,
-771 	_DEROctetString = _KJUR_asn1.DEROctetString,
-772 	_DERInteger = _KJUR_asn1.DERInteger,
-773 	_DERSequence = _KJUR_asn1.DERSequence,
-774 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
-775 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
-776 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp,
-777 	_DEFAULT_HASH = _KJUR_asn1_ocsp.DEFAULT_HASH,
-778 	_KJUR_crypto = _KJUR.crypto,
-779 	_hashHex = _KJUR_crypto.Util.hashHex,
-780 	_X509 = X509,
-781 	_ASN1HEX = ASN1HEX,
-782 	_getVbyList = _ASN1HEX.getVbyList;
-783 
-784     _KJUR_asn1_ocsp.CertID.superclass.constructor.call(this);
-785 
-786     this.DEFAULT_HASH = "sha1";
-787     this.params = null;
-788 
-789     /**
-790      * set CertID ASN.1 object by values.<br/>
-791      * @name setByValue
-792      * @memberOf KJUR.asn1.ocsp.CertID#
-793      * @function
-794      * @param {String} issuerNameHashHex hexadecimal string of hash value of issuer name
-795      * @param {String} issuerKeyHashHex hexadecimal string of hash value of issuer public key
-796      * @param {String} serialNumberHex hexadecimal string of certificate serial number to be verified
-797      * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
-798      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-799      * @example
-800      * o = new KJUR.asn1.ocsp.CertID();
-801      * o.setByValue("1fac...", "fd3a...", "1234"); // sha1 is used by default
-802      * o.setByValue("1fac...", "fd3a...", "1234", "sha256");
-803      */
-804     this.setByValue = function(issuerNameHashHex, issuerKeyHashHex,
-805 			       serialNumberHex, algName) {
-806 	if (algName == undefined) algName = this.DEFAULT_HASH;
-807 	this.params = {
-808 	    alg: algName,
-809 	    issname: issuerNameHashHex,
-810 	    isskey: issuerKeyHashHex,
-811 	    sbjsn: serialNumberHex
-812 	};
-813     };
-814 
-815     /**
-816      * set CertID ASN.1 object by PEM certificates.<br/>
-817      * @name setByCert
-818      * @memberOf KJUR.asn1.ocsp.CertID#
-819      * @function
-820      * @param {String} issuerCert string of PEM issuer certificate
-821      * @param {String} subjectCert string of PEM subject certificate to be verified by OCSP
-822      * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
-823      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-824      * @deprecated since jsrsasign 10.5.7 asn1ocsp 1.1.6. Please use setByParam instead.
-825      *
-826      * @example
-827      * o = new KJUR.asn1.ocsp.CertID();
-828      * o.setByCert("-----BEGIN...", "-----BEGIN..."); // sha1 is used by default
-829      * o.setByCert("-----BEGIN...", "-----BEGIN...", "sha256");
-830      */
-831     this.setByCert = function(issuerCert, subjectCert, algName) {
-832 	if (algName == undefined) algName = this.DEFAULT_HASH;
-833 	this.params = {
-834 	    alg: algName,
-835 	    issuerCert: issuerCert,
-836 	    subjectCert: subjectCert,
-837 	};
-838     };
-839 
-840     /**
-841      * calculate CertID parameter by certificates.<br/>
-842      * @name getParamByCerts
-843      * @memberOf KJUR.asn1.ocsp.CertID#
-844      * @function
-845      * @param {string} issuerCert string of PEM issuer certificate
-846      * @param {string} subjectCert string of PEM subject certificate to be verified by OCSP
-847      * @param {string} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
-848      * @param {object} associative array with alg, issname, isskey and sbjsn members
-849      * @since jsrsasign 10.5.7 asn1ocsp 1.1.6
-850      *
-851      * @description
-852      * This method calculates issuer name hash, issuer key hash and subject serial
-853      * number then returns an associative array with alg, issname, isskey and sbjsn members.
-854      *
-855      * @example
-856      * o = new KJUR.asn1.ocsp.CertID();
-857      * o.getParamByCerts("-----BEGIN...", "-----BEGIN...", "sha256") →
-858      * {
-859      *   alg: "sha256",
-860      *   issname: "12abcd...",
-861      *   isskey: "23cdef...",
-862      *   sbjsn: "57b3..."
-863      * }
-864      */
-865     this.getParamByCerts = function(issCert, sbjCert, algName) {
-866 	if (algName == undefined) algName = this.DEFAULT_HASH;
-867 	var xISS = new _X509(issCert);
-868 	var xSBJ = new _X509(sbjCert);
-869 	var issname = _hashHex(xISS.getSubjectHex(), algName);
-870 	var hSPKI = xISS.getPublicKeyHex();
-871 	var isskey = _hashHex(_getVbyList(hSPKI, 0, [1], "03", true), algName);
-872 	var sbjsn = xSBJ.getSerialNumberHex();
-873 	var info = {
-874 	    alg: algName,
-875 	    issname: issname,
-876 	    isskey: isskey,
-877 	    sbjsn: sbjsn
-878 	};
-879 	return info;
-880     };
-881 
-882     this.tohex = function() {
-883 	if (typeof this.params != "object") throw new Error("params not set");
-884 	    
-885 	var p = this.params;
-886 	var issname, isskey, sbjsn, alg;
-887 
-888 	if (p.alg == undefined) {
-889 	    alg = this.DEFAULT_HASH;
-890 	} else {
-891 	    alg = p.alg;
-892 	}
-893 
-894 	if (p.issuerCert != undefined &&
-895 	    p.subjectCert != undefined) {
-896 	    var info = this.getParamByCerts(p.issuerCert, p.subjectCert, alg);
-897 	    issname = info.issname;
-898 	    isskey = info.isskey;
-899 	    sbjsn = info.sbjsn;
-900 	} else if (p.issname != undefined &&
-901 		   p.isskey != undefined &&
-902 		   p.sbjsn != undefined) {
-903 	    issname = p.issname;
-904 	    isskey = p.isskey;
-905 	    sbjsn = p.sbjsn;
-906 	} else {
-907 	    throw new Error("required param members not defined");
-908 	}
-909 
-910 	var dAlg = new _AlgorithmIdentifier({name: alg});
-911 	var dIssName = new _DEROctetString({hex: issname});
-912 	var dIssKey = new _DEROctetString({hex: isskey});
-913 	var dSbjSn = new _DERInteger({hex: sbjsn});
-914 	var seq = new _DERSequence({array: [dAlg, dIssName, dIssKey, dSbjSn]});
-915         this.hTLV = seq.tohex();
-916         return this.hTLV;
-917     };
-918     this.getEncodedHex = function() { return this.tohex(); };
-919 
-920     if (params !== undefined) this.setByParam(params);
-921 };
-922 extendClass(KJUR.asn1.ocsp.CertID, KJUR.asn1.ASN1Object);
-923 
-924 /**
-925  * CertStatus ASN.1 class encoder<br/>
-926  * @name KJUR.asn1.ocsp.CertStatus
-927  * @class CertStatus ASN.1 class encoder
-928  * @param {Array} params JSON object for CertStatus parameter
-929  * @extends KJUR.asn1.ASN1Object
-930  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-931  * @see KJUR.asn1.ocsp.OCSPResponse
-932  * @see KJUR.asn1.ocsp.ResponseBytes
-933  * @see KJUR.asn1.ocsp.BasicOCSPResponse
-934  * @see KJUR.asn1.ocsp.ResponseData
-935  * @see KJUR.asn1.ocsp.SingleResponse
-936  * @see KJUR.asn1.ocsp.CertID
-937  * @see KJUR.asn1.ocsp.CertStatus
-938  *
-939  * @description
-940  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
-941  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-942  * <pre>
-943  * CertStatus ::= CHOICE {
-944  *     good        [0]     IMPLICIT NULL,
-945  *     revoked     [1]     IMPLICIT RevokedInfo,
-946  *     unknown     [2]     IMPLICIT UnknownInfo }
-947  * RevokedInfo ::= SEQUENCE {
-948  *     revocationTime              GeneralizedTime,
-949  *     revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
-950  * UnknownInfo ::= NULL
-951  * CRLReason ::= ENUMERATED {
-952  *      unspecified             (0),
-953  *      keyCompromise           (1),
-954  *      cACompromise            (2),
-955  *      affiliationChanged      (3),
-956  *      superseded              (4),
-957  *      cessationOfOperation    (5),
-958  *      certificateHold         (6),
-959  *           -- value 7 is not used
-960  *      removeFromCRL           (8),
-961  *      privilegeWithdrawn      (9),
-962  *      aACompromise           (10) }
-963  * </pre>
-964  * Following properties are available:
-965  * <ul>
-966  * <li>{String}status - "good", "revoked" or "unknown"</li>
-967  * <li>{String}time (OPTION) - revocationTime YYYYMMDDHHmmSSZ (ex. "20200904235959Z")</li>
-968  * <li>{Number}reason (OPTION) - revocationReason code number</li>
-969  * </ul>
-970  *
-971  * @example
-972  * new KJUR.asn1.ocsp.CertStatus({status: "good"})
-973  * new KJUR.asn1.ocsp.CertStatus({status: "revoked", time: "20200903235959Z"})
-974  * new KJUR.asn1.ocsp.CertStatus({status: "revoked", time: "20200903235959Z", reason: 3})
-975  * new KJUR.asn1.ocsp.CertStatus({status: "unknown"})
-976  */
-977 KJUR.asn1.ocsp.CertStatus = function(params) {
-978     KJUR.asn1.ocsp.CertStatus.superclass.constructor.call(this);
-979 
-980     this.params = null;
-981 
-982     this.tohex = function() {
-983 	var params = this.params;
-984 	if (params.status == "good") return "8000";
-985 	if (params.status == "unknown") return "8200";
-986 	if (params.status == "revoked") {
-987 	    var a = [{gentime: {str: params.time}}];
-988 	    if (params.reason != undefined) {
-989 		a.push({tag: {tag: 'a0', 
-990 			      explicit: true,
-991 			      obj: {'enum': {'int': params.reason}}}});
-992 	    }
-993 	    var tagParam = {tag: 'a1', explicit: false, obj: {seq: a}};
-994 	    return KJUR.asn1.ASN1Util.newObject({tag: tagParam}).tohex();
-995 	}
-996 	throw new Error("bad status");
-997     };
-998     this.getEncodedHex = function() { return this.tohex(); };
-999 
-1000     this.setByParam = function(params) {
-1001 	this.params = params;
-1002     };
-1003 
-1004     if (params !== undefined) this.setByParam(params);
-1005 };
-1006 extendClass(KJUR.asn1.ocsp.CertStatus, KJUR.asn1.ASN1Object);
-1007 
-1008 // ---- END OF Classes for OCSP response -----------------------------------
-1009 
-1010 /**
-1011  * ASN.1 Request class for OCSP<br/>
-1012  * @name KJUR.asn1.ocsp.Request
-1013  * @class ASN.1 Request class for OCSP
-1014  * @param {Array} params associative array of parameters
-1015  * @extends KJUR.asn1.ASN1Object
-1016  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1017  * @description
-1018  * Request ASN.1 class is defined in 
-1019  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1020  * singleRequestExtensions is not supported yet in this version such as nonce.
-1021  * <pre>
-1022  * Request ::= SEQUENCE {
-1023  *   reqCert                  CertID,
-1024  *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }
-1025  * </pre>
-1026  * @example
-1027  * // default constructor
-1028  * o = new KJUR.asn1.ocsp.Request();
-1029  * // constructor with certs (sha1 is used by default)
-1030  * o = new KJUR.asn1.ocsp.Request({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN..."});
-1031  * // constructor with certs and sha256
-1032  * o = new KJUR.asn1.ocsp.Request({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"});
-1033  * // constructor with values
-1034  * o = new KJUR.asn1.ocsp.Request({namehash: "1a...", keyhash: "ad...", serial: "1234", alg: "sha256"});
-1035  */
-1036 KJUR.asn1.ocsp.Request = function(params) {
-1037     var _KJUR = KJUR,
-1038 	_KJUR_asn1 = _KJUR.asn1,
-1039 	_DERSequence = _KJUR_asn1.DERSequence,
-1040 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
-1041     
-1042     _KJUR_asn1_ocsp.Request.superclass.constructor.call(this);
-1043     this.dReqCert = null;
-1044     this.dExt = null;
-1045     
-1046     this.tohex = function() {
-1047 	var a = [];
-1048 
-1049 	// 1. reqCert
-1050 	if (this.dReqCert === null)
-1051 	    throw "reqCert not set";
-1052 	a.push(this.dReqCert);
+484  * @see X509#getSubject
+485  * @see X509#getExtSubjectKeyIdentifier
+486  *
+487  * @description
+488  * ResponderID ASN.1 class is defined in 
+489  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+490  * <pre>
+491  * ResponderID ::= CHOICE {
+492  *    byName               [1] Name,
+493  *    byKey                [2] KeyHash }
+494  * KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key
+495  *                             (excluding the tag and length fields)
+496  * </pre>
+497  * Following properties are available:
+498  * <ul>
+499  * <li>{Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter,
+500  * PEM string of X.509 certificate or {@link X509 object} for "byName",</li>
+501  * <li>{String}key (OPTION) - hexadecimal string of KeyHash value,
+502  * PEM string of X.509 certificate or {@link X509 object} for "byKey"</li>
+503  * </ul>
+504  * <br/>
+505  * NOTE: From jsrsasign 10.5.20, "name" and "key" member values can be
+506  * specified by PEM string of X.509 certificate or {@link X509 object}.
+507  * For "name", subject field of the certificate will be used and
+508  * for "key", subjectKeyIdentifier extension value of the certificate will be used
+509  * respectively.
+510  *
+511  * @example
+512  * new KJUR.asn1.ocsp.ResponderID({key: "12ab..."})
+513  * new KJUR.asn1.ocsp.ResponderID({name: {str: "/C=JP/O=Resp"}})
+514  * new KJUR.asn1.ocsp.ResponderID({name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}})
+515  * // by certificate
+516  * new KJUR.asn1.ocsp.ResponderID({key: "-----BEGIN CERTIFICATE..."})
+517  * new KJUR.asn1.ocsp.ResponderID({name: "-----BEGIN CERTIFICATE..."})
+518  * // by X509 object
+519  * new KJUR.asn1.ocsp.ResponderID({key: new X509(...)})
+520  * new KJUR.asn1.ocsp.ResponderID({name: new X509(...)})
+521  */
+522 KJUR.asn1.ocsp.ResponderID = function(params) {
+523     KJUR.asn1.ocsp.ResponderID.superclass.constructor.call(this);
+524     var _KJUR = KJUR,
+525 	_KJUR_asn1 = _KJUR.asn1,
+526 	_newObject = _KJUR_asn1.ASN1Util.newObject,
+527 	_X500Name = _KJUR_asn1.x509.X500Name,
+528 	_isHex = _KJUR.lang.String.isHex,
+529 	_Error = Error;
+530     
+531     this.params = null;
+532     
+533     this.tohex = function() {
+534 	var params = this.params;
+535 	if (params.key != undefined) {
+536 	    var hKey = null;
+537 	    if (typeof params.key == "string") {
+538 		if (_isHex(params.key)) hKey = params.key;
+539 		if (params.key.match(/-----BEGIN CERTIFICATE/)) {
+540 		    var x = new X509(params.key);
+541 		    var extSKID = x.getExtSubjectKeyIdentifier();
+542 		    if (extSKID != null) hKey = extSKID.kid.hex;
+543 		}
+544 	    } else if (params.key instanceof X509) {
+545 		var extSKID = params.key.getExtSubjectKeyIdentifier();
+546 		if (extSKID != null) hKey = extSKID.kid.hex;
+547 	    }
+548 	    if (hKey == null) throw new _Error("wrong key member value");
+549 	    var dTag = _newObject({tag: {tag:"a2",
+550 					 explicit:true,
+551 					 obj:{octstr:{hex:hKey}}}});
+552 	    return dTag.tohex();
+553 	} else if (params.name != undefined) {
+554 	    var pName = null;
+555 	    if (typeof params.name == "string" &&
+556 		params.name.match(/-----BEGIN CERTIFICATE/)) {
+557 		var x = new X509(params.name);
+558 		pName = x.getSubject();
+559 	    } else if (params.name instanceof X509) {
+560 		pName = params.name.getSubject();
+561 	    } else if (typeof params.name == "object" &&
+562 		       (params.name.array != undefined ||
+563 			params.name.str != undefined)) {
+564 		pName = params.name;
+565 	    }
+566 	    if (pName == null) throw new _Error("wrong name member value");
+567 	    var dTag = _newObject({tag: {tag:"a1",
+568 					 explicit:true,
+569 					 obj:new _X500Name(pName)}});
+570 	    return dTag.tohex();
+571 	}
+572 	throw new _Error("key or name not specified");
+573     };
+574     this.getEncodedHex = function() { return this.tohex(); };
+575 
+576     this.setByParam = function(params) {
+577 	this.params = params;
+578     };
+579 
+580     if (params !== undefined) this.setByParam(params);
+581 };
+582 extendClass(KJUR.asn1.ocsp.ResponderID, KJUR.asn1.ASN1Object);
+583 
+584 /**
+585  * ASN.1 class encoder for SEQUENCE OF SingleResponse<br/>
+586  * @name KJUR.asn1.ocsp.SingleResponseList
+587  * @class ASN.1 class encoder for SEQUENCE OF SingleResponse
+588  * @param {Array} params array of JSON object for SingleResponse parameters
+589  * @extends KJUR.asn1.ASN1Object
+590  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+591  * @see KJUR.asn1.ocsp.OCSPResponse
+592  * @see KJUR.asn1.ocsp.ResponseBytes
+593  * @see KJUR.asn1.ocsp.BasicOCSPResponse
+594  * @see KJUR.asn1.ocsp.ResponseData
+595  * @see KJUR.asn1.ocsp.SingleResponse
+596  *
+597  * @description
+598  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
+599  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+600  * <pre>
+601  * ResponseData ::= SEQUENCE {
+602  *    version              [0] EXPLICIT Version DEFAULT v1,
+603  *    responderID              ResponderID,
+604  *    producedAt               GeneralizedTime,
+605  *    responses                SEQUENCE OF SingleResponse,
+606  *    responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
+607  * SingleResponse ::= SEQUENCE {
+608  *    certID                       CertID,
+609  *    certStatus                   CertStatus,
+610  *    thisUpdate                   GeneralizedTime,
+611  *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
+612  *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
+613  * </pre>
+614  * Following properties are available:
+615  * <ul>
+616  * <li>{Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter
+617  * for "byName"</li>
+618  * <li>{String}key (OPTION) - hexadecimal string of KeyHash value</li>
+619  * </ul>
+620  *
+621  * @example
+622  * new KJUR.asn1.ocsp.SingleResponseList([{
+623  *   certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
+624  *   status: {status: "good"},
+625  *   thisupdate: "20200903235959Z"
+626  * },{
+627  *   certid: {alg:"sha1",issname:"24ab",isskey:"24ab",sbjsn:"24ab"},
+628  *   status: {status: "good"},
+629  *   thisupdate: "20200904235959Z"
+630  * ])
+631  */
+632 KJUR.asn1.ocsp.SingleResponseList = function(params) {
+633     KJUR.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);
+634 
+635     var _KJUR_asn1 = KJUR.asn1,
+636 	_DERSequence = _KJUR_asn1.DERSequence,
+637 	_SingleResponse = _KJUR_asn1.ocsp.SingleResponse;
+638 
+639     this.params = null;
+640     
+641     this.tohex = function() {
+642 	var params = this.params;
+643 
+644 	if (typeof params != "object" || params.length == undefined) {
+645 	    throw new Error("params not specified properly");
+646 	}
+647 
+648 	var a = [];
+649 	for (var i = 0; i < params.length; i++) {
+650 	    a.push(new _SingleResponse(params[i]));
+651 	}
+652 
+653 	var seq = new _DERSequence({array: a});
+654 	return seq.tohex();
+655     };
+656     this.getEncodedHex = function() { return this.tohex(); };
+657 
+658     this.setByParam = function(params) {
+659 	this.params = params;
+660     };
+661 
+662     if (params !== undefined) this.setByParam(params);
+663 };
+664 extendClass(KJUR.asn1.ocsp.SingleResponseList, KJUR.asn1.ASN1Object);
+665 
+666 /**
+667  * SingleResponse ASN.1 class encoder<br/>
+668  * @name KJUR.asn1.ocsp.SingleResponse
+669  * @class SingleResponse ASN.1 class encoder
+670  * @param {Array} params JSON object for SingleResponse parameter
+671  * @extends KJUR.asn1.ASN1Object
+672  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+673  * @see KJUR.asn1.ocsp.OCSPResponse
+674  * @see KJUR.asn1.ocsp.ResponseBytes
+675  * @see KJUR.asn1.ocsp.BasicOCSPResponse
+676  * @see KJUR.asn1.ocsp.ResponseData
+677  * @see KJUR.asn1.ocsp.SingleResponse
+678  * @see KJUR.asn1.ocsp.CertID
+679  * @see KJUR.asn1.ocsp.CertStatus
+680  *
+681  * @description
+682  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
+683  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+684  * <pre>
+685  * SingleResponse ::= SEQUENCE {
+686  *    certID                       CertID,
+687  *    certStatus                   CertStatus,
+688  *    thisUpdate                   GeneralizedTime,
+689  *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
+690  *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
+691  * </pre>
+692  * Following properties are available:
+693  * <ul>
+694  * <li>{Array}certid - JSON object of {@link KJUR.asn1.ocsp.CertID} parameter</li>
+695  * <li>{Array}status - JSON object of {@link KJUR.asn1.ocsp.CertStatus} parameter</li>
+696  * <li>{Object}thisupdate - {@link KJUR.asn1.DERGeneralizedTime} parameter
+697  * for "thisUpdate"</li>
+698  * <li>{Object}nextupdate (OPTION) - {@link KJUR.asn1.DERGeneralizedTime} parameter
+699  * for "nextUpdate"</li>
+700  * <li>{Array}ext (OPTION) - array of JSON object 
+701  * {@link KJUR.asn1.x509.Extension} sub class parameter for
+702  * "singleExtensions"</li>
+703  * </ul>
+704  *
+705  * @example
+706  * new KJUR.asn1.ocsp.SingleResponse({
+707  *   certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
+708  *   status: {status: "good"},
+709  *   thisupdate: "20200903235959Z",
+710  *   nextupdate: "20200913235959Z",
+711  *   ext: [<<Extension parameters>>...]
+712  * })
+713  */
+714 KJUR.asn1.ocsp.SingleResponse = function(params) {
+715     var _Error = Error,
+716 	_KJUR = KJUR,
+717 	_KJUR_asn1 = _KJUR.asn1,
+718 	_DERSequence = _KJUR_asn1.DERSequence,
+719 	_DERGeneralizedTime = _KJUR_asn1.DERGeneralizedTime,
+720 	_DERTaggedObject = _KJUR_asn1.DERTaggedObject,
+721 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp,
+722 	_CertID = _KJUR_asn1_ocsp.CertID,
+723 	_CertStatus = _KJUR_asn1_ocsp.CertStatus,
+724 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+725 	_Extensions = _KJUR_asn1_x509.Extensions;
+726 
+727     _KJUR_asn1_ocsp.SingleResponse.superclass.constructor.call(this);
+728 
+729     this.params = null;
+730     
+731     this.tohex = function() {
+732 	var params = this.params;
+733 	var a = [];
+734 
+735 	if (params.certid == undefined) throw new _Error("certid unspecified");
+736 	if (params.status == undefined) throw new _Error("status unspecified");
+737 	if (params.thisupdate == undefined) throw new _Error("thisupdate unspecified");
+738 
+739 	a.push(new _CertID(params.certid));
+740 	a.push(new _CertStatus(params.status));
+741 	a.push(new _DERGeneralizedTime(params.thisupdate));
+742 
+743 	if (params.nextupdate != undefined) {
+744 	    var dTime = new _DERGeneralizedTime(params.nextupdate);
+745 	    a.push(new _DERTaggedObject({tag:'a0', explicit:true, obj:dTime}));
+746 	}
+747 
+748 	if (params.ext != undefined) {
+749 	    var dExt = new _Extensions(params.ext);
+750 	    a.push(new _DERTaggedObject({tag:'a1', explicit:true, obj:dExt}));
+751 	}
+752 
+753 	var seq = new _DERSequence({array: a});
+754 	return seq.tohex();
+755     };
+756     this.getEncodedHex = function() { return this.tohex(); };
+757 
+758     this.setByParam = function(params) {
+759 	this.params = params;
+760     };
+761 
+762     if (params !== undefined) this.setByParam(params);
+763 };
+764 extendClass(KJUR.asn1.ocsp.SingleResponse, KJUR.asn1.ASN1Object);
+765 
+766 /**
+767  * ASN.1 CertID class for OCSP<br/>
+768  * @name KJUR.asn1.ocsp.CertID
+769  * @class ASN.1 CertID class for OCSP
+770  * @param {Array} params JSON object of parameters
+771  * @extends KJUR.asn1.ASN1Object
+772  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+773  * @see KJUR.asn1.ocsp.SingleResponse
+774  * @see KJUR.asn1.x509.AlgorithmIdentifier
+775  *
+776  * @description
+777  * CertID ASN.1 class is defined in 
+778  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+779  * <pre>
+780  * CertID ::= SEQUENCE {
+781  *   hashAlgorithm   AlgorithmIdentifier,
+782  *   issuerNameHash  OCTET STRING, -- Hash of issuer's DN
+783  *   issuerKeyHash   OCTET STRING, -- Hash of issuer's public key
+784  *   serialNumber    CertificateSerialNumber }
+785  * </pre>
+786  * Following properties are available in "params" of the constructor:
+787  * <ul>
+788  * <li>{String}alg (OPTION) - hash algorithm name. Default is "sha1" (ex, "sha1")</li>
+789  * <li>{String}issname (OPTION) - hexadecimal string of issuerNameHash</li>
+790  * <li>{String}isskey (OPTION) - hexadecimal string of issuerKeyHash</li>
+791  * <li>{String}sbjsn (OPTION) - hexadecimal string of serial number of subject certificate</li>
+792  * <li>{String}issuerCert (OPTION) - PEM string of issuer certificate.
+793  * Property "issname" and "isskey" will be set by "issuerCert".</li>
+794  * <li>{String}subjectCert (OPTION) - PEM string of issuer certificate.
+795  * Property "sbjsn" will be set by "subjectCert".</li>
+796  * </ul>
+797  * <br/>
+798  * NOTE: Properties "namehash", "keyhash" and "serial" are
+799  * changed to "issname", "isskey", and "sbjsn" respectively
+800  * since jsrsasign 9.1.6 asn1ocsp 1.1.0.
+801  *
+802  * @example
+803  * // constructor with explicit values (changed since jsrsasign 9.1.6)
+804  * new KJUR.asn1.ocsp.CertID({issname: "1a...", isskey: "ad...", sbjsn: "1234", alg: "sha256"});
+805  *
+806  * // constructor with certs (sha1 is used by default)
+807  * o = new KJUR.asn1.ocsp.CertID({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN..."});
+808  *
+809  * // constructor with certs and sha256
+810  * o = new KJUR.asn1.ocsp.CertID({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"});
+811  */
+812 KJUR.asn1.ocsp.CertID = function(params) {
+813     var _KJUR = KJUR,
+814 	_KJUR_asn1 = _KJUR.asn1,
+815 	_DEROctetString = _KJUR_asn1.DEROctetString,
+816 	_DERInteger = _KJUR_asn1.DERInteger,
+817 	_DERSequence = _KJUR_asn1.DERSequence,
+818 	_KJUR_asn1_x509 = _KJUR_asn1.x509,
+819 	_AlgorithmIdentifier = _KJUR_asn1_x509.AlgorithmIdentifier,
+820 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp,
+821 	_DEFAULT_HASH = _KJUR_asn1_ocsp.DEFAULT_HASH,
+822 	_KJUR_crypto = _KJUR.crypto,
+823 	_hashHex = _KJUR_crypto.Util.hashHex,
+824 	_X509 = X509,
+825 	_ASN1HEX = ASN1HEX,
+826 	_getVbyList = _ASN1HEX.getVbyList;
+827 
+828     _KJUR_asn1_ocsp.CertID.superclass.constructor.call(this);
+829 
+830     this.DEFAULT_HASH = "sha1";
+831     this.params = null;
+832 
+833     /**
+834      * set CertID ASN.1 object by values.<br/>
+835      * @name setByValue
+836      * @memberOf KJUR.asn1.ocsp.CertID#
+837      * @function
+838      * @param {String} issuerNameHashHex hexadecimal string of hash value of issuer name
+839      * @param {String} issuerKeyHashHex hexadecimal string of hash value of issuer public key
+840      * @param {String} serialNumberHex hexadecimal string of certificate serial number to be verified
+841      * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
+842      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+843      * @example
+844      * o = new KJUR.asn1.ocsp.CertID();
+845      * o.setByValue("1fac...", "fd3a...", "1234"); // sha1 is used by default
+846      * o.setByValue("1fac...", "fd3a...", "1234", "sha256");
+847      */
+848     this.setByValue = function(issuerNameHashHex, issuerKeyHashHex,
+849 			       serialNumberHex, algName) {
+850 	if (algName == undefined) algName = this.DEFAULT_HASH;
+851 	this.params = {
+852 	    alg: algName,
+853 	    issname: issuerNameHashHex,
+854 	    isskey: issuerKeyHashHex,
+855 	    sbjsn: serialNumberHex
+856 	};
+857     };
+858 
+859     /**
+860      * set CertID ASN.1 object by PEM certificates.<br/>
+861      * @name setByCert
+862      * @memberOf KJUR.asn1.ocsp.CertID#
+863      * @function
+864      * @param {String} issuerCert string of PEM issuer certificate
+865      * @param {String} subjectCert string of PEM subject certificate to be verified by OCSP
+866      * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
+867      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+868      * @deprecated since jsrsasign 10.5.7 asn1ocsp 1.1.6. Please use setByParam instead.
+869      *
+870      * @example
+871      * o = new KJUR.asn1.ocsp.CertID();
+872      * o.setByCert("-----BEGIN...", "-----BEGIN..."); // sha1 is used by default
+873      * o.setByCert("-----BEGIN...", "-----BEGIN...", "sha256");
+874      */
+875     this.setByCert = function(issuerCert, subjectCert, algName) {
+876 	if (algName == undefined) algName = this.DEFAULT_HASH;
+877 	this.params = {
+878 	    alg: algName,
+879 	    issuerCert: issuerCert,
+880 	    subjectCert: subjectCert,
+881 	};
+882     };
+883 
+884     /**
+885      * calculate CertID parameter by certificates.<br/>
+886      * @name getParamByCerts
+887      * @memberOf KJUR.asn1.ocsp.CertID#
+888      * @function
+889      * @param {string} issuerCert string of PEM issuer certificate
+890      * @param {string} subjectCert string of PEM subject certificate to be verified by OCSP
+891      * @param {string} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
+892      * @param {object} associative array with alg, issname, isskey and sbjsn members
+893      * @since jsrsasign 10.5.7 asn1ocsp 1.1.6
+894      *
+895      * @description
+896      * This method calculates issuer name hash, issuer key hash and subject serial
+897      * number then returns an associative array with alg, issname, isskey and sbjsn members.
+898      *
+899      * @example
+900      * o = new KJUR.asn1.ocsp.CertID();
+901      * o.getParamByCerts("-----BEGIN...", "-----BEGIN...", "sha256") →
+902      * {
+903      *   alg: "sha256",
+904      *   issname: "12abcd...",
+905      *   isskey: "23cdef...",
+906      *   sbjsn: "57b3..."
+907      * }
+908      */
+909     this.getParamByCerts = function(issCert, sbjCert, algName) {
+910 	if (algName == undefined) algName = this.DEFAULT_HASH;
+911 	var xISS = new _X509(issCert);
+912 	var xSBJ = new _X509(sbjCert);
+913 	var issname = _hashHex(xISS.getSubjectHex(), algName);
+914 	var hSPKI = xISS.getPublicKeyHex();
+915 	var isskey = _hashHex(_getVbyList(hSPKI, 0, [1], "03", true), algName);
+916 	var sbjsn = xSBJ.getSerialNumberHex();
+917 	var info = {
+918 	    alg: algName,
+919 	    issname: issname,
+920 	    isskey: isskey,
+921 	    sbjsn: sbjsn
+922 	};
+923 	return info;
+924     };
+925 
+926     this.tohex = function() {
+927 	if (typeof this.params != "object") throw new Error("params not set");
+928 	    
+929 	var p = this.params;
+930 	var issname, isskey, sbjsn, alg;
+931 
+932 	if (p.alg == undefined) {
+933 	    alg = this.DEFAULT_HASH;
+934 	} else {
+935 	    alg = p.alg;
+936 	}
+937 
+938 	if (p.issuerCert != undefined &&
+939 	    p.subjectCert != undefined) {
+940 	    var info = this.getParamByCerts(p.issuerCert, p.subjectCert, alg);
+941 	    issname = info.issname;
+942 	    isskey = info.isskey;
+943 	    sbjsn = info.sbjsn;
+944 	} else if (p.issname != undefined &&
+945 		   p.isskey != undefined &&
+946 		   p.sbjsn != undefined) {
+947 	    issname = p.issname;
+948 	    isskey = p.isskey;
+949 	    sbjsn = p.sbjsn;
+950 	} else {
+951 	    throw new Error("required param members not defined");
+952 	}
+953 
+954 	var dAlg = new _AlgorithmIdentifier({name: alg});
+955 	var dIssName = new _DEROctetString({hex: issname});
+956 	var dIssKey = new _DEROctetString({hex: isskey});
+957 	var dSbjSn = new _DERInteger({hex: sbjsn});
+958 	var seq = new _DERSequence({array: [dAlg, dIssName, dIssKey, dSbjSn]});
+959         this.hTLV = seq.tohex();
+960         return this.hTLV;
+961     };
+962     this.getEncodedHex = function() { return this.tohex(); };
+963 
+964     if (params !== undefined) this.setByParam(params);
+965 };
+966 extendClass(KJUR.asn1.ocsp.CertID, KJUR.asn1.ASN1Object);
+967 
+968 /**
+969  * CertStatus ASN.1 class encoder<br/>
+970  * @name KJUR.asn1.ocsp.CertStatus
+971  * @class CertStatus ASN.1 class encoder
+972  * @param {Array} params JSON object for CertStatus parameter
+973  * @extends KJUR.asn1.ASN1Object
+974  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+975  * @see KJUR.asn1.ocsp.OCSPResponse
+976  * @see KJUR.asn1.ocsp.ResponseBytes
+977  * @see KJUR.asn1.ocsp.BasicOCSPResponse
+978  * @see KJUR.asn1.ocsp.ResponseData
+979  * @see KJUR.asn1.ocsp.SingleResponse
+980  * @see KJUR.asn1.ocsp.CertID
+981  * @see KJUR.asn1.ocsp.CertStatus
+982  *
+983  * @description
+984  * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
+985  * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+986  * <pre>
+987  * CertStatus ::= CHOICE {
+988  *     good        [0]     IMPLICIT NULL,
+989  *     revoked     [1]     IMPLICIT RevokedInfo,
+990  *     unknown     [2]     IMPLICIT UnknownInfo }
+991  * RevokedInfo ::= SEQUENCE {
+992  *     revocationTime              GeneralizedTime,
+993  *     revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
+994  * UnknownInfo ::= NULL
+995  * CRLReason ::= ENUMERATED {
+996  *      unspecified             (0),
+997  *      keyCompromise           (1),
+998  *      cACompromise            (2),
+999  *      affiliationChanged      (3),
+1000  *      superseded              (4),
+1001  *      cessationOfOperation    (5),
+1002  *      certificateHold         (6),
+1003  *           -- value 7 is not used
+1004  *      removeFromCRL           (8),
+1005  *      privilegeWithdrawn      (9),
+1006  *      aACompromise           (10) }
+1007  * </pre>
+1008  * Following properties are available:
+1009  * <ul>
+1010  * <li>{String}status - "good", "revoked" or "unknown"</li>
+1011  * <li>{String}time (OPTION) - revocationTime YYYYMMDDHHmmSSZ (ex. "20200904235959Z")</li>
+1012  * <li>{Number}reason (OPTION) - revocationReason code number</li>
+1013  * </ul>
+1014  *
+1015  * @example
+1016  * new KJUR.asn1.ocsp.CertStatus({status: "good"})
+1017  * new KJUR.asn1.ocsp.CertStatus({status: "revoked", time: "20200903235959Z"})
+1018  * new KJUR.asn1.ocsp.CertStatus({status: "revoked", time: "20200903235959Z", reason: 3})
+1019  * new KJUR.asn1.ocsp.CertStatus({status: "unknown"})
+1020  */
+1021 KJUR.asn1.ocsp.CertStatus = function(params) {
+1022     KJUR.asn1.ocsp.CertStatus.superclass.constructor.call(this);
+1023 
+1024     this.params = null;
+1025 
+1026     this.tohex = function() {
+1027 	var params = this.params;
+1028 	if (params.status == "good") return "8000";
+1029 	if (params.status == "unknown") return "8200";
+1030 	if (params.status == "revoked") {
+1031 	    var a = [{gentime: {str: params.time}}];
+1032 	    if (params.reason != undefined) {
+1033 		a.push({tag: {tag: 'a0', 
+1034 			      explicit: true,
+1035 			      obj: {'enum': {'int': params.reason}}}});
+1036 	    }
+1037 	    var tagParam = {tag: 'a1', explicit: false, obj: {seq: a}};
+1038 	    return KJUR.asn1.ASN1Util.newObject({tag: tagParam}).tohex();
+1039 	}
+1040 	throw new Error("bad status");
+1041     };
+1042     this.getEncodedHex = function() { return this.tohex(); };
+1043 
+1044     this.setByParam = function(params) {
+1045 	this.params = params;
+1046     };
+1047 
+1048     if (params !== undefined) this.setByParam(params);
+1049 };
+1050 extendClass(KJUR.asn1.ocsp.CertStatus, KJUR.asn1.ASN1Object);
+1051 
+1052 // ---- END OF Classes for OCSP response -----------------------------------
 1053 
-1054 	// 2. singleRequestExtensions (not supported yet)
-1055 
-1056 	// 3. construct SEQUENCE
-1057 	var seq = new _DERSequence({array: a});
-1058         this.hTLV = seq.tohex();
-1059         return this.hTLV;
-1060     };
-1061     this.getEncodedHex = function() { return this.tohex(); };
-1062 
-1063     if (typeof params !== "undefined") {
-1064 	var o = new _KJUR_asn1_ocsp.CertID(params);
-1065 	this.dReqCert = o;
-1066     }
-1067 };
-1068 extendClass(KJUR.asn1.ocsp.Request, KJUR.asn1.ASN1Object);
-1069 
-1070 /**
-1071  * ASN.1 TBSRequest class for OCSP<br/>
-1072  * @name KJUR.asn1.ocsp.TBSRequest
-1073  * @class ASN.1 TBSRequest class for OCSP
-1074  * @param {Array} params associative array of parameters
-1075  * @extends KJUR.asn1.ASN1Object
-1076  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1077  * @description
-1078  * TBSRequest ASN.1 class is defined in 
-1079  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1080  * <pre>
-1081  * TBSRequest ::= SEQUENCE {
-1082  *   version            [0] EXPLICIT Version DEFAULT v1,
-1083  *   requestorName      [1] EXPLICIT GeneralName OPTIONAL,
-1084  *   requestList            SEQUENCE OF Request,
-1085  *   requestExtensions  [2] EXPLICIT Extensions OPTIONAL }
-1086  * </pre>
-1087  * @example
-1088  * // default constructor
-1089  * o = new KJUR.asn1.ocsp.TBSRequest();
-1090  * // constructor with requestList parameter
-1091  * o = new KJUR.asn1.ocsp.TBSRequest({reqList:[
-1092  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
-1093  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
-1094  * ]});
-1095  */
-1096 KJUR.asn1.ocsp.TBSRequest = function(params) {
-1097     var _KJUR = KJUR,
-1098 	_KJUR_asn1 = _KJUR.asn1,
-1099 	_DERSequence = _KJUR_asn1.DERSequence,
-1100 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
-1101 
-1102     _KJUR_asn1_ocsp.TBSRequest.superclass.constructor.call(this);
-1103     this.version = 0;
-1104     this.dRequestorName = null;
-1105     this.dRequestList = [];
-1106     this.dRequestExt = null;
-1107 
-1108     /**
-1109      * set TBSRequest ASN.1 object by array of parameters.<br/>
-1110      * @name setRequestListByParam
-1111      * @memberOf KJUR.asn1.ocsp.TBSRequest#
-1112      * @function
-1113      * @param {Array} aParams array of parameters for Request class
-1114      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1115      * @example
-1116      * o = new KJUR.asn1.ocsp.TBSRequest();
-1117      * o.setRequestListByParam([
-1118      *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
-1119      *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
-1120      * ]);
-1121      */
-1122     this.setRequestListByParam = function(aParams) {
-1123 	var a = [];
-1124 	for (var i = 0; i < aParams.length; i++) {
-1125 	    var dReq = new _KJUR_asn1_ocsp.Request(aParams[0]);
-1126 	    a.push(dReq);
-1127 	}
-1128 	this.dRequestList = a;
-1129     };
-1130 
-1131     this.tohex = function() {
-1132 	var a = [];
-1133 
-1134 	// 1. version
-1135 	if (this.version !== 0)
-1136 	    throw "not supported version: " + this.version;
-1137 
-1138 	// 2. requestorName
-1139 	if (this.dRequestorName !== null)
-1140 	    throw "requestorName not supported";
-1141 
-1142 	// 3. requestList
-1143 	var seqRequestList = 
-1144 	    new _DERSequence({array: this.dRequestList});
-1145 	a.push(seqRequestList);
-1146 
-1147 	// 4. requestExtensions
-1148 	if (this.dRequestExt !== null)
-1149 	    throw "requestExtensions not supported";
-1150 
-1151 	// 5. construct SEQUENCE
-1152 	var seq = new _DERSequence({array: a});
-1153         this.hTLV = seq.tohex();
-1154         return this.hTLV;
-1155     };
-1156     this.getEncodedHex = function() { return this.tohex(); };
-1157 
-1158     if (params !== undefined) {
-1159 	if (params.reqList !== undefined)
-1160 	    this.setRequestListByParam(params.reqList);
-1161     }
-1162 };
-1163 extendClass(KJUR.asn1.ocsp.TBSRequest, KJUR.asn1.ASN1Object);
-1164 
-1165 
-1166 /**
-1167  * ASN.1 OCSPRequest class for OCSP<br/>
-1168  * @name KJUR.asn1.ocsp.OCSPRequest
-1169  * @class ASN.1 OCSPRequest class for OCSP
-1170  * @param {Array} params associative array of parameters
-1171  * @extends KJUR.asn1.ASN1Object
-1172  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1173  * @description
-1174  * OCSPRequest ASN.1 class is defined in 
-1175  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1176  * A signed request is not supported yet in this version.
-1177  * <pre>
-1178  * OCSPRequest ::= SEQUENCE {
-1179  *   tbsRequest             TBSRequest,
-1180  *   optionalSignature  [0] EXPLICIT Signature OPTIONAL }
-1181  * </pre>
-1182  * @example
-1183  * // default constructor
-1184  * o = new KJUR.asn1.ocsp.OCSPRequest();
-1185  * // constructor with requestList parameter
-1186  * o = new KJUR.asn1.ocsp.OCSPRequest({reqList:[
-1187  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
-1188  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
-1189  * ]});
-1190  */
-1191 KJUR.asn1.ocsp.OCSPRequest = function(params) {
-1192     var _KJUR = KJUR,
-1193 	_KJUR_asn1 = _KJUR.asn1,
-1194 	_DERSequence = _KJUR_asn1.DERSequence,
-1195 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
-1196 
-1197     _KJUR_asn1_ocsp.OCSPRequest.superclass.constructor.call(this);
-1198     this.dTbsRequest = null;
-1199     this.dOptionalSignature = null;
-1200 
-1201     this.tohex = function() {
-1202 	var a = [];
-1203 
-1204 	// 1. tbsRequest
-1205 	if (this.dTbsRequest !== null) {
-1206 	    a.push(this.dTbsRequest);
-1207 	} else {
-1208 	    throw "tbsRequest not set";
-1209 	}
-1210 
-1211 	// 2. optionalSignature
-1212 	if (this.dOptionalSignature !== null)
-1213 	    throw "optionalSignature not supported";
-1214 
-1215 	// 3. construct SEQUENCE
-1216 	var seq = new _DERSequence({array: a});
-1217         this.hTLV = seq.tohex();
-1218         return this.hTLV;
-1219     };
-1220     this.getEncodedHex = function() { return this.tohex(); };
-1221 
-1222     if (params !== undefined) {
-1223 	if (params.reqList !== undefined) {
-1224 	    var o = new _KJUR_asn1_ocsp.TBSRequest(params);
-1225 	    this.dTbsRequest = o;
-1226 	}
-1227     }
-1228 };
-1229 extendClass(KJUR.asn1.ocsp.OCSPRequest, KJUR.asn1.ASN1Object);
-1230 
-1231 /**
-1232  * Utility class for OCSP<br/>
-1233  * @name KJUR.asn1.ocsp.OCSPUtil
-1234  * @class Utility class for OCSP
-1235  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1236  * @description
-1237  * This class provides utility static methods for OCSP.
-1238  * <ul>
-1239  * <li>{@link KJUR.asn1.ocsp.OCSPUtil.getRequestHex} - generates hexadecimal string of OCSP request</li>
-1240  * </ul>
-1241  */
-1242 KJUR.asn1.ocsp.OCSPUtil = {};
-1243 
-1244 /**
-1245  * generates hexadecimal string of OCSP request<br/>
-1246  * @name getRequestHex
-1247  * @memberOf KJUR.asn1.ocsp.OCSPUtil
-1248  * @function
-1249  * @param {String} issuerCert string of PEM issuer certificate
-1250  * @param {String} subjectCert string of PEM subject certificate to be verified by OCSP
-1251  * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
-1252  * @return {String} hexadecimal string of generated OCSP request
-1253  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
-1254  * @description
-1255  * This static method generates hexadecimal string of OCSP request.
-1256  * @example
-1257  * // generate OCSP request using sha1 algorithnm by default.
-1258  * hReq = KJUR.asn1.ocsp.OCSPUtil.getRequestHex("-----BEGIN...", "-----BEGIN...");
-1259  */
-1260 KJUR.asn1.ocsp.OCSPUtil.getRequestHex = function(issuerCert, subjectCert, alg) {
-1261     var _KJUR = KJUR,
-1262 	_KJUR_asn1 = _KJUR.asn1,
-1263 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
-1264 
-1265     if (alg === undefined) alg = _KJUR_asn1_ocsp.DEFAULT_HASH;
-1266     var param = {alg: alg, issuerCert: issuerCert, subjectCert: subjectCert};
-1267     var o = new _KJUR_asn1_ocsp.OCSPRequest({reqList: [param]});
-1268     return o.tohex();
-1269 };
-1270 
-1271 /**
-1272  * simple parser for OCSPResponse (DEPRECATED)<br/>
-1273  * @name getOCSPResponseInfo
-1274  * @memberOf KJUR.asn1.ocsp.OCSPUtil
-1275  * @function
-1276  * @param {String} h hexadecimal string of DER OCSPResponse
-1277  * @return {Object} JSON object of parsed OCSPResponse
-1278  * @since jsrsasign 6.1.0 asn1ocsp 1.0.1
-1279  * @deprecated since jsrsasign 10.4.0 asn1ocsp 1.1.5 Please use OCSPParser.getOCSPRespnose
-1280  *
-1281  * @description
-1282  * This static method parse a hexadecimal string of DER OCSPResponse and
-1283  * returns JSON object of its parsed result.
-1284  * Its result has following properties:
-1285  * <ul>
-1286  * <li>responseStatus - integer of responseStatus</li>
-1287  * <li>certStatus - string of certStatus (ex. good, revoked or unknown)</li>
-1288  * <li>thisUpdate - string of thisUpdate in Zulu(ex. 20151231235959Z)</li>
-1289  * <li>nextUpdate - string of nextUpdate in Zulu(ex. 20151231235959Z)</li>
-1290  * </ul>
-1291  * NOTE: This method may not work preperly. Please use 
-1292  * {@link KJUR.asn1.ocsp.OCSPParser#getOCSPResponse}.
-1293  *
-1294  * @example
-1295  * info = KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo("3082...");
-1296  */
-1297 KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo = function(h) {
-1298     var _ASN1HEX = ASN1HEX,
-1299 	_getVbyList = _ASN1HEX.getVbyList,
-1300 	_getVbyListEx = _ASN1HEX.getVbyListEx,
-1301 	_getIdxbyList = _ASN1HEX.getIdxbyList,
-1302 	_getIdxbyListEx = _ASN1HEX.getIdxbyListEx,
-1303 	_getV = _ASN1HEX.getV;
-1304 
-1305     var result = {};
-1306     try {
-1307 	var v = _getVbyListEx(h, 0, [0], "0a");
-1308 	result.responseStatus = parseInt(v, 16);
-1309     } catch(ex) {};
-1310     if (result.responseStatus !== 0) return result;
-1311 
-1312     try {
-1313 	// certStatus
-1314 	var idxCertStatus = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,1]);
-1315 	if (h.substr(idxCertStatus, 2) === "80") {
-1316 	    result.certStatus = "good";
-1317 	} else if (h.substr(idxCertStatus, 2) === "a1") {
-1318 	    result.certStatus = "revoked";
-1319 	    result.revocationTime = 
-1320 		hextoutf8(_getVbyList(h, idxCertStatus, [0]));
-1321 	} else if (h.substr(idxCertStatus, 2) === "82") {
-1322 	    result.certStatus = "unknown";
-1323 	}
-1324     } catch (ex) {};
-1325 
-1326     // thisUpdate
-1327     try {
-1328 	var idxThisUpdate = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,2]);
-1329 	result.thisUpdate = hextoutf8(_getV(h, idxThisUpdate));
-1330     } catch (ex) {};
-1331 
-1332     // nextUpdate
-1333     try {
-1334 	var idxEncapNextUpdate = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,3]);
-1335 	if (h.substr(idxEncapNextUpdate, 2) === "a0") {
-1336 	    result.nextUpdate = 
-1337 		hextoutf8(_getVbyList(h, idxEncapNextUpdate, [0]));
-1338 	}
-1339     } catch (ex) {};
-1340 
-1341     return result;
-1342 };
-1343 
-1344 /**
-1345  * OCSP request and response parser<br/>
-1346  * @name KJUR.asn1.ocsp.OCSPParser
-1347  * @class OCSP request and response parser
-1348  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1349  *
-1350  * @description
-1351  * This class provides ASN.1 parser for
-1352  * OCSP related ASN.1 data. <br/>
-1353  * NOTE: OCSPResponse parser supported from jsrsasign 10.4.0.
-1354  * <br/>
-1355  * This parser supports following OCSP ASN.1 classes:
-1356  * <ul>
-1357  * <li>OCSP REQUEST
-1358  * <ul>
-1359  * <li>OCSPRequest - {@link KJUR.asn1.ocsp.OCSPParser#getOCSPRequest}</li>
-1360  * <li>TBSRequest - {@link KJUR.asn1.ocsp.OCSPParser#getTBSRequest}</li>
-1361  * <li>SEQUENCE OF Request - {@link KJUR.asn1.ocsp.OCSPParser#getRequestList}</li>
-1362  * <li>Request - {@link KJUR.asn1.ocsp.OCSPParser#getRequest}</li>
-1363  * </ul>
-1364  * </li>
-1365  * <li>OCSP RESPONSE
-1366  * <ul>
-1367  * <li>OCSPResponse - {@link KJUR.asn1.ocsp.OCSPParser#getOCSPResponse}</li>
-1368  * <li>ResponseBytes - {@link KJUR.asn1.ocsp.OCSPParser#getResponseBytes}</li>
-1369  * <li>BasicOCSPResponse - {@link KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse}</li>
-1370  * <li>ResponseData - {@link KJUR.asn1.ocsp.OCSPParser#getResponseData}</li>
-1371  * <li>ResponderID - {@link KJUR.asn1.ocsp.OCSPParser#getResponderID}</li>
-1372  * <li>SEQUENCE OF SingleResponse - {@link KJUR.asn1.ocsp.OCSPParser#getSingleResponseList}</li>
-1373  * <li>SingleResponse - {@link KJUR.asn1.ocsp.OCSPParser#getSingleResponse}</li>
-1374  * <li>CertStatus - {@link KJUR.asn1.ocsp.OCSPParser#getCertStatus}</li>
-1375  * </ul>
-1376  * </li>
-1377  * <li>common
-1378  * <ul>
-1379  * <li>CertID - {@link KJUR.asn1.ocsp.OCSPParser#getCertID}</li>
-1380  * </ul>
-1381  * </li>
-1382  * </ul>
-1383  */
-1384 KJUR.asn1.ocsp.OCSPParser = function() {
-1385     var _Error = Error,
-1386 	_X509 = X509,
-1387 	_x509obj = new _X509(),
-1388 	_ASN1HEX = ASN1HEX,
-1389 	_getV = _ASN1HEX.getV,
-1390 	_getTLV = _ASN1HEX.getTLV,
-1391 	_getIdxbyList = _ASN1HEX.getIdxbyList,
-1392 	_getVbyList = _ASN1HEX.getVbyList,
-1393 	_getTLVbyList = _ASN1HEX.getTLVbyList,
-1394 	_getVbyListEx = _ASN1HEX.getVbyListEx,
-1395 	_getTLVbyListEx = _ASN1HEX.getTLVbyListEx,
-1396 	_getChildIdx = _ASN1HEX.getChildIdx;
-1397 
-1398     /**
-1399      * parse ASN.1 OCSPRequest<br/>
-1400      * @name getOCSPRequest
-1401      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1402      * @function
-1403      * @param {String} h hexadecimal string of ASN.1 OCSPRequest
-1404      * @return {Array} array of JSON object of OCSPRequest parameter
-1405      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1406      *
-1407      * @description
-1408      * This method will parse a hexadecimal string of 
-1409      * OCSPRequest ASN.1 class is defined in 
-1410      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1411      * <pre>
-1412      * OCSPRequest ::= SEQUENCE {
-1413      *   tbsRequest              TBSRequest,
-1414      *   optionalSignature  [0]  EXPLICIT Signature OPTIONAL }
-1415      * TBSRequest  ::=  SEQUENCE {
-1416      *   version            [0]  EXPLICIT Version DEFAULT v1,
-1417      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
-1418      *   requestList             SEQUENCE OF Request,
-1419      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
-1420      * Signature       ::=     SEQUENCE {
-1421      *   signatureAlgorithm      AlgorithmIdentifier,
-1422      *   signature               BIT STRING,
-1423      *   certs              [0] EXPLICIT SEQUENCE OF Certificate
-1424      *                          OPTIONAL}
-1425      * </pre>
-1426      * Currently Signature in OCSPRequest is not supported.
-1427      * <br/>
-1428      * 
-1429      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
-1430      * @see KJUR.asn1.ocsp.OCSPRequest
-1431      *
-1432      * @example
-1433      * o = new KJUR.asn1.ocsp.OCSPParser();
-1434      * o.getOCSPRequest("30...") →
-1435      * { array: [{
-1436      *    "alg": "sha1",
-1437      *    "issname": "105fa67a80089db5279f35ce830b43889ea3c70d",
-1438      *    "isskey": "0f80611c823161d52f28e78d4638b42ce1c6d9e2",
-1439      *    "sbjsn": "0fef62075d715dc5e1d8bd03775c9686" }]}
-1440      */
-1441     this.getOCSPRequest = function(h) {
-1442 	var a = _getChildIdx(h, 0);
-1443 
-1444 	if (a.length != 1 && a.length != 2) {
-1445 	    throw new _Error("wrong number elements: " + a.length);
-1446 	}
-1447 
-1448 	var result = this.getTBSRequest(_getTLV(h, a[0]));
-1449 	return result;
-1450     };
-1451 
-1452     /**
-1453      * parse ASN.1 TBSRequest of OCSP<br/>
-1454      * @name getTBSRequest
-1455      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1456      * @function
-1457      * @param {String} h hexadecimal string of ASN.1 TBSRequest of OCSP
-1458      * @return {Array} array of JSON object of TBSRequest parameter
-1459      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1460      *
-1461      * @description
-1462      * This method will parse
-1463      * TBSRequest ASN.1 class is defined in 
-1464      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1465      * <pre>
-1466      * TBSRequest  ::=  SEQUENCE {
-1467      *   version            [0]  EXPLICIT Version DEFAULT v1,
-1468      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
-1469      *   requestList             SEQUENCE OF Request,
-1470      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
-1471      * </pre>
-1472      *
-1473      * @see KJUR.asn1.ocsp.OCSPParser#getOCSPRequest
-1474      * @see KJUR.asn1.ocsp.OCSPParser#getRequestList
-1475      * @see KJUR.asn1.ocsp.TBSRequest
-1476      *
-1477      * @example
-1478      * o = new KJUR.asn1.ocsp.OCSPParser();
-1479      * o.getTBSRequest("30...") →
-1480      * {array: [{
-1481      *   "alg": "sha1",
-1482      *   "issname": "105fa67a80089db5279f35ce830b43889ea3c70d",
-1483      *   "isskey": "0f80611c823161d52f28e78d4638b42ce1c6d9e2",
-1484      *   "sbjsn": "0fef62075d715dc5e1d8bd03775c9686" }]}
-1485      */
-1486     this.getTBSRequest = function(h) {
-1487 	var result = {};
-1488 	var hReqList = _getTLVbyListEx(h, 0, [0], "30");
-1489 	result.array = this.getRequestList(hReqList);
-1490 	var hExt = _getTLVbyListEx(h, 0, ["[2]", 0], "30");
-1491 	if (hExt != null) {
-1492 	    result.ext = _x509obj.getExtParamArray(hExt);
-1493 	}
-1494 
-1495 	return result;
-1496     };
-1497 
-1498     /**
-1499      * parse ASN.1 SEQUENCE OF Request in OCSP<br/>
-1500      * @name getRequestList
-1501      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1502      * @function
-1503      * @param {String} h hexadecimal string of ASN.1 SEQUENCE OF Request in OCSP
-1504      * @return {Array} array of JSON object of Request parameter
-1505      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1506      *
-1507      * @description
-1508      * This method will parse a hexadecimal string of
-1509      * SEQUENCE OF Request ASN.1 class is defined in 
-1510      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1511      * <br/>
-1512      * NOTE: singleRequestExtensions is not supported yet in this version such as nonce.
-1513      * <pre>
-1514      * TBSRequest  ::=  SEQUENCE {
-1515      *   version            [0]  EXPLICIT Version DEFAULT v1,
-1516      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
-1517      *   requestList             SEQUENCE OF Request,
-1518      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
-1519      * Request ::= SEQUENCE {
-1520      *   reqCert                  CertID,
-1521      *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }      
-1522      * </pre>
-1523      *
-1524      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
-1525      * @see KJUR.asn1.ocsp.OCSPParser#getRequest
-1526      * @see KJUR.asn1.ocsp.RequestList
-1527      * @see KJUR.asn1.ocsp.Request
-1528      *
-1529      * @example
-1530      * o = new KJUR.asn1.ocsp.OCSPParser();
-1531      * o.getRequestList("30...") →
-1532      * [{ alg: "sha1"
-1533      *   issname: "...hex...",
-1534      *   isskey: "...hex...",
-1535      *   sbjsn: "...hex...",
-1536      *   ext: [<<singleRequestExtension parameters>>...] }]
-1537      */
-1538     this.getRequestList = function(h) {
-1539 	var result = [];
-1540 	var a = _getChildIdx(h, 0);
-1541 	for (var i = 0; i < a.length; i++) {
-1542 	    var h = _getTLV(h, a[i]);
-1543 	    result.push(this.getRequest(h));
-1544 	}
-1545 	return result;
-1546     };
-1547 
-1548     /**
-1549      * parse ASN.1 Request of OCSP<br/>
-1550      * @name getRequest
-1551      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1552      * @function
-1553      * @param {String} h hexadecimal string of ASN.1 Request of OCSP
-1554      * @return JSON object of Request parameter
-1555      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1556      *
-1557      * @description
-1558      * This method will parse a hexadecimal string of
-1559      * Request ASN.1 class is defined in 
-1560      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1561      * <pre>
-1562      * Request ::= SEQUENCE {
-1563      *   reqCert                  CertID,
-1564      *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }      
-1565      * </pre>
-1566      *
-1567      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
-1568      * @see KJUR.asn1.ocsp.OCSPParser#getRequestList
-1569      * @see KJUR.asn1.ocsp.OCSPParser#getCertID
+1054 /**
+1055  * ASN.1 Request class for OCSP<br/>
+1056  * @name KJUR.asn1.ocsp.Request
+1057  * @class ASN.1 Request class for OCSP
+1058  * @param {Array} params associative array of parameters
+1059  * @extends KJUR.asn1.ASN1Object
+1060  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1061  * @description
+1062  * Request ASN.1 class is defined in 
+1063  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1064  * singleRequestExtensions is not supported yet in this version such as nonce.
+1065  * <pre>
+1066  * Request ::= SEQUENCE {
+1067  *   reqCert                  CertID,
+1068  *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }
+1069  * </pre>
+1070  * @example
+1071  * // default constructor
+1072  * o = new KJUR.asn1.ocsp.Request();
+1073  * // constructor with certs (sha1 is used by default)
+1074  * o = new KJUR.asn1.ocsp.Request({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN..."});
+1075  * // constructor with certs and sha256
+1076  * o = new KJUR.asn1.ocsp.Request({issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"});
+1077  * // constructor with values
+1078  * o = new KJUR.asn1.ocsp.Request({namehash: "1a...", keyhash: "ad...", serial: "1234", alg: "sha256"});
+1079  */
+1080 KJUR.asn1.ocsp.Request = function(params) {
+1081     var _KJUR = KJUR,
+1082 	_KJUR_asn1 = _KJUR.asn1,
+1083 	_DERSequence = _KJUR_asn1.DERSequence,
+1084 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
+1085     
+1086     _KJUR_asn1_ocsp.Request.superclass.constructor.call(this);
+1087     this.dReqCert = null;
+1088     this.dExt = null;
+1089     
+1090     this.tohex = function() {
+1091 	var a = [];
+1092 
+1093 	// 1. reqCert
+1094 	if (this.dReqCert === null)
+1095 	    throw "reqCert not set";
+1096 	a.push(this.dReqCert);
+1097 
+1098 	// 2. singleRequestExtensions (not supported yet)
+1099 
+1100 	// 3. construct SEQUENCE
+1101 	var seq = new _DERSequence({array: a});
+1102         this.hTLV = seq.tohex();
+1103         return this.hTLV;
+1104     };
+1105     this.getEncodedHex = function() { return this.tohex(); };
+1106 
+1107     if (typeof params !== "undefined") {
+1108 	var o = new _KJUR_asn1_ocsp.CertID(params);
+1109 	this.dReqCert = o;
+1110     }
+1111 };
+1112 extendClass(KJUR.asn1.ocsp.Request, KJUR.asn1.ASN1Object);
+1113 
+1114 /**
+1115  * ASN.1 TBSRequest class for OCSP<br/>
+1116  * @name KJUR.asn1.ocsp.TBSRequest
+1117  * @class ASN.1 TBSRequest class for OCSP
+1118  * @param {Array} params associative array of parameters
+1119  * @extends KJUR.asn1.ASN1Object
+1120  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1121  * @description
+1122  * TBSRequest ASN.1 class is defined in 
+1123  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1124  * <pre>
+1125  * TBSRequest ::= SEQUENCE {
+1126  *   version            [0] EXPLICIT Version DEFAULT v1,
+1127  *   requestorName      [1] EXPLICIT GeneralName OPTIONAL,
+1128  *   requestList            SEQUENCE OF Request,
+1129  *   requestExtensions  [2] EXPLICIT Extensions OPTIONAL }
+1130  * </pre>
+1131  * @example
+1132  * // default constructor
+1133  * o = new KJUR.asn1.ocsp.TBSRequest();
+1134  * // constructor with requestList parameter
+1135  * o = new KJUR.asn1.ocsp.TBSRequest({reqList:[
+1136  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
+1137  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
+1138  * ]});
+1139  */
+1140 KJUR.asn1.ocsp.TBSRequest = function(params) {
+1141     var _KJUR = KJUR,
+1142 	_KJUR_asn1 = _KJUR.asn1,
+1143 	_DERSequence = _KJUR_asn1.DERSequence,
+1144 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
+1145 
+1146     _KJUR_asn1_ocsp.TBSRequest.superclass.constructor.call(this);
+1147     this.version = 0;
+1148     this.dRequestorName = null;
+1149     this.dRequestList = [];
+1150     this.dRequestExt = null;
+1151 
+1152     /**
+1153      * set TBSRequest ASN.1 object by array of parameters.<br/>
+1154      * @name setRequestListByParam
+1155      * @memberOf KJUR.asn1.ocsp.TBSRequest#
+1156      * @function
+1157      * @param {Array} aParams array of parameters for Request class
+1158      * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1159      * @example
+1160      * o = new KJUR.asn1.ocsp.TBSRequest();
+1161      * o.setRequestListByParam([
+1162      *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
+1163      *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
+1164      * ]);
+1165      */
+1166     this.setRequestListByParam = function(aParams) {
+1167 	var a = [];
+1168 	for (var i = 0; i < aParams.length; i++) {
+1169 	    var dReq = new _KJUR_asn1_ocsp.Request(aParams[0]);
+1170 	    a.push(dReq);
+1171 	}
+1172 	this.dRequestList = a;
+1173     };
+1174 
+1175     this.tohex = function() {
+1176 	var a = [];
+1177 
+1178 	// 1. version
+1179 	if (this.version !== 0)
+1180 	    throw "not supported version: " + this.version;
+1181 
+1182 	// 2. requestorName
+1183 	if (this.dRequestorName !== null)
+1184 	    throw "requestorName not supported";
+1185 
+1186 	// 3. requestList
+1187 	var seqRequestList = 
+1188 	    new _DERSequence({array: this.dRequestList});
+1189 	a.push(seqRequestList);
+1190 
+1191 	// 4. requestExtensions
+1192 	if (this.dRequestExt !== null)
+1193 	    throw "requestExtensions not supported";
+1194 
+1195 	// 5. construct SEQUENCE
+1196 	var seq = new _DERSequence({array: a});
+1197         this.hTLV = seq.tohex();
+1198         return this.hTLV;
+1199     };
+1200     this.getEncodedHex = function() { return this.tohex(); };
+1201 
+1202     if (params !== undefined) {
+1203 	if (params.reqList !== undefined)
+1204 	    this.setRequestListByParam(params.reqList);
+1205     }
+1206 };
+1207 extendClass(KJUR.asn1.ocsp.TBSRequest, KJUR.asn1.ASN1Object);
+1208 
+1209 
+1210 /**
+1211  * ASN.1 OCSPRequest class for OCSP<br/>
+1212  * @name KJUR.asn1.ocsp.OCSPRequest
+1213  * @class ASN.1 OCSPRequest class for OCSP
+1214  * @param {Array} params associative array of parameters
+1215  * @extends KJUR.asn1.ASN1Object
+1216  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1217  * @description
+1218  * OCSPRequest ASN.1 class is defined in 
+1219  * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1220  * A signed request is not supported yet in this version.
+1221  * <pre>
+1222  * OCSPRequest ::= SEQUENCE {
+1223  *   tbsRequest             TBSRequest,
+1224  *   optionalSignature  [0] EXPLICIT Signature OPTIONAL }
+1225  * </pre>
+1226  * @example
+1227  * // default constructor
+1228  * o = new KJUR.asn1.ocsp.OCSPRequest();
+1229  * // constructor with requestList parameter
+1230  * o = new KJUR.asn1.ocsp.OCSPRequest({reqList:[
+1231  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg:},
+1232  *   {issuerCert: "-----BEGIN...", subjectCert: "-----BEGIN...", alg: "sha256"}
+1233  * ]});
+1234  */
+1235 KJUR.asn1.ocsp.OCSPRequest = function(params) {
+1236     var _KJUR = KJUR,
+1237 	_KJUR_asn1 = _KJUR.asn1,
+1238 	_DERSequence = _KJUR_asn1.DERSequence,
+1239 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
+1240 
+1241     _KJUR_asn1_ocsp.OCSPRequest.superclass.constructor.call(this);
+1242     this.dTbsRequest = null;
+1243     this.dOptionalSignature = null;
+1244 
+1245     this.tohex = function() {
+1246 	var a = [];
+1247 
+1248 	// 1. tbsRequest
+1249 	if (this.dTbsRequest !== null) {
+1250 	    a.push(this.dTbsRequest);
+1251 	} else {
+1252 	    throw "tbsRequest not set";
+1253 	}
+1254 
+1255 	// 2. optionalSignature
+1256 	if (this.dOptionalSignature !== null)
+1257 	    throw "optionalSignature not supported";
+1258 
+1259 	// 3. construct SEQUENCE
+1260 	var seq = new _DERSequence({array: a});
+1261         this.hTLV = seq.tohex();
+1262         return this.hTLV;
+1263     };
+1264     this.getEncodedHex = function() { return this.tohex(); };
+1265 
+1266     if (params !== undefined) {
+1267 	if (params.reqList !== undefined) {
+1268 	    var o = new _KJUR_asn1_ocsp.TBSRequest(params);
+1269 	    this.dTbsRequest = o;
+1270 	}
+1271     }
+1272 };
+1273 extendClass(KJUR.asn1.ocsp.OCSPRequest, KJUR.asn1.ASN1Object);
+1274 
+1275 /**
+1276  * Utility class for OCSP<br/>
+1277  * @name KJUR.asn1.ocsp.OCSPUtil
+1278  * @class Utility class for OCSP
+1279  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1280  * @description
+1281  * This class provides utility static methods for OCSP.
+1282  * <ul>
+1283  * <li>{@link KJUR.asn1.ocsp.OCSPUtil.getRequestHex} - generates hexadecimal string of OCSP request</li>
+1284  * </ul>
+1285  */
+1286 KJUR.asn1.ocsp.OCSPUtil = {};
+1287 
+1288 /**
+1289  * generates hexadecimal string of OCSP request<br/>
+1290  * @name getRequestHex
+1291  * @memberOf KJUR.asn1.ocsp.OCSPUtil
+1292  * @function
+1293  * @param {String} issuerCert string of PEM issuer certificate
+1294  * @param {String} subjectCert string of PEM subject certificate to be verified by OCSP
+1295  * @param {String} algName hash algorithm name used for above arguments (ex. "sha1") DEFAULT: sha1
+1296  * @return {String} hexadecimal string of generated OCSP request
+1297  * @since jsrsasign 6.1.0 asn1ocsp 1.0.0
+1298  * @description
+1299  * This static method generates hexadecimal string of OCSP request.
+1300  * @example
+1301  * // generate OCSP request using sha1 algorithnm by default.
+1302  * hReq = KJUR.asn1.ocsp.OCSPUtil.getRequestHex("-----BEGIN...", "-----BEGIN...");
+1303  */
+1304 KJUR.asn1.ocsp.OCSPUtil.getRequestHex = function(issuerCert, subjectCert, alg) {
+1305     var _KJUR = KJUR,
+1306 	_KJUR_asn1 = _KJUR.asn1,
+1307 	_KJUR_asn1_ocsp = _KJUR_asn1.ocsp;
+1308 
+1309     if (alg === undefined) alg = _KJUR_asn1_ocsp.DEFAULT_HASH;
+1310     var param = {alg: alg, issuerCert: issuerCert, subjectCert: subjectCert};
+1311     var o = new _KJUR_asn1_ocsp.OCSPRequest({reqList: [param]});
+1312     return o.tohex();
+1313 };
+1314 
+1315 /**
+1316  * simple parser for OCSPResponse (DEPRECATED)<br/>
+1317  * @name getOCSPResponseInfo
+1318  * @memberOf KJUR.asn1.ocsp.OCSPUtil
+1319  * @function
+1320  * @param {String} h hexadecimal string of DER OCSPResponse
+1321  * @return {Object} JSON object of parsed OCSPResponse
+1322  * @since jsrsasign 6.1.0 asn1ocsp 1.0.1
+1323  * @deprecated since jsrsasign 10.4.0 asn1ocsp 1.1.5 Please use OCSPParser.getOCSPRespnose
+1324  *
+1325  * @description
+1326  * This static method parse a hexadecimal string of DER OCSPResponse and
+1327  * returns JSON object of its parsed result.
+1328  * Its result has following properties:
+1329  * <ul>
+1330  * <li>responseStatus - integer of responseStatus</li>
+1331  * <li>certStatus - string of certStatus (ex. good, revoked or unknown)</li>
+1332  * <li>thisUpdate - string of thisUpdate in Zulu(ex. 20151231235959Z)</li>
+1333  * <li>nextUpdate - string of nextUpdate in Zulu(ex. 20151231235959Z)</li>
+1334  * </ul>
+1335  * NOTE: This method may not work preperly. Please use 
+1336  * {@link KJUR.asn1.ocsp.OCSPParser#getOCSPResponse}.
+1337  *
+1338  * @example
+1339  * info = KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo("3082...");
+1340  */
+1341 KJUR.asn1.ocsp.OCSPUtil.getOCSPResponseInfo = function(h) {
+1342     var _ASN1HEX = ASN1HEX,
+1343 	_getVbyList = _ASN1HEX.getVbyList,
+1344 	_getVbyListEx = _ASN1HEX.getVbyListEx,
+1345 	_getIdxbyList = _ASN1HEX.getIdxbyList,
+1346 	_getIdxbyListEx = _ASN1HEX.getIdxbyListEx,
+1347 	_getV = _ASN1HEX.getV;
+1348 
+1349     var result = {};
+1350     try {
+1351 	var v = _getVbyListEx(h, 0, [0], "0a");
+1352 	result.responseStatus = parseInt(v, 16);
+1353     } catch(ex) {};
+1354     if (result.responseStatus !== 0) return result;
+1355 
+1356     try {
+1357 	// certStatus
+1358 	var idxCertStatus = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,1]);
+1359 	if (h.substr(idxCertStatus, 2) === "80") {
+1360 	    result.certStatus = "good";
+1361 	} else if (h.substr(idxCertStatus, 2) === "a1") {
+1362 	    result.certStatus = "revoked";
+1363 	    result.revocationTime = 
+1364 		hextoutf8(_getVbyList(h, idxCertStatus, [0]));
+1365 	} else if (h.substr(idxCertStatus, 2) === "82") {
+1366 	    result.certStatus = "unknown";
+1367 	}
+1368     } catch (ex) {};
+1369 
+1370     // thisUpdate
+1371     try {
+1372 	var idxThisUpdate = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,2]);
+1373 	result.thisUpdate = hextoutf8(_getV(h, idxThisUpdate));
+1374     } catch (ex) {};
+1375 
+1376     // nextUpdate
+1377     try {
+1378 	var idxEncapNextUpdate = _getIdxbyList(h, 0, [1,0,1,0,0,2,0,3]);
+1379 	if (h.substr(idxEncapNextUpdate, 2) === "a0") {
+1380 	    result.nextUpdate = 
+1381 		hextoutf8(_getVbyList(h, idxEncapNextUpdate, [0]));
+1382 	}
+1383     } catch (ex) {};
+1384 
+1385     return result;
+1386 };
+1387 
+1388 /**
+1389  * OCSP request and response parser<br/>
+1390  * @name KJUR.asn1.ocsp.OCSPParser
+1391  * @class OCSP request and response parser
+1392  * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1393  *
+1394  * @description
+1395  * This class provides ASN.1 parser for
+1396  * OCSP related ASN.1 data. <br/>
+1397  * NOTE: OCSPResponse parser supported from jsrsasign 10.4.0.
+1398  * <br/>
+1399  * This parser supports following OCSP ASN.1 classes:
+1400  * <ul>
+1401  * <li>OCSP REQUEST
+1402  * <ul>
+1403  * <li>OCSPRequest - {@link KJUR.asn1.ocsp.OCSPParser#getOCSPRequest}</li>
+1404  * <li>TBSRequest - {@link KJUR.asn1.ocsp.OCSPParser#getTBSRequest}</li>
+1405  * <li>SEQUENCE OF Request - {@link KJUR.asn1.ocsp.OCSPParser#getRequestList}</li>
+1406  * <li>Request - {@link KJUR.asn1.ocsp.OCSPParser#getRequest}</li>
+1407  * </ul>
+1408  * </li>
+1409  * <li>OCSP RESPONSE
+1410  * <ul>
+1411  * <li>OCSPResponse - {@link KJUR.asn1.ocsp.OCSPParser#getOCSPResponse}</li>
+1412  * <li>ResponseBytes - {@link KJUR.asn1.ocsp.OCSPParser#getResponseBytes}</li>
+1413  * <li>BasicOCSPResponse - {@link KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse}</li>
+1414  * <li>ResponseData - {@link KJUR.asn1.ocsp.OCSPParser#getResponseData}</li>
+1415  * <li>ResponderID - {@link KJUR.asn1.ocsp.OCSPParser#getResponderID}</li>
+1416  * <li>SEQUENCE OF SingleResponse - {@link KJUR.asn1.ocsp.OCSPParser#getSingleResponseList}</li>
+1417  * <li>SingleResponse - {@link KJUR.asn1.ocsp.OCSPParser#getSingleResponse}</li>
+1418  * <li>CertStatus - {@link KJUR.asn1.ocsp.OCSPParser#getCertStatus}</li>
+1419  * </ul>
+1420  * </li>
+1421  * <li>common
+1422  * <ul>
+1423  * <li>CertID - {@link KJUR.asn1.ocsp.OCSPParser#getCertID}</li>
+1424  * </ul>
+1425  * </li>
+1426  * </ul>
+1427  */
+1428 KJUR.asn1.ocsp.OCSPParser = function() {
+1429     var _Error = Error,
+1430 	_X509 = X509,
+1431 	_x509obj = new _X509(),
+1432 	_ASN1HEX = ASN1HEX,
+1433 	_getV = _ASN1HEX.getV,
+1434 	_getTLV = _ASN1HEX.getTLV,
+1435 	_getIdxbyList = _ASN1HEX.getIdxbyList,
+1436 	_getVbyList = _ASN1HEX.getVbyList,
+1437 	_getTLVbyList = _ASN1HEX.getTLVbyList,
+1438 	_getVbyListEx = _ASN1HEX.getVbyListEx,
+1439 	_getTLVbyListEx = _ASN1HEX.getTLVbyListEx,
+1440 	_getChildIdx = _ASN1HEX.getChildIdx;
+1441 
+1442     /**
+1443      * parse ASN.1 OCSPRequest<br/>
+1444      * @name getOCSPRequest
+1445      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1446      * @function
+1447      * @param {String} h hexadecimal string of ASN.1 OCSPRequest
+1448      * @return {Array} array of JSON object of OCSPRequest parameter
+1449      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1450      *
+1451      * @description
+1452      * This method will parse a hexadecimal string of 
+1453      * OCSPRequest ASN.1 class is defined in 
+1454      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1455      * <pre>
+1456      * OCSPRequest ::= SEQUENCE {
+1457      *   tbsRequest              TBSRequest,
+1458      *   optionalSignature  [0]  EXPLICIT Signature OPTIONAL }
+1459      * TBSRequest  ::=  SEQUENCE {
+1460      *   version            [0]  EXPLICIT Version DEFAULT v1,
+1461      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
+1462      *   requestList             SEQUENCE OF Request,
+1463      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
+1464      * Signature       ::=     SEQUENCE {
+1465      *   signatureAlgorithm      AlgorithmIdentifier,
+1466      *   signature               BIT STRING,
+1467      *   certs              [0] EXPLICIT SEQUENCE OF Certificate
+1468      *                          OPTIONAL}
+1469      * </pre>
+1470      * Currently Signature in OCSPRequest is not supported.
+1471      * <br/>
+1472      * 
+1473      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
+1474      * @see KJUR.asn1.ocsp.OCSPRequest
+1475      *
+1476      * @example
+1477      * o = new KJUR.asn1.ocsp.OCSPParser();
+1478      * o.getOCSPRequest("30...") →
+1479      * { array: [{
+1480      *    "alg": "sha1",
+1481      *    "issname": "105fa67a80089db5279f35ce830b43889ea3c70d",
+1482      *    "isskey": "0f80611c823161d52f28e78d4638b42ce1c6d9e2",
+1483      *    "sbjsn": "0fef62075d715dc5e1d8bd03775c9686" }]}
+1484      */
+1485     this.getOCSPRequest = function(h) {
+1486 	var a = _getChildIdx(h, 0);
+1487 
+1488 	if (a.length != 1 && a.length != 2) {
+1489 	    throw new _Error("wrong number elements: " + a.length);
+1490 	}
+1491 
+1492 	var result = this.getTBSRequest(_getTLV(h, a[0]));
+1493 	return result;
+1494     };
+1495 
+1496     /**
+1497      * parse ASN.1 TBSRequest of OCSP<br/>
+1498      * @name getTBSRequest
+1499      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1500      * @function
+1501      * @param {String} h hexadecimal string of ASN.1 TBSRequest of OCSP
+1502      * @return {Array} array of JSON object of TBSRequest parameter
+1503      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1504      *
+1505      * @description
+1506      * This method will parse
+1507      * TBSRequest ASN.1 class is defined in 
+1508      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1509      * <pre>
+1510      * TBSRequest  ::=  SEQUENCE {
+1511      *   version            [0]  EXPLICIT Version DEFAULT v1,
+1512      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
+1513      *   requestList             SEQUENCE OF Request,
+1514      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
+1515      * </pre>
+1516      *
+1517      * @see KJUR.asn1.ocsp.OCSPParser#getOCSPRequest
+1518      * @see KJUR.asn1.ocsp.OCSPParser#getRequestList
+1519      * @see KJUR.asn1.ocsp.TBSRequest
+1520      *
+1521      * @example
+1522      * o = new KJUR.asn1.ocsp.OCSPParser();
+1523      * o.getTBSRequest("30...") →
+1524      * {array: [{
+1525      *   "alg": "sha1",
+1526      *   "issname": "105fa67a80089db5279f35ce830b43889ea3c70d",
+1527      *   "isskey": "0f80611c823161d52f28e78d4638b42ce1c6d9e2",
+1528      *   "sbjsn": "0fef62075d715dc5e1d8bd03775c9686" }]}
+1529      */
+1530     this.getTBSRequest = function(h) {
+1531 	var result = {};
+1532 	var hReqList = _getTLVbyListEx(h, 0, [0], "30");
+1533 	result.array = this.getRequestList(hReqList);
+1534 	var hExt = _getTLVbyListEx(h, 0, ["[2]", 0], "30");
+1535 	if (hExt != null) {
+1536 	    result.ext = _x509obj.getExtParamArray(hExt);
+1537 	}
+1538 
+1539 	return result;
+1540     };
+1541 
+1542     /**
+1543      * parse ASN.1 SEQUENCE OF Request in OCSP<br/>
+1544      * @name getRequestList
+1545      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1546      * @function
+1547      * @param {String} h hexadecimal string of ASN.1 SEQUENCE OF Request in OCSP
+1548      * @return {Array} array of JSON object of Request parameter
+1549      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1550      *
+1551      * @description
+1552      * This method will parse a hexadecimal string of
+1553      * SEQUENCE OF Request ASN.1 class is defined in 
+1554      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1555      * <br/>
+1556      * NOTE: singleRequestExtensions is not supported yet in this version such as nonce.
+1557      * <pre>
+1558      * TBSRequest  ::=  SEQUENCE {
+1559      *   version            [0]  EXPLICIT Version DEFAULT v1,
+1560      *   requestorName      [1]  EXPLICIT GeneralName OPTIONAL,
+1561      *   requestList             SEQUENCE OF Request,
+1562      *   requestExtensions  [2]  EXPLICIT Extensions OPTIONAL }
+1563      * Request ::= SEQUENCE {
+1564      *   reqCert                  CertID,
+1565      *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }      
+1566      * </pre>
+1567      *
+1568      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
+1569      * @see KJUR.asn1.ocsp.OCSPParser#getRequest
 1570      * @see KJUR.asn1.ocsp.RequestList
 1571      * @see KJUR.asn1.ocsp.Request
-1572      * @see KJUR.asn1.ocsp.CertID
-1573      *
-1574      * @example
-1575      * o = new KJUR.asn1.ocsp.OCSPParser();
-1576      * o.getRequest("30...") →
-1577      * { alg: "sha1"
-1578      *   issname: "...hex...",
-1579      *   isskey: "...hex...",
-1580      *   sbjsn: "...hex...",
-1581      *   ext: [<<singleRequestExtension parameters>>...] }
-1582      */
-1583     this.getRequest = function(h) {
+1572      *
+1573      * @example
+1574      * o = new KJUR.asn1.ocsp.OCSPParser();
+1575      * o.getRequestList("30...") →
+1576      * [{ alg: "sha1"
+1577      *   issname: "...hex...",
+1578      *   isskey: "...hex...",
+1579      *   sbjsn: "...hex...",
+1580      *   ext: [<<singleRequestExtension parameters>>...] }]
+1581      */
+1582     this.getRequestList = function(h) {
+1583 	var result = [];
 1584 	var a = _getChildIdx(h, 0);
-1585 	if (a.length != 1 && a.length != 2) {
-1586 	    throw new _Error("wrong number elements: " + a.length);
-1587 	}
-1588 	
-1589 	var params = this.getCertID(_getTLV(h, a[0]));
-1590 
-1591 	if (a.length == 2) {
-1592 	    var idxExt = _getIdxbyList(h, 0, [1, 0]);
-1593 	    params.ext = _x509obj.getExtParamArray(_getTLV(h, idxExt));
-1594 	}
-1595 
-1596 	return params;
-1597     };
-1598 
-1599     /**
-1600      * parse ASN.1 CertID of OCSP<br/>
-1601      * @name getCertID
-1602      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1603      * @function
-1604      * @param {String} h hexadecimal string of CertID
-1605      * @return JSON object of CertID parameter
-1606      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
-1607      *
-1608      * @description
-1609      * This method will parse a hexadecimal string of
-1610      * CertID ASN.1 class is defined in 
-1611      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
-1612      * <pre>
-1613      * CertID ::= SEQUENCE {
-1614      *   hashAlgorithm   AlgorithmIdentifier,
-1615      *   issuerNameHash  OCTET STRING, -- Hash of issuer's DN
-1616      *   issuerKeyHash   OCTET STRING, -- Hash of issuer's public key
-1617      *   serialNumber    CertificateSerialNumber }
-1618      * </pre>
-1619      *
-1620      * @see KJUR.asn1.ocsp.OCSPParser#getRequest
-1621      * @see KJUR.asn1.ocsp.OCSPParser#getSingleResponse
-1622      * @see KJUR.asn1.ocsp.CertID
-1623      *
-1624      * @example
-1625      * o = new KJUR.asn1.ocsp.OCSPParser();
-1626      * o.getCertID("30...") →
-1627      * { alg: "sha1"
-1628      *   issname: "...hex...",
-1629      *   isskey: "...hex...",
-1630      *   sbjsn: "...hex..." }
-1631      */
-1632     this.getCertID = function(h) {
-1633 	var a = _getChildIdx(h, 0);
-1634 	if (a.length != 4) {
-1635 	    throw new _Error("wrong number elements: " + a.length);
-1636 	}
-1637 	
-1638 	var x = new _X509();
-1639 	var result = {};
-1640 	result.alg = x.getAlgorithmIdentifierName(_getTLV(h, a[0]));
-1641 	result.issname = _getV(h, a[1]);
-1642 	result.isskey = _getV(h, a[2]);
-1643 	result.sbjsn = _getV(h, a[3]);
-1644 	
-1645 	return result;
-1646     };
-1647 
-1648     /**
-1649      * parse ASN.1 OCSPResponse of OCSP<br/>
-1650      * @name getOCSPResponse
-1651      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1652      * @function
-1653      * @param {String} h hexadecimal string of OCSPResponse
-1654      * @return JSON object of OCSResponse parameter
-1655      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1656      *
-1657      * @description
-1658      * This method will parse a hexadecimal string of
-1659      * ASN.1 OCSPResponse defined in
-1660      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1661      * <pre>
-1662      * OCSPResponse ::= SEQUENCE {
-1663      *    responseStatus         OCSPResponseStatus,
-1664      *    responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
-1665      * OCSPResponseStatus ::= ENUMERATED {
-1666      *     successful            (0),  -- Response has valid confirmations
-1667      *     malformedRequest      (1),  -- Illegal confirmation request
-1668      *     internalError         (2),  -- Internal error in issuer
-1669      *     tryLater              (3),  -- Try again later
-1670      *                                 -- (4) is not used
-1671      *     sigRequired           (5),  -- Must sign the request
-1672      *     unauthorized          (6)   -- Request unauthorized }
-1673      * </pre>
-1674      *
-1675      * @see KJUR.asn1.ocsp.OCSPParser#getResponseBytes
-1676      * @see KJUR.asn1.ocsp.OCSPResponse
-1677      *
-1678      * @example
-1679      * o = new KJUR.asn1.ocsp.OCSPParser();
-1680      * o.getOCSPResponse("30..") →
-1681      * { resstatus: 0,
-1682      *   restype: "ocspBasic",
-1683      *   respid: {key: "12ab"},
-1684      *   prodat: "20200903235959Z",
-1685      *   array: [{
-1686      *     certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
-1687      *     status: {status: "good"},
-1688      *     thisupdate: "20200903235959Z" }],
-1689      *   ext: [{extname: "ocspNonce", hex: "1234abcd"}],
-1690      *   alg: "SHA256withRSA",
-1691      *   sighex: "12ab",
-1692      *   certs: ["3082...", "3082..."] }
-1693      */
-1694     this.getOCSPResponse = function(h) {
-1695 	var a = _getChildIdx(h, 0);
-1696 	var result;
-1697 
-1698 	var hStatusV = _getV(h, a[0]);
-1699 	var iStatusV = parseInt(hStatusV);
-1700 	
-1701 	if (a.length == 1) return {resstatus: iStatusV};
-1702 
-1703 	var hResponseBytes = _getTLVbyList(h, 0, [1, 0]);
-1704 	result = this.getResponseBytes(hResponseBytes);
-1705 	result.resstatus = iStatusV;
-1706 	
-1707 	return result;
-1708     };
-1709 
-1710     /**
-1711      * parse ASN.1 ResponseBytes of OCSP<br/>
-1712      * @name getResponseBytes
-1713      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1714      * @function
-1715      * @param {String} h hexadecimal string of ResponseBytes
-1716      * @return JSON object of ResponseBytes parameter
-1717      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
+1585 	for (var i = 0; i < a.length; i++) {
+1586 	    var h = _getTLV(h, a[i]);
+1587 	    result.push(this.getRequest(h));
+1588 	}
+1589 	return result;
+1590     };
+1591 
+1592     /**
+1593      * parse ASN.1 Request of OCSP<br/>
+1594      * @name getRequest
+1595      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1596      * @function
+1597      * @param {String} h hexadecimal string of ASN.1 Request of OCSP
+1598      * @return JSON object of Request parameter
+1599      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1600      *
+1601      * @description
+1602      * This method will parse a hexadecimal string of
+1603      * Request ASN.1 class is defined in 
+1604      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1605      * <pre>
+1606      * Request ::= SEQUENCE {
+1607      *   reqCert                  CertID,
+1608      *   singleRequestExtensions  [0] EXPLICIT Extensions OPTIONAL }      
+1609      * </pre>
+1610      *
+1611      * @see KJUR.asn1.ocsp.OCSPParser#getTBSRequest
+1612      * @see KJUR.asn1.ocsp.OCSPParser#getRequestList
+1613      * @see KJUR.asn1.ocsp.OCSPParser#getCertID
+1614      * @see KJUR.asn1.ocsp.RequestList
+1615      * @see KJUR.asn1.ocsp.Request
+1616      * @see KJUR.asn1.ocsp.CertID
+1617      *
+1618      * @example
+1619      * o = new KJUR.asn1.ocsp.OCSPParser();
+1620      * o.getRequest("30...") →
+1621      * { alg: "sha1"
+1622      *   issname: "...hex...",
+1623      *   isskey: "...hex...",
+1624      *   sbjsn: "...hex...",
+1625      *   ext: [<<singleRequestExtension parameters>>...] }
+1626      */
+1627     this.getRequest = function(h) {
+1628 	var a = _getChildIdx(h, 0);
+1629 	if (a.length != 1 && a.length != 2) {
+1630 	    throw new _Error("wrong number elements: " + a.length);
+1631 	}
+1632 	
+1633 	var params = this.getCertID(_getTLV(h, a[0]));
+1634 
+1635 	if (a.length == 2) {
+1636 	    var idxExt = _getIdxbyList(h, 0, [1, 0]);
+1637 	    params.ext = _x509obj.getExtParamArray(_getTLV(h, idxExt));
+1638 	}
+1639 
+1640 	return params;
+1641     };
+1642 
+1643     /**
+1644      * parse ASN.1 CertID of OCSP<br/>
+1645      * @name getCertID
+1646      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1647      * @function
+1648      * @param {String} h hexadecimal string of CertID
+1649      * @return JSON object of CertID parameter
+1650      * @since jsrsasign 9.1.6 asn1ocsp 1.1.0
+1651      *
+1652      * @description
+1653      * This method will parse a hexadecimal string of
+1654      * CertID ASN.1 class is defined in 
+1655      * <a href="https://tools.ietf.org/html/rfc6960#section-4.1.1">RFC 6960 4.1.1</a>. 
+1656      * <pre>
+1657      * CertID ::= SEQUENCE {
+1658      *   hashAlgorithm   AlgorithmIdentifier,
+1659      *   issuerNameHash  OCTET STRING, -- Hash of issuer's DN
+1660      *   issuerKeyHash   OCTET STRING, -- Hash of issuer's public key
+1661      *   serialNumber    CertificateSerialNumber }
+1662      * </pre>
+1663      *
+1664      * @see KJUR.asn1.ocsp.OCSPParser#getRequest
+1665      * @see KJUR.asn1.ocsp.OCSPParser#getSingleResponse
+1666      * @see KJUR.asn1.ocsp.CertID
+1667      *
+1668      * @example
+1669      * o = new KJUR.asn1.ocsp.OCSPParser();
+1670      * o.getCertID("30...") →
+1671      * { alg: "sha1"
+1672      *   issname: "...hex...",
+1673      *   isskey: "...hex...",
+1674      *   sbjsn: "...hex..." }
+1675      */
+1676     this.getCertID = function(h) {
+1677 	var a = _getChildIdx(h, 0);
+1678 	if (a.length != 4) {
+1679 	    throw new _Error("wrong number elements: " + a.length);
+1680 	}
+1681 	
+1682 	var x = new _X509();
+1683 	var result = {};
+1684 	result.alg = x.getAlgorithmIdentifierName(_getTLV(h, a[0]));
+1685 	result.issname = _getV(h, a[1]);
+1686 	result.isskey = _getV(h, a[2]);
+1687 	result.sbjsn = _getV(h, a[3]);
+1688 	
+1689 	return result;
+1690     };
+1691 
+1692     /**
+1693      * parse ASN.1 OCSPResponse of OCSP<br/>
+1694      * @name getOCSPResponse
+1695      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1696      * @function
+1697      * @param {String} h hexadecimal string of OCSPResponse
+1698      * @return JSON object of OCSResponse parameter
+1699      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
+1700      *
+1701      * @description
+1702      * This method will parse a hexadecimal string of
+1703      * ASN.1 OCSPResponse defined in
+1704      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+1705      * <pre>
+1706      * OCSPResponse ::= SEQUENCE {
+1707      *    responseStatus         OCSPResponseStatus,
+1708      *    responseBytes          [0] EXPLICIT ResponseBytes OPTIONAL }
+1709      * OCSPResponseStatus ::= ENUMERATED {
+1710      *     successful            (0),  -- Response has valid confirmations
+1711      *     malformedRequest      (1),  -- Illegal confirmation request
+1712      *     internalError         (2),  -- Internal error in issuer
+1713      *     tryLater              (3),  -- Try again later
+1714      *                                 -- (4) is not used
+1715      *     sigRequired           (5),  -- Must sign the request
+1716      *     unauthorized          (6)   -- Request unauthorized }
+1717      * </pre>
 1718      *
-1719      * @description
-1720      * This method will parse a hexadecimal string of
-1721      * ASN.1 ResponseBytes defined in
-1722      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1723      * <pre>
-1724      * ResponseBytes ::=       SEQUENCE {
-1725      *     responseType   OBJECT IDENTIFIER,
-1726      *     response       OCTET STRING }
-1727      * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
-1728      * id-pkix-ocsp-basic     OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 }
-1729      *
-1730      * BasicOCSPResponse       ::= SEQUENCE {
-1731      *    tbsResponseData      ResponseData,
-1732      *    signatureAlgorithm   AlgorithmIdentifier,
-1733      *    signature            BIT STRING,
-1734      *    certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
-1735      * </pre>
-1736      *
-1737      * @see KJUR.asn1.ocsp.OCSPParser#getOCSPResponse
-1738      * @see KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse
-1739      * @see KJUR.asn1.ocsp.ResponseBytes
-1740      *
-1741      * @example
-1742      * o = new KJUR.asn1.ocsp.OCSPParser();
-1743      * o.getResponseBytes("30..") →
-1744      * { restype: "ocspBasic",
-1745      *   ...<<BasicOCSPResponse properties...>>...
-1746      */
-1747     this.getResponseBytes = function(h) {
-1748 	var a = _getChildIdx(h, 0);
-1749 	var result;
-1750 
-1751 	var hBasicOCSPResponse = _getTLVbyList(h, 0, [1, 0]);
-1752 	result = this.getBasicOCSPResponse(hBasicOCSPResponse);
+1719      * @see KJUR.asn1.ocsp.OCSPParser#getResponseBytes
+1720      * @see KJUR.asn1.ocsp.OCSPResponse
+1721      *
+1722      * @example
+1723      * o = new KJUR.asn1.ocsp.OCSPParser();
+1724      * o.getOCSPResponse("30..") →
+1725      * { resstatus: 0,
+1726      *   restype: "ocspBasic",
+1727      *   respid: {key: "12ab"},
+1728      *   prodat: "20200903235959Z",
+1729      *   array: [{
+1730      *     certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
+1731      *     status: {status: "good"},
+1732      *     thisupdate: "20200903235959Z" }],
+1733      *   ext: [{extname: "ocspNonce", hex: "1234abcd"}],
+1734      *   alg: "SHA256withRSA",
+1735      *   sighex: "12ab",
+1736      *   certs: ["3082...", "3082..."] }
+1737      */
+1738     this.getOCSPResponse = function(h) {
+1739 	var a = _getChildIdx(h, 0);
+1740 	var result;
+1741 
+1742 	var hStatusV = _getV(h, a[0]);
+1743 	var iStatusV = parseInt(hStatusV);
+1744 	
+1745 	if (a.length == 1) return {resstatus: iStatusV};
+1746 
+1747 	var hResponseBytes = _getTLVbyList(h, 0, [1, 0]);
+1748 	result = this.getResponseBytes(hResponseBytes);
+1749 	result.resstatus = iStatusV;
+1750 	
+1751 	return result;
+1752     };
 1753 
-1754 	var hResTypeV = _getV(h, a[0]);
-1755 	result.restype = KJUR.asn1.x509.OID.oid2name(hextooid(hResTypeV));
-1756 	
-1757 	return result;
-1758     };
-1759 
-1760     /**
-1761      * parse ASN.1 BasicOCSPResponse of OCSP<br/>
-1762      * @name getBasicOCSPResponse
-1763      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1764      * @function
-1765      * @param {String} h hexadecimal string of BasicOCSPResponse
-1766      * @return JSON object of BasicOCSPResponse parameter
-1767      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1768      *
-1769      * @description
-1770      * This method will parse a hexadecimal string of
-1771      * BasicOCSPResponse defined in 
-1772      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1773      * <pre>
+1754     /**
+1755      * parse ASN.1 ResponseBytes of OCSP<br/>
+1756      * @name getResponseBytes
+1757      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1758      * @function
+1759      * @param {String} h hexadecimal string of ResponseBytes
+1760      * @return JSON object of ResponseBytes parameter
+1761      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
+1762      *
+1763      * @description
+1764      * This method will parse a hexadecimal string of
+1765      * ASN.1 ResponseBytes defined in
+1766      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+1767      * <pre>
+1768      * ResponseBytes ::=       SEQUENCE {
+1769      *     responseType   OBJECT IDENTIFIER,
+1770      *     response       OCTET STRING }
+1771      * id-pkix-ocsp           OBJECT IDENTIFIER ::= { id-ad-ocsp }
+1772      * id-pkix-ocsp-basic     OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 }
+1773      *
 1774      * BasicOCSPResponse       ::= SEQUENCE {
 1775      *    tbsResponseData      ResponseData,
 1776      *    signatureAlgorithm   AlgorithmIdentifier,
@@ -1785,307 +1785,351 @@
 1778      *    certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
 1779      * </pre>
 1780      *
-1781      * @see KJUR.asn1.ocsp.OCSPParser#getResponseBytes
-1782      * @see KJUR.asn1.ocsp.OCSPParser#getResponseData
-1783      * @see KJUR.asn1.ocsp.BasicOCSPResponse
+1781      * @see KJUR.asn1.ocsp.OCSPParser#getOCSPResponse
+1782      * @see KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse
+1783      * @see KJUR.asn1.ocsp.ResponseBytes
 1784      *
 1785      * @example
 1786      * o = new KJUR.asn1.ocsp.OCSPParser();
-1787      * o.getBasicOCSPResponse("30..") →
-1788      * { ...<<ResponseData properties...>>...
-1789      *   sigalg: "SHA256withRSA",
-1790      *   sighex: "12abcd...",
-1791      *   certs: [<<PEMorHEXstringOfCert1>>,...] });
-1792      */
-1793     this.getBasicOCSPResponse = function(h) {
-1794 	var a = _getChildIdx(h, 0);
-1795 	var result;
-1796 
-1797 	result = this.getResponseData(_getTLV(h, a[0]));
-1798 
-1799 	var x = new X509();
-1800 	result.alg = x.getAlgorithmIdentifierName(_getTLV(h, a[1]));
-1801 
-1802 	var hSigHex = _getV(h, a[2]);
-1803 	result.sighex = hSigHex.substr(2);
-1804 	
-1805 	var hExt = _getVbyListEx(h, 0, ["[0]"]);
-1806 	if (hExt != null) {
-1807 	    var aCertIdx = _getChildIdx(hExt, 0);
-1808 	    var aCert = [];
-1809 	    for (var i = 0; i < aCertIdx.length; i++) {
-1810 		var hCert = _getTLV(hExt, aCertIdx[i]);
-1811 		aCert.push(hCert);
-1812 	    }
-1813 	    result.certs = aCert;
-1814 	}
-1815 
-1816 	return result;
-1817     };
-1818 
-1819     /**
-1820      * parse ASN.1 ResponseData of OCSP<br/>
-1821      * @name getResponseData
-1822      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1823      * @function
-1824      * @param {String} h hexadecimal string of ResponseData
-1825      * @return JSON object of ResponseData parameter
-1826      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1827      *
-1828      * @description
-1829      * This method will parse a hexadecimal string of
-1830      * ASN.1 ResponseData defined in
-1831      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1832      * <pre>
-1833      * ResponseData ::= SEQUENCE {
-1834      *    version              [0] EXPLICIT Version DEFAULT v1,
-1835      *    responderID              ResponderID,
-1836      *    producedAt               GeneralizedTime,
-1837      *    responses                SEQUENCE OF SingleResponse,
-1838      *    responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
-1839      * </pre>
-1840      *
-1841      * @see KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse
-1842      * @see KJUR.asn1.ocsp.OCSPParser#getSingleResponse
-1843      * @see KJUR.asn1.ocsp.ResponseData
-1844      *
-1845      * @example
-1846      * o = new KJUR.asn1.ocsp.OCSPParser();
-1847      * o.getResponseData("30..") →
-1848      * { respid: {key: "12ab..."},
-1849      *   prodat: "20200903235959Z",
-1850      *   array: [<<SingleResponse parameter1>>, ...],
-1851      *   ext: [
-1852      *     {extname:"ocspNonce",hex:"12ab..."}]}
-1853      */
-1854     this.getResponseData = function(h) {
-1855 	var a = _getChildIdx(h, 0);
-1856 	var alen = a.length;
-1857 	var result = {};
-1858 	var idx = 0;
+1787      * o.getResponseBytes("30..") →
+1788      * { restype: "ocspBasic",
+1789      *   ...<<BasicOCSPResponse properties...>>...
+1790      */
+1791     this.getResponseBytes = function(h) {
+1792 	var a = _getChildIdx(h, 0);
+1793 	var result;
+1794 
+1795 	var hBasicOCSPResponse = _getTLVbyList(h, 0, [1, 0]);
+1796 	result = this.getBasicOCSPResponse(hBasicOCSPResponse);
+1797 
+1798 	var hResTypeV = _getV(h, a[0]);
+1799 	result.restype = KJUR.asn1.x509.OID.oid2name(hextooid(hResTypeV));
+1800 	
+1801 	return result;
+1802     };
+1803 
+1804     /**
+1805      * parse ASN.1 BasicOCSPResponse of OCSP<br/>
+1806      * @name getBasicOCSPResponse
+1807      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1808      * @function
+1809      * @param {String} h hexadecimal string of BasicOCSPResponse
+1810      * @return JSON object of BasicOCSPResponse parameter
+1811      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
+1812      *
+1813      * @description
+1814      * This method will parse a hexadecimal string of
+1815      * BasicOCSPResponse defined in 
+1816      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+1817      * <pre>
+1818      * BasicOCSPResponse       ::= SEQUENCE {
+1819      *    tbsResponseData      ResponseData,
+1820      *    signatureAlgorithm   AlgorithmIdentifier,
+1821      *    signature            BIT STRING,
+1822      *    certs            [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL }
+1823      * </pre>
+1824      *
+1825      * @see KJUR.asn1.ocsp.OCSPParser#getResponseBytes
+1826      * @see KJUR.asn1.ocsp.OCSPParser#getResponseData
+1827      * @see KJUR.asn1.ocsp.BasicOCSPResponse
+1828      *
+1829      * @example
+1830      * o = new KJUR.asn1.ocsp.OCSPParser();
+1831      * o.getBasicOCSPResponse("30..") →
+1832      * { ...<<ResponseData properties...>>...
+1833      *   sigalg: "SHA256withRSA",
+1834      *   sighex: "12abcd...",
+1835      *   certs: [<<PEMorHEXstringOfCert1>>,...] });
+1836      */
+1837     this.getBasicOCSPResponse = function(h) {
+1838 	var a = _getChildIdx(h, 0);
+1839 	var result;
+1840 
+1841 	result = this.getResponseData(_getTLV(h, a[0]));
+1842 
+1843 	var x = new X509();
+1844 	result.alg = x.getAlgorithmIdentifierName(_getTLV(h, a[1]));
+1845 
+1846 	var hSigHex = _getV(h, a[2]);
+1847 	result.sighex = hSigHex.substr(2);
+1848 	
+1849 	var hExt = _getVbyListEx(h, 0, ["[0]"]);
+1850 	if (hExt != null) {
+1851 	    var aCertIdx = _getChildIdx(hExt, 0);
+1852 	    var aCert = [];
+1853 	    for (var i = 0; i < aCertIdx.length; i++) {
+1854 		var hCert = _getTLV(hExt, aCertIdx[i]);
+1855 		aCert.push(hCert);
+1856 	    }
+1857 	    result.certs = aCert;
+1858 	}
 1859 
-1860 	// skip to relax interoperability even though explicit DEFAULT
-1861 	if (h.substr(a[0], 2) == "a0") idx++;
+1860 	return result;
+1861     };
 1862 
-1863 	result.respid = this.getResponderID(_getTLV(h, a[idx++]));
-1864 	
-1865 	var hProdAtV = _getV(h, a[idx++]);
-1866 	result.prodat = hextoutf8(hProdAtV);
-1867 	
-1868 	result.array = this.getSingleResponseList(_getTLV(h, a[idx++]));
-1869 
-1870 	if (h.substr(a[alen - 1], 2) == "a1") {
-1871 	    var hExt =  _getTLVbyList(h, a[alen - 1], [0]);
-1872 	    var x = new X509();
-1873 	    result.ext = x.getExtParamArray(hExt);
-1874 	}
-1875 
-1876 	return result;
-1877     };
-1878 
-1879     /**
-1880      * parse ASN.1 ResponderID of OCSP<br/>
-1881      * @name getResponderID
-1882      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1883      * @function
-1884      * @param {String} h hexadecimal string of ResponderID
-1885      * @return JSON object of ResponderID parameter
-1886      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1887      * @see KJUR.asn1.ocsp.ResponderID
+1863     /**
+1864      * parse ASN.1 ResponseData of OCSP<br/>
+1865      * @name getResponseData
+1866      * @memberOf KJUR.asn1.ocsp.OCSPParser#
+1867      * @function
+1868      * @param {String} h hexadecimal string of ResponseData
+1869      * @return JSON object of ResponseData parameter
+1870      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
+1871      *
+1872      * @description
+1873      * This method will parse a hexadecimal string of
+1874      * ASN.1 ResponseData defined in
+1875      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
+1876      * <pre>
+1877      * ResponseData ::= SEQUENCE {
+1878      *    version              [0] EXPLICIT Version DEFAULT v1,
+1879      *    responderID              ResponderID,
+1880      *    producedAt               GeneralizedTime,
+1881      *    responses                SEQUENCE OF SingleResponse,
+1882      *    responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
+1883      * </pre>
+1884      *
+1885      * @see KJUR.asn1.ocsp.OCSPParser#getBasicOCSPResponse
+1886      * @see KJUR.asn1.ocsp.OCSPParser#getSingleResponse
+1887      * @see KJUR.asn1.ocsp.ResponseData
 1888      *
-1889      * @description
-1890      * <pre>
-1891      * ResponderID ::= CHOICE {
-1892      *    byName               [1] Name,
-1893      *    byKey                [2] KeyHash }
-1894      * KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key
-1895      *                             (excluding the tag and length fields)
-1896      * </pre>
-1897      *
-1898      * @example
-1899      * o = new KJUR.asn1.ocsp.OCSPParser();
-1900      * o.getResponderID("a1..") → {name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}}
-1901      * o.getResponderID("a2..") → {key: "12ab..."}
-1902      */
-1903     this.getResponderID = function(h) {
-1904 	var result = {};
-1905 
-1906 	if (h.substr(0, 2) == "a2") {
-1907 	    var hKeyV = _getVbyList(h, 0, [0]);
-1908 	    result.key = hKeyV;
-1909 	}
-1910 	if (h.substr(0, 2) == "a1") {
-1911 	    var hName = _getTLVbyList(h, 0, [0]);
-1912 	    var x = new X509();
-1913 	    result.name = x.getX500Name(hName);
-1914 	}
-1915 	
-1916 	return result;
-1917     };
-1918 
-1919     /**
-1920      * parse ASN.1 SEQUENCE OF SingleResponse of OCSP<br/>
-1921      * @name getSingleResponseList
-1922      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1923      * @function
-1924      * @param {String} h hexadecimal string of SEQUENCE OF SingleResponse
-1925      * @return array of SingleResponse parameter JSON object
-1926      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1927      *
-1928      * @description
-1929      * This method will parse a hexadecimal string of
-1930      * ASN.1 class of SEQUENCE OF SingleResponse is defined in 
-1931      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1932      * <pre>
-1933      * ResponseData ::= SEQUENCE {
-1934      *    version              [0] EXPLICIT Version DEFAULT v1,
-1935      *    responderID              ResponderID,
-1936      *    producedAt               GeneralizedTime,
-1937      *    responses                SEQUENCE OF SingleResponse,
-1938      *    responseExtensions   [1] EXPLICIT Extensions OPTIONAL }
-1939      * SingleResponse ::= SEQUENCE {
-1940      *    certID                       CertID,
-1941      *    certStatus                   CertStatus,
-1942      *    thisUpdate                   GeneralizedTime,
-1943      *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
-1944      *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
-1945      * </pre>
-1946      *
-1947      * @see KJUR.asn1.ocsp.OCSPParse#getResponseData
-1948      * @see KJUR.asn1.ocsp.OCSPParse#getSingleResponse
-1949      * @see KJUR.asn1.ocsp.OCSPParse#getCertID
-1950      * @see KJUR.asn1.ocsp.SingleResponseList
-1951      *
-1952      * @example
-1953      * o = new KJUR.asn1.ocsp.OCSPParser();
-1954      * o.getSingleResponseList("30..") →
-1955      * [{ certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
-1956      *    status: {status: "good"},
-1957      *    thisupdate: "20200903235959Z",
-1958      *    nextupdate: "20200913235959Z",
-1959      *    ext: [<<Extension parameters>>...] }]
-1960      */
-1961     this.getSingleResponseList = function(h) {
-1962 	var a = _getChildIdx(h, 0);
-1963 	var result = [];
-1964 
-1965 	for (var i = 0; i < a.length; i++) {
-1966 	    var p = this.getSingleResponse(_getTLV(h, a[i]));
-1967 	    result.push(p);
-1968 	}
-1969 	return result;
-1970     };
-1971 
-1972     /**
-1973      * parse ASN.1 SingleResponse of OCSP<br/>
-1974      * @name getSingleResponse
-1975      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-1976      * @function
-1977      * @param {String} h hexadecimal string of SingleResponse
-1978      * @return JSON object of SingleResponse parameter
-1979      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-1980      *
-1981      * @description
-1982      * This method will parse a hexadecimal string of
-1983      * ASN.1 class of SingleResponse is defined in 
-1984      * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. 
-1985      * <pre>
-1986      * SingleResponse ::= SEQUENCE {
-1987      *    certID                       CertID,
-1988      *    certStatus                   CertStatus,
-1989      *    thisUpdate                   GeneralizedTime,
-1990      *    nextUpdate         [0]       EXPLICIT GeneralizedTime OPTIONAL,
-1991      *    singleExtensions   [1]       EXPLICIT Extensions OPTIONAL }
-1992      * </pre>
-1993      *
-1994      * @see KJUR.asn1.ocsp.OCSPParse#getSingleResponseList
-1995      * @see KJUR.asn1.ocsp.OCSPParse#getCertID
-1996      * @see KJUR.asn1.ocsp.SingleResponse
-1997      *
-1998      * @example
-1999      * o = new KJUR.asn1.ocsp.OCSPParser();
-2000      * o.getSingleResponse("30..") →
-2001      * { certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"},
-2002      *   status: {status: "good"},
-2003      *   thisupdate: "20200903235959Z",
-2004      *   nextupdate: "20200913235959Z",
-2005      *   ext: [<<Extension parameters>>...] }
-2006      */
-2007     this.getSingleResponse = function(h) {
-2008 	var a = _getChildIdx(h, 0);
-2009 	var result = {};
-2010 
-2011 	// 1. CertID
-2012 	var pCertID = this.getCertID(_getTLV(h, a[0]));
-2013 	result.certid = pCertID;
-2014 
-2015 	// 2. CertStatus
-2016 	var pCertStatus = this.getCertStatus(_getTLV(h, a[1]));
-2017 	result.status = pCertStatus;
-2018 
-2019 	// 3. ThisUpdate(GeneralizedTime)
-2020 	if (h.substr(a[2], 2) == "18") {
-2021 	    var hThisUpdateV = _getV(h, a[2]);
-2022 	    result.thisupdate = hextoutf8(hThisUpdateV);
-2023 	}
-2024 	
-2025 	// 4. OPTIONAL(nextUpdate, singleExtensions)
-2026 	for (var i = 3; i < a.length; i++) {
-2027 	    if (h.substr(a[i], 2) == "a0") { // nextUpdate
-2028 		var hNextUpdateV = _getVbyList(h, a[i], [0], "18");
-2029 		result.nextupdate = hextoutf8(hNextUpdateV);
-2030 	    }
-2031 	    if (h.substr(a[i], 2) == "a1") { // singleExtensions
-2032 		var x = new X509();
-2033 		var hExt = _getTLVbyList(h, 0, [i, 0]);
-2034 		result.ext = x.getExtParamArray(hExt);
-2035 	    }
-2036 	}
-2037 
-2038 	return result;
-2039     };
-2040 
-2041     /**
-2042      * parse ASN.1 CertStatus of OCSP<br/>
-2043      * @name getCertStatus
-2044      * @memberOf KJUR.asn1.ocsp.OCSPParser#
-2045      * @function
-2046      * @param {String} h hexadecimal string of CertStatus
-2047      * @return JSON object of CertStatus parameter
-2048      * @since jsrsasign 10.4.0 asn1ocsp 1.1.5
-2049      * @see KJUR.asn1.ocsp.CertStatus
-2050      *
-2051      * @description
-2052      * <pre>
-2053      * CertStatus ::= CHOICE {
-2054      *     good        [0]     IMPLICIT NULL,
-2055      *     revoked     [1]     IMPLICIT RevokedInfo,
-2056      *     unknown     [2]     IMPLICIT UnknownInfo }
-2057      * RevokedInfo ::= SEQUENCE {
-2058      *     revocationTime              GeneralizedTime,
-2059      *     revocationReason    [0]     EXPLICIT CRLReason OPTIONAL }
-2060      * UnknownInfo ::= NULL
-2061      * </pre>
-2062      * NOTE: Currently revocationReason not supported.
-2063      *
-2064      * @example
-2065      * o = new KJUR.asn1.ocsp.OCSPParser();
-2066      * o.getCertStatus("8000") → {status: "good"}
-2067      * o.getCertStatus("8200") → {status: "unknown"}
-2068      * o.getCertStatus("a1..") → {status: "revoked", time: "2021...Z"}
-2069      */
-2070     this.getCertStatus = function(h) {
-2071 	var result = {};
-2072 	if (h == "8000") return {status: "good"};
-2073 	if (h == "8200") return {status: "unknown"};
-2074 	if (h.substr(0, 2) == "a1") {
-2075 	    result.status = "revoked";
-2076 	    var hTime = _getVbyList(h, 0, [0]);
-2077 	    var sTime = hextoutf8(hTime);
-2078 	    result.time = sTime;
-2079 	}
-2080 	return result;
-2081     };
-2082 };
-2083 
-2084 
\ No newline at end of file +1889 * @example +1890 * o = new KJUR.asn1.ocsp.OCSPParser(); +1891 * o.getResponseData("30..") → +1892 * { respid: {key: "12ab..."}, +1893 * prodat: "20200903235959Z", +1894 * array: [<<SingleResponse parameter1>>, ...], +1895 * ext: [ +1896 * {extname:"ocspNonce",hex:"12ab..."}]} +1897 */
+1898 this.getResponseData = function(h) { +1899 var a = _getChildIdx(h, 0); +1900 var alen = a.length; +1901 var result = {}; +1902 var idx = 0; +1903 +1904 // skip to relax interoperability even though explicit DEFAULT +1905 if (h.substr(a[0], 2) == "a0") idx++; +1906 +1907 result.respid = this.getResponderID(_getTLV(h, a[idx++])); +1908 +1909 var hProdAtV = _getV(h, a[idx++]); +1910 result.prodat = hextoutf8(hProdAtV); +1911 +1912 result.array = this.getSingleResponseList(_getTLV(h, a[idx++])); +1913 +1914 if (h.substr(a[alen - 1], 2) == "a1") { +1915 var hExt = _getTLVbyList(h, a[alen - 1], [0]); +1916 var x = new X509(); +1917 result.ext = x.getExtParamArray(hExt); +1918 } +1919 +1920 return result; +1921 }; +1922 +1923 /** +1924 * parse ASN.1 ResponderID of OCSP<br/> +1925 * @name getResponderID +1926 * @memberOf KJUR.asn1.ocsp.OCSPParser# +1927 * @function +1928 * @param {String} h hexadecimal string of ResponderID +1929 * @return JSON object of ResponderID parameter +1930 * @since jsrsasign 10.4.0 asn1ocsp 1.1.5 +1931 * @see KJUR.asn1.ocsp.ResponderID +1932 * +1933 * @description +1934 * <pre> +1935 * ResponderID ::= CHOICE { +1936 * byName [1] Name, +1937 * byKey [2] KeyHash } +1938 * KeyHash ::= OCTET STRING -- SHA-1 hash of responder's public key +1939 * (excluding the tag and length fields) +1940 * </pre> +1941 * +1942 * @example +1943 * o = new KJUR.asn1.ocsp.OCSPParser(); +1944 * o.getResponderID("a1..") → {name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}} +1945 * o.getResponderID("a2..") → {key: "12ab..."} +1946 */ +1947 this.getResponderID = function(h) { +1948 var result = {}; +1949 +1950 if (h.substr(0, 2) == "a2") { +1951 var hKeyV = _getVbyList(h, 0, [0]); +1952 result.key = hKeyV; +1953 } +1954 if (h.substr(0, 2) == "a1") { +1955 var hName = _getTLVbyList(h, 0, [0]); +1956 var x = new X509(); +1957 result.name = x.getX500Name(hName); +1958 } +1959 +1960 return result; +1961 }; +1962 +1963 /** +1964 * parse ASN.1 SEQUENCE OF SingleResponse of OCSP<br/> +1965 * @name getSingleResponseList +1966 * @memberOf KJUR.asn1.ocsp.OCSPParser# +1967 * @function +1968 * @param {String} h hexadecimal string of SEQUENCE OF SingleResponse +1969 * @return array of SingleResponse parameter JSON object +1970 * @since jsrsasign 10.4.0 asn1ocsp 1.1.5 +1971 * +1972 * @description +1973 * This method will parse a hexadecimal string of +1974 * ASN.1 class of SEQUENCE OF SingleResponse is defined in +1975 * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. +1976 * <pre> +1977 * ResponseData ::= SEQUENCE { +1978 * version [0] EXPLICIT Version DEFAULT v1, +1979 * responderID ResponderID, +1980 * producedAt GeneralizedTime, +1981 * responses SEQUENCE OF SingleResponse, +1982 * responseExtensions [1] EXPLICIT Extensions OPTIONAL } +1983 * SingleResponse ::= SEQUENCE { +1984 * certID CertID, +1985 * certStatus CertStatus, +1986 * thisUpdate GeneralizedTime, +1987 * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, +1988 * singleExtensions [1] EXPLICIT Extensions OPTIONAL } +1989 * </pre> +1990 * +1991 * @see KJUR.asn1.ocsp.OCSPParse#getResponseData +1992 * @see KJUR.asn1.ocsp.OCSPParse#getSingleResponse +1993 * @see KJUR.asn1.ocsp.OCSPParse#getCertID +1994 * @see KJUR.asn1.ocsp.SingleResponseList +1995 * +1996 * @example +1997 * o = new KJUR.asn1.ocsp.OCSPParser(); +1998 * o.getSingleResponseList("30..") → +1999 * [{ certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"}, +2000 * status: {status: "good"}, +2001 * thisupdate: "20200903235959Z", +2002 * nextupdate: "20200913235959Z", +2003 * ext: [<<Extension parameters>>...] }] +2004 */ +2005 this.getSingleResponseList = function(h) { +2006 var a = _getChildIdx(h, 0); +2007 var result = []; +2008 +2009 for (var i = 0; i < a.length; i++) { +2010 var p = this.getSingleResponse(_getTLV(h, a[i])); +2011 result.push(p); +2012 } +2013 return result; +2014 }; +2015 +2016 /** +2017 * parse ASN.1 SingleResponse of OCSP<br/> +2018 * @name getSingleResponse +2019 * @memberOf KJUR.asn1.ocsp.OCSPParser# +2020 * @function +2021 * @param {String} h hexadecimal string of SingleResponse +2022 * @return JSON object of SingleResponse parameter +2023 * @since jsrsasign 10.4.0 asn1ocsp 1.1.5 +2024 * +2025 * @description +2026 * This method will parse a hexadecimal string of +2027 * ASN.1 class of SingleResponse is defined in +2028 * <a href="https://tools.ietf.org/html/rfc6960#section-4.2.1">RFC 6960 4.2.1</a>. +2029 * <pre> +2030 * SingleResponse ::= SEQUENCE { +2031 * certID CertID, +2032 * certStatus CertStatus, +2033 * thisUpdate GeneralizedTime, +2034 * nextUpdate [0] EXPLICIT GeneralizedTime OPTIONAL, +2035 * singleExtensions [1] EXPLICIT Extensions OPTIONAL } +2036 * </pre> +2037 * +2038 * @see KJUR.asn1.ocsp.OCSPParse#getSingleResponseList +2039 * @see KJUR.asn1.ocsp.OCSPParse#getCertID +2040 * @see KJUR.asn1.ocsp.SingleResponse +2041 * +2042 * @example +2043 * o = new KJUR.asn1.ocsp.OCSPParser(); +2044 * o.getSingleResponse("30..") → +2045 * { certid: {alg:"sha1",issname:"12ab",isskey:"12ab",sbjsn:"12ab"}, +2046 * status: {status: "good"}, +2047 * thisupdate: "20200903235959Z", +2048 * nextupdate: "20200913235959Z", +2049 * ext: [<<Extension parameters>>...] } +2050 */ +2051 this.getSingleResponse = function(h) { +2052 var a = _getChildIdx(h, 0); +2053 var result = {}; +2054 +2055 // 1. CertID +2056 var pCertID = this.getCertID(_getTLV(h, a[0])); +2057 result.certid = pCertID; +2058 +2059 // 2. CertStatus +2060 var pCertStatus = this.getCertStatus(_getTLV(h, a[1])); +2061 result.status = pCertStatus; +2062 +2063 // 3. ThisUpdate(GeneralizedTime) +2064 if (h.substr(a[2], 2) == "18") { +2065 var hThisUpdateV = _getV(h, a[2]); +2066 result.thisupdate = hextoutf8(hThisUpdateV); +2067 } +2068 +2069 // 4. OPTIONAL(nextUpdate, singleExtensions) +2070 for (var i = 3; i < a.length; i++) { +2071 if (h.substr(a[i], 2) == "a0") { // nextUpdate +2072 var hNextUpdateV = _getVbyList(h, a[i], [0], "18"); +2073 result.nextupdate = hextoutf8(hNextUpdateV); +2074 } +2075 if (h.substr(a[i], 2) == "a1") { // singleExtensions +2076 var x = new X509(); +2077 var hExt = _getTLVbyList(h, 0, [i, 0]); +2078 result.ext = x.getExtParamArray(hExt); +2079 } +2080 } +2081 +2082 return result; +2083 }; +2084 +2085 /** +2086 * parse ASN.1 CertStatus of OCSP<br/> +2087 * @name getCertStatus +2088 * @memberOf KJUR.asn1.ocsp.OCSPParser# +2089 * @function +2090 * @param {String} h hexadecimal string of CertStatus +2091 * @return JSON object of CertStatus parameter +2092 * @since jsrsasign 10.4.0 asn1ocsp 1.1.5 +2093 * @see KJUR.asn1.ocsp.CertStatus +2094 * +2095 * @description +2096 * <pre> +2097 * CertStatus ::= CHOICE { +2098 * good [0] IMPLICIT NULL, +2099 * revoked [1] IMPLICIT RevokedInfo, +2100 * unknown [2] IMPLICIT UnknownInfo } +2101 * RevokedInfo ::= SEQUENCE { +2102 * revocationTime GeneralizedTime, +2103 * revocationReason [0] EXPLICIT CRLReason OPTIONAL } +2104 * UnknownInfo ::= NULL +2105 * </pre> +2106 * NOTE: Currently revocationReason not supported. +2107 * +2108 * @example +2109 * o = new KJUR.asn1.ocsp.OCSPParser(); +2110 * o.getCertStatus("8000") → {status: "good"} +2111 * o.getCertStatus("8200") → {status: "unknown"} +2112 * o.getCertStatus("a1..") → {status: "revoked", time: "2021...Z"} +2113 */ +2114 this.getCertStatus = function(h) { +2115 var result = {}; +2116 if (h == "8000") return {status: "good"}; +2117 if (h == "8200") return {status: "unknown"}; +2118 if (h.substr(0, 2) == "a1") { +2119 result.status = "revoked"; +2120 var hTime = _getVbyList(h, 0, [0]); +2121 var sTime = hextoutf8(hTime); +2122 result.time = sTime; +2123 } +2124 return result; +2125 }; +2126 }; +2127 +2128
\ No newline at end of file diff --git a/bower.json b/bower.json index 0099e320..e462d3d5 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "kjur-jsrsasign", - "version": "10.5.19", + "version": "10.5.20", "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/index.html b/index.html index 63f46756..1c76e7ba 100755 --- a/index.html +++ b/index.html @@ -155,11 +155,6 @@

Cryptocurrency

  • Bitcoin Cash(BCH): bitcoincash:pq3hy08pc9vm57q6ddgsc06cqdffmfzwwqxd9yejyf
  • -

    SILVER SPONSORS

    -

    - -

    - diff --git a/jsrsasign-all-min.js b/jsrsasign-all-min.js index 54d227c3..10c3ef79 100644 --- a/jsrsasign-all-min.js +++ b/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.5.20 (2022-04-26) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -224,7 +224,7 @@ if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!K if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}if(typeof KJUR.asn1.tsp=="undefined"||!KJUR.asn1.tsp){KJUR.asn1.tsp={}}KJUR.asn1.tsp.TimeStampToken=function(d){var c=KJUR,b=c.asn1,a=b.tsp;a.TimeStampToken.superclass.constructor.call(this);this.params=null;this.getEncodedHexPrepare=function(){var e=new a.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=e.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.TimeStampToken,KJUR.asn1.cms.SignedData);KJUR.asn1.tsp.TSTInfo=function(f){var m=Error,c=KJUR,j=c.asn1,g=j.DERSequence,i=j.DERInteger,l=j.DERBoolean,h=j.DERGeneralizedTime,n=j.DERObjectIdentifier,e=j.DERTaggedObject,k=j.tsp,d=k.MessageImprint,b=k.Accuracy,a=j.x509.X500Name,o=j.x509.GeneralName;k.TSTInfo.superclass.constructor.call(this);this.dVersion=new i({"int":1});this.dPolicy=null;this.dMessageImprint=null;this.dSerial=null;this.dGenTime=null;this.dAccuracy=null;this.dOrdering=null;this.dNonce=null;this.dTsa=null;this.tohex=function(){var p=[this.dVersion];if(this.dPolicy==null){throw new Error("policy shall be specified.")}p.push(this.dPolicy);if(this.dMessageImprint==null){throw new Error("messageImprint shall be specified.")}p.push(this.dMessageImprint);if(this.dSerial==null){throw new Error("serialNumber shall be specified.")}p.push(this.dSerial);if(this.dGenTime==null){throw new Error("genTime shall be specified.")}p.push(this.dGenTime);if(this.dAccuracy!=null){p.push(this.dAccuracy)}if(this.dOrdering!=null){p.push(this.dOrdering)}if(this.dNonce!=null){p.push(this.dNonce)}if(this.dTsa!=null){p.push(this.dTsa)}var q=new g({array:p});this.hTLV=q.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){if(typeof f.policy=="string"){if(!f.policy.match(/^[0-9.]+$/)){throw"policy shall be oid like 0.1.4.134"}this.dPolicy=new n({oid:f.policy})}if(f.messageImprint!==undefined){this.dMessageImprint=new d(f.messageImprint)}if(f.serial!==undefined){this.dSerial=new i(f.serial)}if(f.genTime!==undefined){this.dGenTime=new h(f.genTime)}if(f.accuracy!==undefined){this.dAccuracy=new b(f.accuracy)}if(f.ordering!==undefined&&f.ordering==true){this.dOrdering=new l()}if(f.nonce!==undefined){this.dNonce=new i(f.nonce)}if(f.tsa!==undefined){this.dTsa=new e({tag:"a0",explicit:true,obj:new o({dn:f.tsa})})}}};extendClass(KJUR.asn1.tsp.TSTInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.Accuracy=function(d){var c=KJUR,b=c.asn1,a=b.ASN1Util.newObject;b.tsp.Accuracy.superclass.constructor.call(this);this.params=null;this.tohex=function(){var f=this.params;var e=[];if(f.seconds!=undefined&&typeof f.seconds=="number"){e.push({"int":f.seconds})}if(f.millis!=undefined&&typeof f.millis=="number"){e.push({tag:{tagi:"80",obj:{"int":f.millis}}})}if(f.micros!=undefined&&typeof f.micros=="number"){e.push({tag:{tagi:"81",obj:{"int":f.micros}}})}return a({seq:e}).tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.Accuracy,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.MessageImprint=function(g){var c=KJUR,b=c.asn1,a=b.DERSequence,d=b.DEROctetString,f=b.x509,e=f.AlgorithmIdentifier;b.tsp.MessageImprint.superclass.constructor.call(this);this.params=null;this.tohex=function(){var k=this.params;var j=new e({name:k.alg});var h=new d({hex:k.hash});var i=new a({array:[j,h]});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!==undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.MessageImprint,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampReq=function(c){var a=KJUR,f=a.asn1,d=f.DERSequence,e=f.DERInteger,h=f.DERBoolean,j=f.ASN1Object,i=f.DERObjectIdentifier,g=f.tsp,b=g.MessageImprint;g.TimeStampReq.superclass.constructor.call(this);this.params=null;this.tohex=function(){var m=this.params;var k=[];k.push(new e({"int":1}));if(m.messageImprint instanceof KJUR.asn1.ASN1Object){k.push(m.messageImprint)}else{k.push(new b(m.messageImprint))}if(m.policy!=undefined){k.push(new i(m.policy))}if(m.nonce!=undefined){k.push(new e(m.nonce))}if(m.certreq==true){k.push(new h())}var l=new d({array:k});return l.tohex()};this.getEncodedHex=function(){return this.tohex()};if(c!=undefined){this.setByParam(c)}};extendClass(KJUR.asn1.tsp.TimeStampReq,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampResp=function(g){var e=KJUR,d=e.asn1,c=d.DERSequence,f=d.ASN1Object,a=d.tsp,b=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this);this.params=null;this.tohex=function(){var j=this.params;var h=[];if(j.econtent!=undefined||j.tst!=undefined){if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{h.push(new b("granted"))}if(j.econtent!=undefined){h.push((new a.TimeStampToken(j)).getContentInfo())}else{if(j.tst instanceof d.ASN1Object){h.push(j.tst)}else{throw new Error("improper member tst value")}}}else{if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{throw new Error("parameter for token nor statusinfo not specified")}}var i=new c({array:h});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.TimeStampResp,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatusInfo=function(d){var h=Error,a=KJUR,g=a.asn1,e=g.DERSequence,i=g.tsp,f=i.PKIStatus,c=i.PKIFreeText,b=i.PKIFailureInfo;i.PKIStatusInfo.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;var j=[];if(typeof l=="string"){j.push(new f(l))}else{if(l.status==undefined){throw new h("property 'status' unspecified")}j.push(new f(l.status));if(l.statusstr!=undefined){j.push(new c(l.statusstr))}if(l.failinfo!=undefined){j.push(new b(l.failinfo))}}var k=new e({array:j});return k.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.PKIStatusInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatus=function(g){var e=Error,d=KJUR,c=d.asn1,f=c.DERInteger,b=c.tsp;b.PKIStatus.superclass.constructor.call(this);var a={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null;this.tohex=function(){var k=this.params;var h,j;if(typeof k=="string"){try{j=a[k]}catch(i){throw new e("undefined name: "+k)}}else{if(typeof k=="number"){j=k}else{throw new e("unsupported params")}}return(new f({"int":j})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.PKIStatus,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIFreeText=function(g){var f=Error,e=KJUR,d=e.asn1,b=d.DERSequence,c=d.DERUTF8String,a=d.tsp;a.PKIFreeText.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;if(!l instanceof Array){throw new f("wrong params: not array")}var h=[];for(var k=0;k1){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>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; diff --git a/jsrsasign-jwths-min.js b/jsrsasign-jwths-min.js index 947d526c..9cb38389 100644 --- a/jsrsasign-jwths-min.js +++ b/jsrsasign-jwths-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(jwths) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(jwths) 10.5.20 (2022-04-26) (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 3a90056e..46c697f1 100644 --- a/jsrsasign-rsa-min.js +++ b/jsrsasign-rsa-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(rsa) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(rsa) 10.5.20 (2022-04-26) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js diff --git a/min/asn1ocsp-1.0.min.js b/min/asn1ocsp-1.0.min.js index bfca1cb6..c4a699be 100644 --- a/min/asn1ocsp-1.0.min.js +++ b/min/asn1ocsp-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.ocsp=="undefined"||!KJUR.asn1.ocsp){KJUR.asn1.ocsp={}}KJUR.asn1.ocsp.DEFAULT_HASH="sha1";KJUR.asn1.ocsp.OCSPResponse=function(e){KJUR.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var a=KJUR.asn1.DEREnumerated,b=KJUR.asn1.ASN1Util.newObject,c=KJUR.asn1.ocsp.ResponseBytes;var d=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null;this._getStatusCode=function(){var f=this.params.resstatus;if(typeof f=="number"){return f}if(typeof f!="string"){return -1}return d.indexOf(f)};this.setByParam=function(f){this.params=f};this.tohex=function(){var h=this.params;var g=this._getStatusCode();if(g==-1){throw new Error("responseStatus not supported: "+h.resstatus)}if(g!=0){return b({seq:[{"enum":{"int":g}}]}).tohex()}var f=new c(h);return b({seq:[{"enum":{"int":0}},{tag:{tag:"a0",explicit:true,obj:f}}]}).tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.setByParam(e)}};extendClass(KJUR.asn1.ocsp.OCSPResponse,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.ResponseBytes=function(e){KJUR.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var b=KJUR.asn1,a=b.DERSequence,f=b.DERObjectIdentifier,c=b.DEROctetString,d=b.ocsp.BasicOCSPResponse;this.params=null;this.setByParam=function(g){this.params=g};this.tohex=function(){var j=this.params;if(j.restype!="ocspBasic"){throw new Error("not supported responseType: "+j.restype)}var i=new d(j);var g=[];g.push(new f({name:"ocspBasic"}));g.push(new c({hex:i.tohex()}));var h=new a({array:g});return h.tohex()};this.getEncodedHex=function(){return this.tohex()};if(e!==undefined){this.setByParam(e)}};extendClass(KJUR.asn1.ocsp.ResponseBytes,KJUR.asn1.ASN1Object);KJUR.asn1.ocsp.BasicOCSPResponse=function(d){KJUR.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var i=Error,g=KJUR.asn1,j=g.ASN1Object,e=g.DERSequence,f=g.DERGeneralizedTime,c=g.DERTaggedObject,b=g.DERBitString,h=g.x509.Extensions,k=g.x509.AlgorithmIdentifier,l=g.ocsp,a=l.ResponderID;_SingleResponseList=l.SingleResponseList,_ResponseData=l.ResponseData;this.params=null;this.setByParam=function(m){this.params=m};this.sign=function(){var o=this.params;var m=o.tbsresp.tohex();var n=new KJUR.crypto.Signature({alg:o.sigalg});n.init(o.reskey);n.updateHex(m);o.sighex=n.sign()};this.tohex=function(){var t=this.params;if(t.tbsresp==undefined){t.tbsresp=new _ResponseData(t)}if(t.sighex==undefined&&t.reskey!=undefined){this.sign()}var n=[];n.push(t.tbsresp);n.push(new k({name:t.sigalg}));n.push(new b({hex:"00"+t.sighex}));if(t.certs!=undefined&&t.certs.length!=undefined){var m=[];for(var q=0;q -Silver Sponsors
    - -

    diff --git a/npm/lib/jsrsasign-all-min.js b/npm/lib/jsrsasign-all-min.js index 54d227c3..10c3ef79 100644 --- a/npm/lib/jsrsasign-all-min.js +++ b/npm/lib/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.5.20 (2022-04-26) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -224,7 +224,7 @@ if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!K if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}if(typeof KJUR.asn1.tsp=="undefined"||!KJUR.asn1.tsp){KJUR.asn1.tsp={}}KJUR.asn1.tsp.TimeStampToken=function(d){var c=KJUR,b=c.asn1,a=b.tsp;a.TimeStampToken.superclass.constructor.call(this);this.params=null;this.getEncodedHexPrepare=function(){var e=new a.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=e.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.TimeStampToken,KJUR.asn1.cms.SignedData);KJUR.asn1.tsp.TSTInfo=function(f){var m=Error,c=KJUR,j=c.asn1,g=j.DERSequence,i=j.DERInteger,l=j.DERBoolean,h=j.DERGeneralizedTime,n=j.DERObjectIdentifier,e=j.DERTaggedObject,k=j.tsp,d=k.MessageImprint,b=k.Accuracy,a=j.x509.X500Name,o=j.x509.GeneralName;k.TSTInfo.superclass.constructor.call(this);this.dVersion=new i({"int":1});this.dPolicy=null;this.dMessageImprint=null;this.dSerial=null;this.dGenTime=null;this.dAccuracy=null;this.dOrdering=null;this.dNonce=null;this.dTsa=null;this.tohex=function(){var p=[this.dVersion];if(this.dPolicy==null){throw new Error("policy shall be specified.")}p.push(this.dPolicy);if(this.dMessageImprint==null){throw new Error("messageImprint shall be specified.")}p.push(this.dMessageImprint);if(this.dSerial==null){throw new Error("serialNumber shall be specified.")}p.push(this.dSerial);if(this.dGenTime==null){throw new Error("genTime shall be specified.")}p.push(this.dGenTime);if(this.dAccuracy!=null){p.push(this.dAccuracy)}if(this.dOrdering!=null){p.push(this.dOrdering)}if(this.dNonce!=null){p.push(this.dNonce)}if(this.dTsa!=null){p.push(this.dTsa)}var q=new g({array:p});this.hTLV=q.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){if(typeof f.policy=="string"){if(!f.policy.match(/^[0-9.]+$/)){throw"policy shall be oid like 0.1.4.134"}this.dPolicy=new n({oid:f.policy})}if(f.messageImprint!==undefined){this.dMessageImprint=new d(f.messageImprint)}if(f.serial!==undefined){this.dSerial=new i(f.serial)}if(f.genTime!==undefined){this.dGenTime=new h(f.genTime)}if(f.accuracy!==undefined){this.dAccuracy=new b(f.accuracy)}if(f.ordering!==undefined&&f.ordering==true){this.dOrdering=new l()}if(f.nonce!==undefined){this.dNonce=new i(f.nonce)}if(f.tsa!==undefined){this.dTsa=new e({tag:"a0",explicit:true,obj:new o({dn:f.tsa})})}}};extendClass(KJUR.asn1.tsp.TSTInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.Accuracy=function(d){var c=KJUR,b=c.asn1,a=b.ASN1Util.newObject;b.tsp.Accuracy.superclass.constructor.call(this);this.params=null;this.tohex=function(){var f=this.params;var e=[];if(f.seconds!=undefined&&typeof f.seconds=="number"){e.push({"int":f.seconds})}if(f.millis!=undefined&&typeof f.millis=="number"){e.push({tag:{tagi:"80",obj:{"int":f.millis}}})}if(f.micros!=undefined&&typeof f.micros=="number"){e.push({tag:{tagi:"81",obj:{"int":f.micros}}})}return a({seq:e}).tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.Accuracy,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.MessageImprint=function(g){var c=KJUR,b=c.asn1,a=b.DERSequence,d=b.DEROctetString,f=b.x509,e=f.AlgorithmIdentifier;b.tsp.MessageImprint.superclass.constructor.call(this);this.params=null;this.tohex=function(){var k=this.params;var j=new e({name:k.alg});var h=new d({hex:k.hash});var i=new a({array:[j,h]});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!==undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.MessageImprint,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampReq=function(c){var a=KJUR,f=a.asn1,d=f.DERSequence,e=f.DERInteger,h=f.DERBoolean,j=f.ASN1Object,i=f.DERObjectIdentifier,g=f.tsp,b=g.MessageImprint;g.TimeStampReq.superclass.constructor.call(this);this.params=null;this.tohex=function(){var m=this.params;var k=[];k.push(new e({"int":1}));if(m.messageImprint instanceof KJUR.asn1.ASN1Object){k.push(m.messageImprint)}else{k.push(new b(m.messageImprint))}if(m.policy!=undefined){k.push(new i(m.policy))}if(m.nonce!=undefined){k.push(new e(m.nonce))}if(m.certreq==true){k.push(new h())}var l=new d({array:k});return l.tohex()};this.getEncodedHex=function(){return this.tohex()};if(c!=undefined){this.setByParam(c)}};extendClass(KJUR.asn1.tsp.TimeStampReq,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampResp=function(g){var e=KJUR,d=e.asn1,c=d.DERSequence,f=d.ASN1Object,a=d.tsp,b=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this);this.params=null;this.tohex=function(){var j=this.params;var h=[];if(j.econtent!=undefined||j.tst!=undefined){if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{h.push(new b("granted"))}if(j.econtent!=undefined){h.push((new a.TimeStampToken(j)).getContentInfo())}else{if(j.tst instanceof d.ASN1Object){h.push(j.tst)}else{throw new Error("improper member tst value")}}}else{if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{throw new Error("parameter for token nor statusinfo not specified")}}var i=new c({array:h});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.TimeStampResp,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatusInfo=function(d){var h=Error,a=KJUR,g=a.asn1,e=g.DERSequence,i=g.tsp,f=i.PKIStatus,c=i.PKIFreeText,b=i.PKIFailureInfo;i.PKIStatusInfo.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;var j=[];if(typeof l=="string"){j.push(new f(l))}else{if(l.status==undefined){throw new h("property 'status' unspecified")}j.push(new f(l.status));if(l.statusstr!=undefined){j.push(new c(l.statusstr))}if(l.failinfo!=undefined){j.push(new b(l.failinfo))}}var k=new e({array:j});return k.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.PKIStatusInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatus=function(g){var e=Error,d=KJUR,c=d.asn1,f=c.DERInteger,b=c.tsp;b.PKIStatus.superclass.constructor.call(this);var a={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null;this.tohex=function(){var k=this.params;var h,j;if(typeof k=="string"){try{j=a[k]}catch(i){throw new e("undefined name: "+k)}}else{if(typeof k=="number"){j=k}else{throw new e("unsupported params")}}return(new f({"int":j})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.PKIStatus,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIFreeText=function(g){var f=Error,e=KJUR,d=e.asn1,b=d.DERSequence,c=d.DERUTF8String,a=d.tsp;a.PKIFreeText.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;if(!l instanceof Array){throw new f("wrong params: not array")}var h=[];for(var k=0;k1){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>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; diff --git a/npm/lib/jsrsasign-jwths-min.js b/npm/lib/jsrsasign-jwths-min.js index 947d526c..9cb38389 100644 --- a/npm/lib/jsrsasign-jwths-min.js +++ b/npm/lib/jsrsasign-jwths-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(jwths) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(jwths) 10.5.20 (2022-04-26) (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 3a90056e..46c697f1 100644 --- a/npm/lib/jsrsasign-rsa-min.js +++ b/npm/lib/jsrsasign-rsa-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(rsa) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(rsa) 10.5.20 (2022-04-26) (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 fc5f310f..5896ca8f 100755 --- a/npm/lib/jsrsasign.js +++ b/npm/lib/jsrsasign.js @@ -4,7 +4,7 @@ navigator.userAgent = false; var window = {}; /* - * jsrsasign(all) 10.5.19 (2022-04-23) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license + * jsrsasign(all) 10.5.20 (2022-04-26) (c) 2010-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /*! CryptoJS v3.1.2 core-fix.js @@ -229,7 +229,7 @@ if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!K if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}if(typeof KJUR.asn1.tsp=="undefined"||!KJUR.asn1.tsp){KJUR.asn1.tsp={}}KJUR.asn1.tsp.TimeStampToken=function(d){var c=KJUR,b=c.asn1,a=b.tsp;a.TimeStampToken.superclass.constructor.call(this);this.params=null;this.getEncodedHexPrepare=function(){var e=new a.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=e.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.TimeStampToken,KJUR.asn1.cms.SignedData);KJUR.asn1.tsp.TSTInfo=function(f){var m=Error,c=KJUR,j=c.asn1,g=j.DERSequence,i=j.DERInteger,l=j.DERBoolean,h=j.DERGeneralizedTime,n=j.DERObjectIdentifier,e=j.DERTaggedObject,k=j.tsp,d=k.MessageImprint,b=k.Accuracy,a=j.x509.X500Name,o=j.x509.GeneralName;k.TSTInfo.superclass.constructor.call(this);this.dVersion=new i({"int":1});this.dPolicy=null;this.dMessageImprint=null;this.dSerial=null;this.dGenTime=null;this.dAccuracy=null;this.dOrdering=null;this.dNonce=null;this.dTsa=null;this.tohex=function(){var p=[this.dVersion];if(this.dPolicy==null){throw new Error("policy shall be specified.")}p.push(this.dPolicy);if(this.dMessageImprint==null){throw new Error("messageImprint shall be specified.")}p.push(this.dMessageImprint);if(this.dSerial==null){throw new Error("serialNumber shall be specified.")}p.push(this.dSerial);if(this.dGenTime==null){throw new Error("genTime shall be specified.")}p.push(this.dGenTime);if(this.dAccuracy!=null){p.push(this.dAccuracy)}if(this.dOrdering!=null){p.push(this.dOrdering)}if(this.dNonce!=null){p.push(this.dNonce)}if(this.dTsa!=null){p.push(this.dTsa)}var q=new g({array:p});this.hTLV=q.tohex();return this.hTLV};this.getEncodedHex=function(){return this.tohex()};if(f!==undefined){if(typeof f.policy=="string"){if(!f.policy.match(/^[0-9.]+$/)){throw"policy shall be oid like 0.1.4.134"}this.dPolicy=new n({oid:f.policy})}if(f.messageImprint!==undefined){this.dMessageImprint=new d(f.messageImprint)}if(f.serial!==undefined){this.dSerial=new i(f.serial)}if(f.genTime!==undefined){this.dGenTime=new h(f.genTime)}if(f.accuracy!==undefined){this.dAccuracy=new b(f.accuracy)}if(f.ordering!==undefined&&f.ordering==true){this.dOrdering=new l()}if(f.nonce!==undefined){this.dNonce=new i(f.nonce)}if(f.tsa!==undefined){this.dTsa=new e({tag:"a0",explicit:true,obj:new o({dn:f.tsa})})}}};extendClass(KJUR.asn1.tsp.TSTInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.Accuracy=function(d){var c=KJUR,b=c.asn1,a=b.ASN1Util.newObject;b.tsp.Accuracy.superclass.constructor.call(this);this.params=null;this.tohex=function(){var f=this.params;var e=[];if(f.seconds!=undefined&&typeof f.seconds=="number"){e.push({"int":f.seconds})}if(f.millis!=undefined&&typeof f.millis=="number"){e.push({tag:{tagi:"80",obj:{"int":f.millis}}})}if(f.micros!=undefined&&typeof f.micros=="number"){e.push({tag:{tagi:"81",obj:{"int":f.micros}}})}return a({seq:e}).tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.Accuracy,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.MessageImprint=function(g){var c=KJUR,b=c.asn1,a=b.DERSequence,d=b.DEROctetString,f=b.x509,e=f.AlgorithmIdentifier;b.tsp.MessageImprint.superclass.constructor.call(this);this.params=null;this.tohex=function(){var k=this.params;var j=new e({name:k.alg});var h=new d({hex:k.hash});var i=new a({array:[j,h]});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!==undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.MessageImprint,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampReq=function(c){var a=KJUR,f=a.asn1,d=f.DERSequence,e=f.DERInteger,h=f.DERBoolean,j=f.ASN1Object,i=f.DERObjectIdentifier,g=f.tsp,b=g.MessageImprint;g.TimeStampReq.superclass.constructor.call(this);this.params=null;this.tohex=function(){var m=this.params;var k=[];k.push(new e({"int":1}));if(m.messageImprint instanceof KJUR.asn1.ASN1Object){k.push(m.messageImprint)}else{k.push(new b(m.messageImprint))}if(m.policy!=undefined){k.push(new i(m.policy))}if(m.nonce!=undefined){k.push(new e(m.nonce))}if(m.certreq==true){k.push(new h())}var l=new d({array:k});return l.tohex()};this.getEncodedHex=function(){return this.tohex()};if(c!=undefined){this.setByParam(c)}};extendClass(KJUR.asn1.tsp.TimeStampReq,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.TimeStampResp=function(g){var e=KJUR,d=e.asn1,c=d.DERSequence,f=d.ASN1Object,a=d.tsp,b=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this);this.params=null;this.tohex=function(){var j=this.params;var h=[];if(j.econtent!=undefined||j.tst!=undefined){if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{h.push(new b("granted"))}if(j.econtent!=undefined){h.push((new a.TimeStampToken(j)).getContentInfo())}else{if(j.tst instanceof d.ASN1Object){h.push(j.tst)}else{throw new Error("improper member tst value")}}}else{if(j.statusinfo!=undefined){h.push(new b(j.statusinfo))}else{throw new Error("parameter for token nor statusinfo not specified")}}var i=new c({array:h});return i.tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.TimeStampResp,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatusInfo=function(d){var h=Error,a=KJUR,g=a.asn1,e=g.DERSequence,i=g.tsp,f=i.PKIStatus,c=i.PKIFreeText,b=i.PKIFailureInfo;i.PKIStatusInfo.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;var j=[];if(typeof l=="string"){j.push(new f(l))}else{if(l.status==undefined){throw new h("property 'status' unspecified")}j.push(new f(l.status));if(l.statusstr!=undefined){j.push(new c(l.statusstr))}if(l.failinfo!=undefined){j.push(new b(l.failinfo))}}var k=new e({array:j});return k.tohex()};this.getEncodedHex=function(){return this.tohex()};if(d!=undefined){this.setByParam(d)}};extendClass(KJUR.asn1.tsp.PKIStatusInfo,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIStatus=function(g){var e=Error,d=KJUR,c=d.asn1,f=c.DERInteger,b=c.tsp;b.PKIStatus.superclass.constructor.call(this);var a={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null;this.tohex=function(){var k=this.params;var h,j;if(typeof k=="string"){try{j=a[k]}catch(i){throw new e("undefined name: "+k)}}else{if(typeof k=="number"){j=k}else{throw new e("unsupported params")}}return(new f({"int":j})).tohex()};this.getEncodedHex=function(){return this.tohex()};if(g!=undefined){this.setByParam(g)}};extendClass(KJUR.asn1.tsp.PKIStatus,KJUR.asn1.ASN1Object);KJUR.asn1.tsp.PKIFreeText=function(g){var f=Error,e=KJUR,d=e.asn1,b=d.DERSequence,c=d.DERUTF8String,a=d.tsp;a.PKIFreeText.superclass.constructor.call(this);this.params=null;this.tohex=function(){var l=this.params;if(!l instanceof Array){throw new f("wrong params: not array")}var h=[];for(var k=0;k1){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>6);var i=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16))}var j=224|((h&240)>>4);var i=128|((h&15)<<2)|((a&192)>>6);var g=128|(a&63);return hextoutf8(j.toString(16)+i.toString(16)+g.toString(16))}var c=d.match(/.{4}/g);var b=c.map(e);return b.join("")}function encodeURIComponentAll(a){var d=encodeURIComponent(a);var b="";for(var c=0;c"7"){return"00"+a}return a}function intarystrtohex(b){b=b.replace(/^\s*\[\s*/,"");b=b.replace(/\s*\]\s*$/,"");b=b.replace(/\s*/g,"");try{var c=b.split(/,/).map(function(g,e,h){var f=parseInt(g);if(f<0||255a.length){d=a.length}for(var b=0;b0){o=o+"."+k.join(".")}return o}catch(j){return null}}var strpad=function(c,b,a){if(a==undefined){a="0"}if(c.length>=b){return c}return new Array(b-c.length+1).join(a)+c};function bitstrtoint(e){if(e.length%2!=0){return -1}e=e.toLowerCase();if(e.match(/^[0-9a-f]+$/)==null){return -1}try{var a=e.substr(0,2);if(a=="00"){return parseInt(e.substr(2),16)}var b=parseInt(a,16);if(b>7){return -1}var g=e.substr(2);var d=parseInt(g,16).toString(2);if(d=="0"){d="00000000"}d=d.slice(0,0-b);var f=parseInt(d,2);if(f==NaN){return -1}return f}catch(c){return -1}}function inttobitstr(e){if(typeof e!="number"){return null}if(e<0){return null}var c=Number(e).toString(2);var b=8-c.length%8;if(b==8){b=0}c=c+strpad("",b,"0");var d=parseInt(c,2).toString(16);if(d.length%2==1){d="0"+d}var a="0"+b;return a+d}function bitstrtobinstr(a){var b=bitstrtoint(a);if(b==-1){return null}return b.toString(2)}function binstrtobitstr(b){if(typeof b!="string"){return null}if(b.match(/^[01]+$/)==null){return null}try{var c=parseInt(b,2);return inttobitstr(c)}catch(a){return null}}function extendClass(c,a){var b=function(){};b.prototype=a.prototype;c.prototype=new b();c.prototype.constructor=c;c.superclass=a.prototype;if(a.prototype.constructor==Object.prototype.constructor){a.prototype.constructor=a}}; if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.crypto=="undefined"||!KJUR.crypto){KJUR.crypto={}}KJUR.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414",};this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa",};this.CRYPTOJSMESSAGEDIGESTNAME={md5:CryptoJS.algo.MD5,sha1:CryptoJS.algo.SHA1,sha224:CryptoJS.algo.SHA224,sha256:CryptoJS.algo.SHA256,sha384:CryptoJS.algo.SHA384,sha512:CryptoJS.algo.SHA512,ripemd160:CryptoJS.algo.RIPEMD160};this.getDigestInfoHex=function(a,b){if(typeof this.DIGESTINFOHEAD[b]=="undefined"){throw"alg not supported in Util.DIGESTINFOHEAD: "+b}return this.DIGESTINFOHEAD[b]+a};this.getPaddedDigestInfoHex=function(h,a,j){var c=this.getDigestInfoHex(h,a);var d=j/4;if(c.length+22>d){throw"key is too short for SigAlg: keylen="+j+","+a}var b="0001";var k="00"+c;var g="";var l=d-b.length-k.length;for(var f=0;f=0;--u){v=v.twice2D();v.z=f.ONE;if(t.testBit(u)){if(s.testBit(u)){v=v.add2D(y)}else{v=v.add2D(x)}}else{if(s.testBit(u)){v=v.add2D(w)}}}return v}this.getBigRandom=function(r){return new f(r.bitLength(),a).mod(r.subtract(f.ONE)).add(f.ONE)};this.setNamedCurve=function(r){this.ecparams=c.getByName(r);this.prvKeyHex=null;this.pubKeyHex=null;this.curveName=r};this.setPrivateKeyHex=function(r){this.isPrivate=true;this.prvKeyHex=r};this.setPublicKeyHex=function(r){this.isPublic=true;this.pubKeyHex=r};this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if(t.substr(0,2)!=="04"){throw"this method supports uncompressed format(04) only"}var s=this.ecparams.keycharlen;if(t.length!==2+s*2){throw"malformed public key hex length"}var r={};r.x=t.substr(2,s);r.y=t.substr(2+s);return r};this.getShortNISTPCurveName=function(){var r=this.curveName;if(r==="secp256r1"||r==="NIST P-256"||r==="P-256"||r==="prime256v1"){return"P-256"}if(r==="secp384r1"||r==="NIST P-384"||r==="P-384"){return"P-384"}if(r==="secp521r1"||r==="NIST P-521"||r==="P-521"){return"P-521"}return null};this.generateKeyPairHex=function(){var s=this.ecparams.n;var u=this.getBigRandom(s);var r=this.ecparams.keycharlen;var t=("0000000000"+u.toString(16)).slice(-r);this.setPrivateKeyHex(t);var v=this.generatePublicKeyHex();return{ecprvhex:t,ecpubhex:v}};this.generatePublicKeyHex=function(){var u=new f(this.prvKeyHex,16);var w=this.ecparams.G.multiply(u);var t=w.getX().toBigInteger();var s=w.getY().toBigInteger();var r=this.ecparams.keycharlen;var y=("0000000000"+t.toString(16)).slice(-r);var v=("0000000000"+s.toString(16)).slice(-r);var x="04"+y+v;this.setPublicKeyHex(x);return x};this.signWithMessageHash=function(r){return this.signHex(r,this.prvKeyHex)};this.signHex=function(x,u){var A=new f(u,16);var v=this.ecparams.n;var z=new f(x.substring(0,this.ecparams.keycharlen),16);do{var w=this.getBigRandom(v);var B=this.ecparams.G;var y=B.multiply(w);var t=y.getX().toBigInteger().mod(v)}while(t.compareTo(f.ZERO)<=0);var C=w.modInverse(v).multiply(z.add(A.multiply(t))).mod(v);return m.biRSSigToASN1Sig(t,C)};this.sign=function(w,B){var z=B;var u=this.ecparams.n;var y=f.fromByteArrayUnsigned(w);do{var v=this.getBigRandom(u);var A=this.ecparams.G;var x=A.multiply(v);var t=x.getX().toBigInteger().mod(u)}while(t.compareTo(BigInteger.ZERO)<=0);var C=v.modInverse(u).multiply(y.add(z.multiply(t))).mod(u);return this.serializeSig(t,C)};this.verifyWithMessageHash=function(s,r){return this.verifyHex(s,r,this.pubKeyHex)};this.verifyHex=function(v,y,u){try{var t,B;var w=m.parseSigHex(y);t=w.r;B=w.s;var x=h.decodeFromHex(this.ecparams.curve,u);var z=new f(v.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(z,t,B,x)}catch(A){return false}};this.verify=function(z,A,u){var w,t;if(Bitcoin.Util.isArray(A)){var y=this.parseSig(A);w=y.r;t=y.s}else{if("object"===typeof A&&A.r&&A.s){w=A.r;t=A.s}else{throw"Invalid value for signature"}}var v;if(u instanceof ECPointFp){v=u}else{if(Bitcoin.Util.isArray(u)){v=h.decodeFrom(this.ecparams.curve,u)}else{throw"Invalid format for pubkey value, must be byte array or ECPointFp"}}var x=f.fromByteArrayUnsigned(z);return this.verifyRaw(x,w,t,v)};this.verifyRaw=function(z,t,E,y){var x=this.ecparams.n;var D=this.ecparams.G;if(t.compareTo(f.ONE)<0||t.compareTo(x)>=0){return false}if(E.compareTo(f.ONE)<0||E.compareTo(x)>=0){return false}var A=E.modInverse(x);var w=z.multiply(A).mod(x);var u=t.multiply(A).mod(x);var B=D.multiply(w).add(y.multiply(u));var C=B.getX().toBigInteger().mod(x);return C.equals(t)};this.serializeSig=function(v,u){var w=v.toByteArraySigned();var t=u.toByteArraySigned();var x=[];x.push(2);x.push(w.length);x=x.concat(w);x.push(2);x.push(t.length);x=x.concat(t);x.unshift(x.length);x.unshift(48);return x};this.parseSig=function(y){var x;if(y[0]!=48){throw new Error("Signature not a valid DERSequence")}x=2;if(y[x]!=2){throw new Error("First element in signature must be a DERInteger")}var w=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];if(y[x]!=2){throw new Error("Second element in signature must be a DERInteger")}var t=y.slice(x+2,x+2+y[x+1]);x+=2+y[x+1];var v=f.fromByteArrayUnsigned(w);var u=f.fromByteArrayUnsigned(t);return{r:v,s:u}};this.parseSigCompact=function(w){if(w.length!==65){throw"Signature has the wrong length"}var t=w[0]-27;if(t<0||t>7){throw"Invalid signature type"}var x=this.ecparams.n;var v=f.fromByteArrayUnsigned(w.slice(1,33)).mod(x);var u=f.fromByteArrayUnsigned(w.slice(33,65)).mod(x);return{r:v,s:u,i:t}};this.readPKCS5PrvKeyHex=function(u){if(k(u)===false){throw new Error("not ASN.1 hex string")}var r,t,v;try{r=n(u,0,["[0]",0],"06");t=n(u,0,[1],"04");try{v=n(u,0,["[1]",0],"03")}catch(s){}}catch(s){throw new Error("malformed PKCS#1/5 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw"unsupported curve name"}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v);this.setPrivateKeyHex(t);this.isPublic=false};this.readPKCS8PrvKeyHex=function(v){if(k(v)===false){throw new j("not ASN.1 hex string")}var t,r,u,w;try{t=n(v,0,[1,0],"06");r=n(v,0,[1,1],"06");u=n(v,0,[2,0,1],"04");try{w=n(v,0,[2,0,"[1]",0],"03")}catch(s){}}catch(s){throw new j("malformed PKCS#8 plain ECC private key")}this.curveName=d(r);if(this.curveName===undefined){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(w);this.setPrivateKeyHex(u);this.isPublic=false};this.readPKCS8PubKeyHex=function(u){if(k(u)===false){throw new j("not ASN.1 hex string")}var t,r,v;try{t=n(u,0,[0,0],"06");r=n(u,0,[0,1],"06");v=n(u,0,[1],"03")}catch(s){throw new j("malformed PKCS#8 ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(v)};this.readCertPubKeyHex=function(t,v){if(k(t)===false){throw new j("not ASN.1 hex string")}var r,u;try{r=n(t,0,[0,5,0,1],"06");u=n(t,0,[0,5,1],"03")}catch(s){throw new j("malformed X.509 certificate ECC public key")}this.curveName=d(r);if(this.curveName===null){throw new j("unsupported curve name")}this.setNamedCurve(this.curveName);this.setPublicKeyHex(u)};if(e!==undefined){if(e.curve!==undefined){this.curveName=e.curve}}if(this.curveName===undefined){this.curveName=g}this.setNamedCurve(this.curveName);if(e!==undefined){if(e.prv!==undefined){this.setPrivateKeyHex(e.prv)}if(e.pub!==undefined){this.setPublicKeyHex(e.pub)}}};KJUR.crypto.ECDSA.parseSigHex=function(a){var b=KJUR.crypto.ECDSA.parseSigHexInHexRS(a);var d=new BigInteger(b.r,16);var c=new BigInteger(b.s,16);return{r:d,s:c}};KJUR.crypto.ECDSA.parseSigHexInHexRS=function(f){var j=ASN1HEX,i=j.getChildIdx,g=j.getV;j.checkStrictDER(f,0);if(f.substr(0,2)!="30"){throw new Error("signature is not a ASN.1 sequence")}var h=i(f,0);if(h.length!=2){throw new Error("signature shall have two elements")}var e=h[0];var d=h[1];if(f.substr(e,2)!="02"){throw new Error("1st item not ASN.1 integer")}if(f.substr(d,2)!="02"){throw new Error("2nd item not ASN.1 integer")}var c=g(f,e);var b=g(f,d);return{r:c,s:b}};KJUR.crypto.ECDSA.asn1SigToConcatSig=function(d){var e=KJUR.crypto.ECDSA.parseSigHexInHexRS(d);var b=e.r;var a=e.s;if(b.length>=130&&b.length<=134){if(b.length%2!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%2!=0){throw Error("unknown ECDSA sig s length error")}if(b.substr(0,2)=="00"){b=b.substr(2)}if(a.substr(0,2)=="00"){a=a.substr(2)}var c=Math.max(b.length,a.length);b=("000000"+b).slice(-c);a=("000000"+a).slice(-c);return b+a}if(b.substr(0,2)=="00"&&(b.length%32)==2){b=b.substr(2)}if(a.substr(0,2)=="00"&&(a.length%32)==2){a=a.substr(2)}if((b.length%32)==30){b="00"+b}if((a.length%32)==30){a="00"+a}if(b.length%32!=0){throw Error("unknown ECDSA sig r length error")}if(a.length%32!=0){throw Error("unknown ECDSA sig s length error")}return b+a};KJUR.crypto.ECDSA.concatSigToASN1Sig=function(a){if(a.length%4!=0){throw Error("unknown ECDSA concatinated r-s sig length error")}var c=a.substr(0,a.length/2);var b=a.substr(a.length/2);return KJUR.crypto.ECDSA.hexRSSigToASN1Sig(c,b)};KJUR.crypto.ECDSA.hexRSSigToASN1Sig=function(b,a){var d=new BigInteger(b,16);var c=new BigInteger(a,16);return KJUR.crypto.ECDSA.biRSSigToASN1Sig(d,c)};KJUR.crypto.ECDSA.biRSSigToASN1Sig=function(f,d){var c=KJUR.asn1;var b=new c.DERInteger({bigint:f});var a=new c.DERInteger({bigint:d});var e=new c.DERSequence({array:[b,a]});return e.tohex()};KJUR.crypto.ECDSA.getName=function(a){if(a==="2b8104001f"){return"secp192k1"}if(a==="2a8648ce3d030107"){return"secp256r1"}if(a==="2b8104000a"){return"secp256k1"}if(a==="2b81040021"){return"secp224r1"}if(a==="2b81040022"){return"secp384r1"}if(a==="2b81040023"){return"secp521r1"}if("|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(a)!==-1){return"secp256r1"}if("|secp256k1|".indexOf(a)!==-1){return"secp256k1"}if("|secp224r1|NIST P-224|P-224|".indexOf(a)!==-1){return"secp224r1"}if("|secp384r1|NIST P-384|P-384|".indexOf(a)!==-1){return"secp384r1"}if("|secp521r1|NIST P-521|P-521|".indexOf(a)!==-1){return"secp521r1"}return null}; diff --git a/npm/package.json b/npm/package.json index 5da0d169..cc20d471 100755 --- a/npm/package.json +++ b/npm/package.json @@ -1,6 +1,6 @@ { "name": "jsrsasign", - "version": "10.5.19", + "version": "10.5.20", "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/asn1ocsp-1.0.js b/src/asn1ocsp-1.0.js index 84aa44c9..2fc465dd 100644 --- a/src/asn1ocsp-1.0.js +++ b/src/asn1ocsp-1.0.js @@ -1,4 +1,4 @@ -/* asn1ocsp-1.1.7.js (c) 2016-2022 Kenji Urushima | kjur.github.io/jsrsasign/license +/* asn1ocsp-1.1.8.js (c) 2016-2022 Kenji Urushima | kjur.github.io/jsrsasign/license */ /* * asn1ocsp.js - ASN.1 DER encoder classes for OCSP protocol @@ -16,7 +16,7 @@ * @fileOverview * @name asn1ocsp-1.0.js * @author Kenji Urushima kenji.urushima@gmail.com - * @version jsrsasign 10.5.16 asn1ocsp 1.1.7 (2022-Apr-08) + * @version jsrsasign 10.5.20 asn1ocsp 1.1.8 (2022-Apr-25) * @since jsrsasign 6.1.0 * @license MIT License */ @@ -481,6 +481,8 @@ extendClass(KJUR.asn1.ocsp.ResponseData, KJUR.asn1.ASN1Object); * @see KJUR.asn1.ocsp.ResponseBytes * @see KJUR.asn1.ocsp.BasicOCSPResponse * @see KJUR.asn1.ocsp.ResponseData + * @see X509#getSubject + * @see X509#getExtSubjectKeyIdentifier * * @description * ResponderID ASN.1 class is defined in @@ -494,38 +496,80 @@ extendClass(KJUR.asn1.ocsp.ResponseData, KJUR.asn1.ASN1Object); * * Following properties are available: *
      - *
    • {Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter - * for "byName"
    • - *
    • {String}key (OPTION) - hexadecimal string of KeyHash value
    • + *
    • {Array}name (OPTION) - JSON object of {@link KJUR.asn1.x509.X500Name} parameter, + * PEM string of X.509 certificate or {@link X509 object} for "byName",
    • + *
    • {String}key (OPTION) - hexadecimal string of KeyHash value, + * PEM string of X.509 certificate or {@link X509 object} for "byKey"
    • *
    + *
    + * NOTE: From jsrsasign 10.5.20, "name" and "key" member values can be + * specified by PEM string of X.509 certificate or {@link X509 object}. + * For "name", subject field of the certificate will be used and + * for "key", subjectKeyIdentifier extension value of the certificate will be used + * respectively. * * @example + * new KJUR.asn1.ocsp.ResponderID({key: "12ab..."}) * new KJUR.asn1.ocsp.ResponderID({name: {str: "/C=JP/O=Resp"}}) * new KJUR.asn1.ocsp.ResponderID({name: {array: [[{type:"C",value:"JP",ds:"prn"}]...]}}) - * new KJUR.asn1.ocsp.ResponderID({key: "12ab..."}) + * // by certificate + * new KJUR.asn1.ocsp.ResponderID({key: "-----BEGIN CERTIFICATE..."}) + * new KJUR.asn1.ocsp.ResponderID({name: "-----BEGIN CERTIFICATE..."}) + * // by X509 object + * new KJUR.asn1.ocsp.ResponderID({key: new X509(...)}) + * new KJUR.asn1.ocsp.ResponderID({name: new X509(...)}) */ KJUR.asn1.ocsp.ResponderID = function(params) { KJUR.asn1.ocsp.ResponderID.superclass.constructor.call(this); - var _KJUR_asn1 = KJUR.asn1, + var _KJUR = KJUR, + _KJUR_asn1 = _KJUR.asn1, _newObject = _KJUR_asn1.ASN1Util.newObject, - _X500Name = _KJUR_asn1.x509.X500Name; + _X500Name = _KJUR_asn1.x509.X500Name, + _isHex = _KJUR.lang.String.isHex, + _Error = Error; this.params = null; this.tohex = function() { var params = this.params; if (params.key != undefined) { + var hKey = null; + if (typeof params.key == "string") { + if (_isHex(params.key)) hKey = params.key; + if (params.key.match(/-----BEGIN CERTIFICATE/)) { + var x = new X509(params.key); + var extSKID = x.getExtSubjectKeyIdentifier(); + if (extSKID != null) hKey = extSKID.kid.hex; + } + } else if (params.key instanceof X509) { + var extSKID = params.key.getExtSubjectKeyIdentifier(); + if (extSKID != null) hKey = extSKID.kid.hex; + } + if (hKey == null) throw new _Error("wrong key member value"); var dTag = _newObject({tag: {tag:"a2", explicit:true, - obj:{octstr:{hex:params.key}}}}); + obj:{octstr:{hex:hKey}}}}); return dTag.tohex(); } else if (params.name != undefined) { + var pName = null; + if (typeof params.name == "string" && + params.name.match(/-----BEGIN CERTIFICATE/)) { + var x = new X509(params.name); + pName = x.getSubject(); + } else if (params.name instanceof X509) { + pName = params.name.getSubject(); + } else if (typeof params.name == "object" && + (params.name.array != undefined || + params.name.str != undefined)) { + pName = params.name; + } + if (pName == null) throw new _Error("wrong name member value"); var dTag = _newObject({tag: {tag:"a1", explicit:true, - obj:new _X500Name(params.name)}}); + obj:new _X500Name(pName)}}); return dTag.tohex(); } - throw new Error("key or name not specified"); + throw new _Error("key or name not specified"); }; this.getEncodedHex = function() { return this.tohex(); }; diff --git a/test/qunit-do-asn1ocsp.html b/test/qunit-do-asn1ocsp.html index be474f2d..6731e6a9 100755 --- a/test/qunit-do-asn1ocsp.html +++ b/test/qunit-do-asn1ocsp.html @@ -124,6 +124,9 @@ -----END CERTIFICATE----- */}).toString().match(/\/\*([^]*)\*\//)[1]; +// raymii.org cert +// SBJDN=/OU=Domain Control Validated/OU=PositiveSSL/CN=raymii.org +// SKID=70585f8fd3eff27167b12b4a5a9faa8f3154a592 var certEE1 = (function() {/* -----BEGIN CERTIFICATE----- MIIGQzCCBSugAwIBAgIRANCSgmNDA6l/rfVVaKSMqH4wDQYJKoZIhvcNAQELBQAw @@ -319,23 +322,56 @@ test("ResponderID test", function() { var _ResponderID = KJUR.asn1.ocsp.ResponderID; +var pIn, hExpect; -var hExpect = "a204040212ab"; -var params = {key: "12ab"}; -equal((new _ResponderID(params)).getEncodedHex(), hExpect, "hex by key"); +pIn = {key: "12ab"}; +hExpect = "a204040212ab"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "hex by key"); equal( -ASN1HEX.dump((new _ResponderID(params)).getEncodedHex()), +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), ASN1HEX.dump(hExpect), -"dump by key"); +"dump by key hex"); -var hExpect2 = "a11c301a310b3009060355040613024a50310b3009060355040a0c024f31"; -var params2 = {name: {str: "/C=JP/O=O1"}}; -equal((new _ResponderID(params2)).getEncodedHex(), hExpect2, "hex by name"); +pIn = {name: {str: "/C=JP/O=O1"}}; +hExpect = "a11c301a310b3009060355040613024a50310b3009060355040a0c024f31"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "hex by name param"); equal( -ASN1HEX.dump((new _ResponderID(params2)).getEncodedHex()), -ASN1HEX.dump(hExpect2), +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), +ASN1HEX.dump(hExpect), "dump by name"); +pIn = {key: certEE1}; +hExpect = "a216041470585f8fd3eff27167b12b4a5a9faa8f3154a592"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "key by cert"); +equal( +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), +ASN1HEX.dump(hExpect), +"key by cert dump"); + +pIn = {name: certEE1}; +hExpect = "a150304e3121301f060355040b1318446f6d61696e20436f6e74726f6c2056616c69646174656431143012060355040b130b506f73697469766553534c311330110603550403130a7261796d69692e6f7267"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "name by cert"); +equal( +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), +ASN1HEX.dump(hExpect), +"name by cert dump"); + +pIn = {key: new X509(certEE1)}; +hExpect = "a216041470585f8fd3eff27167b12b4a5a9faa8f3154a592"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "key by X509 obj"); +equal( +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), +ASN1HEX.dump(hExpect), +"key by X509 obj dump"); + +pIn = {name: new X509(certEE1)}; +hExpect = "a150304e3121301f060355040b1318446f6d61696e20436f6e74726f6c2056616c69646174656431143012060355040b130b506f73697469766553534c311330110603550403130a7261796d69692e6f7267"; +equal((new _ResponderID(pIn)).tohex(), hExpect, "name by X509 obj"); +equal( +ASN1HEX.dump((new _ResponderID(pIn)).tohex()), +ASN1HEX.dump(hExpect), +"name by X509 obj dump"); + }); test("SingleResponseList test", function() {