diff --git a/ChangeLog.txt b/ChangeLog.txt index 7ff3d36d..73f0610b 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,19 @@ ChangeLog for jsrsasign +add SigningCertificateV2 for CMSParser and issue fix +* Changes from 10.1.1 to 10.1.2 release (2020-11-21) + - src/asn1cms.js + - CMSParser + - getAttribute updated to support + SigningCertificateV2 + - add setSigningCertificateV2 method + - add getESSCertIDv2 method + - change sortflag of result parameter to true in + CMSParser.getCertificateSet + - test/qunit-do-asn1cms.html + - updated to follow above + CMSSignedData and TimeStamp parser bugfix * Changes from 10.1.0 to 10.1.1 release (2020-11-20) - src/asn1tsp.js diff --git a/api/files.html b/api/files.html index e50412a6..8e2addf6 100644 --- a/api/files.html +++ b/api/files.html @@ -559,7 +559,7 @@

asn1cms-1.0.js

Version:
-
jsrsasign 10.1.1 asn1cms 2.0.2 (2020-Nov-20)
+
jsrsasign 10.1.2 asn1cms 2.0.3 (2020-Nov-21)
diff --git a/api/symbols/KJUR.asn1.cms.CMSParser.html b/api/symbols/KJUR.asn1.cms.CMSParser.html index c810f7ea..b4f0638d 100644 --- a/api/symbols/KJUR.asn1.cms.CMSParser.html +++ b/api/symbols/KJUR.asn1.cms.CMSParser.html @@ -654,6 +654,18 @@

+ +   + +
getESSCertIDv2(h) +
+
parse ASN.1 ESSCertIDv2
+This method parses ASN.1 ESSCertIDv2 defined in + +RFC 5035 section 4.
+ + +   @@ -781,6 +793,18 @@

+ +   + +
setSigningCertificateV2(pAttr) +
+
set SigningCertificateV2 attribute
+This sets an attribute as SigningCertificateV2 defined in + +RFC 5035 section 3.
+ + +   @@ -884,10 +908,11 @@

Following attribute type are supported in the latest version: @@ -1298,6 +1323,89 @@

+
+ + +
+ + {Array} + getESSCertIDv2(h) + +
+
+ parse ASN.1 ESSCertIDv2
+This method parses ASN.1 ESSCertIDv2 defined in + +RFC 5035 section 4. +
+ESSCertIDv2 ::=  SEQUENCE {
+   hashAlgorithm           AlgorithmIdentifier
+                           DEFAULT {algorithm id-sha256},
+   certHash                Hash,
+   issuerSerial            IssuerSerial OPTIONAL }
+Hash ::= OCTET STRING
+IssuerSerial ::= SEQUENCE {
+   issuer                  GeneralNames,
+   serialNumber            CertificateSerialNumber }
+
+ + +
+ + + +
parser = new KJUR.asn1.cms.CMSParser();
+parser.getESSCertID("30...") →
+{
+  hash: "3f2d...",
+  alg: "sha512",
+  issuer: {str: "/C=JP/O=T1"},
+  serial: {hex: "12ab..."}
+}
+ + + + +
+
Parameters:
+ +
+ {String} h + +
+
hexadecimal string of ASN.1 ESSCertIDv2
+ +
+ + + +
+
Since:
+
jsrsasign 10.1.2 asn1cms 2.0.3
+
+ + + + +
+
Returns:
+ +
{Array} array of JSON object of ESSCertIDv2 parameter
+ +
+ + + +
+
See:
+ +
KJUR.asn1.cms.ESSCertIDv2
+ +
KJUR.asn1.cms.CMSParser.getESSCertID
+ +
+ +
@@ -1975,6 +2083,85 @@

+
+ + +
+ + + setSigningCertificateV2(pAttr) + +
+
+ set SigningCertificateV2 attribute
+This sets an attribute as SigningCertificateV2 defined in + +RFC 5035 section 3. + + +
+ + + +
parser = new KJUR.asn1.cms.CMSParser();
+pAttr = {
+  attr: "signingCertificateV2"
+  valhex: '...'
+};
+parser.setSigningCertificateV2(pAttr);
+pAttr → {
+  attr: "signingCertificateV2",
+  array: [{
+    hash: "123456...",
+    alg: "sha256",
+    issuer: {
+      array: [[{type:"C",value:"JP",ds:"prn"},...]],
+      str: "/C=JP/O=T1"
+    },
+    serial: {hex: "123456..."}
+  }]
+}
+ + + + +
+
Parameters:
+ +
+ {Array} pAttr + +
+
JSON object of attribute parameter
+ +
+ + + +
+
Since:
+
jsrsasign 10.1.2 asn1cms 2.0.3
+
+ + + + + + +
+
See:
+ +
KJUR.asn1.cms.CMSParser#getAttribute
+ +
KJUR.asn1.cms.CMSParser#getESSCertIDv2
+ +
KJUR.asn1.cms.SigningCertificateV2
+ +
KJUR.asn1.cms.ESSCertIDv2
+ +
+ +
diff --git a/api/symbols/src/asn1cms-1.0.js.html b/api/symbols/src/asn1cms-1.0.js.html index f6486d6f..a046c888 100644 --- a/api/symbols/src/asn1cms-1.0.js.html +++ b/api/symbols/src/asn1cms-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 /* asn1cms-2.0.2.js (c) 2013-2020 Kenji Urushima | kjur.github.io/jsrsasign/license
+	
  1 /* asn1cms-2.0.3.js (c) 2013-2020 Kenji Urushima | kjur.github.io/jsrsasign/license
   2  */
   3 /*
   4  * asn1cms.js - ASN.1 DER encoder and verifier classes for Cryptographic Message Syntax(CMS)
@@ -23,7 +23,7 @@
  16  * @fileOverview
  17  * @name asn1cms-1.0.js
  18  * @author Kenji Urushima kenji.urushima@gmail.com
- 19  * @version jsrsasign 10.1.1 asn1cms 2.0.2 (2020-Nov-20)
+ 19  * @version jsrsasign 10.1.2 asn1cms 2.0.3 (2020-Nov-21)
  20  * @since jsrsasign 4.2.4
  21  * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a>
  22  */
@@ -2719,348 +2719,478 @@
 2712      * Following attribute type are supported in the
 2713      * latest version:
 2714      * <ul>
-2715      * <li>contentType</li>
-2716      * <li>messageDigest</li>
-2717      * <li>signingTime</li>
-2718      * <li>signingCertificate</li>
-2719      * </ul>
-2720      * 
-2721      * @example
-2722      * parser = new KJUR.asn1.cms.CMSParser();
-2723      * parser.getAttribute("30...") →
-2724      * {attr: "contentType", type: "tstinfo"}
-2725      */
-2726     this.getAttribute = function(h) {
-2727 	var pResult = {};
-2728 	var aIdx = _getChildIdx(h, 0);
-2729 
-2730 	var attrTypeOID = _ASN1HEX.getOID(h, aIdx[0]);
-2731 	var attrType = KJUR.asn1.x509.OID.oid2name(attrTypeOID);
-2732 	pResult.attr = attrType;
-2733 
-2734 	var hSet = _getTLV(h, aIdx[1]);
-2735 	var aSetIdx = _getChildIdx(hSet, 0);
-2736 	if (aSetIdx.length == 1) {
-2737 	    pResult.valhex = _getTLV(hSet, aSetIdx[0]);
-2738 	} else {
-2739 	    var a = [];
-2740 	    for (var i = 0; i < aSetIdx.length; i++) {
-2741 		a.push(_getTLV(hSet, aSetIdx[i]));
-2742 	    }
-2743 	    pResult.valhex = a;
-2744 	}
-2745 
-2746 	if (attrType == "contentType") {
-2747 	    this.setContentType(pResult);
-2748 	} else if (attrType == "messageDigest") {
-2749 	    this.setMessageDigest(pResult);
-2750 	} else if (attrType == "signingTime") {
-2751 	    this.setSigningTime(pResult);
-2752 	} else if (attrType == "signingCertificate") {
-2753 	    this.setSigningCertificate(pResult);
-2754 	}
-2755 
-2756 	return pResult;
-2757     };
-2758 
-2759     /**
-2760      * set ContentType attribute<br/>
-2761      * @name setContentType
-2762      * @memberOf KJUR.asn1.cms.CMSParser#
-2763      * @function
-2764      * @param {Array} pAttr JSON object of attribute parameter
-2765      * @see KJUR.asn1.cms.CMSParser#getAttribute
-2766      *
-2767      * @description
-2768      * This sets an attribute as ContentType defined in
-2769      * RFC 5652 
-2770      * <a href="https://tools.ietf.org/html/rfc5652#section-5.1">
-2771      * section 5</a>.
-2772      *
-2773      * @example
-2774      * parser = new KJUR.asn1.cms.CMSParser();
-2775      * pAttr = {
-2776      *   attr: "contentType"
-2777      *   valhex: '060b2a864886f70d0109100104'
-2778      * };
-2779      * parser.setContentInfo(pAttr);
-2780      * pAttr → {
-2781      *   attr: "contentType"
-2782      *   type: "tstinfo"
-2783      * }
-2784      */
-2785     this.setContentType = function(pAttr) {
-2786 	var contentType = _ASN1HEX.getOIDName(pAttr.valhex, 0, null);
-2787 	if (contentType != null) {
-2788 	    pAttr.type = contentType;
-2789 	    delete pAttr.valhex;
-2790 	}
-2791     };
-2792 
-2793     /**
-2794      * set SigningTime attribute<br/>
-2795      * @name setSigningTime
-2796      * @memberOf KJUR.asn1.cms.CMSParser#
-2797      * @function
-2798      * @param {Array} pAttr JSON object of attribute parameter
-2799      * @see KJUR.asn1.cms.CMSParser#getAttribute
-2800      *
-2801      * @description
-2802      * This sets an attribute as SigningTime defined in
-2803      * RFC 5652 
-2804      * <a href="https://tools.ietf.org/html/rfc5652#section-5.1">
-2805      * section 5</a>.
-2806      *
-2807      * @example
-2808      * parser = new KJUR.asn1.cms.CMSParser();
-2809      * pAttr = {
-2810      *   attr: "signingTime"
-2811      *   valhex: '170d3230313233313233353935395a'
-2812      * };
-2813      * parser.setSigningTime(pAttr);
-2814      * pAttr → {
-2815      *   attr: "signingTime",
-2816      *   str: "2012315959Z"
-2817      * }
-2818      */
-2819     this.setSigningTime = function(pAttr) {
-2820 	var hSigningTime = _getV(pAttr.valhex, 0);
-2821 	var signingTime = hextoutf8(hSigningTime);
-2822 	pAttr.str = signingTime;
-2823 	delete pAttr.valhex;
-2824     };
-2825 
-2826     /**
-2827      * set MessageDigest attribute<br/>
-2828      * @name setMessageDigest
-2829      * @memberOf KJUR.asn1.cms.CMSParser#
-2830      * @function
-2831      * @param {Array} pAttr JSON object of attribute parameter
-2832      * @see KJUR.asn1.cms.CMSParser#getAttribute
-2833      *
-2834      * @description
-2835      * This sets an attribute as SigningTime defined in
-2836      * RFC 5652 
-2837      * <a href="https://tools.ietf.org/html/rfc5652#section-5.1">
-2838      * section 5</a>.
-2839      *
-2840      * @example
-2841      * parser = new KJUR.asn1.cms.CMSParser();
-2842      * pAttr = {
-2843      *   attr: "messageDigest"
-2844      *   valhex: '0403123456'
-2845      * };
-2846      * parser.setMessageDigest(pAttr);
-2847      * pAttr → {
-2848      *   attr: "messageDigest",
-2849      *   hex: "123456"
-2850      * }
-2851      */
-2852     this.setMessageDigest = function(pAttr) {
-2853 	var hMD = _getV(pAttr.valhex, 0);
-2854 	pAttr.hex = hMD;
-2855 	delete pAttr.valhex;
-2856     };
-2857 
-2858     /**
-2859      * set SigningCertificate attribute<br/>
-2860      * @name setSigningCertificate
-2861      * @memberOf KJUR.asn1.cms.CMSParser#
-2862      * @function
-2863      * @param {Array} pAttr JSON object of attribute parameter
-2864      * @see KJUR.asn1.cms.CMSParser#getAttribute
-2865      *
-2866      * @description
-2867      * This sets an attribute as SigningCertificate defined in
-2868      * <a href="https://tools.ietf.org/html/rfc5035#section-5">
-2869      * RFC 5035 section 5</a>.
-2870      *
-2871      * @example
-2872      * parser = new KJUR.asn1.cms.CMSParser();
-2873      * pAttr = {
-2874      *   attr: "signingCertificate"
-2875      *   valhex: '...'
-2876      * };
-2877      * parser.setSigningCertificate(pAttr);
-2878      * pAttr → {
-2879      *   attr: "signingCertificate",
-2880      *   array: [{
-2881      *     hash: "123456...",
-2882      *     issuer: {
-2883      *       array: [[{type:"C",value:"JP",ds:"prn"},...]],
-2884      *       str: "/C=JP/O=T1"
-2885      *     },
-2886      *     serial: {hex: "123456..."}
-2887      *   }]
-2888      * }
-2889      */
-2890     this.setSigningCertificate = function(pAttr) {
-2891 	var aIdx = _getChildIdx(pAttr.valhex, 0);
-2892 	if (aIdx.length > 0) {
-2893 	    var hCerts = _getTLV(pAttr.valhex, aIdx[0]);
-2894 	    var aCertIdx = _getChildIdx(hCerts, 0);
-2895 	    var a = [];
-2896 	    for (var i = 0; i < aCertIdx.length; i++) {
-2897 		var hESSCertID = _getTLV(hCerts, aCertIdx[i]);
-2898 		var pESSCertID = this.getESSCertID(hESSCertID);
-2899 		a.push(pESSCertID);
-2900 	    }
-2901 	    pAttr.array = a;
-2902 	}
-2903 
-2904 	if (aIdx.length > 1) {
-2905 	    var hPolicies = _getTLV(pAttr.valhex, aIdx[1]);
-2906 	    pAttr.polhex = hPolicies;
-2907 	}
-2908 	delete pAttr.valhex;
-2909     };
-2910 
-2911     /**
-2912      * parse ASN.1 ESSCertID<br/>
-2913      * @name getESSCertID
-2914      * @memberOf KJUR.asn1.cms.CMSParser#
-2915      * @function
-2916      * @param {String} h hexadecimal string of ASN.1 ESSCertID
-2917      * @return {Array} array of JSON object of ESSCertID parameter
-2918      * @see KJUR.asn1.cms.ESSCertID
-2919      *
-2920      * @description
-2921      * This method parses ASN.1 ESSCertID defined in 
-2922      * <a href="https://tools.ietf.org/html/rfc5035#section-6">
-2923      * RFC 5035 section 6</a>.
-2924      * <pre>
-2925      * ESSCertID ::= SEQUENCE {
-2926      *    certHash Hash,
-2927      *    issuerSerial IssuerSerial OPTIONAL }
-2928      * IssuerSerial ::= SEQUENCE {
-2929      *    issuer GeneralNames,
-2930      *    serialNumber CertificateSerialNumber }
-2931      * </pre>
-2932      * 
-2933      * @example
-2934      * parser = new KJUR.asn1.cms.CMSParser();
-2935      * parser.getESSCertID("30...") →
-2936      * { hash: "12ab...",
-2937      *   issuer: {
-2938      *     array: [[{type:"C",value:"JP",ds:"prn"}],...],
-2939      *     str: "/C=JP/O=T1"
-2940      *   },
-2941      *   serial: {hex: "12ab..."} }
-2942      */
-2943     this.getESSCertID = function(h) {
-2944 	var pResult = {};
-2945 	var aIdx = _getChildIdx(h, 0);
-2946 
-2947 	if (aIdx.length > 0) {
-2948 	    var hCertHash = _getV(h, aIdx[0]);
-2949 	    pResult.hash = hCertHash;
-2950 	}
-2951 
-2952 	if (aIdx.length > 1) {
-2953 	    var hIssuerSerial = _getTLV(h, aIdx[1]);
-2954 	    var pIssuerSerial = 
-2955 		this.getIssuerSerial(hIssuerSerial);
-2956 
-2957 	    if (pIssuerSerial.serial != undefined)
-2958 		pResult.serial = pIssuerSerial.serial;
-2959 
-2960 	    if (pIssuerSerial.issuer != undefined)
-2961 		pResult.issuer = pIssuerSerial.issuer;
-2962 	}
-2963 
-2964 	return pResult;
-2965     };
-2966 
-2967     /**
-2968      * parse ASN.1 IssuerSerial<br/>
-2969      * @name getIssuerSerial
-2970      * @memberOf KJUR.asn1.cms.CMSParser#
-2971      * @function
-2972      * @param {String} h hexadecimal string of ASN.1 IssuerSerial
-2973      * @return {Array} array of JSON object of IssuerSerial parameter
-2974      * @see KJUR.asn1.cms.IssuerSerial
-2975      * @see KJUR.asn1.x509.X500Name
-2976      *
-2977      * @description
-2978      * This method parses ASN.1 IssuerSerial defined in 
-2979      * <a href="https://tools.ietf.org/html/rfc5035#section-6">
-2980      * RFC 5035 section 6</a>.
-2981      * <pre>
-2982      * IssuerSerial ::= SEQUENCE {
-2983      *    issuer GeneralNames,
-2984      *    serialNumber CertificateSerialNumber }
-2985      * </pre>
-2986      * 
-2987      * @example
-2988      * parser = new KJUR.asn1.cms.CMSParser();
-2989      * parser.getIssuerSerial("30...") →
-2990      * { issuer: {
-2991      *     array: [[{type:"C",value:"JP",ds:"prn"}],...],
-2992      *     str: "/C=JP/O=T1",
-2993      *   },
-2994      *   serial: {hex: "12ab..."} }
-2995      */
-2996     this.getIssuerSerial = function(h) {
-2997 	var pResult = {};
-2998 	var aIdx = _getChildIdx(h, 0);
-2999 
-3000 	var hIssuer = _getTLV(h, aIdx[0]);
-3001 	var pIssuerGN = _x509obj.getGeneralNames(hIssuer);
-3002 	var pIssuerName = pIssuerGN[0].dn;
-3003 	pResult.issuer = pIssuerName;
-3004 
-3005 	var hSerial = _getV(h, aIdx[1]);
-3006 	pResult.serial = {hex: hSerial};
-3007 
-3008 	return pResult;
-3009     };
-3010 
-3011     /**
-3012      * parse ASN.1 CertificateSet<br/>
-3013      * @name getCertificateSet
-3014      * @memberOf KJUR.asn1.cms.CMSParser#
-3015      * @function
-3016      * @param {String} h hexadecimal string of ASN.1 CertificateSet
-3017      * @return {Array} array of JSON object of CertificateSet parameter
-3018      * @see KJUR.asn1.cms.CertificateSet
-3019      *
-3020      * @description
-3021      * This method parses ASN.1 IssuerSerial defined in 
-3022      * <a href="https://tools.ietf.org/html/rfc5652#section-10.2.3">
-3023      * RFC 5652 CMS section 10.2.3</a> and 
-3024      * <a href="https://tools.ietf.org/html/rfc5652#section-10.2.2">
-3025      * section 10.2.2</a>.
-3026      * <pre>
-3027      * CertificateSet ::= SET OF CertificateChoices
-3028      * CertificateChoices ::= CHOICE {
-3029      *   certificate Certificate,
-3030      *   extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete
-3031      *   v1AttrCert [1] IMPLICIT AttributeCertificateV1,       -- Obsolete
-3032      *   v2AttrCert [2] IMPLICIT AttributeCertificateV2,
-3033      *   other [3] IMPLICIT OtherCertificateFormat }
-3034      * OtherCertificateFormat ::= SEQUENCE {
-3035      *   otherCertFormat OBJECT IDENTIFIER,
-3036      *   otherCert ANY DEFINED BY otherCertFormat }
-3037      * </pre>
-3038      * Currently only "certificate" is supported in
-3039      * CertificateChoices.
-3040      * 
-3041      * @example
-3042      * parser = new KJUR.asn1.cms.CMSParser();
-3043      * parser.getCertificateSet("a0...") →
-3044      * [ "-----BEGIN CERTIFICATE...", ... ]
-3045      */
-3046     this.getCertificateSet = function(h) {
-3047 	var aIdx = _getChildIdx(h, 0);
-3048 	var  a = [];
-3049 	for (var i = 0; i < aIdx.length; i++) {
-3050 	    var hCert = _getTLV(h, aIdx[i]);
-3051 	    if (hCert.substr(0, 2) == "30") {
-3052 		var pem = hextopem(hCert, "CERTIFICATE");
-3053 		a.push(pem);
-3054 	    }
-3055 	}
-3056 	return a;
-3057     };
-3058 };
-3059 
\ No newline at end of file +2715 * <li>contentType - {@link KJUR.asn1.cms.CMSParser.setContentType}</li> +2716 * <li>messageDigest - {@link KJUR.asn1.cms.CMSParser.setMessageDigest}</li> +2717 * <li>signingTime - {@link KJUR.asn1.cms.CMSParser.setSigningTime}</li> +2718 * <li>signingCertificate - {@link KJUR.asn1.cms.CMSParser.setSigningCertificate}</li> +2719 * <li>signingCertificateV2 - {@link KJUR.asn1.cms.CMSParser.setSigningCertificateV2}</li> +2720 * </ul> +2721 * +2722 * @example +2723 * parser = new KJUR.asn1.cms.CMSParser(); +2724 * parser.getAttribute("30...") → +2725 * {attr: "contentType", type: "tstinfo"} +2726 */
+2727 this.getAttribute = function(h) { +2728 var pResult = {}; +2729 var aIdx = _getChildIdx(h, 0); +2730 +2731 var attrTypeOID = _ASN1HEX.getOID(h, aIdx[0]); +2732 var attrType = KJUR.asn1.x509.OID.oid2name(attrTypeOID); +2733 pResult.attr = attrType; +2734 +2735 var hSet = _getTLV(h, aIdx[1]); +2736 var aSetIdx = _getChildIdx(hSet, 0); +2737 if (aSetIdx.length == 1) { +2738 pResult.valhex = _getTLV(hSet, aSetIdx[0]); +2739 } else { +2740 var a = []; +2741 for (var i = 0; i < aSetIdx.length; i++) { +2742 a.push(_getTLV(hSet, aSetIdx[i])); +2743 } +2744 pResult.valhex = a; +2745 } +2746 +2747 if (attrType == "contentType") { +2748 this.setContentType(pResult); +2749 } else if (attrType == "messageDigest") { +2750 this.setMessageDigest(pResult); +2751 } else if (attrType == "signingTime") { +2752 this.setSigningTime(pResult); +2753 } else if (attrType == "signingCertificate") { +2754 this.setSigningCertificate(pResult); +2755 } else if (attrType == "signingCertificateV2") { +2756 //alert(pResult.valhex); +2757 this.setSigningCertificateV2(pResult); +2758 } +2759 +2760 return pResult; +2761 }; +2762 +2763 /** +2764 * set ContentType attribute<br/> +2765 * @name setContentType +2766 * @memberOf KJUR.asn1.cms.CMSParser# +2767 * @function +2768 * @param {Array} pAttr JSON object of attribute parameter +2769 * @see KJUR.asn1.cms.CMSParser#getAttribute +2770 * +2771 * @description +2772 * This sets an attribute as ContentType defined in +2773 * RFC 5652 +2774 * <a href="https://tools.ietf.org/html/rfc5652#section-5.1"> +2775 * section 5</a>. +2776 * +2777 * @example +2778 * parser = new KJUR.asn1.cms.CMSParser(); +2779 * pAttr = { +2780 * attr: "contentType" +2781 * valhex: '060b2a864886f70d0109100104' +2782 * }; +2783 * parser.setContentInfo(pAttr); +2784 * pAttr → { +2785 * attr: "contentType" +2786 * type: "tstinfo" +2787 * } +2788 */ +2789 this.setContentType = function(pAttr) { +2790 var contentType = _ASN1HEX.getOIDName(pAttr.valhex, 0, null); +2791 if (contentType != null) { +2792 pAttr.type = contentType; +2793 delete pAttr.valhex; +2794 } +2795 }; +2796 +2797 /** +2798 * set SigningTime attribute<br/> +2799 * @name setSigningTime +2800 * @memberOf KJUR.asn1.cms.CMSParser# +2801 * @function +2802 * @param {Array} pAttr JSON object of attribute parameter +2803 * @see KJUR.asn1.cms.CMSParser#getAttribute +2804 * +2805 * @description +2806 * This sets an attribute as SigningTime defined in +2807 * RFC 5652 +2808 * <a href="https://tools.ietf.org/html/rfc5652#section-5.1"> +2809 * section 5</a>. +2810 * +2811 * @example +2812 * parser = new KJUR.asn1.cms.CMSParser(); +2813 * pAttr = { +2814 * attr: "signingTime" +2815 * valhex: '170d3230313233313233353935395a' +2816 * }; +2817 * parser.setSigningTime(pAttr); +2818 * pAttr → { +2819 * attr: "signingTime", +2820 * str: "2012315959Z" +2821 * } +2822 */ +2823 this.setSigningTime = function(pAttr) { +2824 var hSigningTime = _getV(pAttr.valhex, 0); +2825 var signingTime = hextoutf8(hSigningTime); +2826 pAttr.str = signingTime; +2827 delete pAttr.valhex; +2828 }; +2829 +2830 /** +2831 * set MessageDigest attribute<br/> +2832 * @name setMessageDigest +2833 * @memberOf KJUR.asn1.cms.CMSParser# +2834 * @function +2835 * @param {Array} pAttr JSON object of attribute parameter +2836 * @see KJUR.asn1.cms.CMSParser#getAttribute +2837 * +2838 * @description +2839 * This sets an attribute as SigningTime defined in +2840 * RFC 5652 +2841 * <a href="https://tools.ietf.org/html/rfc5652#section-5.1"> +2842 * section 5</a>. +2843 * +2844 * @example +2845 * parser = new KJUR.asn1.cms.CMSParser(); +2846 * pAttr = { +2847 * attr: "messageDigest" +2848 * valhex: '0403123456' +2849 * }; +2850 * parser.setMessageDigest(pAttr); +2851 * pAttr → { +2852 * attr: "messageDigest", +2853 * hex: "123456" +2854 * } +2855 */ +2856 this.setMessageDigest = function(pAttr) { +2857 var hMD = _getV(pAttr.valhex, 0); +2858 pAttr.hex = hMD; +2859 delete pAttr.valhex; +2860 }; +2861 +2862 /** +2863 * set SigningCertificate attribute<br/> +2864 * @name setSigningCertificate +2865 * @memberOf KJUR.asn1.cms.CMSParser# +2866 * @function +2867 * @param {Array} pAttr JSON object of attribute parameter +2868 * @see KJUR.asn1.cms.CMSParser#getAttribute +2869 * +2870 * @description +2871 * This sets an attribute as SigningCertificate defined in +2872 * <a href="https://tools.ietf.org/html/rfc5035#section-5"> +2873 * RFC 5035 section 5</a>. +2874 * +2875 * @example +2876 * parser = new KJUR.asn1.cms.CMSParser(); +2877 * pAttr = { +2878 * attr: "signingCertificate" +2879 * valhex: '...' +2880 * }; +2881 * parser.setSigningCertificate(pAttr); +2882 * pAttr → { +2883 * attr: "signingCertificate", +2884 * array: [{ +2885 * hash: "123456...", +2886 * issuer: { +2887 * array: [[{type:"C",value:"JP",ds:"prn"},...]], +2888 * str: "/C=JP/O=T1" +2889 * }, +2890 * serial: {hex: "123456..."} +2891 * }] +2892 * } +2893 */ +2894 this.setSigningCertificate = function(pAttr) { +2895 var aIdx = _getChildIdx(pAttr.valhex, 0); +2896 if (aIdx.length > 0) { +2897 var hCerts = _getTLV(pAttr.valhex, aIdx[0]); +2898 var aCertIdx = _getChildIdx(hCerts, 0); +2899 var a = []; +2900 for (var i = 0; i < aCertIdx.length; i++) { +2901 var hESSCertID = _getTLV(hCerts, aCertIdx[i]); +2902 var pESSCertID = this.getESSCertID(hESSCertID); +2903 a.push(pESSCertID); +2904 } +2905 pAttr.array = a; +2906 } +2907 +2908 if (aIdx.length > 1) { +2909 var hPolicies = _getTLV(pAttr.valhex, aIdx[1]); +2910 pAttr.polhex = hPolicies; +2911 } +2912 delete pAttr.valhex; +2913 }; +2914 +2915 /** +2916 * set SigningCertificateV2 attribute<br/> +2917 * @name setSigningCertificateV2 +2918 * @memberOf KJUR.asn1.cms.CMSParser# +2919 * @function +2920 * @param {Array} pAttr JSON object of attribute parameter +2921 * @since jsrsasign 10.1.2 asn1cms 2.0.3 +2922 * @see KJUR.asn1.cms.CMSParser#getAttribute +2923 * @see KJUR.asn1.cms.CMSParser#getESSCertIDv2 +2924 * @see KJUR.asn1.cms.SigningCertificateV2 +2925 * @see KJUR.asn1.cms.ESSCertIDv2 +2926 * +2927 * @description +2928 * This sets an attribute as SigningCertificateV2 defined in +2929 * <a href="https://tools.ietf.org/html/rfc5035#section-3"> +2930 * RFC 5035 section 3</a>. +2931 * +2932 * @example +2933 * parser = new KJUR.asn1.cms.CMSParser(); +2934 * pAttr = { +2935 * attr: "signingCertificateV2" +2936 * valhex: '...' +2937 * }; +2938 * parser.setSigningCertificateV2(pAttr); +2939 * pAttr → { +2940 * attr: "signingCertificateV2", +2941 * array: [{ +2942 * hash: "123456...", +2943 * alg: "sha256", +2944 * issuer: { +2945 * array: [[{type:"C",value:"JP",ds:"prn"},...]], +2946 * str: "/C=JP/O=T1" +2947 * }, +2948 * serial: {hex: "123456..."} +2949 * }] +2950 * } +2951 */ +2952 this.setSigningCertificateV2 = function(pAttr) { +2953 var aIdx = _getChildIdx(pAttr.valhex, 0); +2954 if (aIdx.length > 0) { +2955 var hCerts = _getTLV(pAttr.valhex, aIdx[0]); +2956 var aCertIdx = _getChildIdx(hCerts, 0); +2957 var a = []; +2958 for (var i = 0; i < aCertIdx.length; i++) { +2959 var hESSCertIDv2 = _getTLV(hCerts, aCertIdx[i]); +2960 var pESSCertIDv2 = this.getESSCertIDv2(hESSCertIDv2); +2961 a.push(pESSCertIDv2); +2962 } +2963 pAttr.array = a; +2964 } +2965 +2966 if (aIdx.length > 1) { +2967 var hPolicies = _getTLV(pAttr.valhex, aIdx[1]); +2968 pAttr.polhex = hPolicies; +2969 } +2970 delete pAttr.valhex; +2971 }; +2972 +2973 /** +2974 * parse ASN.1 ESSCertID<br/> +2975 * @name getESSCertID +2976 * @memberOf KJUR.asn1.cms.CMSParser# +2977 * @function +2978 * @param {String} h hexadecimal string of ASN.1 ESSCertID +2979 * @return {Array} array of JSON object of ESSCertID parameter +2980 * @see KJUR.asn1.cms.ESSCertID +2981 * +2982 * @description +2983 * This method parses ASN.1 ESSCertID defined in +2984 * <a href="https://tools.ietf.org/html/rfc5035#section-6"> +2985 * RFC 5035 section 6</a>. +2986 * <pre> +2987 * ESSCertID ::= SEQUENCE { +2988 * certHash Hash, +2989 * issuerSerial IssuerSerial OPTIONAL } +2990 * IssuerSerial ::= SEQUENCE { +2991 * issuer GeneralNames, +2992 * serialNumber CertificateSerialNumber } +2993 * </pre> +2994 * +2995 * @example +2996 * parser = new KJUR.asn1.cms.CMSParser(); +2997 * parser.getESSCertID("30...") → +2998 * { hash: "12ab...", +2999 * issuer: { +3000 * array: [[{type:"C",value:"JP",ds:"prn"}],...], +3001 * str: "/C=JP/O=T1" +3002 * }, +3003 * serial: {hex: "12ab..."} } +3004 */ +3005 this.getESSCertID = function(h) { +3006 var pResult = {}; +3007 var aIdx = _getChildIdx(h, 0); +3008 +3009 if (aIdx.length > 0) { +3010 var hCertHash = _getV(h, aIdx[0]); +3011 pResult.hash = hCertHash; +3012 } +3013 +3014 if (aIdx.length > 1) { +3015 var hIssuerSerial = _getTLV(h, aIdx[1]); +3016 var pIssuerSerial = +3017 this.getIssuerSerial(hIssuerSerial); +3018 +3019 if (pIssuerSerial.serial != undefined) +3020 pResult.serial = pIssuerSerial.serial; +3021 +3022 if (pIssuerSerial.issuer != undefined) +3023 pResult.issuer = pIssuerSerial.issuer; +3024 } +3025 +3026 return pResult; +3027 }; +3028 +3029 /** +3030 * parse ASN.1 ESSCertIDv2<br/> +3031 * @name getESSCertIDv2 +3032 * @memberOf KJUR.asn1.cms.CMSParser# +3033 * @function +3034 * @param {String} h hexadecimal string of ASN.1 ESSCertIDv2 +3035 * @return {Array} array of JSON object of ESSCertIDv2 parameter +3036 * @since jsrsasign 10.1.2 asn1cms 2.0.3 +3037 * @see KJUR.asn1.cms.ESSCertIDv2 +3038 * @see KJUR.asn1.cms.CMSParser.getESSCertID +3039 * +3040 * @description +3041 * This method parses ASN.1 ESSCertIDv2 defined in +3042 * <a href="https://tools.ietf.org/html/rfc5035#section-4"> +3043 * RFC 5035 section 4</a>. +3044 * <pre> +3045 * ESSCertIDv2 ::= SEQUENCE { +3046 * hashAlgorithm AlgorithmIdentifier +3047 * DEFAULT {algorithm id-sha256}, +3048 * certHash Hash, +3049 * issuerSerial IssuerSerial OPTIONAL } +3050 * Hash ::= OCTET STRING +3051 * IssuerSerial ::= SEQUENCE { +3052 * issuer GeneralNames, +3053 * serialNumber CertificateSerialNumber } +3054 * </pre> +3055 * +3056 * @example +3057 * parser = new KJUR.asn1.cms.CMSParser(); +3058 * parser.getESSCertID("30...") → +3059 * { +3060 * hash: "3f2d...", +3061 * alg: "sha512", +3062 * issuer: {str: "/C=JP/O=T1"}, +3063 * serial: {hex: "12ab..."} +3064 * } +3065 */ +3066 this.getESSCertIDv2 = function(h) { +3067 var aResult = {}; +3068 var aIdx = _getChildIdx(h, 0); +3069 +3070 if (aIdx.length < 1 || 3 < aIdx.length) +3071 throw new _Error("wrong number of elements"); +3072 +3073 var offset = 0; +3074 if (h.substr(aIdx[0], 2) == "30") { +3075 var hHashAlg = _getTLV(h, aIdx[0]); +3076 aResult.alg = +3077 _x509obj.getAlgorithmIdentifierName(hHashAlg); +3078 offset++; +3079 } else { +3080 aResult.alg = "sha256"; +3081 } +3082 +3083 var hHash = _getV(h, aIdx[offset]); +3084 aResult.hash = hHash; +3085 +3086 if (aIdx.length > offset + 1) { +3087 var hIssuerSerial = _getTLV(h, aIdx[offset + 1]); +3088 var pIssuerSerial = +3089 this.getIssuerSerial(hIssuerSerial); +3090 aResult.issuer = pIssuerSerial.issuer; +3091 aResult.serial = pIssuerSerial.serial; +3092 } +3093 +3094 return aResult; +3095 }; +3096 +3097 /** +3098 * parse ASN.1 IssuerSerial<br/> +3099 * @name getIssuerSerial +3100 * @memberOf KJUR.asn1.cms.CMSParser# +3101 * @function +3102 * @param {String} h hexadecimal string of ASN.1 IssuerSerial +3103 * @return {Array} array of JSON object of IssuerSerial parameter +3104 * @see KJUR.asn1.cms.IssuerSerial +3105 * @see KJUR.asn1.x509.X500Name +3106 * +3107 * @description +3108 * This method parses ASN.1 IssuerSerial defined in +3109 * <a href="https://tools.ietf.org/html/rfc5035#section-6"> +3110 * RFC 5035 section 6</a>. +3111 * <pre> +3112 * IssuerSerial ::= SEQUENCE { +3113 * issuer GeneralNames, +3114 * serialNumber CertificateSerialNumber } +3115 * </pre> +3116 * +3117 * @example +3118 * parser = new KJUR.asn1.cms.CMSParser(); +3119 * parser.getIssuerSerial("30...") → +3120 * { issuer: { +3121 * array: [[{type:"C",value:"JP",ds:"prn"}],...], +3122 * str: "/C=JP/O=T1", +3123 * }, +3124 * serial: {hex: "12ab..."} } +3125 */ +3126 this.getIssuerSerial = function(h) { +3127 var pResult = {}; +3128 var aIdx = _getChildIdx(h, 0); +3129 +3130 var hIssuer = _getTLV(h, aIdx[0]); +3131 var pIssuerGN = _x509obj.getGeneralNames(hIssuer); +3132 var pIssuerName = pIssuerGN[0].dn; +3133 pResult.issuer = pIssuerName; +3134 +3135 var hSerial = _getV(h, aIdx[1]); +3136 pResult.serial = {hex: hSerial}; +3137 +3138 return pResult; +3139 }; +3140 +3141 /** +3142 * parse ASN.1 CertificateSet<br/> +3143 * @name getCertificateSet +3144 * @memberOf KJUR.asn1.cms.CMSParser# +3145 * @function +3146 * @param {String} h hexadecimal string of ASN.1 CertificateSet +3147 * @return {Array} array of JSON object of CertificateSet parameter +3148 * @see KJUR.asn1.cms.CertificateSet +3149 * +3150 * @description +3151 * This method parses ASN.1 IssuerSerial defined in +3152 * <a href="https://tools.ietf.org/html/rfc5652#section-10.2.3"> +3153 * RFC 5652 CMS section 10.2.3</a> and +3154 * <a href="https://tools.ietf.org/html/rfc5652#section-10.2.2"> +3155 * section 10.2.2</a>. +3156 * <pre> +3157 * CertificateSet ::= SET OF CertificateChoices +3158 * CertificateChoices ::= CHOICE { +3159 * certificate Certificate, +3160 * extendedCertificate [0] IMPLICIT ExtendedCertificate, -- Obsolete +3161 * v1AttrCert [1] IMPLICIT AttributeCertificateV1, -- Obsolete +3162 * v2AttrCert [2] IMPLICIT AttributeCertificateV2, +3163 * other [3] IMPLICIT OtherCertificateFormat } +3164 * OtherCertificateFormat ::= SEQUENCE { +3165 * otherCertFormat OBJECT IDENTIFIER, +3166 * otherCert ANY DEFINED BY otherCertFormat } +3167 * </pre> +3168 * Currently only "certificate" is supported in +3169 * CertificateChoices. +3170 * +3171 * @example +3172 * parser = new KJUR.asn1.cms.CMSParser(); +3173 * parser.getCertificateSet("a0...") → +3174 * [ "-----BEGIN CERTIFICATE...", ... ] +3175 */ +3176 this.getCertificateSet = function(h) { +3177 var aIdx = _getChildIdx(h, 0); +3178 var a = []; +3179 for (var i = 0; i < aIdx.length; i++) { +3180 var hCert = _getTLV(h, aIdx[i]); +3181 if (hCert.substr(0, 2) == "30") { +3182 var pem = hextopem(hCert, "CERTIFICATE"); +3183 a.push(pem); +3184 } +3185 } +3186 return {array: a, sortflag: false}; +3187 }; +3188 }; +3189
\ No newline at end of file diff --git a/bower.json b/bower.json index b25d4629..c91f7562 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "kjur-jsrsasign", - "version": "10.1.1", + "version": "10.1.2", "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/jsrsasign-all-min.js b/jsrsasign-all-min.js index 97c69d5c..fc8ccc9c 100644 --- a/jsrsasign-all-min.js +++ b/jsrsasign-all-min.js @@ -1,5 +1,5 @@ /* - * jsrsasign(all) 10.1.1 (2020-11-20) (c) 2010-2020 Kenji Urushima | kjur.github.com/jsrsasign/license + * jsrsasign(all) 10.1.2 (2020-11-21) (c) 2010-2020 Kenji Urushima | kjur.github.com/jsrsasign/license */ /*! @@ -228,7 +228,7 @@ var jsonParse=(function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][ if(typeof KJUR=="undefined"||!KJUR){KJUR={}}if(typeof KJUR.asn1=="undefined"||!KJUR.asn1){KJUR.asn1={}}KJUR.asn1.ASN1Util=new function(){this.integerToByteHex=function(a){var b=a.toString(16);if((b.length%2)==1){b="0"+b}return b};this.bigIntToMinTwosComplementsHex=function(j){var f=j.toString(16);if(f.substr(0,1)!="-"){if(f.length%2==1){f="0"+f}else{if(!f.match(/^[0-7]/)){f="00"+f}}}else{var a=f.substr(1);var e=a.length;if(e%2==1){e+=1}else{if(!f.match(/^[0-7]/)){e+=2}}var g="";for(var d=0;d15){throw"ASN.1 length too long to represent by 8x: n = "+j.toString(16)}var g=128+h;return g.toString(16)+i}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(d,b,e){if(e==undefined){e=-1}try{if(d.substr(b,2)!="02"){return e}var a=ASN1HEX.getV(d,b);return parseInt(a,16)}catch(c){return e}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.getEncodedHex()};if(f!==undefined){this.setByParam(f)}};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.getEncodedHex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.getEncodedHex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.getEncodedHex()};if(d!==undefined){this.params=d}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.getEncodedHex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.getEncodedHex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.getEncodedHex()}};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.getEncodedHex()};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.getEncodedHex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.getEncodedHex();return this.TLV};if(c!==undefined){this.setByParam(c)}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.getEncodedHex();return this.hTLV};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type="rfc822";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type="dns";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type="uri";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type="dn";this.explicit=true;if(typeof p.dn==="string"){u=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){u=p.dn}else{u=new a(p.dn)}}}if(p.ldapdn!==undefined){this.type="dn";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type="dn";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certissuer param not cert"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type="dn";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certsubj param not cert"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type="ip";this.explicit=false;var q=p.ip;var s;var n="malformed IP address";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex("["+q.split(".").join(",")+"]");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw"unsupported type in params="+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var n=this.getPKIStatusInfo(b(m,k[0]));var l=b(m,k[1]);var o=this.getToken(l);o.statusinfo=n;return o}}};this.getToken=function(l){var k=new KJUR.asn1.cms.CMSParser;var m=k.getCMSSignedData(l);this.setTSTInfo(m);return m};this.setTSTInfo=function(k){var n=k.econtent;if(n.type=="tstinfo"){var m=n.content.hex;var l=this.getTSTInfo(m);n.content=l}};this.getTSTInfo=function(q){var w={};var r=h(q,0);var o=g(q,r[1]);w.policy=hextooid(o);var n=b(q,r[2]);w.messageImprint=this.getMessageImprint(n);var t=g(q,r[3]);w.serial={hex:t};var x=g(q,r[4]);w.genTime={str:hextoutf8(x)};var p=0;if(r.length>5&&q.substr(r[5],2)=="30"){var u=b(q,r[5]);w.accuracy=this.getAccuracy(u);p++}if(r.length>5+p&&q.substr(r[5+p],2)=="01"){var y=g(q,r[5+p]);if(y=="ff"){w.ordering=true}p++}if(r.length>5+p&&q.substr(r[5+p],2)=="02"){var m=g(q,r[5+p]);w.nonce={hex:m};p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a0"){var l=b(q,r[5+p]);l="30"+l.substr(2);pGeneralNames=f.getGeneralNames(l);var s=pGeneralNames[0].dn;w.tsa=s;p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a1"){var k=b(q,r[5+p]);k="30"+k.substr(2);var v=f.getExtParamArray(k);w.ext=v;p++}return w};this.getAccuracy=function(p){var q={};var n=h(p,0);for(var o=0;o0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o15){throw"ASN.1 length too long to represent by 8x: n = "+j.toString(16)}var g=128+h;return g.toString(16)+i}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(d,b,e){if(e==undefined){e=-1}try{if(d.substr(b,2)!="02"){return e}var a=ASN1HEX.getV(d,b);return parseInt(a,16)}catch(c){return e}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.getEncodedHex()};if(f!==undefined){this.setByParam(f)}};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.getEncodedHex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.getEncodedHex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.getEncodedHex()};if(d!==undefined){this.params=d}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.getEncodedHex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.getEncodedHex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.getEncodedHex()}};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.getEncodedHex()};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.getEncodedHex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.getEncodedHex();return this.TLV};if(c!==undefined){this.setByParam(c)}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.getEncodedHex();return this.hTLV};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type="rfc822";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type="dns";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type="uri";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type="dn";this.explicit=true;if(typeof p.dn==="string"){u=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){u=p.dn}else{u=new a(p.dn)}}}if(p.ldapdn!==undefined){this.type="dn";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type="dn";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certissuer param not cert"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type="dn";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certsubj param not cert"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type="ip";this.explicit=false;var q=p.ip;var s;var n="malformed IP address";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex("["+q.split(".").join(",")+"]");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw"unsupported type in params="+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var n=this.getPKIStatusInfo(b(m,k[0]));var l=b(m,k[1]);var o=this.getToken(l);o.statusinfo=n;return o}}};this.getToken=function(l){var k=new KJUR.asn1.cms.CMSParser;var m=k.getCMSSignedData(l);this.setTSTInfo(m);return m};this.setTSTInfo=function(k){var n=k.econtent;if(n.type=="tstinfo"){var m=n.content.hex;var l=this.getTSTInfo(m);n.content=l}};this.getTSTInfo=function(q){var w={};var r=h(q,0);var o=g(q,r[1]);w.policy=hextooid(o);var n=b(q,r[2]);w.messageImprint=this.getMessageImprint(n);var t=g(q,r[3]);w.serial={hex:t};var x=g(q,r[4]);w.genTime={str:hextoutf8(x)};var p=0;if(r.length>5&&q.substr(r[5],2)=="30"){var u=b(q,r[5]);w.accuracy=this.getAccuracy(u);p++}if(r.length>5+p&&q.substr(r[5+p],2)=="01"){var y=g(q,r[5+p]);if(y=="ff"){w.ordering=true}p++}if(r.length>5+p&&q.substr(r[5+p],2)=="02"){var m=g(q,r[5+p]);w.nonce={hex:m};p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a0"){var l=b(q,r[5+p]);l="30"+l.substr(2);pGeneralNames=f.getGeneralNames(l);var s=pGeneralNames[0].dn;w.tsa=s;p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a1"){var k=b(q,r[5+p]);k="30"+k.substr(2);var v=f.getExtParamArray(k);w.ext=v;p++}return w};this.getAccuracy=function(p){var q={};var n=h(p,0);for(var o=0;o15){throw"ASN.1 length too long to represent by 8x: n = "+j.toString(16)}var g=128+h;return g.toString(16)+i}};this.getEncodedHex=function(){if(this.hTLV==null||this.isModified){this.hV=this.getFreshValueHex();this.hL=this.getLengthHexFromValue();this.hTLV=this.hT+this.hL+this.hV;this.isModified=false}return this.hTLV};this.getValueHex=function(){this.getEncodedHex();return this.hV};this.getFreshValueHex=function(){return""};this.setByParam=function(g){this.params=g};if(e!=undefined){if(e.tlv!=undefined){this.hTLV=e.tlv;this.isModified=false}}};KJUR.asn1.DERAbstractString=function(c){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var b=null;var a=null;this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=utf8tohex(this.s).toLowerCase()};this.setStringHex=function(d){this.hTLV=null;this.isModified=true;this.s=null;this.hV=d};this.getFreshValueHex=function(){return this.hV};if(typeof c!="undefined"){if(typeof c=="string"){this.setString(c)}else{if(typeof c.str!="undefined"){this.setString(c.str)}else{if(typeof c.hex!="undefined"){this.setStringHex(c.hex)}}}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractString,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractTime=function(c){KJUR.asn1.DERAbstractTime.superclass.constructor.call(this);var b=null;var a=null;this.localDateToUTC=function(g){var e=g.getTime()+(g.getTimezoneOffset()*60000);var f=new Date(e);return f};this.formatDate=function(m,o,e){var g=this.zeroPadding;var n=this.localDateToUTC(m);var p=String(n.getFullYear());if(o=="utc"){p=p.substr(2,2)}var l=g(String(n.getMonth()+1),2);var q=g(String(n.getDate()),2);var h=g(String(n.getHours()),2);var i=g(String(n.getMinutes()),2);var j=g(String(n.getSeconds()),2);var r=p+l+q+h+i+j;if(e===true){var f=n.getMilliseconds();if(f!=0){var k=g(String(f),3);k=k.replace(/[0]+$/,"");r=r+"."+k}}return r+"Z"};this.zeroPadding=function(e,d){if(e.length>=d){return e}return new Array(d-e.length+1).join("0")+e};this.getString=function(){return this.s};this.setString=function(d){this.hTLV=null;this.isModified=true;this.s=d;this.hV=stohex(d)};this.setByDateValue=function(h,j,e,d,f,g){var i=new Date(Date.UTC(h,j-1,e,d,f,g,0));this.setByDate(i)};this.getFreshValueHex=function(){return this.hV}};YAHOO.lang.extend(KJUR.asn1.DERAbstractTime,KJUR.asn1.ASN1Object);KJUR.asn1.DERAbstractStructured=function(b){KJUR.asn1.DERAbstractString.superclass.constructor.call(this);var a=null;this.setByASN1ObjectArray=function(c){this.hTLV=null;this.isModified=true;this.asn1Array=c};this.appendASN1Object=function(c){this.hTLV=null;this.isModified=true;this.asn1Array.push(c)};this.asn1Array=new Array();if(typeof b!="undefined"){if(typeof b.array!="undefined"){this.asn1Array=b.array}}};YAHOO.lang.extend(KJUR.asn1.DERAbstractStructured,KJUR.asn1.ASN1Object);KJUR.asn1.DERBoolean=function(a){KJUR.asn1.DERBoolean.superclass.constructor.call(this);this.hT="01";if(a==false){this.hTLV="010100"}else{this.hTLV="0101ff"}};YAHOO.lang.extend(KJUR.asn1.DERBoolean,KJUR.asn1.ASN1Object);KJUR.asn1.DERInteger=function(a){KJUR.asn1.DERInteger.superclass.constructor.call(this);this.hT="02";this.setByBigInteger=function(b){this.hTLV=null;this.isModified=true;this.hV=KJUR.asn1.ASN1Util.bigIntToMinTwosComplementsHex(b)};this.setByInteger=function(c){var b=new BigInteger(String(c),10);this.setByBigInteger(b)};this.setValueHex=function(b){this.hV=b};this.getFreshValueHex=function(){return this.hV};if(typeof a!="undefined"){if(typeof a.bigint!="undefined"){this.setByBigInteger(a.bigint)}else{if(typeof a["int"]!="undefined"){this.setByInteger(a["int"])}else{if(typeof a=="number"){this.setByInteger(a)}else{if(typeof a.hex!="undefined"){this.setValueHex(a.hex)}}}}}};YAHOO.lang.extend(KJUR.asn1.DERInteger,KJUR.asn1.ASN1Object);KJUR.asn1.DERBitString=function(b){if(b!==undefined&&typeof b.obj!=="undefined"){var a=KJUR.asn1.ASN1Util.newObject(b.obj);b.hex="00"+a.getEncodedHex()}KJUR.asn1.DERBitString.superclass.constructor.call(this);this.hT="03";this.setHexValueIncludingUnusedBits=function(c){this.hTLV=null;this.isModified=true;this.hV=c};this.setUnusedBitsAndHexValue=function(c,e){if(c<0||7=f){break}}return j};ASN1HEX.getNthChildIdx=function(d,b,e){var c=ASN1HEX.getChildIdx(d,b);return c[e]};ASN1HEX.getIdxbyList=function(e,d,c,i){var g=ASN1HEX;var f,b;if(c.length==0){if(i!==undefined){if(e.substr(d,2)!==i){return -1}}return d}f=c.shift();b=g.getChildIdx(e,d);if(f>=b.length){return -1}return g.getIdxbyList(e,b[f],c,i)};ASN1HEX.getIdxbyListEx=function(f,k,b,g){var m=ASN1HEX;var d,l;if(b.length==0){if(g!==undefined){if(f.substr(k,2)!==g){return -1}}return k}d=b.shift();l=m.getChildIdx(f,k);var j=0;for(var e=0;e=d.length){return null}return e.getTLV(d,a)};ASN1HEX.getTLVbyListEx=function(d,c,b,f){var e=ASN1HEX;var a=e.getIdxbyListEx(d,c,b,f);if(a==-1){return null}return e.getTLV(d,a)};ASN1HEX.getVbyList=function(e,c,b,g,i){var f=ASN1HEX;var a,d;a=f.getIdxbyList(e,c,b,g);if(a==-1){return null}if(a>=e.length){return null}d=f.getV(e,a);if(i===true){d=d.substr(2)}return d};ASN1HEX.getVbyListEx=function(b,e,a,d,f){var j=ASN1HEX;var g,c,i;g=j.getIdxbyListEx(b,e,a,d);if(g==-1){return null}i=j.getV(b,g);if(b.substr(g,2)=="03"&&f!==false){i=i.substr(2)}return i};ASN1HEX.getInt=function(d,b,e){if(e==undefined){e=-1}try{if(d.substr(b,2)!="02"){return e}var a=ASN1HEX.getV(d,b);return parseInt(a,16)}catch(c){return e}};ASN1HEX.getOID=function(c,a,d){if(d==undefined){d=null}try{if(c.substr(a,2)!="06"){return d}var e=ASN1HEX.getV(c,a);return hextooid(e)}catch(b){return d}};ASN1HEX.getOIDName=function(d,a,f){if(f==undefined){f=null}try{var e=ASN1HEX.getOID(d,a,f);if(e==f){return f}var b=KJUR.asn1.x509.OID.oid2name(e);if(b==""){return e}return b}catch(c){return f}};ASN1HEX.hextooidstr=function(e){var h=function(b,a){if(b.length>=a){return b}return new Array(a-b.length+1).join("0")+b};var l=[];var o=e.substr(0,2);var f=parseInt(o,16);l[0]=new String(Math.floor(f/40));l[1]=new String(f%40);var m=e.substr(2);var k=[];for(var g=0;g0){n=n+"."+j.join(".")}return n};ASN1HEX.dump=function(t,c,l,g){var p=ASN1HEX;var j=p.getV;var y=p.dump;var w=p.getChildIdx;var e=t;if(t instanceof KJUR.asn1.ASN1Object){e=t.getEncodedHex()}var q=function(A,i){if(A.length<=i*2){return A}else{var v=A.substr(0,i)+"..(total "+A.length/2+"bytes).."+A.substr(A.length-i,i);return v}};if(c===undefined){c={ommit_long_octet:32}}if(l===undefined){l=0}if(g===undefined){g=""}var x=c.ommit_long_octet;var z=e.substr(l,2);if(z=="01"){var h=j(e,l);if(h=="00"){return g+"BOOLEAN FALSE\n"}else{return g+"BOOLEAN TRUE\n"}}if(z=="02"){var h=j(e,l);return g+"INTEGER "+q(h,x)+"\n"}if(z=="03"){var h=j(e,l);if(p.isASN1HEX(h.substr(2))){var k=g+"BITSTRING, encapsulates\n";k=k+y(h.substr(2),c,0,g+" ");return k}else{return g+"BITSTRING "+q(h,x)+"\n"}}if(z=="04"){var h=j(e,l);if(p.isASN1HEX(h)){var k=g+"OCTETSTRING, encapsulates\n";k=k+y(h,c,0,g+" ");return k}else{return g+"OCTETSTRING "+q(h,x)+"\n"}}if(z=="05"){return g+"NULL\n"}if(z=="06"){var m=j(e,l);var b=KJUR.asn1.ASN1Util.oidHexToInt(m);var o=KJUR.asn1.x509.OID.oid2name(b);var a=b.replace(/\./g," ");if(o!=""){return g+"ObjectIdentifier "+o+" ("+a+")\n"}else{return g+"ObjectIdentifier ("+a+")\n"}}if(z=="0a"){return g+"ENUMERATED "+parseInt(j(e,l))+"\n"}if(z=="0c"){return g+"UTF8String '"+hextoutf8(j(e,l))+"'\n"}if(z=="13"){return g+"PrintableString '"+hextoutf8(j(e,l))+"'\n"}if(z=="14"){return g+"TeletexString '"+hextoutf8(j(e,l))+"'\n"}if(z=="16"){return g+"IA5String '"+hextoutf8(j(e,l))+"'\n"}if(z=="17"){return g+"UTCTime "+hextoutf8(j(e,l))+"\n"}if(z=="18"){return g+"GeneralizedTime "+hextoutf8(j(e,l))+"\n"}if(z=="1a"){return g+"VisualString '"+hextoutf8(j(e,l))+"'\n"}if(z=="1e"){return g+"BMPString '"+hextoutf8(j(e,l))+"'\n"}if(z=="30"){if(e.substr(l,4)=="3000"){return g+"SEQUENCE {}\n"}var k=g+"SEQUENCE\n";var d=w(e,l);var f=c;if((d.length==2||d.length==3)&&e.substr(d[0],2)=="06"&&e.substr(d[d.length-1],2)=="04"){var o=p.oidname(j(e,d[0]));var r=JSON.parse(JSON.stringify(c));r.x509ExtName=o;f=r}for(var u=0;u31){return false}if(((f&192)==128)&&((f&31)==e)){return true}return false}catch(d){return false}};ASN1HEX.isASN1HEX=function(e){var d=ASN1HEX;if(e.length%2==1){return false}var c=d.getVblen(e,0);var b=e.substr(0,2);var f=d.getL(e,0);var a=e.length-b.length-f.length;if(a==c*2){return true}return false};ASN1HEX.checkStrictDER=function(g,o,d,c,r){var s=ASN1HEX;if(d===undefined){if(typeof g!="string"){throw new Error("not hex string")}g=g.toLowerCase();if(!KJUR.lang.String.isHex(g)){throw new Error("not hex string")}d=g.length;c=g.length/2;if(c<128){r=1}else{r=Math.ceil(c.toString(16))+1}}var k=s.getL(g,o);if(k.length>r*2){throw new Error("L of TLV too long: idx="+o)}var n=s.getVblen(g,o);if(n>c){throw new Error("value of L too long than hex: idx="+o)}var q=s.getTLV(g,o);var f=q.length-2-s.getL(g,o).length;if(f!==(n*2)){throw new Error("V string length and L's value not the same:"+f+"/"+(n*2))}if(o===0){if(g.length!=q.length){throw new Error("total length and TLV length unmatch:"+g.length+"!="+q.length)}}var b=g.substr(o,2);if(b==="02"){var a=s.getVidx(g,o);if(g.substr(a,2)=="00"&&g.charCodeAt(a+2)<56){throw new Error("not least zeros for DER INTEGER")}}if(parseInt(b,16)&32){var p=s.getVblen(g,o);var m=0;var l=s.getChildIdx(g,o);for(var e=0;e0){n.push(new c({tag:"a3",obj:new j(q.ext)}))}var o=new KJUR.asn1.DERSequence({array:n});return o.getEncodedHex()};if(f!==undefined){this.setByParam(f)}};YAHOO.lang.extend(KJUR.asn1.x509.TBSCertificate,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Extensions=function(d){KJUR.asn1.x509.Extensions.superclass.constructor.call(this);var c=KJUR,b=c.asn1,a=b.DERSequence,e=b.x509;this.aParam=[];this.setByParam=function(f){this.aParam=f};this.getEncodedHex=function(){var f=[];for(var h=0;h-1){i.push(new f({"int":this.pathLen}))}var h=new b({array:i});this.asn1ExtnValue=h;return this.asn1ExtnValue.getEncodedHex()};this.oid="2.5.29.19";this.cA=false;this.pathLen=-1;if(g!==undefined){if(g.cA!==undefined){this.cA=g.cA}if(g.pathLen!==undefined){this.pathLen=g.pathLen}}};YAHOO.lang.extend(KJUR.asn1.x509.BasicConstraints,KJUR.asn1.x509.Extension);KJUR.asn1.x509.CRLDistributionPoints=function(d){KJUR.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,d);var b=KJUR,a=b.asn1,c=a.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.getEncodedHex()};this.setByDPArray=function(e){var f=[];for(var g=0;g0){f.push(new b({array:j}))}}var g=new b({array:f});return g.getEncodedHex()};if(d!==undefined){this.params=d}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyInformation,KJUR.asn1.ASN1Object);KJUR.asn1.x509.PolicyQualifierInfo=function(e){KJUR.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var c=KJUR.asn1,b=c.DERSequence,d=c.DERIA5String,f=c.DERObjectIdentifier,a=c.x509.UserNotice;this.params=null;this.getEncodedHex=function(){if(this.params.cps!==undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.1"}),new d({str:this.params.cps})]});return g.getEncodedHex()}if(this.params.unotice!=undefined){var g=new b({array:[new f({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return g.getEncodedHex()}};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.PolicyQualifierInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.UserNotice=function(e){KJUR.asn1.x509.UserNotice.superclass.constructor.call(this,e);var a=KJUR.asn1.DERSequence,d=KJUR.asn1.DERInteger,c=KJUR.asn1.x509.DisplayText,b=KJUR.asn1.x509.NoticeReference;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.noticeref!==undefined){f.push(new b(this.params.noticeref))}if(this.params.exptext!==undefined){f.push(new c(this.params.exptext))}var g=new a({array:f});return g.getEncodedHex()};if(e!==undefined){this.params=e}};YAHOO.lang.extend(KJUR.asn1.x509.UserNotice,KJUR.asn1.ASN1Object);KJUR.asn1.x509.NoticeReference=function(d){KJUR.asn1.x509.NoticeReference.superclass.constructor.call(this,d);var a=KJUR.asn1.DERSequence,c=KJUR.asn1.DERInteger,b=KJUR.asn1.x509.DisplayText;this.params=null;this.getEncodedHex=function(){var f=[];if(this.params.org!==undefined){f.push(new b(this.params.org))}if(this.params.noticenum!==undefined){var h=[];var e=this.params.noticenum;for(var j=0;j0){for(var g=0;g0;f++){var h=c.shift();if(e===true){var d=b.pop();var j=(d+","+h).replace(/\\,/g,",");b.push(j);e=false}else{b.push(h)}if(h.substr(-1,1)==="\\"){e=true}}b=b.map(function(a){return a.replace("/","\\/")});b.reverse();return"/"+b.join("/")};KJUR.asn1.x509.X500Name.ldapToOneline=function(a){return KJUR.asn1.x509.X500Name.ldapToCompat(a)};KJUR.asn1.x509.RDN=function(b){KJUR.asn1.x509.RDN.superclass.constructor.call(this);this.asn1Array=[];this.paramArray=[];this.sRule="utf8";var a=KJUR.asn1.x509.AttributeTypeAndValue;this.setByParam=function(c){if(c.rule!==undefined){this.sRule=c.rule}if(c.str!==undefined){this.addByMultiValuedString(c.str)}if(c.array!==undefined){this.paramArray=c.array}};this.addByString=function(c){this.asn1Array.push(new KJUR.asn1.x509.AttributeTypeAndValue({str:c,rule:this.sRule}))};this.addByMultiValuedString=function(e){var c=KJUR.asn1.x509.RDN.parseString(e);for(var d=0;d0){for(var d=0;d0;g++){var k=j.shift();if(h===true){var f=c.pop();var d=(f+"+"+k).replace(/\\\+/g,"+");c.push(d);h=false}else{c.push(k)}if(k.substr(-1,1)==="\\"){h=true}}var l=false;var b=[];for(var g=0;c.length>0;g++){var k=c.shift();if(l===true){var e=b.pop();if(k.match(/"$/)){var d=(e+"+"+k).replace(/^([^=]+)="(.*)"$/,"$1=$2");b.push(d);l=false}else{b.push(e+"+"+k)}}else{b.push(k)}if(k.match(/^[^=]+="/)){l=true}}return b};KJUR.asn1.x509.AttributeTypeAndValue=function(c){KJUR.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this);this.sRule="utf8";this.sType=null;this.sValue=null;this.dsType=null;var a=KJUR,g=a.asn1,d=g.DERSequence,l=g.DERUTF8String,i=g.DERPrintableString,h=g.DERTeletexString,b=g.DERIA5String,e=g.DERVisibleString,k=g.DERBMPString,f=a.lang.String.isMail,j=a.lang.String.isPrintable;this.setByParam=function(o){if(o.rule!==undefined){this.sRule=o.rule}if(o.ds!==undefined){this.dsType=o.ds}if(o.value===undefined&&o.str!==undefined){var n=o.str;var m=n.match(/^([^=]+)=(.+)$/);if(m){this.sType=m[1];this.sValue=m[2]}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}}else{this.sType=o.type;this.sValue=o.value}};this.setByString=function(n,o){if(o!==undefined){this.sRule=o}var m=n.match(/^([^=]+)=(.+)$/);if(m){this.setByAttrTypeAndValueStr(m[1],m[2])}else{throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}};this._getDsType=function(){var o=this.sType;var n=this.sValue;var m=this.sRule;if(m==="prn"){if(o=="CN"&&f(n)){return"ia5"}if(j(n)){return"prn"}return"utf8"}else{if(m==="utf8"){if(o=="CN"&&f(n)){return"ia5"}if(o=="C"){return"prn"}return"utf8"}}return"utf8"};this.setByAttrTypeAndValueStr=function(o,n,m){if(m!==undefined){this.sRule=m}this.sType=o;this.sValue=n};this.getValueObj=function(n,m){if(n=="utf8"){return new l({str:m})}if(n=="prn"){return new i({str:m})}if(n=="tel"){return new h({str:m})}if(n=="ia5"){return new b({str:m})}if(n=="vis"){return new e({str:m})}if(n=="bmp"){return new k({str:m})}throw new Error("unsupported directory string type: type="+n+" value="+m)};this.getEncodedHex=function(){if(this.dsType==null){this.dsType=this._getDsType()}var n=KJUR.asn1.x509.OID.atype2obj(this.sType);var m=this.getValueObj(this.dsType,this.sValue);var p=new d({array:[n,m]});this.TLV=p.getEncodedHex();return this.TLV};if(c!==undefined){this.setByParam(c)}};YAHOO.lang.extend(KJUR.asn1.x509.AttributeTypeAndValue,KJUR.asn1.ASN1Object);KJUR.asn1.x509.SubjectPublicKeyInfo=function(f){KJUR.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var l=null,k=null,a=KJUR,j=a.asn1,i=j.DERInteger,b=j.DERBitString,m=j.DERObjectIdentifier,e=j.DERSequence,h=j.ASN1Util.newObject,d=j.x509,o=d.AlgorithmIdentifier,g=a.crypto,n=g.ECDSA,c=g.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null){throw"algId and/or subjPubKey not set"}var p=new e({array:[this.asn1AlgId,this.asn1SubjPKey]});return p};this.getEncodedHex=function(){var p=this.getASN1Object();this.hTLV=p.getEncodedHex();return this.hTLV};this.setPubKey=function(q){try{if(q instanceof RSAKey){var u=h({seq:[{"int":{bigint:q.n}},{"int":{"int":q.e}}]});var s=u.getEncodedHex();this.asn1AlgId=new o({name:"rsaEncryption"});this.asn1SubjPKey=new b({hex:"00"+s})}}catch(p){}try{if(q instanceof KJUR.crypto.ECDSA){var r=new m({name:q.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:r});this.asn1SubjPKey=new b({hex:"00"+q.pubKeyHex})}}catch(p){}try{if(q instanceof KJUR.crypto.DSA){var r=new h({seq:[{"int":{bigint:q.p}},{"int":{bigint:q.q}},{"int":{bigint:q.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:r});var t=new i({bigint:q.y});this.asn1SubjPKey=new b({hex:"00"+t.getEncodedHex()})}}catch(p){}};if(f!==undefined){this.setPubKey(f)}};YAHOO.lang.extend(KJUR.asn1.x509.SubjectPublicKeyInfo,KJUR.asn1.ASN1Object);KJUR.asn1.x509.Time=function(f){KJUR.asn1.x509.Time.superclass.constructor.call(this);var e=null,a=null,d=KJUR,c=d.asn1,b=c.DERUTCTime,g=c.DERGeneralizedTime;this.setTimeParams=function(h){this.timeParams=h};this.getEncodedHex=function(){var h=null;if(this.timeParams!=null){if(this.type=="utc"){h=new b(this.timeParams)}else{h=new g(this.timeParams)}}else{if(this.type=="utc"){h=new b()}else{h=new g()}}this.TLV=h.getEncodedHex();return this.TLV};this.type="utc";if(f!==undefined){if(f.type!==undefined){this.type=f.type}else{if(f.str!==undefined){if(f.str.match(/^[0-9]{12}Z$/)){this.type="utc"}if(f.str.match(/^[0-9]{14}Z$/)){this.type="gen"}}}this.timeParams=f}};YAHOO.lang.extend(KJUR.asn1.x509.Time,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier=function(e){KJUR.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this);this.nameAlg=null;this.asn1Alg=null;this.asn1Params=null;this.paramEmpty=false;var b=KJUR,a=b.asn1,c=a.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;this.getEncodedHex=function(){if(this.nameAlg===null&&this.asn1Alg===null){throw new Error("algorithm not specified")}if(this.nameAlg!==null){var f=null;for(var h in c){if(h===this.nameAlg){f=c[h]}}if(f!==null){this.hTLV=f;return this.hTLV}}if(this.nameAlg!==null&&this.asn1Alg===null){this.asn1Alg=a.x509.OID.name2obj(this.nameAlg)}var g=[this.asn1Alg];if(this.asn1Params!==null){g.push(this.asn1Params)}var i=new a.DERSequence({array:g});this.hTLV=i.getEncodedHex();return this.hTLV};if(e!==undefined){if(e.name!==undefined){this.nameAlg=e.name}if(e.asn1params!==undefined){this.asn1Params=e.asn1params}if(e.paramempty!==undefined){this.paramEmpty=e.paramempty}}if(this.asn1Params===null&&this.paramEmpty===false&&this.nameAlg!==null){if(this.nameAlg.name!==undefined){this.nameAlg=this.nameAlg.name}var d=this.nameAlg.toLowerCase();if(d.substr(-7,7)!=="withdsa"&&d.substr(-9,9)!=="withecdsa"){this.asn1Params=new a.DERNull()}}};YAHOO.lang.extend(KJUR.asn1.x509.AlgorithmIdentifier,KJUR.asn1.ASN1Object);KJUR.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};KJUR.asn1.x509.GeneralName=function(e){KJUR.asn1.x509.GeneralName.superclass.constructor.call(this);var m=null,i=null,k={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87"},b=KJUR,g=b.asn1,f=g.DERSequence,j=g.DEROctetString,d=g.DERIA5String,c=g.DERTaggedObject,l=g.ASN1Object,a=g.x509.X500Name,h=pemtohex;this.explicit=false;this.setByParam=function(p){var r=null;var u=null;if(p===undefined){return}if(p.rfc822!==undefined){this.type="rfc822";u=new d({str:p[this.type]})}if(p.dns!==undefined){this.type="dns";u=new d({str:p[this.type]})}if(p.uri!==undefined){this.type="uri";u=new d({str:p[this.type]})}if(p.dn!==undefined){this.type="dn";this.explicit=true;if(typeof p.dn==="string"){u=new a({str:p.dn})}else{if(p.dn instanceof KJUR.asn1.x509.X500Name){u=p.dn}else{u=new a(p.dn)}}}if(p.ldapdn!==undefined){this.type="dn";this.explicit=true;u=new a({ldapstr:p.ldapdn})}if(p.certissuer!==undefined){this.type="dn";this.explicit=true;var o=p.certissuer;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certissuer param not cert"}var t=new X509();t.hex=w;var y=t.getIssuerHex();u=new l();u.hTLV=y}if(p.certsubj!==undefined){this.type="dn";this.explicit=true;var o=p.certsubj;var w=null;if(o.match(/^[0-9A-Fa-f]+$/)){w==o}if(o.indexOf("-----BEGIN ")!=-1){w=h(o)}if(w==null){throw"certsubj param not cert"}var t=new X509();t.hex=w;var y=t.getSubjectHex();u=new l();u.hTLV=y}if(p.ip!==undefined){this.type="ip";this.explicit=false;var q=p.ip;var s;var n="malformed IP address";if(q.match(/^[0-9.]+[.][0-9.]+$/)){s=intarystrtohex("["+q.split(".").join(",")+"]");if(s.length!==8){throw n}}else{if(q.match(/^[0-9A-Fa-f:]+:[0-9A-Fa-f:]+$/)){s=ipv6tohex(q)}else{if(q.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/)){s=q}else{throw n}}}u=new j({hex:s})}if(this.type==null){throw"unsupported type in params="+p}this.asn1Obj=new c({explicit:this.explicit,tag:k[this.type],obj:u})};this.getEncodedHex=function(){return this.asn1Obj.getEncodedHex()};if(e!==undefined){this.setByParam(e)}};YAHOO.lang.extend(KJUR.asn1.x509.GeneralName,KJUR.asn1.ASN1Object);KJUR.asn1.x509.GeneralNames=function(d){KJUR.asn1.x509.GeneralNames.superclass.constructor.call(this);var a=null,c=KJUR,b=c.asn1;this.setByParamArray=function(g){for(var e=0;e0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o0){var m=b(n.valhex,q[0]);var p=j(m,0);var t=[];for(var o=0;o1){var r=b(n.valhex,q[1]);n.polhex=r}delete n.valhex};this.setSigningCertificateV2=function(o){var s=j(o.valhex,0);if(s.length>0){var n=b(o.valhex,s[0]);var r=j(n,0);var u=[];for(var q=0;q1){var t=b(o.valhex,s[1]);o.polhex=t}delete o.valhex};this.getESSCertID=function(o){var p={};var n=j(o,0);if(n.length>0){var q=i(o,n[0]);p.hash=q}if(n.length>1){var m=b(o,n[1]);var r=this.getIssuerSerial(m);if(r.serial!=undefined){p.serial=r.serial}if(r.issuer!=undefined){p.issuer=r.issuer}}return p};this.getESSCertIDv2=function(q){var s={};var p=j(q,0);if(p.length<1||3r+1){var m=b(q,p[r+1]);var t=this.getIssuerSerial(m);s.issuer=t.issuer;s.serial=t.serial}return s};this.getIssuerSerial=function(q){var r={};var n=j(q,0);var m=b(q,n[0]);var p=h.getGeneralNames(m);var o=p[0].dn;r.issuer=o;var s=i(q,n[1]);r.serial={hex:s};return r};this.getCertificateSet=function(p){var n=j(p,0);var m=[];for(var o=0;o1){var n=this.getPKIStatusInfo(b(m,k[0]));var l=b(m,k[1]);var o=this.getToken(l);o.statusinfo=n;return o}}};this.getToken=function(l){var k=new KJUR.asn1.cms.CMSParser;var m=k.getCMSSignedData(l);this.setTSTInfo(m);return m};this.setTSTInfo=function(k){var n=k.econtent;if(n.type=="tstinfo"){var m=n.content.hex;var l=this.getTSTInfo(m);n.content=l}};this.getTSTInfo=function(q){var w={};var r=h(q,0);var o=g(q,r[1]);w.policy=hextooid(o);var n=b(q,r[2]);w.messageImprint=this.getMessageImprint(n);var t=g(q,r[3]);w.serial={hex:t};var x=g(q,r[4]);w.genTime={str:hextoutf8(x)};var p=0;if(r.length>5&&q.substr(r[5],2)=="30"){var u=b(q,r[5]);w.accuracy=this.getAccuracy(u);p++}if(r.length>5+p&&q.substr(r[5+p],2)=="01"){var y=g(q,r[5+p]);if(y=="ff"){w.ordering=true}p++}if(r.length>5+p&&q.substr(r[5+p],2)=="02"){var m=g(q,r[5+p]);w.nonce={hex:m};p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a0"){var l=b(q,r[5+p]);l="30"+l.substr(2);pGeneralNames=f.getGeneralNames(l);var s=pGeneralNames[0].dn;w.tsa=s;p++}if(r.length>5+p&&q.substr(r[5+p],2)=="a1"){var k=b(q,r[5+p]);k="30"+k.substr(2);var v=f.getExtParamArray(k);w.ext=v;p++}return w};this.getAccuracy=function(p){var q={};var n=h(p,0);for(var o=0;oMIT License */ @@ -2712,10 +2712,11 @@ KJUR.asn1.cms.CMSParser = function() { * Following attribute type are supported in the * latest version: *
    - *
  • contentType
  • - *
  • messageDigest
  • - *
  • signingTime
  • - *
  • signingCertificate
  • + *
  • contentType - {@link KJUR.asn1.cms.CMSParser.setContentType}
  • + *
  • messageDigest - {@link KJUR.asn1.cms.CMSParser.setMessageDigest}
  • + *
  • signingTime - {@link KJUR.asn1.cms.CMSParser.setSigningTime}
  • + *
  • signingCertificate - {@link KJUR.asn1.cms.CMSParser.setSigningCertificate}
  • + *
  • signingCertificateV2 - {@link KJUR.asn1.cms.CMSParser.setSigningCertificateV2}
  • *
* * @example @@ -2751,6 +2752,9 @@ KJUR.asn1.cms.CMSParser = function() { this.setSigningTime(pResult); } else if (attrType == "signingCertificate") { this.setSigningCertificate(pResult); + } else if (attrType == "signingCertificateV2") { + //alert(pResult.valhex); + this.setSigningCertificateV2(pResult); } return pResult; @@ -2908,6 +2912,64 @@ KJUR.asn1.cms.CMSParser = function() { delete pAttr.valhex; }; + /** + * set SigningCertificateV2 attribute
+ * @name setSigningCertificateV2 + * @memberOf KJUR.asn1.cms.CMSParser# + * @function + * @param {Array} pAttr JSON object of attribute parameter + * @since jsrsasign 10.1.2 asn1cms 2.0.3 + * @see KJUR.asn1.cms.CMSParser#getAttribute + * @see KJUR.asn1.cms.CMSParser#getESSCertIDv2 + * @see KJUR.asn1.cms.SigningCertificateV2 + * @see KJUR.asn1.cms.ESSCertIDv2 + * + * @description + * This sets an attribute as SigningCertificateV2 defined in + * + * RFC 5035 section 3. + * + * @example + * parser = new KJUR.asn1.cms.CMSParser(); + * pAttr = { + * attr: "signingCertificateV2" + * valhex: '...' + * }; + * parser.setSigningCertificateV2(pAttr); + * pAttr → { + * attr: "signingCertificateV2", + * array: [{ + * hash: "123456...", + * alg: "sha256", + * issuer: { + * array: [[{type:"C",value:"JP",ds:"prn"},...]], + * str: "/C=JP/O=T1" + * }, + * serial: {hex: "123456..."} + * }] + * } + */ + this.setSigningCertificateV2 = function(pAttr) { + var aIdx = _getChildIdx(pAttr.valhex, 0); + if (aIdx.length > 0) { + var hCerts = _getTLV(pAttr.valhex, aIdx[0]); + var aCertIdx = _getChildIdx(hCerts, 0); + var a = []; + for (var i = 0; i < aCertIdx.length; i++) { + var hESSCertIDv2 = _getTLV(hCerts, aCertIdx[i]); + var pESSCertIDv2 = this.getESSCertIDv2(hESSCertIDv2); + a.push(pESSCertIDv2); + } + pAttr.array = a; + } + + if (aIdx.length > 1) { + var hPolicies = _getTLV(pAttr.valhex, aIdx[1]); + pAttr.polhex = hPolicies; + } + delete pAttr.valhex; + }; + /** * parse ASN.1 ESSCertID
* @name getESSCertID @@ -2964,6 +3026,74 @@ KJUR.asn1.cms.CMSParser = function() { return pResult; }; + /** + * parse ASN.1 ESSCertIDv2
+ * @name getESSCertIDv2 + * @memberOf KJUR.asn1.cms.CMSParser# + * @function + * @param {String} h hexadecimal string of ASN.1 ESSCertIDv2 + * @return {Array} array of JSON object of ESSCertIDv2 parameter + * @since jsrsasign 10.1.2 asn1cms 2.0.3 + * @see KJUR.asn1.cms.ESSCertIDv2 + * @see KJUR.asn1.cms.CMSParser.getESSCertID + * + * @description + * This method parses ASN.1 ESSCertIDv2 defined in + * + * RFC 5035 section 4. + *
+     * ESSCertIDv2 ::=  SEQUENCE {
+     *    hashAlgorithm           AlgorithmIdentifier
+     *                            DEFAULT {algorithm id-sha256},
+     *    certHash                Hash,
+     *    issuerSerial            IssuerSerial OPTIONAL }
+     * Hash ::= OCTET STRING
+     * IssuerSerial ::= SEQUENCE {
+     *    issuer                  GeneralNames,
+     *    serialNumber            CertificateSerialNumber }
+     * 
+ * + * @example + * parser = new KJUR.asn1.cms.CMSParser(); + * parser.getESSCertID("30...") → + * { + * hash: "3f2d...", + * alg: "sha512", + * issuer: {str: "/C=JP/O=T1"}, + * serial: {hex: "12ab..."} + * } + */ + this.getESSCertIDv2 = function(h) { + var aResult = {}; + var aIdx = _getChildIdx(h, 0); + + if (aIdx.length < 1 || 3 < aIdx.length) + throw new _Error("wrong number of elements"); + + var offset = 0; + if (h.substr(aIdx[0], 2) == "30") { + var hHashAlg = _getTLV(h, aIdx[0]); + aResult.alg = + _x509obj.getAlgorithmIdentifierName(hHashAlg); + offset++; + } else { + aResult.alg = "sha256"; + } + + var hHash = _getV(h, aIdx[offset]); + aResult.hash = hHash; + + if (aIdx.length > offset + 1) { + var hIssuerSerial = _getTLV(h, aIdx[offset + 1]); + var pIssuerSerial = + this.getIssuerSerial(hIssuerSerial); + aResult.issuer = pIssuerSerial.issuer; + aResult.serial = pIssuerSerial.serial; + } + + return aResult; + }; + /** * parse ASN.1 IssuerSerial
* @name getIssuerSerial @@ -3053,6 +3183,6 @@ KJUR.asn1.cms.CMSParser = function() { a.push(pem); } } - return a; + return {array: a, sortflag: false}; }; }; diff --git a/test/qunit-do-asn1cms.html b/test/qunit-do-asn1cms.html index d25ed54a..9900d10c 100755 --- a/test/qunit-do-asn1cms.html +++ b/test/qunit-do-asn1cms.html @@ -1096,8 +1096,83 @@ deepEqual(parser.getAttribute(hIn), pExpect, "attr"); var hIn = "a08207c3308207bf308205a7a0030201020210406a1417b3309f78ff5de3bc931fc064300d06092a864886f70d01010b05003081b7310b3009060355040613024348311e301c0603550461131556415443482d4348452d3232312e3033322e353733313e303c060355040a133542756e646573616d74206675657220496e666f726d6174696b20756e642054656c656b6f6d6d756e696b6174696f6e202842495429311d301b060355040b1314537769737320476f7665726e6d656e7420504b493129302706035504031320537769737320476f7665726e6d656e7420526567756c61746564204341203032301e170d3139303530373038313730385a170d3232303530373038313730385a3081d8310b3009060355040613024348310d300b06035504070c044265726e311e301c0603550461131556415443482d4348452d3232312e3033322e353733313e303c060355040a0c3542756e646573616d74206675657220496e666f726d6174696b20756e642054656c656b6f6d6d756e696b6174696f6e202842495429311d301b060355040b0c14537769737320476f7665726e6d656e7420504b49311c301a060355040b0c1354696d65205374616d70205365727669636573311d301b06035504030c14537769737320476f7665726e6d656e742054534130820122300d06092a864886f70d01010105000382010f003082010a0282010100c03ebdc580e752ac7c7d295fcd5aa76878ff8581c24cd93966d1735277f45d26da968f85893008cbf23af61e590b7dee26838329f98ba056af360defd6269ef67a5abcb93b888140d712245b3aebcb90989d0d319a12df8990e25b5302b4ab1123fac5217901082a2ee6387be5d1f2f1855bcbe086c2b02afb20ef255d505baebe151a2148075692cc53cd6c1d529a6d35862b5e7caca45e9f4e7d40e212d38ed343b3fded2dfc0ac74884995ef209c014c338464c94d68b2504ca8f47ea7922512b5e4ab2e4ea15b5861e2ce7c89ac7440b7e3271b1a8ee4d3c5ade47e803681676d8e5b23c55f0e88c84b867774d58761f41f67ea0a0a236f140b994a107e30203010001a38202a23082029e30819306082b06010505070103048186308183300a06082b06010505070b023009060704008bec4901023008060604008e460104304b060604008e4601053041303f1639687474703a2f2f7777772e706b692e61646d696e2e63682f6370732f5044532d5347504b495f526567756c617465645f43415f30322e7064661302454e3013060604008e4601063009060704008e46010602300e0603551d0f0101ff04040302078030160603551d250101ff040c300a06082b060105050703083081d60603551d200481ce3081cb3081c806096085740111030502043081ba304306082b060105050702011637687474703a2f2f7777772e706b692e61646d696e2e63682f6370732f4350535f325f31365f3735365f315f31375f335f355f302e706466307306082b0601050507020230670c6554686973206973206120726567756c61746564206365727469666963617465206f662074686520537769737320476f7665726e6d656e7420526567756c617465642043412030322043505320666f722074696d657374616d70696e6720707572706f736573307706082b06010505070101046b3069303906082b06010505073002862d687474703a2f2f7777772e706b692e61646d696e2e63682f6169612f526567756c61746564434130322e637274302c06082b060105050730018620687474703a2f2f7777772e706b692e61646d696e2e63682f6169612f6f637370303e0603551d1f043730353033a031a02f862d687474703a2f2f7777772e706b692e61646d696e2e63682f63726c2f526567756c61746564434130322e63726c301f0603551d23041830168014340bbef2153ea40f5707e241648b3211d1290b61301d0603551d0e04160414e493988ac4bd3720d3b06950adedb7433fac9abe300c0603551d130101ff04023000300d06092a864886f70d01010b0500038202010098a5eb8bb576916f18550d84250c0cbf63976d7b90256ca0e06fcf41908d1320bcd6cdf806ffb6a34653b7a07b988b3a29fc0683a58dcec61dc2cd3ded8ce346f2017ac7d3563ceaaa3b2b5d62c2a6df58b1c58545216e74404ee3f5306f684b06b0a94776afef082fde274775c5e32560b73ce3613b80101d6cbec22f6537c98f443bb03cef12a321ffe44b5453c26d95267dc34f466488cf5f6a6d4fa7ee9cacd3e2d02551fc52cfe6672a281b930106c7a76a12e3be1a8636b024d0b1493bff33ab5a31d316cce684732f6d0438dc5cad2a71b3ead582b2f6085c11e7a70d1b2a0b33a9a37c98af41e47efa8375cb4c74012344e71f743cf4c2a99b3dde0485816553916b731ca9ddafdc0c3eddda821639a157f1c41f0cfb71db0ddd96d949a9b3bfb59886126d816a9096b2a2c2e495c0a8503131d49b2711b5d55e43f40c857ac89387f5884a8d1b1c7340ced06ea2f888653739e76b52292ad486110c2ee5c21240f8792a2b468c21d270144e4cb2b45c3cc31ccdffce5d59f30d24bc9d174d32f5c7a9d7b5df3872c988aa75aee285954a99a456973f5894c4c58dd9fd05054daaa6306f35336392207b72c414e589168a0b13cbd7e3ee26ad5e15478302e6d81df72cfcff982c765d16c91facafc5e599675cc5215c4599316df9a2d5479bd6bf40781134ed61dc59242a1aed0dd4c3068297c6e589aea449a9794c"; -var aOut = ["-----BEGIN CERTIFICATE-----\r\nMIIHvzCCBaegAwIBAgIQQGoUF7Mwn3j/XeO8kx/AZDANBgkqhkiG9w0BAQsFADCB\r\ntzELMAkGA1UEBhMCQ0gxHjAcBgNVBGETFVZBVENILUNIRS0yMjEuMDMyLjU3MzE+\r\nMDwGA1UEChM1QnVuZGVzYW10IGZ1ZXIgSW5mb3JtYXRpayB1bmQgVGVsZWtvbW11\r\nbmlrYXRpb24gKEJJVCkxHTAbBgNVBAsTFFN3aXNzIEdvdmVybm1lbnQgUEtJMSkw\r\nJwYDVQQDEyBTd2lzcyBHb3Zlcm5tZW50IFJlZ3VsYXRlZCBDQSAwMjAeFw0xOTA1\r\nMDcwODE3MDhaFw0yMjA1MDcwODE3MDhaMIHYMQswCQYDVQQGEwJDSDENMAsGA1UE\r\nBwwEQmVybjEeMBwGA1UEYRMVVkFUQ0gtQ0hFLTIyMS4wMzIuNTczMT4wPAYDVQQK\r\nDDVCdW5kZXNhbXQgZnVlciBJbmZvcm1hdGlrIHVuZCBUZWxla29tbXVuaWthdGlv\r\nbiAoQklUKTEdMBsGA1UECwwUU3dpc3MgR292ZXJubWVudCBQS0kxHDAaBgNVBAsM\r\nE1RpbWUgU3RhbXAgU2VydmljZXMxHTAbBgNVBAMMFFN3aXNzIEdvdmVybm1lbnQg\r\nVFNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwD69xYDnUqx8fSlf\r\nzVqnaHj/hYHCTNk5ZtFzUnf0XSbalo+FiTAIy/I69h5ZC33uJoODKfmLoFavNg3v\r\n1iae9npavLk7iIFA1xIkWzrry5CYnQ0xmhLfiZDiW1MCtKsRI/rFIXkBCCou5jh7\r\n5dHy8YVby+CGwrAq+yDvJV1QW66+FRohSAdWksxTzWwdUpptNYYrXnyspF6fTn1A\r\n4hLTjtNDs/3tLfwKx0iEmV7yCcAUwzhGTJTWiyUEyo9H6nkiUSteSrLk6hW1hh4s\r\n58iax0QLfjJxsajuTTxa3kfoA2gWdtjlsjxV8OiMhLhnd01Ydh9B9n6goKI28UC5\r\nlKEH4wIDAQABo4ICojCCAp4wgZMGCCsGAQUFBwEDBIGGMIGDMAoGCCsGAQUFBwsC\r\nMAkGBwQAi+xJAQIwCAYGBACORgEEMEsGBgQAjkYBBTBBMD8WOWh0dHA6Ly93d3cu\r\ncGtpLmFkbWluLmNoL2Nwcy9QRFMtU0dQS0lfUmVndWxhdGVkX0NBXzAyLnBkZhMC\r\nRU4wEwYGBACORgEGMAkGBwQAjkYBBgIwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB\r\n/wQMMAoGCCsGAQUFBwMIMIHWBgNVHSAEgc4wgcswgcgGCWCFdAERAwUCBDCBujBD\r\nBggrBgEFBQcCARY3aHR0cDovL3d3dy5wa2kuYWRtaW4uY2gvY3BzL0NQU18yXzE2\r\nXzc1Nl8xXzE3XzNfNV8wLnBkZjBzBggrBgEFBQcCAjBnDGVUaGlzIGlzIGEgcmVn\r\ndWxhdGVkIGNlcnRpZmljYXRlIG9mIHRoZSBTd2lzcyBHb3Zlcm5tZW50IFJlZ3Vs\r\nYXRlZCBDQSAwMiBDUFMgZm9yIHRpbWVzdGFtcGluZyBwdXJwb3NlczB3BggrBgEF\r\nBQcBAQRrMGkwOQYIKwYBBQUHMAKGLWh0dHA6Ly93d3cucGtpLmFkbWluLmNoL2Fp\r\nYS9SZWd1bGF0ZWRDQTAyLmNydDAsBggrBgEFBQcwAYYgaHR0cDovL3d3dy5wa2ku\r\nYWRtaW4uY2gvYWlhL29jc3AwPgYDVR0fBDcwNTAzoDGgL4YtaHR0cDovL3d3dy5w\r\na2kuYWRtaW4uY2gvY3JsL1JlZ3VsYXRlZENBMDIuY3JsMB8GA1UdIwQYMBaAFDQL\r\nvvIVPqQPVwfiQWSLMhHRKQthMB0GA1UdDgQWBBTkk5iKxL03INOwaVCt7bdDP6ya\r\nvjAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4ICAQCYpeuLtXaRbxhVDYQl\r\nDAy/Y5dte5AlbKDgb89BkI0TILzWzfgG/7ajRlO3oHuYizop/AaDpY3Oxh3CzT3t\r\njONG8gF6x9NWPOqqOytdYsKm31ixxYVFIW50QE7j9TBvaEsGsKlHdq/vCC/eJ0d1\r\nxeMlYLc842E7gBAdbL7CL2U3yY9EO7A87xKjIf/kS1RTwm2VJn3DT0ZkiM9fam1P\r\np+6crNPi0CVR/FLP5mcqKBuTAQbHp2oS474ahjawJNCxSTv/M6taMdMWzOaEcy9t\r\nBDjcXK0qcbPq1YKy9ghcEeenDRsqCzOpo3yYr0HkfvqDdctMdAEjROcfdDz0wqmb\r\nPd4EhYFlU5Frcxyp3a/cDD7d2oIWOaFX8cQfDPtx2w3dltlJqbO/tZiGEm2BapCW\r\nsqLC5JXAqFAxMdSbJxG11V5D9AyFesiTh/WISo0bHHNAztBuoviIZTc552tSKSrU\r\nhhEMLuXCEkD4eSorRowh0nAUTkyytFw8wxzN/85dWfMNJLydF00y9cep17XfOHLJ\r\niKp1ruKFlUqZpFaXP1iUxMWN2f0FBU2qpjBvNTNjkiB7csQU5YkWigsTy9fj7iat\r\nXhVHgwLm2B33LPz/mCx2XRbJH6yvxeWZZ1zFIVxFmTFt+aLVR5vWv0B4ETTtYdxZ\r\nJCoa7Q3UwwaCl8blia6kSal5TA==\r\n-----END CERTIFICATE-----\r\n"]; -deepEqual(parser.getCertificateSet(hIn), aOut, "set"); +var aExp = {array: ["-----BEGIN CERTIFICATE-----\r\nMIIHvzCCBaegAwIBAgIQQGoUF7Mwn3j/XeO8kx/AZDANBgkqhkiG9w0BAQsFADCB\r\ntzELMAkGA1UEBhMCQ0gxHjAcBgNVBGETFVZBVENILUNIRS0yMjEuMDMyLjU3MzE+\r\nMDwGA1UEChM1QnVuZGVzYW10IGZ1ZXIgSW5mb3JtYXRpayB1bmQgVGVsZWtvbW11\r\nbmlrYXRpb24gKEJJVCkxHTAbBgNVBAsTFFN3aXNzIEdvdmVybm1lbnQgUEtJMSkw\r\nJwYDVQQDEyBTd2lzcyBHb3Zlcm5tZW50IFJlZ3VsYXRlZCBDQSAwMjAeFw0xOTA1\r\nMDcwODE3MDhaFw0yMjA1MDcwODE3MDhaMIHYMQswCQYDVQQGEwJDSDENMAsGA1UE\r\nBwwEQmVybjEeMBwGA1UEYRMVVkFUQ0gtQ0hFLTIyMS4wMzIuNTczMT4wPAYDVQQK\r\nDDVCdW5kZXNhbXQgZnVlciBJbmZvcm1hdGlrIHVuZCBUZWxla29tbXVuaWthdGlv\r\nbiAoQklUKTEdMBsGA1UECwwUU3dpc3MgR292ZXJubWVudCBQS0kxHDAaBgNVBAsM\r\nE1RpbWUgU3RhbXAgU2VydmljZXMxHTAbBgNVBAMMFFN3aXNzIEdvdmVybm1lbnQg\r\nVFNBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwD69xYDnUqx8fSlf\r\nzVqnaHj/hYHCTNk5ZtFzUnf0XSbalo+FiTAIy/I69h5ZC33uJoODKfmLoFavNg3v\r\n1iae9npavLk7iIFA1xIkWzrry5CYnQ0xmhLfiZDiW1MCtKsRI/rFIXkBCCou5jh7\r\n5dHy8YVby+CGwrAq+yDvJV1QW66+FRohSAdWksxTzWwdUpptNYYrXnyspF6fTn1A\r\n4hLTjtNDs/3tLfwKx0iEmV7yCcAUwzhGTJTWiyUEyo9H6nkiUSteSrLk6hW1hh4s\r\n58iax0QLfjJxsajuTTxa3kfoA2gWdtjlsjxV8OiMhLhnd01Ydh9B9n6goKI28UC5\r\nlKEH4wIDAQABo4ICojCCAp4wgZMGCCsGAQUFBwEDBIGGMIGDMAoGCCsGAQUFBwsC\r\nMAkGBwQAi+xJAQIwCAYGBACORgEEMEsGBgQAjkYBBTBBMD8WOWh0dHA6Ly93d3cu\r\ncGtpLmFkbWluLmNoL2Nwcy9QRFMtU0dQS0lfUmVndWxhdGVkX0NBXzAyLnBkZhMC\r\nRU4wEwYGBACORgEGMAkGBwQAjkYBBgIwDgYDVR0PAQH/BAQDAgeAMBYGA1UdJQEB\r\n/wQMMAoGCCsGAQUFBwMIMIHWBgNVHSAEgc4wgcswgcgGCWCFdAERAwUCBDCBujBD\r\nBggrBgEFBQcCARY3aHR0cDovL3d3dy5wa2kuYWRtaW4uY2gvY3BzL0NQU18yXzE2\r\nXzc1Nl8xXzE3XzNfNV8wLnBkZjBzBggrBgEFBQcCAjBnDGVUaGlzIGlzIGEgcmVn\r\ndWxhdGVkIGNlcnRpZmljYXRlIG9mIHRoZSBTd2lzcyBHb3Zlcm5tZW50IFJlZ3Vs\r\nYXRlZCBDQSAwMiBDUFMgZm9yIHRpbWVzdGFtcGluZyBwdXJwb3NlczB3BggrBgEF\r\nBQcBAQRrMGkwOQYIKwYBBQUHMAKGLWh0dHA6Ly93d3cucGtpLmFkbWluLmNoL2Fp\r\nYS9SZWd1bGF0ZWRDQTAyLmNydDAsBggrBgEFBQcwAYYgaHR0cDovL3d3dy5wa2ku\r\nYWRtaW4uY2gvYWlhL29jc3AwPgYDVR0fBDcwNTAzoDGgL4YtaHR0cDovL3d3dy5w\r\na2kuYWRtaW4uY2gvY3JsL1JlZ3VsYXRlZENBMDIuY3JsMB8GA1UdIwQYMBaAFDQL\r\nvvIVPqQPVwfiQWSLMhHRKQthMB0GA1UdDgQWBBTkk5iKxL03INOwaVCt7bdDP6ya\r\nvjAMBgNVHRMBAf8EAjAAMA0GCSqGSIb3DQEBCwUAA4ICAQCYpeuLtXaRbxhVDYQl\r\nDAy/Y5dte5AlbKDgb89BkI0TILzWzfgG/7ajRlO3oHuYizop/AaDpY3Oxh3CzT3t\r\njONG8gF6x9NWPOqqOytdYsKm31ixxYVFIW50QE7j9TBvaEsGsKlHdq/vCC/eJ0d1\r\nxeMlYLc842E7gBAdbL7CL2U3yY9EO7A87xKjIf/kS1RTwm2VJn3DT0ZkiM9fam1P\r\np+6crNPi0CVR/FLP5mcqKBuTAQbHp2oS474ahjawJNCxSTv/M6taMdMWzOaEcy9t\r\nBDjcXK0qcbPq1YKy9ghcEeenDRsqCzOpo3yYr0HkfvqDdctMdAEjROcfdDz0wqmb\r\nPd4EhYFlU5Frcxyp3a/cDD7d2oIWOaFX8cQfDPtx2w3dltlJqbO/tZiGEm2BapCW\r\nsqLC5JXAqFAxMdSbJxG11V5D9AyFesiTh/WISo0bHHNAztBuoviIZTc552tSKSrU\r\nhhEMLuXCEkD4eSorRowh0nAUTkyytFw8wxzN/85dWfMNJLydF00y9cep17XfOHLJ\r\niKp1ruKFlUqZpFaXP1iUxMWN2f0FBU2qpjBvNTNjkiB7csQU5YkWigsTy9fj7iat\r\nXhVHgwLm2B33LPz/mCx2XRbJH6yvxeWZZ1zFIVxFmTFt+aLVR5vWv0B4ETTtYdxZ\r\nJCoa7Q3UwwaCl8blia6kSal5TA==\r\n-----END CERTIFICATE-----\r\n"], sortflag: false}; +deepEqual(parser.getCertificateSet(hIn), aExp, "set"); +}); + +test("CMSParser.getESSCertIDv2 test", function() { +var parser = new KJUR.asn1.cms.CMSParser(); + +var hIn = "30470420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e944423023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101"; +var pExp = { + alg: "sha256", + hash: "c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442", + issuer: { + array: [ + [{type:"C",value:"US",ds:"prn"}], + [{type:"O",value:"Z4",ds:"utf8"}] + ], + str: "/C=US/O=Z4" + }, + serial: {hex: "01"} +}; +deepEqual(parser.getESSCertIDv2(hIn), pExp, "z4certpem"); + +var hIn2 = "3051300d06096086480165030402030500044026b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c5"; +var pExp2 = { + hash: "26b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c5", + alg: "sha512" +}; +deepEqual(parser.getESSCertIDv2(hIn2), pExp2, "z4certpem sha512 no-isssn"); + +var hIn3 = "3076300d06096086480165030402030500044026b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c53023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101"; +var pExp3 = { + hash: "26b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c5", + alg: "sha512", + issuer: { + array: [ + [{type:"C",value:"US",ds:"prn"}], + [{type:"O",value:"Z4",ds:"utf8"}] + ], + str: "/C=US/O=Z4" + }, + serial: {hex: "01"} +}; +deepEqual(parser.getESSCertIDv2(hIn3), pExp3, "z4certpem sha512 isssn"); + +}); + +test("CMSParser.getAttribute signingCertificateV2", function() { +var parser = new KJUR.asn1.cms.CMSParser(); + +var hIn = "30818b060b2a864886f70d010910022f317c307a30783076300d06096086480165030402030500044026b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c53023301ea41c301a310b3009060355040613025553310b3009060355040a0c025a34020101"; +var pExp = { + attr: "signingCertificateV2", + array: [{ + hash: "26b07a87ff25e74b6a9115ca502a1c913f8f8ee92285418cdfb3c35e910bf30838c98ded14349b8641ce5287616bb0a493e20ee27ac4c377f797dcfcb70fc8c5", + alg: "sha512", + issuer: { + array: [ + [{type:"C",value:"US",ds:"prn"}], + [{type:"O",value:"Z4",ds:"utf8"}] + ], + str: "/C=US/O=Z4" + }, + serial: {hex: "01"} + }] +}; +deepEqual(parser.getAttribute(hIn), pExp, "z4cert sha512 isssn"); + +var hIn2 = "3037060b2a864886f70d010910022f31283026302430220420c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442"; +var pExp2 = { + attr: "signingCertificateV2", + array: [{ + hash: "c355dc4ee1dca2a95053ed90d27ff13025c887824da7d7cc83348ab2a0e94442", + alg: "sha256" + }] +}; +deepEqual(parser.getAttribute(hIn2), pExp2, "z4cert sha256 no-isssn"); + });