jiezhangxin-utils 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jiezhangxin-utils.cjs.js +26 -1
- package/dist/jiezhangxin-utils.cjs.js.map +1 -1
- package/dist/jiezhangxin-utils.esm.js +26 -1
- package/dist/jiezhangxin-utils.esm.js.map +1 -1
- package/dist/jiezhangxin-utils.umd.js +26 -1
- package/dist/jiezhangxin-utils.umd.js.map +1 -1
- package/package.json +10 -4
- package/.gitattributes +0 -19
- package/src/cache/cookies.js +0 -152
- package/src/constants.js +0 -30
- package/src/directives/input-limit.js +0 -100
- package/src/index.js +0 -12
- package/src/scrollToId/scrollToId.js +0 -47
- package/src/utils.js +0 -726
|
@@ -1,2 +1,27 @@
|
|
|
1
|
-
"use strict";var e=require("element-plus"),t=require("jsrsasign");const o={TOKEN:"token",USER_INFO:"userInfo",COMPANYCODE:"companyCode",COMPANYNAME:"companyName"};function r(){return localStorage.getItem(o.TOKEN)}const n=(e,t=!1)=>e.map(e=>{const o={title:e.name};return e.url&&(o.path=e.url),e.icon&&(o.svgName=e.icon),e.type&&(o.type=e.type),t?e.children&&e.children.length>0&&0===e.type&&(o.children=n(e.children)):e.children&&e.children.length>0&&(o.children=n(e.children)),o});exports.CacheKey=o,exports.MENU_DATA_KEY="user_menu_data",exports.WHITE_LIST=["/login","/404","/403","/register","/file-views","/iitc","/account"],exports.copyText=t=>{if(!t)return void e.ElMessage.warning("暂无可复制内容");const o=document.createElement("input");o.value=t,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),e.ElMessage.success("复制成功")},exports.debounce=(e,t=300)=>{let o=null;return function(...r){o&&clearTimeout(o),o=setTimeout(()=>{e.apply(this,r)},t)}},exports.downloadFile=(e,t)=>{const o=document.createElement("a");if(o.style.display="none","string"==typeof e)o.href=e;else{if(!(e instanceof Blob))return void console.error("不支持的文件源类型");o.href=URL.createObjectURL(e)}o.setAttribute("download",t),document.body.appendChild(o),o.click(),document.body.removeChild(o),e instanceof Blob&&window.URL.revokeObjectURL(o.href)},exports.exportFile=async(t,o,n)=>{try{const t=await fetch(o,{method:"get",headers:{token:r()},responseType:"blob"});t.ok||e.ElMessage.error("请求失败");const s=await t.blob(),a=t.headers.get("content-disposition");let c=n;if(a){const e=a.match(/filename="?([^"]+)"?/);e&&e[1]&&(c=decodeURIComponent(e[1]))}const i=window.URL.createObjectURL(s),l=document.createElement("a");l.href=i,l.download=c,document.body.appendChild(l),l.click(),e.ElMessage.success("下载成功"),window.URL.revokeObjectURL(i),document.body.removeChild(l)}catch(t){console.error("下载Excel失败:",t),e.ElMessage.error("下载失败")}},exports.extractPropValues=(e=[],t="",{keepEmpty:o=!1}={})=>{if(!Array.isArray(e))return[];const r=t.split(".").filter(e=>e.trim());return e.map(e=>{let t=e;for(const e of r)if(t=t?.[e],null==t)break;return t}).filter(e=>o||null!=e)},exports.formatAmount=e=>null==e||isNaN(e)?"":Number(e).toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),exports.formatAmountToUnits=function(e){const t=["","","","","","","","","","",""];if("number"!=typeof e||isNaN(e)||!isFinite(e))return t;if(e>999999999.99)return console.warn("金额过大,最大支持999999999.99元"),t;if(e<0)return console.warn("金额不能为负数"),t;if(0===e)return t;const o=Math.abs(e).toFixed(2),[r,n]=o.split("."),s=r.length;for(let e=0;e<s;e++){const o=r[s-1-e],n=8-e;n>=0&&(t[n]=o)}return(parseInt(r)>0||parseInt(n)>0)&&(t[9]=n[0],t[10]=n[1]),t},exports.formatMenuData=n,exports.formatMenuTree=function e(t){return Array.isArray(t)?t.filter(e=>1===e.type||void 0===e.type).map(t=>{const o={title:t.title,...t.path&&{path:t.path},...t.svgName&&{svgName:t.svgName}};if(t.children&&t.children.length){const r=e(t.children);r.length&&(o.children=r)}return o}):[]},exports.formatMoney=(e,t,o,r=!0)=>{if(null==e||isNaN(Number(e)))return r?"0":"";let n=Number(e);if(0===n&&!r)return"";void 0!==o&&"number"==typeof o&&o>=0?n=n.toFixed(o):void 0!==t&&"number"==typeof t&&t>=0&&(n=n.toFixed(t));const s=n.toString().split("."),a=s[0],c=s[1]||"",i=a.replace(/\B(?=(\d{3})+(?!\d))/g,",");return c?`${i}.${c}`:i},exports.formatToFirstDay=function(e){if(!e)return"";const[t,o]=e.split("-");return`${t}-${o}-01`},exports.generate32BitRandomString=function(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let o=0;o<32;o++)if("undefined"!=typeof crypto&&crypto.getRandomValues){const o=new Uint8Array(1);crypto.getRandomValues(o);const r=o[0]%62;t+=e.charAt(r)}else{const o=Math.floor(62*Math.random());t+=e.charAt(o)}return t},exports.generateTimestamp=function(e=13){if(10===e)return Math.floor(Date.now()/1e3);if(13===e)return Date.now();throw new Error("只支持10位或13位时间戳")},exports.getCompanyAccountPeriod=function(){return localStorage.getItem(o.COMPANYACCOUNTPERIOD)},exports.getCompanyAccountPeriodNow=function(){return localStorage.getItem(o.COMPANYACCOUNTPERIODNOW)},exports.getCompanyAuditStatusMsg=function(){return localStorage.getItem(o.COMPANYAUDITSTATUSMSG)},exports.getCompanyAuditStatusMsgNow=function(){return localStorage.getItem(o.COMPANYAUDITSTATUSMSGNOW)},exports.getCompanyCode=function(){return localStorage.getItem(o.COMPANYCODE)},exports.getCompanyName=function(){return localStorage.getItem(o.COMPANYNAME)},exports.getCompanyType=function(){return localStorage.getItem(o.COMPANYTYPE)},exports.getCurrentMonth=()=>{const e=new Date;return`${e.getFullYear()}-${(e.getMonth()+1).toString().padStart(2,"0")}`},exports.getFileTypeFromUrlRegex=e=>{if(!e||"string"!=typeof e)return"unknown";const t=e.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);if(!t)return"unknown";const o=t[1].toLowerCase();return/^pdf$/i.test(o)?"pdf":/^(jpg|jpeg|png|gif|bmp|webp|svg|ico|tiff|tif|heic|heif)$/i.test(o)?"image":"unknown"},exports.getFinancialStandardDictType=function(){return localStorage.getItem(o.FINANCIALSTANDARDDICTTYPE)},exports.getFormattedDateTime=function(){const e=new Date;return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}${String(e.getHours()).padStart(2,"0")}${String(e.getMinutes()).padStart(2,"0")}${String(e.getSeconds()).padStart(2,"0")}`},exports.getToken=r,exports.getUserInfo=function(){return localStorage.getItem(o.USER_INFO)},exports.handleViewFile=function(e){if("string"!=typeof e){const t="文件地址必须是字符串,当前传入类型:"+typeof e;return console.error("[handleViewFile] 错误:",t),{success:!1,error:t}}if(!e.trim()){const e="文件地址不能为空或仅空格";return console.error("[handleViewFile] 错误:",e),{success:!1,error:e}}let t;try{t=new URL(e)}catch(t){const o=`无效的URL格式:${e}(请检查是否包含特殊字符或缺失协议)`;return console.error("[handleViewFile] URL解析错误:",t,"| 地址:",e),{success:!1,error:o}}if(!["http:","https:"].includes(t.protocol)){const e=`仅支持HTTP/HTTPS协议,当前协议:${t.protocol}`;return console.error("[handleViewFile] 协议错误:",e),{success:!1,error:e}}const o=t.pathname,r=o.lastIndexOf(".");if(-1===r){const t=`文件地址不含后缀名:${e}(需是jpg/png/pdf)`;return console.error("[handleViewFile] 格式错误:",t),{success:!1,error:t}}const n=o.slice(r+1).toLowerCase(),s=["jpg","jpeg","png","pdf"];if(!s.includes(n)){const e=`不支持的文件格式:.${n},仅支持${s.join("、")}`;return console.error("[handleViewFile] 格式错误:",e),{success:!1,error:e}}try{if(!window.open(e,"_blank","noopener,noreferrer,width=1000,height=800")){const e="文件窗口被浏览器拦截,请允许弹窗后重试(地址栏右侧查看拦截提示)";return console.warn("[handleViewFile] 弹窗被拦截:",e),{success:!1,error:e}}return console.log("[handleViewFile] 成功:文件已在新窗口打开,地址:",e),{success:!0,message:"文件已在新窗口打开"}}catch(t){const o=`打开文件失败:${t.message}(可能是浏览器安全设置或网络问题)`;return console.error("[handleViewFile] 打开失败:",t,"| 地址:",e),{success:!1,error:o}}},exports.percentToNumber=function(e){const t=String(e).replace(/%/g,""),o=Number(t);return isNaN(o)?0:o},exports.periodDisabledDate=e=>{const t=new Date,o=t.getFullYear(),r=t.getMonth(),n=e.getFullYear(),s=e.getMonth();if(0===r){return!(n===o-1&&11===s||n===o)}return n!==o},exports.periodDisabledDateAllAfter=e=>{const t=new Date,o=t.getFullYear(),r=t.getMonth(),n=e.getFullYear(),s=e.getMonth();return n>o||n===o&&s>=r},exports.phoneRegex=/^1[3-9]\d{9}$/,exports.postExportFile=async(t,o,n,s)=>{try{const t=await fetch(o,{method:"post",headers:{token:r(),"Content-Type":"application/json"},responseType:"blob",body:JSON.stringify(s)});t.ok||e.ElMessage.error("请求失败");const a=await t.blob(),c=t.headers.get("content-disposition");let i=n;if(c){const e=c.match(/filename="?([^"]+)"?/);e&&e[1]&&(i=decodeURIComponent(e[1]))}const l=window.URL.createObjectURL(a),u=document.createElement("a");u.href=l,u.download=i,document.body.appendChild(u),u.click(),e.ElMessage.success("下载成功"),window.URL.revokeObjectURL(l),document.body.removeChild(u)}catch(t){console.error("下载Excel失败:",t),e.ElMessage.error("下载失败")}},exports.processVoucherArrayEnhanced=function(e,t={}){const{emptyObject:o={},preserveOriginal:r=!1}=t;if(!Array.isArray(e))throw new Error("参数必须是数组");const n=[];return e.forEach((e,t)=>{if(!e||"object"!=typeof e)return;const s=e.voucherList;if(!Array.isArray(s)){const s=r?{...e}:{...e,_metadata:{originalIndex:t,isPadded:!0,originalLength:0}};return s.voucherList=[{...o},{...o},{...o},{...o},{...o}],s.page=1,s.pageCount=1,void n.push(s)}const a=Math.ceil(s.length/5);if(s.length>5)for(let c=0;c<s.length;c+=5){const i=s.slice(c,c+5),l=Math.floor(c/5)+1,u=[...i];for(;u.length<5;)u.push({...o});const p=r?{...e}:{...e,_metadata:{originalIndex:t,isSplit:c>0,chunkIndex:Math.floor(c/5),totalChunks:a}};p.voucherList=u,p.page=l,p.pageCount=a,n.push(p)}else if(s.length<5){const a=s.map(e=>({...e}));for(;a.length<5;)a.push({...o});const c=r?{...e}:{...e,_metadata:{originalIndex:t,isPadded:!0,originalLength:s.length}};c.voucherList=a,c.page=1,c.pageCount=1,n.push(c)}else{const o=r?{...e}:{...e,_metadata:{originalIndex:t,isOriginal:!0}};o.page=1,o.pageCount=1,n.push(o)}}),n},exports.publicKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL/EwnX/3BaH5gJXJiv7qKhuKKol5JSgayGyYMWDdRO8KKAtOFrniXp/iAGGoV6Y0GF9Z8iY3xHOiU3rHeSJ3G6wFDY87Qr4k2m48/6YRX+s/iMGJ5j5obdCFiDkFUzoR/EHTqC6PM3h6bhDNNIXQpqVbQrg28tW5Y57+yxqRrUjAgMBAAECgYAHlgB9S3xI1eJm6Eylw8RFuWnZZTtYF8p1IEnMtmkMuU5AG9nVWsBo/J+EM++xPslLefr/h/CXEz0CPJFHp551HucLlRA7EOXSPfwLGODlz5rMnXyM8jD3ZMACXsRLvLEiNt+0nP+G7M+Dxuf6SLkmvqYa/NdJACb5/16E2P+pNQJBAO0hgUcKYfvJSXVolonVQNpR8Hu/4LH+5bBVLef+D6JNP6x0hr9U/ce+nI7I5wIPbBgFknvCWfVbgz16tPZhmC0CQQDPBzLArfdUfMs2h/3cxQAeZnX0ybt3F6CR3K9dliDJRn1p3ovdK0OmyggpKfx94KH+VRcJSaWTHLeFvub8KgSPAkEAhUWcY7HZKeqSB5OVb7fT8B+3OcW4YjFxI+5rk4Q9gylJTQJcrPH2g6mEUddlxcmnJcUT88xiRLx/ATGSvRpSrQJAJSfTkgUm6IDlL8pEY4TvuoUFEoPKI1uYM9V5m8A/7h+6jm+khnMnVx3XTRv99tGEAVNgKQiQsNBsl5JlfkhEPQJBAJ2nPXpGolp/R5usP+LP314snwj93G54+HaZnuOoIB0ApusErnpWCSHXbQtvXKo1n6SE3ccp010CPJBnOm/LRaA=",exports.recalculateCashFlowData=e=>{if(!e||!e.length)return;e.forEach(e=>{1==e.draftCalType&&(e.currentAmount=0)});let t=null;e.forEach(e=>{if(1==e.draftCalType)t=e;else if((2==e.draftCalType||3==e.draftCalType)&&t){const o=Number(e.currentAmount)||0,r=-1===e.calDirection?-1:1;t.currentAmount=(t.currentAmount||0)+o*r}})},exports.removeCompanyAccountPeriod=function(){localStorage.removeItem(o.COMPANYACCOUNTPERIOD)},exports.removeCompanyAccountPeriodNow=function(){localStorage.removeItem(o.COMPANYACCOUNTPERIODNOW)},exports.removeCompanyAuditStatusMsg=function(){localStorage.removeItem(o.COMPANYAUDITSTATUSMSG)},exports.removeCompanyAuditStatusMsgNow=function(){localStorage.removeItem(o.COMPANYAUDITSTATUSMSGNOW)},exports.removeCompanyCode=function(){localStorage.removeItem(o.COMPANYCODE)},exports.removeCompanyName=function(){localStorage.removeItem(o.COMPANYNAME)},exports.removeCompanyType=function(){localStorage.removeItem(o.COMPANYTYPE)},exports.removeFinancialStandardDictType=function(){localStorage.removeItem(o.FINANCIALSTANDARDDICTTYPE)},exports.removeToken=function(){localStorage.removeItem(o.TOKEN)},exports.removeUserInfo=function(){localStorage.removeItem(o.USER_INFO)},exports.scrollToId=function(e,t=0,o=500){if("string"!=typeof e||!e.trim())return console.error("[scrollToId] 错误:id必须是非空字符串"),!1;const r=document.getElementById(e);if(!r)return console.error(`[scrollToId] 错误:未找到ID为"${e}"的元素`),!1;const n=r.getBoundingClientRect().top+window.pageYOffset,s=window.pageYOffset,a=n-s-t;let c=null;return requestAnimationFrame(function e(t){null===c&&(c=t);const r=t-c,n=(i=r,l=s,u=a,(i/=o/2)<1?u/2*i*i+l:(i--,-u/2*(i*(i-2)-1)+l));var i,l,u;window.scrollTo(0,n),r<o&&requestAnimationFrame(e)}),!0},exports.setCompanyAccountPeriod=function(e){localStorage.setItem(o.COMPANYACCOUNTPERIOD,e)},exports.setCompanyAccountPeriodNow=function(e){localStorage.setItem(o.COMPANYACCOUNTPERIODNOW,e)},exports.setCompanyAuditStatusMsg=function(e){localStorage.setItem(o.COMPANYAUDITSTATUSMSG,e)},exports.setCompanyAuditStatusMsgNow=function(e){localStorage.setItem(o.COMPANYAUDITSTATUSMSGNOW,e)},exports.setCompanyCode=function(e){localStorage.setItem(o.COMPANYCODE,e)},exports.setCompanyName=function(e){localStorage.setItem(o.COMPANYNAME,e)},exports.setCompanyType=function(e){localStorage.setItem(o.COMPANYTYPE,e)},exports.setFinancialStandardDictType=function(e){localStorage.setItem(o.FINANCIALSTANDARDDICTTYPE,e)},exports.setToken=function(e){localStorage.setItem(o.TOKEN,e)},exports.setUserInfo=function(e){localStorage.setItem(o.USER_INFO,e)},exports.signWithSHA256RSA=function(e,o){console.log(e,o);const r=new t.KJUR.crypto.Signature({alg:"SHA256withRSA",prov:"cryptojs/jsrsa"});return r.init(o),r.updateString(e),r.sign()},exports.svgConst={viewBox:"0 0 1536 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em"},exports.svgSjPath={d:"M73.75498878 312.79929781L689.59344939 960.31767875A98.63975344 98.63975344 0 0 0 762.55326659 991.9976a98.63975344 98.63975344 0 0 0 72.71981813-31.67992125L1451.3515444 312.79929781a106.55973375 106.55973375 0 0 0 23.99994-114.23971406 113.75971594 113.75971594 0 0 0-96.95975719-70.55982375l-1231.19692219 0a113.27971688 113.27971688 0 0 0-97.19975718 70.31982375 106.55973375 106.55973375 0 0 0 23.75994094 114.47971406z",fill:"#001533"},exports.truncateToTwoDecimals=function(e,t){if(!isFinite(e)||0===e)return e.toFixed(2);const o=Math.trunc(100*e)/100;return Object.is(o,-0)?"-0.00":o.toFixed(t)},exports.unclosablePaths=["/accounting/accounting-voucher-detail","/accounting/accounting-voucher-add","/accounting/accounting-voucher-red"],exports.version="0.0.3";
|
|
1
|
+
"use strict";var t=require("element-plus");const e={TOKEN:"token",USER_INFO:"userInfo",COMPANYCODE:"companyCode",COMPANYNAME:"companyName"};function r(){return localStorage.getItem(e.TOKEN)}var i,n,s,a,o,h,u,c,l,f={userAgent:!1},p={},g=g||function(t){var e={},r=e.lib={},i=r.Base=function(){function t(){}return{extend:function(e){t.prototype=this;var r=new t;return e&&r.mixIn(e),r.hasOwnProperty("init")||(r.init=function(){r.$super.init.apply(this,arguments)}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),n=r.WordArray=i.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||a).stringify(this)},concat:function(t){var e=this.words,r=t.words,i=this.sigBytes,n=t.sigBytes;if(this.clamp(),i%4)for(var s=0;s<n;s++){var a=r[s>>>2]>>>24-s%4*8&255;e[i+s>>>2]|=a<<24-(i+s)%4*8}else for(s=0;s<n;s+=4)e[i+s>>>2]=r[s>>>2];return this.sigBytes+=n,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=i.clone.call(this);return t.words=this.words.slice(0),t},random:function(e){for(var r=[],i=0;i<e;i+=4)r.push(4294967296*t.random()|0);return new n.init(r,e)}}),s=e.enc={},a=s.Hex={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push((s>>>4).toString(16)),i.push((15&s).toString(16))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i+=2)r[i>>>3]|=parseInt(t.substr(i,2),16)<<24-i%8*4;return new n.init(r,e/2)}},o=s.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,i=[],n=0;n<r;n++){var s=e[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(s))}return i.join("")},parse:function(t){for(var e=t.length,r=[],i=0;i<e;i++)r[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;return new n.init(r,e)}},h=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(o.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return o.parse(unescape(encodeURIComponent(t)))}},u=r.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new n.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r=this._data,i=r.words,s=r.sigBytes,a=this.blockSize,o=s/(4*a),h=(o=e?t.ceil(o):t.max((0|o)-this._minBufferSize,0))*a,u=t.min(4*h,s);if(h){for(var c=0;c<h;c+=a)this._doProcessBlock(i,c);var l=i.splice(0,h);r.sigBytes-=u}return new n.init(l,u)},clone:function(){var t=i.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});r.Hasher=u.extend({cfg:i.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(e,r){return new t.init(r).finalize(e)}},_createHmacHelper:function(t){return function(e,r){return new c.HMAC.init(t,r).finalize(e)}}});var c=e.algo={};return e}(Math);n=(i=g).lib,s=n.Base,a=n.WordArray,(i=i.x64={}).Word=s.extend({init:function(t,e){this.high=t,this.low=e}}),i.WordArray=s.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:8*t.length},toX32:function(){for(var t=this.words,e=t.length,r=[],i=0;i<e;i++){var n=t[i];r.push(n.high),r.push(n.low)}return a.create(r,this.sigBytes)},clone:function(){for(var t=s.clone.call(this),e=t.words=this.words.slice(0),r=e.length,i=0;i<r;i++)e[i]=e[i].clone();return t}}),g.lib.Cipher||function(){var t=(f=g).lib,e=t.Base,r=t.WordArray,i=t.BufferedBlockAlgorithm,n=f.enc.Base64,s=f.algo.EvpKDF,a=t.Cipher=i.extend({cfg:e.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){i.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(t){return{encrypt:function(e,r,i){return("string"==typeof r?p:l).encrypt(t,e,r,i)},decrypt:function(e,r,i){return("string"==typeof r?p:l).decrypt(t,e,r,i)}}}});t.StreamCipher=a.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var o=f.mode={},h=function(t,e,r){var i=this._iv;i?this._iv=undefined:i=this._prevBlock;for(var n=0;n<r;n++)t[e+n]^=i[n]},u=(t.BlockCipherMode=e.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}})).extend();u.Encryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize;h.call(this,t,e,i),r.encryptBlock(t,e),this._prevBlock=t.slice(e,e+i)}}),u.Decryptor=u.extend({processBlock:function(t,e){var r=this._cipher,i=r.blockSize,n=t.slice(e,e+i);r.decryptBlock(t,e),h.call(this,t,e,i),this._prevBlock=n}}),o=o.CBC=u,u=(f.pad={}).Pkcs7={pad:function(t,e){for(var i,n=(i=(i=4*e)-t.sigBytes%i)<<24|i<<16|i<<8|i,s=[],a=0;a<i;a+=4)s.push(n);i=r.create(s,i),t.concat(i)},unpad:function(t){t.sigBytes-=255&t.words[t.sigBytes-1>>>2]}},t.BlockCipher=a.extend({cfg:a.cfg.extend({mode:o,padding:u}),reset:function(){a.reset.call(this);var t=(e=this.cfg).iv,e=e.mode;if(this._xformMode==this._ENC_XFORM_MODE)var r=e.createEncryptor;else r=e.createDecryptor,this._minBufferSize=1;this._mode=r.call(e,this,t&&t.words)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){t.pad(this._data,this.blockSize);var e=this._process(!0)}else e=this._process(!0),t.unpad(e);return e},blockSize:4});var c=t.CipherParams=e.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}}),l=(o=(f.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext;return((t=t.salt)?r.create([1398893684,1701076831]).concat(t).concat(e):e).toString(n)},parse:function(t){var e=(t=n.parse(t)).words;if(1398893684==e[0]&&1701076831==e[1]){var i=r.create(e.slice(2,4));e.splice(0,4),t.sigBytes-=16}return c.create({ciphertext:t,salt:i})}},t.SerializableCipher=e.extend({cfg:e.extend({format:o}),encrypt:function(t,e,r,i){i=this.cfg.extend(i);var n=t.createEncryptor(r,i);return e=n.finalize(e),n=n.cfg,c.create({ciphertext:e,key:r,iv:n.iv,algorithm:t,mode:n.mode,padding:n.padding,blockSize:t.blockSize,formatter:i.format})},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),t.createDecryptor(r,i).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}})),f=(f.kdf={}).OpenSSL={execute:function(t,e,i,n){return n||(n=r.random(8)),t=s.create({keySize:e+i}).compute(t,n),i=r.create(t.words.slice(e),4*i),t.sigBytes=4*e,c.create({key:t,iv:i,salt:n})}},p=t.PasswordBasedCipher=l.extend({cfg:l.cfg.extend({kdf:f}),encrypt:function(t,e,r,i){return r=(i=this.cfg.extend(i)).kdf.execute(r,t.keySize,t.ivSize),i.iv=r.iv,(t=l.encrypt.call(this,t,e,r.key,i)).mixIn(r),t},decrypt:function(t,e,r,i){return i=this.cfg.extend(i),e=this._parse(e,i.format),r=i.kdf.execute(r,t.keySize,t.ivSize,e.salt),i.iv=r.iv,l.decrypt.call(this,t,e,r.key,i)}})}(),function(){for(var t=g,e=t.lib.BlockCipher,r=t.algo,i=[],n=[],s=[],a=[],o=[],h=[],u=[],c=[],l=[],f=[],p=[],d=0;256>d;d++)p[d]=128>d?d<<1:d<<1^283;var v=0,m=0;for(d=0;256>d;d++){var y=(y=m^m<<1^m<<2^m<<3^m<<4)>>>8^255&y^99;i[v]=y,n[y]=v;var x=p[v],S=p[x],E=p[S],w=257*p[y]^16843008*y;s[v]=w<<24|w>>>8,a[v]=w<<16|w>>>16,o[v]=w<<8|w>>>24,h[v]=w,w=16843009*E^65537*S^257*x^16843008*v,u[y]=w<<24|w>>>8,c[y]=w<<16|w>>>16,l[y]=w<<8|w>>>24,f[y]=w,v?(v=x^p[p[p[E^x]]],m^=p[p[m]]):v=m=1}var F=[0,1,2,4,8,16,32,64,128,27,54];r=r.AES=e.extend({_doReset:function(){for(var t=(r=this._key).words,e=r.sigBytes/4,r=4*((this._nRounds=e+6)+1),n=this._keySchedule=[],s=0;s<r;s++)if(s<e)n[s]=t[s];else{var a=n[s-1];s%e?6<e&&4==s%e&&(a=i[a>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a]):(a=i[(a=a<<8|a>>>24)>>>24]<<24|i[a>>>16&255]<<16|i[a>>>8&255]<<8|i[255&a],a^=F[s/e|0]<<24),n[s]=n[s-e]^a}for(t=this._invKeySchedule=[],e=0;e<r;e++)s=r-e,a=e%4?n[s]:n[s-4],t[e]=4>e||4>=s?a:u[i[a>>>24]]^c[i[a>>>16&255]]^l[i[a>>>8&255]]^f[i[255&a]]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,s,a,o,h,i)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,u,c,l,f,n),r=t[e+1],t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,i,n,s,a,o){for(var h=this._nRounds,u=t[e]^r[0],c=t[e+1]^r[1],l=t[e+2]^r[2],f=t[e+3]^r[3],p=4,g=1;g<h;g++){var d=i[u>>>24]^n[c>>>16&255]^s[l>>>8&255]^a[255&f]^r[p++],v=i[c>>>24]^n[l>>>16&255]^s[f>>>8&255]^a[255&u]^r[p++],m=i[l>>>24]^n[f>>>16&255]^s[u>>>8&255]^a[255&c]^r[p++];f=i[f>>>24]^n[u>>>16&255]^s[c>>>8&255]^a[255&l]^r[p++],u=d,c=v,l=m}d=(o[u>>>24]<<24|o[c>>>16&255]<<16|o[l>>>8&255]<<8|o[255&f])^r[p++],v=(o[c>>>24]<<24|o[l>>>16&255]<<16|o[f>>>8&255]<<8|o[255&u])^r[p++],m=(o[l>>>24]<<24|o[f>>>16&255]<<16|o[u>>>8&255]<<8|o[255&c])^r[p++],f=(o[f>>>24]<<24|o[u>>>16&255]<<16|o[c>>>8&255]<<8|o[255&l])^r[p++],t[e]=d,t[e+1]=v,t[e+2]=m,t[e+3]=f},keySize:8});t.AES=e._createHelper(r)}(),function(){function t(t,e){var r=(this._lBlock>>>t^this._rBlock)&e;this._rBlock^=r,this._lBlock^=r<<t}function e(t,e){var r=(this._rBlock>>>t^this._lBlock)&e;this._lBlock^=r,this._rBlock^=r<<t}var r=g,i=(n=r.lib).WordArray,n=n.BlockCipher,s=r.algo,a=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],o=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],h=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],u=[{0:8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{0:1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{0:260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{0:2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{0:128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{0:268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{0:1048576,16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{0:134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],c=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],l=s.DES=n.extend({_doReset:function(){for(var t=this._key.words,e=[],r=0;56>r;r++){var i=a[r]-1;e[r]=t[i>>>5]>>>31-i%32&1}for(t=this._subKeys=[],i=0;16>i;i++){var n=t[i]=[],s=h[i];for(r=0;24>r;r++)n[r/6|0]|=e[(o[r]-1+s)%28]<<31-r%6,n[4+(r/6|0)]|=e[28+(o[r+24]-1+s)%28]<<31-r%6;for(n[0]=n[0]<<1|n[0]>>>31,r=1;7>r;r++)n[r]>>>=4*(r-1)+3;n[7]=n[7]<<5|n[7]>>>27}for(e=this._invSubKeys=[],r=0;16>r;r++)e[r]=t[15-r]},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._subKeys)},decryptBlock:function(t,e){this._doCryptBlock(t,e,this._invSubKeys)},_doCryptBlock:function(r,i,n){this._lBlock=r[i],this._rBlock=r[i+1],t.call(this,4,252645135),t.call(this,16,65535),e.call(this,2,858993459),e.call(this,8,16711935),t.call(this,1,1431655765);for(var s=0;16>s;s++){for(var a=n[s],o=this._lBlock,h=this._rBlock,l=0,f=0;8>f;f++)l|=u[f][((h^a[f])&c[f])>>>0];this._lBlock=h,this._rBlock=o^l}n=this._lBlock,this._lBlock=this._rBlock,this._rBlock=n,t.call(this,1,1431655765),e.call(this,8,16711935),e.call(this,2,858993459),t.call(this,16,65535),t.call(this,4,252645135),r[i]=this._lBlock,r[i+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=n._createHelper(l),s=s.TripleDES=n.extend({_doReset:function(){var t=this._key.words;this._des1=l.createEncryptor(i.create(t.slice(0,2))),this._des2=l.createEncryptor(i.create(t.slice(2,4))),this._des3=l.createEncryptor(i.create(t.slice(4,6)))},encryptBlock:function(t,e){this._des1.encryptBlock(t,e),this._des2.decryptBlock(t,e),this._des3.encryptBlock(t,e)},decryptBlock:function(t,e){this._des3.decryptBlock(t,e),this._des2.encryptBlock(t,e),this._des1.decryptBlock(t,e)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=n._createHelper(s)}(),function(){var t=g,e=t.lib.WordArray;t.enc.Base64={stringify:function(t){var e=t.words,r=t.sigBytes,i=this._map;t.clamp(),t=[];for(var n=0;n<r;n+=3)for(var s=(e[n>>>2]>>>24-n%4*8&255)<<16|(e[n+1>>>2]>>>24-(n+1)%4*8&255)<<8|e[n+2>>>2]>>>24-(n+2)%4*8&255,a=0;4>a&&n+.75*a<r;a++)t.push(i.charAt(s>>>6*(3-a)&63));if(e=i.charAt(64))for(;t.length%4;)t.push(e);return t.join("")},parse:function(t){var r=t.length,i=this._map;(n=i.charAt(64))&&(-1!=(n=t.indexOf(n))&&(r=n));for(var n=[],s=0,a=0;a<r;a++)if(a%4){var o=i.indexOf(t.charAt(a-1))<<a%4*2,h=i.indexOf(t.charAt(a))>>>6-a%4*2;n[s>>>2]|=(o|h)<<24-s%4*8,s++}return e.create(n,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(t){function e(t,e,r,i,n,s,a){return((t=t+(e&r|~e&i)+n+a)<<s|t>>>32-s)+e}function r(t,e,r,i,n,s,a){return((t=t+(e&i|r&~i)+n+a)<<s|t>>>32-s)+e}function i(t,e,r,i,n,s,a){return((t=t+(e^r^i)+n+a)<<s|t>>>32-s)+e}function n(t,e,r,i,n,s,a){return((t=t+(r^(e|~i))+n+a)<<s|t>>>32-s)+e}for(var s=g,a=(h=s.lib).WordArray,o=h.Hasher,h=s.algo,u=[],c=0;64>c;c++)u[c]=4294967296*t.abs(t.sin(c+1))|0;h=h.MD5=o.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(t,s){for(var a=0;16>a;a++){var o=t[h=s+a];t[h]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8)}a=this._hash.words;var h=t[s+0],c=(o=t[s+1],t[s+2]),l=t[s+3],f=t[s+4],p=t[s+5],g=t[s+6],d=t[s+7],v=t[s+8],m=t[s+9],y=t[s+10],x=t[s+11],S=t[s+12],E=t[s+13],w=t[s+14],F=t[s+15],b=e(b=a[0],C=a[1],D=a[2],A=a[3],h,7,u[0]),A=e(A,b,C,D,o,12,u[1]),D=e(D,A,b,C,c,17,u[2]),C=e(C,D,A,b,l,22,u[3]);b=e(b,C,D,A,f,7,u[4]),A=e(A,b,C,D,p,12,u[5]),D=e(D,A,b,C,g,17,u[6]),C=e(C,D,A,b,d,22,u[7]),b=e(b,C,D,A,v,7,u[8]),A=e(A,b,C,D,m,12,u[9]),D=e(D,A,b,C,y,17,u[10]),C=e(C,D,A,b,x,22,u[11]),b=e(b,C,D,A,S,7,u[12]),A=e(A,b,C,D,E,12,u[13]),D=e(D,A,b,C,w,17,u[14]),b=r(b,C=e(C,D,A,b,F,22,u[15]),D,A,o,5,u[16]),A=r(A,b,C,D,g,9,u[17]),D=r(D,A,b,C,x,14,u[18]),C=r(C,D,A,b,h,20,u[19]),b=r(b,C,D,A,p,5,u[20]),A=r(A,b,C,D,y,9,u[21]),D=r(D,A,b,C,F,14,u[22]),C=r(C,D,A,b,f,20,u[23]),b=r(b,C,D,A,m,5,u[24]),A=r(A,b,C,D,w,9,u[25]),D=r(D,A,b,C,l,14,u[26]),C=r(C,D,A,b,v,20,u[27]),b=r(b,C,D,A,E,5,u[28]),A=r(A,b,C,D,c,9,u[29]),D=r(D,A,b,C,d,14,u[30]),b=i(b,C=r(C,D,A,b,S,20,u[31]),D,A,p,4,u[32]),A=i(A,b,C,D,v,11,u[33]),D=i(D,A,b,C,x,16,u[34]),C=i(C,D,A,b,w,23,u[35]),b=i(b,C,D,A,o,4,u[36]),A=i(A,b,C,D,f,11,u[37]),D=i(D,A,b,C,d,16,u[38]),C=i(C,D,A,b,y,23,u[39]),b=i(b,C,D,A,E,4,u[40]),A=i(A,b,C,D,h,11,u[41]),D=i(D,A,b,C,l,16,u[42]),C=i(C,D,A,b,g,23,u[43]),b=i(b,C,D,A,m,4,u[44]),A=i(A,b,C,D,S,11,u[45]),D=i(D,A,b,C,F,16,u[46]),b=n(b,C=i(C,D,A,b,c,23,u[47]),D,A,h,6,u[48]),A=n(A,b,C,D,d,10,u[49]),D=n(D,A,b,C,w,15,u[50]),C=n(C,D,A,b,p,21,u[51]),b=n(b,C,D,A,S,6,u[52]),A=n(A,b,C,D,l,10,u[53]),D=n(D,A,b,C,y,15,u[54]),C=n(C,D,A,b,o,21,u[55]),b=n(b,C,D,A,v,6,u[56]),A=n(A,b,C,D,F,10,u[57]),D=n(D,A,b,C,g,15,u[58]),C=n(C,D,A,b,E,21,u[59]),b=n(b,C,D,A,f,6,u[60]),A=n(A,b,C,D,x,10,u[61]),D=n(D,A,b,C,c,15,u[62]),C=n(C,D,A,b,m,21,u[63]);a[0]=a[0]+b|0,a[1]=a[1]+C|0,a[2]=a[2]+D|0,a[3]=a[3]+A|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;r[n>>>5]|=128<<24-n%32;var s=t.floor(i/4294967296);for(r[15+(n+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),r[14+(n+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),e.sigBytes=4*(r.length+1),this._process(),r=(e=this._hash).words,i=0;4>i;i++)n=r[i],r[i]=16711935&(n<<8|n>>>24)|4278255360&(n<<24|n>>>8);return e},clone:function(){var t=o.clone.call(this);return t._hash=this._hash.clone(),t}}),s.MD5=o._createHelper(h),s.HmacMD5=o._createHmacHelper(h)}(Math),h=(l=(o=g).lib).WordArray,u=l.Hasher,c=[],l=o.algo.SHA1=u.extend({_doReset:function(){this._hash=new h.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],s=r[2],a=r[3],o=r[4],h=0;80>h;h++){if(16>h)c[h]=0|t[e+h];else{var u=c[h-3]^c[h-8]^c[h-14]^c[h-16];c[h]=u<<1|u>>>31}u=(i<<5|i>>>27)+o+c[h],u=20>h?u+(1518500249+(n&s|~n&a)):40>h?u+(1859775393+(n^s^a)):60>h?u+((n&s|n&a|s&a)-1894007588):u+((n^s^a)-899497514),o=a,a=s,s=n<<30|n>>>2,n=i,i=u}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+s|0,r[3]=r[3]+a|0,r[4]=r[4]+o|0},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=Math.floor(r/4294967296),e[15+(i+64>>>9<<4)]=r,t.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=u.clone.call(this);return t._hash=this._hash.clone(),t}}),o.SHA1=u._createHelper(l),o.HmacSHA1=u._createHmacHelper(l),function(t){for(var e=g,r=(n=e.lib).WordArray,i=n.Hasher,n=e.algo,s=[],a=[],o=function(t){return 4294967296*(t-(0|t))|0},h=2,u=0;64>u;){var c;t:{c=h;for(var l=t.sqrt(c),f=2;f<=l;f++)if(!(c%f)){c=!1;break t}c=!0}c&&(8>u&&(s[u]=o(t.pow(h,.5))),a[u]=o(t.pow(h,1/3)),u++),h++}var p=[];n=n.SHA256=i.extend({_doReset:function(){this._hash=new r.init(s.slice(0))},_doProcessBlock:function(t,e){for(var r=this._hash.words,i=r[0],n=r[1],s=r[2],o=r[3],h=r[4],u=r[5],c=r[6],l=r[7],f=0;64>f;f++){if(16>f)p[f]=0|t[e+f];else{var g=p[f-15],d=p[f-2];p[f]=((g<<25|g>>>7)^(g<<14|g>>>18)^g>>>3)+p[f-7]+((d<<15|d>>>17)^(d<<13|d>>>19)^d>>>10)+p[f-16]}g=l+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&u^~h&c)+a[f]+p[f],d=((i<<30|i>>>2)^(i<<19|i>>>13)^(i<<10|i>>>22))+(i&n^i&s^n&s),l=c,c=u,u=h,h=o+g|0,o=s,s=n,n=i,i=g+d|0}r[0]=r[0]+i|0,r[1]=r[1]+n|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+h|0,r[5]=r[5]+u|0,r[6]=r[6]+c|0,r[7]=r[7]+l|0},_doFinalize:function(){var e=this._data,r=e.words,i=8*this._nDataBytes,n=8*e.sigBytes;return r[n>>>5]|=128<<24-n%32,r[14+(n+64>>>9<<4)]=t.floor(i/4294967296),r[15+(n+64>>>9<<4)]=i,e.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});e.SHA256=i._createHelper(n),e.HmacSHA256=i._createHmacHelper(n)}(Math),function(){var t=g,e=t.lib.WordArray,r=(i=t.algo).SHA256,i=i.SHA224=r.extend({_doReset:function(){this._hash=new e.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var t=r._doFinalize.call(this);return t.sigBytes-=4,t}});t.SHA224=r._createHelper(i),t.HmacSHA224=r._createHmacHelper(i)}(),function(){function t(){return i.create.apply(i,arguments)}for(var e=g,r=e.lib.Hasher,i=(s=e.x64).Word,n=s.WordArray,s=e.algo,a=[t(1116352408,3609767458),t(1899447441,602891725),t(3049323471,3964484399),t(3921009573,2173295548),t(961987163,4081628472),t(1508970993,3053834265),t(2453635748,2937671579),t(2870763221,3664609560),t(3624381080,2734883394),t(310598401,1164996542),t(607225278,1323610764),t(1426881987,3590304994),t(1925078388,4068182383),t(2162078206,991336113),t(2614888103,633803317),t(3248222580,3479774868),t(3835390401,2666613458),t(4022224774,944711139),t(264347078,2341262773),t(604807628,2007800933),t(770255983,1495990901),t(1249150122,1856431235),t(1555081692,3175218132),t(1996064986,2198950837),t(2554220882,3999719339),t(2821834349,766784016),t(2952996808,2566594879),t(3210313671,3203337956),t(3336571891,1034457026),t(3584528711,2466948901),t(113926993,3758326383),t(338241895,168717936),t(666307205,1188179964),t(773529912,1546045734),t(1294757372,1522805485),t(1396182291,2643833823),t(1695183700,2343527390),t(1986661051,1014477480),t(2177026350,1206759142),t(2456956037,344077627),t(2730485921,1290863460),t(2820302411,3158454273),t(3259730800,3505952657),t(3345764771,106217008),t(3516065817,3606008344),t(3600352804,1432725776),t(4094571909,1467031594),t(275423344,851169720),t(430227734,3100823752),t(506948616,1363258195),t(659060556,3750685593),t(883997877,3785050280),t(958139571,3318307427),t(1322822218,3812723403),t(1537002063,2003034995),t(1747873779,3602036899),t(1955562222,1575990012),t(2024104815,1125592928),t(2227730452,2716904306),t(2361852424,442776044),t(2428436474,593698344),t(2756734187,3733110249),t(3204031479,2999351573),t(3329325298,3815920427),t(3391569614,3928383900),t(3515267271,566280711),t(3940187606,3454069534),t(4118630271,4000239992),t(116418474,1914138554),t(174292421,2731055270),t(289380356,3203993006),t(460393269,320620315),t(685471733,587496836),t(852142971,1086792851),t(1017036298,365543100),t(1126000580,2618297676),t(1288033470,3409855158),t(1501505948,4234509866),t(1607167915,987167468),t(1816402316,1246189591)],o=[],h=0;80>h;h++)o[h]=t();s=s.SHA512=r.extend({_doReset:function(){this._hash=new n.init([new i.init(1779033703,4089235720),new i.init(3144134277,2227873595),new i.init(1013904242,4271175723),new i.init(2773480762,1595750129),new i.init(1359893119,2917565137),new i.init(2600822924,725511199),new i.init(528734635,4215389547),new i.init(1541459225,327033209)])},_doProcessBlock:function(t,e){for(var r=(l=this._hash.words)[0],i=l[1],n=l[2],s=l[3],h=l[4],u=l[5],c=l[6],l=l[7],f=r.high,p=r.low,g=i.high,d=i.low,v=n.high,m=n.low,y=s.high,x=s.low,S=h.high,E=h.low,w=u.high,F=u.low,b=c.high,A=c.low,D=l.high,C=l.low,I=f,P=p,T=g,R=d,N=v,B=m,H=y,O=x,j=S,V=E,K=w,k=F,L=b,q=A,M=D,U=C,_=0;80>_;_++){var G=o[_];if(16>_)var z=G.high=0|t[e+2*_],W=G.low=0|t[e+2*_+1];else{z=((W=(z=o[_-15]).high)>>>1|(J=z.low)<<31)^(W>>>8|J<<24)^W>>>7;var J=(J>>>1|W<<31)^(J>>>8|W<<24)^(J>>>7|W<<25),Y=((W=(Y=o[_-2]).high)>>>19|($=Y.low)<<13)^(W<<3|$>>>29)^W>>>6,$=($>>>19|W<<13)^($<<3|W>>>29)^($>>>6|W<<26),X=(W=o[_-7]).high,Z=(Q=o[_-16]).high,Q=Q.low;z=(z=(z=z+X+((W=J+W.low)>>>0<J>>>0?1:0))+Y+((W=W+$)>>>0<$>>>0?1:0))+Z+((W=W+Q)>>>0<Q>>>0?1:0);G.high=z,G.low=W}X=j&K^~j&L,Q=V&k^~V&q,G=I&T^I&N^T&N;var tt=P&R^P&B^R&B,et=(J=(I>>>28|P<<4)^(I<<30|P>>>2)^(I<<25|P>>>7),Y=(P>>>28|I<<4)^(P<<30|I>>>2)^(P<<25|I>>>7),($=a[_]).high),rt=$.low;Z=M+((j>>>14|V<<18)^(j>>>18|V<<14)^(j<<23|V>>>9))+(($=U+((V>>>14|j<<18)^(V>>>18|j<<14)^(V<<23|j>>>9)))>>>0<U>>>0?1:0),M=L,U=q,L=K,q=k,K=j,k=V,j=H+(Z=(Z=(Z=Z+X+(($=$+Q)>>>0<Q>>>0?1:0))+et+(($=$+rt)>>>0<rt>>>0?1:0))+z+(($=$+W)>>>0<W>>>0?1:0))+((V=O+$|0)>>>0<O>>>0?1:0)|0,H=N,O=B,N=T,B=R,T=I,R=P,I=Z+(G=J+G+((W=Y+tt)>>>0<Y>>>0?1:0))+((P=$+W|0)>>>0<$>>>0?1:0)|0}p=r.low=p+P,r.high=f+I+(p>>>0<P>>>0?1:0),d=i.low=d+R,i.high=g+T+(d>>>0<R>>>0?1:0),m=n.low=m+B,n.high=v+N+(m>>>0<B>>>0?1:0),x=s.low=x+O,s.high=y+H+(x>>>0<O>>>0?1:0),E=h.low=E+V,h.high=S+j+(E>>>0<V>>>0?1:0),F=u.low=F+k,u.high=w+K+(F>>>0<k>>>0?1:0),A=c.low=A+q,c.high=b+L+(A>>>0<q>>>0?1:0),C=l.low=C+U,l.high=D+M+(C>>>0<U>>>0?1:0)},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;return e[i>>>5]|=128<<24-i%32,e[30+(i+128>>>10<<5)]=Math.floor(r/4294967296),e[31+(i+128>>>10<<5)]=r,t.sigBytes=4*e.length,this._process(),this._hash.toX32()},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t},blockSize:32}),e.SHA512=r._createHelper(s),e.HmacSHA512=r._createHmacHelper(s)}(),function(){var t=g,e=(n=t.x64).Word,r=n.WordArray,i=(n=t.algo).SHA512,n=n.SHA384=i.extend({_doReset:function(){this._hash=new r.init([new e.init(3418070365,3238371032),new e.init(1654270250,914150663),new e.init(2438529370,812702999),new e.init(355462360,4144912697),new e.init(1731405415,4290775857),new e.init(2394180231,1750603025),new e.init(3675008525,1694076839),new e.init(1203062813,3204075428)])},_doFinalize:function(){var t=i._doFinalize.call(this);return t.sigBytes-=16,t}});t.SHA384=i._createHelper(n),t.HmacSHA384=i._createHmacHelper(n)}(),function(){var t=g,e=(i=t.lib).WordArray,r=i.Hasher,i=t.algo,n=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),s=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=e.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),o=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),h=e.create([0,1518500249,1859775393,2400959708,2840853838]),u=e.create([1352829926,1548603684,1836072691,2053994217,0]);i=i.RIPEMD160=r.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(t,e){for(var r=0;16>r;r++){var i=t[S=e+r];t[S]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8)}var c,l,f,p,g,d,v,m,y,x,S=this._hash.words,E=(i=h.words,u.words),w=n.words,F=s.words,b=a.words,A=o.words;d=c=S[0],v=l=S[1],m=f=S[2],y=p=S[3],x=g=S[4];var D;for(r=0;80>r;r+=1)D=c+t[e+w[r]]|0,D=16>r?D+((l^f^p)+i[0]):32>r?D+((l&f|~l&p)+i[1]):48>r?D+(((l|~f)^p)+i[2]):64>r?D+((l&p|f&~p)+i[3]):D+((l^(f|~p))+i[4]),D=(D=(D|=0)<<b[r]|D>>>32-b[r])+g|0,c=g,g=p,p=f<<10|f>>>22,f=l,l=D,D=d+t[e+F[r]]|0,D=16>r?D+((v^(m|~y))+E[0]):32>r?D+((v&y|m&~y)+E[1]):48>r?D+(((v|~m)^y)+E[2]):64>r?D+((v&m|~v&y)+E[3]):D+((v^m^y)+E[4]),D=(D=(D|=0)<<A[r]|D>>>32-A[r])+x|0,d=x,x=y,y=m<<10|m>>>22,m=v,v=D;D=S[1]+f+y|0,S[1]=S[2]+p+x|0,S[2]=S[3]+g+d|0,S[3]=S[4]+c+v|0,S[4]=S[0]+l+m|0,S[0]=D},_doFinalize:function(){var t=this._data,e=t.words,r=8*this._nDataBytes,i=8*t.sigBytes;for(e[i>>>5]|=128<<24-i%32,e[14+(i+64>>>9<<4)]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8),t.sigBytes=4*(e.length+1),this._process(),e=(t=this._hash).words,r=0;5>r;r++)i=e[r],e[r]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8);return t},clone:function(){var t=r.clone.call(this);return t._hash=this._hash.clone(),t}});t.RIPEMD160=r._createHelper(i),t.HmacRIPEMD160=r._createHmacHelper(i)}(),function(){var t=g,e=t.enc.Utf8;t.algo.HMAC=t.lib.Base.extend({init:function(t,r){t=this._hasher=new t.init,"string"==typeof r&&(r=e.parse(r));var i=t.blockSize,n=4*i;r.sigBytes>n&&(r=t.finalize(r)),r.clamp();for(var s=this._oKey=r.clone(),a=this._iKey=r.clone(),o=s.words,h=a.words,u=0;u<i;u++)o[u]^=1549556828,h[u]^=909522486;s.sigBytes=a.sigBytes=n,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var e=this._hasher;return t=e.finalize(t),e.reset(),e.finalize(this._oKey.clone().concat(t))}})}(),function(){var t,e=g,r=(t=e.lib).Base,i=t.WordArray,n=(t=e.algo).HMAC,s=t.PBKDF2=r.extend({cfg:r.extend({keySize:4,hasher:t.SHA1,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){var r=this.cfg,s=n.create(r.hasher,t),a=i.create(),o=i.create([1]),h=a.words,u=o.words,c=r.keySize;for(r=r.iterations;h.length<c;){var l=s.update(e).finalize(o);s.reset();for(var f=l.words,p=f.length,g=l,d=1;d<r;d++){g=s.finalize(g),s.reset();for(var v=g.words,m=0;m<p;m++)f[m]^=v[m]}a.concat(l),u[0]++}return a.sigBytes=4*c,a}});e.PBKDF2=function(t,e,r){return s.create(r).compute(t,e)}}();
|
|
2
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
3
|
+
*/
|
|
4
|
+
var d,v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function m(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=v.charAt(r>>6)+v.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=v.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=v.charAt(r>>2)+v.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function y(t){var e,r,i,n="",s=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e)(i=v.indexOf(t.charAt(e)))<0||(0==s?(n+=A(i>>2),r=3&i,s=1):1==s?(n+=A(r<<2|i>>4),r=15&i,s=2):2==s?(n+=A(r),n+=A(i>>2),r=3&i,s=3):(n+=A(r<<2|i>>4),n+=A(15&i),s=0));return 1==s&&(n+=A(r<<2)),n}
|
|
5
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
6
|
+
*/function x(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}function S(){return new x(null)}"Microsoft Internet Explorer"==f.appName?(x.prototype.am=function(t,e,r,i,n,s){for(var a=32767&e,o=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=o*h+u*a;n=((h=a*h+((32767&c)<<15)+r[i]+(1073741823&n))>>>30)+(c>>>15)+o*u+(n>>>30),r[i++]=1073741823&h}return n},d=30):"Netscape"!=f.appName?(x.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var a=e*this[t++]+r[i]+n;n=Math.floor(a/67108864),r[i++]=67108863&a}return n},d=26):(x.prototype.am=function(t,e,r,i,n,s){for(var a=16383&e,o=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=o*h+u*a;n=((h=a*h+((16383&c)<<14)+r[i]+n)>>28)+(c>>14)+o*u,r[i++]=268435455&h}return n},d=28),x.prototype.DB=d,x.prototype.DM=(1<<d)-1,x.prototype.DV=1<<d;x.prototype.FV=Math.pow(2,52),x.prototype.F1=52-d,x.prototype.F2=2*d-52;var E,w,F="0123456789abcdefghijklmnopqrstuvwxyz",b=new Array;for(E="0".charCodeAt(0),w=0;w<=9;++w)b[E++]=w;for(E="a".charCodeAt(0),w=10;w<36;++w)b[E++]=w;for(E="A".charCodeAt(0),w=10;w<36;++w)b[E++]=w;function A(t){return F.charAt(t)}function D(t,e){var r=b[t.charCodeAt(e)];return null==r?-1:r}function C(t){var e=S();return e.fromInt(t),e}function I(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}function P(t){this.m=t}function T(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function R(t,e){return t&e}function N(t,e){return t|e}function B(t,e){return t^e}function H(t,e){return t&~e}function O(t){if(0==t)return-1;var e=0;return 65535&t||(t>>=16,e+=16),255&t||(t>>=8,e+=8),15&t||(t>>=4,e+=4),3&t||(t>>=2,e+=2),1&t||++e,e}function j(t){for(var e=0;0!=t;)t&=t-1,++e;return e}function V(){}function K(t){return t}function k(t){this.r2=S(),this.q3=S(),x.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}P.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},P.prototype.revert=function(t){return t},P.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},P.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},P.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},T.prototype.convert=function(t){var e=S();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(x.ZERO)>0&&this.m.subTo(e,e),e},T.prototype.revert=function(t){var e=S();return t.copyTo(e),this.reduce(e),e},T.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},T.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},T.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},x.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},x.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},x.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,n=!1,s=0;--i>=0;){var a=8==r?255&t[i]:D(t,i);a<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=a:s+r>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&x.ZERO.subTo(this,this)},x.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},x.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},x.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},x.prototype.lShiftTo=function(t,e){var r,i=t%this.DB,n=this.DB-i,s=(1<<n)-1,a=Math.floor(t/this.DB),o=this.s<<i&this.DM;for(r=this.t-1;r>=0;--r)e[r+a+1]=this[r]>>n|o,o=(this[r]&s)<<i;for(r=a-1;r>=0;--r)e[r]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},x.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,s=(1<<i)-1;e[0]=this[r]>>i;for(var a=r+1;a<this.t;++a)e[a-r-1]|=(this[a]&s)<<n,e[a-r]=this[a]>>i;i>0&&(e[this.t-r-1]|=(this.s&s)<<n),e.t=this.t-r,e.clamp()}},x.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},x.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&x.ZERO.subTo(e,e)},x.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},x.prototype.divRemTo=function(t,e,r){var i=t.abs();if(i.t<=0)throw"BigInteger divide by zero";var n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=S());var s=S(),a=this.s,o=t.s,h=this.DB-I(i[i.t-1]);h>0?(i.lShiftTo(h,s),n.lShiftTo(h,r)):(i.copyTo(s),n.copyTo(r));var u=s.t,c=s[u-1];if(0!=c){var l=c*(1<<this.F1)+(u>1?s[u-2]>>this.F2:0),f=this.FV/l,p=(1<<this.F1)/l,g=1<<this.F2,d=r.t,v=d-u,m=null==e?S():e;for(s.dlShiftTo(v,m),r.compareTo(m)>=0&&(r[r.t++]=1,r.subTo(m,r)),x.ONE.dlShiftTo(u,m),m.subTo(s,s);s.t<u;)s[s.t++]=0;for(;--v>=0;){var y=r[--d]==c?this.DM:Math.floor(r[d]*f+(r[d-1]+g)*p);if((r[d]+=s.am(0,y,r,v,0,u))<y)for(s.dlShiftTo(v,m),r.subTo(m,r);r[d]<--y;)r.subTo(m,r)}null!=e&&(r.drShiftTo(u,e),a!=o&&x.ZERO.subTo(e,e)),r.t=u,r.clamp(),h>0&&r.rShiftTo(h,r),a<0&&x.ZERO.subTo(r,r)}},x.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},x.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},x.prototype.exp=function(t,e){if(t>4294967295||t<1)return x.ONE;var r=S(),i=S(),n=e.convert(this),s=I(t)-1;for(n.copyTo(r);--s>=0;)if(e.sqrTo(r,i),(t&1<<s)>0)e.mulTo(i,n,r);else{var a=r;r=i,i=a}return e.revert(r)},x.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var r,i=(1<<e)-1,n=!1,s="",a=this.t,o=this.DB-a*this.DB%e;if(a-- >0)for(o<this.DB&&(r=this[a]>>o)>0&&(n=!0,s=A(r));a>=0;)o<e?(r=(this[a]&(1<<o)-1)<<e-o,r|=this[--a]>>(o+=this.DB-e)):(r=this[a]>>(o-=e)&i,o<=0&&(o+=this.DB,--a)),r>0&&(n=!0),n&&(s+=A(r));return n?s:"0"},x.prototype.negate=function(){var t=S();return x.ZERO.subTo(this,t),t},x.prototype.abs=function(){return this.s<0?this.negate():this},x.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},x.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+I(this[this.t-1]^this.s&this.DM)},x.prototype.mod=function(t){var e=S();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(x.ZERO)>0&&t.subTo(e,e),e},x.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new P(e):new T(e),this.exp(t,r)},x.ZERO=C(0),x.ONE=C(1),V.prototype.convert=K,V.prototype.revert=K,V.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},V.prototype.sqrTo=function(t,e){t.squareTo(e)},k.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=S();return t.copyTo(e),this.reduce(e),e},k.prototype.revert=function(t){return t},k.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},k.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},k.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)};var L=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],q=(1<<26)/L[L.length-1];
|
|
7
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
8
|
+
*/
|
|
9
|
+
function M(){this.i=0,this.j=0,this.S=new Array}x.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},x.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=C(r),n=S(),s=S(),a="";for(this.divRemTo(i,n,s);n.signum()>0;)a=(r+s.intValue()).toString(t).substr(1)+a,n.divRemTo(i,n,s);return s.intValue().toString(t)+a},x.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),n=!1,s=0,a=0,o=0;o<t.length;++o){var h=D(t,o);h<0?"-"==t.charAt(o)&&0==this.signum()&&(n=!0):(a=e*a+h,++s>=r&&(this.dMultiply(i),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(a,0)),n&&x.ZERO.subTo(this,this)},x.prototype.fromNumber=function(t,e,r){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,r),this.testBit(t-1)||this.bitwiseTo(x.ONE.shiftLeft(t-1),N,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(x.ONE.shiftLeft(t-1),this);else{var i=new Array,n=7&t;i.length=1+(t>>3),e.nextBytes(i),n>0?i[0]&=(1<<n)-1:i[0]=0,this.fromString(i,256)}},x.prototype.bitwiseTo=function(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;i<s;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=s;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<t.t;++i)r[i]=e(n,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},x.prototype.changeBit=function(t,e){var r=x.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},x.prototype.addTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},x.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},x.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},x.prototype.multiplyLowerTo=function(t,e,r){var i,n=Math.min(this.t+t.t,e);for(r.s=0,r.t=n;n>0;)r[--n]=0;for(i=r.t-this.t;n<i;++n)r[n+this.t]=this.am(0,t[n],r,n,0,this.t);for(i=Math.min(t.t,e);n<i;++n)this.am(0,t[n],r,n,0,e-n);r.clamp()},x.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},x.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},x.prototype.millerRabin=function(t){if(this.signum()<=0)return!1;var e=this.subtract(x.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>L.length&&(t=L.length);for(var n=S(),s=0;s<t;++s){n.fromInt(L[Math.floor(Math.random()*L.length)]);var a=n.modPow(i,this);if(0!=a.compareTo(x.ONE)&&0!=a.compareTo(e)){for(var o=1;o++<r&&0!=a.compareTo(e);)if(0==(a=a.modPowInt(2,this)).compareTo(x.ONE))return!1;if(0!=a.compareTo(e))return!1}}return!0},x.prototype.clone=
|
|
10
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
11
|
+
*/
|
|
12
|
+
function(){var t=S();return this.copyTo(t),t},x.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},x.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},x.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},x.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},x.prototype.toByteArray=function(){var t=this.t,e=new Array;e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&r&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},x.prototype.equals=function(t){return 0==this.compareTo(t)},x.prototype.min=function(t){return this.compareTo(t)<0?this:t},x.prototype.max=function(t){return this.compareTo(t)>0?this:t},x.prototype.and=function(t){var e=S();return this.bitwiseTo(t,R,e),e},x.prototype.or=function(t){var e=S();return this.bitwiseTo(t,N,e),e},x.prototype.xor=function(t){var e=S();return this.bitwiseTo(t,B,e),e},x.prototype.andNot=function(t){var e=S();return this.bitwiseTo(t,H,e),e},x.prototype.not=function(){for(var t=S(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},x.prototype.shiftLeft=function(t){var e=S();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},x.prototype.shiftRight=function(t){var e=S();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},x.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+O(this[t]);return this.s<0?this.t*this.DB:-1},x.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=j(this[r]^e);return t},x.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:!!(this[e]&1<<t%this.DB)},x.prototype.setBit=function(t){return this.changeBit(t,N)},x.prototype.clearBit=function(t){return this.changeBit(t,H)},x.prototype.flipBit=function(t){return this.changeBit(t,B)},x.prototype.add=function(t){var e=S();return this.addTo(t,e),e},x.prototype.subtract=function(t){var e=S();return this.subTo(t,e),e},x.prototype.multiply=function(t){var e=S();return this.multiplyTo(t,e),e},x.prototype.divide=function(t){var e=S();return this.divRemTo(t,e,null),e},x.prototype.remainder=function(t){var e=S();return this.divRemTo(t,null,e),e},x.prototype.divideAndRemainder=function(t){var e=S(),r=S();return this.divRemTo(t,e,r),new Array(e,r)},x.prototype.modPow=function(t,e){if(t.signum()<0)return this.modInverse(e).modPow(t.negate(),e);var r,i,n=t.bitLength(),s=C(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new P(e):e.isEven()?new k(e):new T(e);var a=new Array,o=3,h=r-1,u=(1<<r)-1;if(a[1]=i.convert(this),r>1){var c=S();for(i.sqrTo(a[1],c);o<=u;)a[o]=S(),i.mulTo(c,a[o-2],a[o]),o+=2}var l,f,p=t.t-1,g=!0,d=S();for(n=I(t[p])-1;p>=0;){for(n>=h?l=t[p]>>n-h&u:(l=(t[p]&(1<<n+1)-1)<<h-n,p>0&&(l|=t[p-1]>>this.DB+n-h)),o=r;!(1&l);)l>>=1,--o;if((n-=o)<0&&(n+=this.DB,--p),g)a[l].copyTo(s),g=!1;else{for(;o>1;)i.sqrTo(s,d),i.sqrTo(d,s),o-=2;o>0?i.sqrTo(s,d):(f=s,s=d,d=f),i.mulTo(d,a[l],s)}for(;p>=0&&!(t[p]&1<<n);)i.sqrTo(s,d),f=s,s=d,d=f,--n<0&&(n=this.DB-1,--p)}return i.revert(s)},x.prototype.modInverse=function(t){if(0==t.signum())return x.ZERO;var e=this.mod(t),r=t.isEven();if(e.isEven()&&r||0==e.signum())return x.ZERO;for(var i=t.clone(),n=e.clone(),s=C(1),a=C(0),o=C(0),h=C(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),r?(s.isEven()&&a.isEven()||(s.addTo(e,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),r?(o.isEven()&&h.isEven()||(o.addTo(e,o),h.subTo(t,h)),o.rShiftTo(1,o)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(n)>=0?(i.subTo(n,i),r&&s.subTo(o,s),a.subTo(h,a)):(n.subTo(i,n),r&&o.subTo(s,o),h.subTo(a,h))}return 0!=n.compareTo(x.ONE)?x.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},x.prototype.pow=function(t){return this.exp(t,new V)},x.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},x.prototype.isProbablePrime=function(t){if(this.signum()<=0)return!1;var e,r=this.abs();if(1==r.t&&r[0]<=L[L.length-1]){for(e=0;e<L.length;++e)if(r[0]==L[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<L.length;){for(var i=L[e],n=e+1;n<L.length&&i<q;)i*=L[n++];for(i=r.modInt(i);e<n;)if(i%L[e++]==0)return!1}return r.millerRabin(t)},x.prototype.square=function(){var t=S();return this.squareTo(t),t},x.prototype.sqrt=function(){for(var t=x.ZERO.setBit(this.bitLength()/2),e=t;;){var r=t.add(this.divide(t)).shiftRight(1);if(r.equals(t)||r.equals(e))return r;e=t,t=r}},M.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},M.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var U,_,G,z=256;
|
|
13
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
14
|
+
*/function W(){!function(t){_[G++]^=255&t,_[G++]^=t>>8&255,_[G++]^=t>>16&255,_[G++]^=t>>24&255,G>=z&&(G-=z)}((new Date).getTime())}if(null==_){var J;if(_=new Array,G=0,void 0!==p&&(void 0!==p.crypto||void 0!==p.msCrypto)){var Y=p.crypto||p.msCrypto;if(Y.getRandomValues){var $=new Uint8Array(32);for(Y.getRandomValues($),J=0;J<32;++J)_[G++]=$[J]}else if("Netscape"==f.appName&&f.appVersion<"5"){var X=p.crypto.random(32);for(J=0;J<X.length;++J)_[G++]=255&X.charCodeAt(J)}}if(G<z&&"undefined"!=typeof globalThis&&globalThis.crypto&&globalThis.crypto.getRandomValues){var Z=new Uint8Array(z-G);for(globalThis.crypto.getRandomValues(Z),J=0;J<Z.length;++J)_[G++]=Z[J]}for(;G<z;)J=Math.floor(65536*Math.random()),_[G++]=J>>>8,_[G++]=255&J;G=0,W()}function Q(){if(null==U){for(W(),(U=new M).init(_),G=0;G<_.length;++G)_[G]=0;G=0}return U.next()}function tt(){}
|
|
15
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
16
|
+
*/
|
|
17
|
+
function et(t,e){return new x(t,e)}function rt(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}
|
|
18
|
+
/*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/
|
|
19
|
+
*/
|
|
20
|
+
function it(t,e){this.x=e,this.q=t}function nt(t,e,r,i){this.curve=t,this.x=e,this.y=r,this.z=null==i?x.ONE:i,this.zinv=null}function st(t,e,r){this.q=t,this.a=this.fromBigInteger(e),this.b=this.fromBigInteger(r),this.infinity=new nt(this,null,null)}tt.prototype.nextBytes=function(t){var e;for(e=0;e<t.length;++e)t[e]=Q()},rt.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},rt.prototype.setPublic=function(t,e){if(this.isPublic=!0,this.isPrivate=!1,"string"!=typeof t)this.n=t,this.e=e;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA public key";this.n=et(t,16),this.e=parseInt(e,16)}if(null==this.n||"function"!=typeof this.n.compareTo||this.n.compareTo(x.ONE)<=0||null==this.e||isNaN(this.e)||this.e<=0)throw"Invalid RSA public key"},rt.prototype.type="RSA",rt.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},rt.prototype.setPrivate=function(t,e,r){if(this.isPrivate=!0,"string"!=typeof t)this.n=t,this.e=e,this.d=r;else{if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16)}},rt.prototype.setPrivateEx=function(t,e,r,i,n,s,a,o){if(this.isPrivate=!0,this.isPublic=!1,null==t)throw"RSASetPrivateEx N == null";if(null==e)throw"RSASetPrivateEx E == null";if(0==t.length)throw"RSASetPrivateEx N.length == 0";if(0==e.length)throw"RSASetPrivateEx E.length == 0";if(!(null!=t&&null!=e&&t.length>0&&e.length>0))throw"Invalid RSA private key in RSASetPrivateEx";this.n=et(t,16),this.e=parseInt(e,16),this.d=et(r,16),this.p=et(i,16),this.q=et(n,16),this.dmp1=et(s,16),this.dmq1=et(a,16),this.coeff=et(o,16)},rt.prototype.generate=function(t,e){var r=new tt,i=t>>1;this.e=parseInt(e,16);for(var n=new x(e,16),s=t/2-100,a=x.ONE.shiftLeft(s);;){for(;this.p=new x(t-i,1,r),0!=this.p.subtract(x.ONE).gcd(n).compareTo(x.ONE)||!this.p.isProbablePrime(10););for(;this.q=new x(i,1,r),0!=this.q.subtract(x.ONE).gcd(n).compareTo(x.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var h=this.q.subtract(this.p).abs();if(!(h.bitLength()<s||h.compareTo(a)<=0)){var u=this.p.subtract(x.ONE),c=this.q.subtract(x.ONE),l=u.multiply(c);if(0==l.gcd(n).compareTo(x.ONE)&&(this.n=this.p.multiply(this.q),this.n.bitLength()==t)){this.d=n.modInverse(l),this.dmp1=this.d.mod(u),this.dmq1=this.d.mod(c),this.coeff=this.q.modInverse(this.p);break}}}this.isPrivate=!0},it.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.x.equals(t.x)},it.prototype.toBigInteger=function(){return this.x},it.prototype.negate=function(){return new it(this.q,this.x.negate().mod(this.q))},it.prototype.add=function(t){return new it(this.q,this.x.add(t.toBigInteger()).mod(this.q))},it.prototype.subtract=function(t){return new it(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))},it.prototype.multiply=function(t){return new it(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))},it.prototype.square=function(){return new it(this.q,this.x.square().mod(this.q))},it.prototype.divide=function(t){return new it(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))},it.prototype.sqrt=function(){return new it(this.q,this.x.sqrt().mod(this.q))},nt.prototype.getX=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))},nt.prototype.getY=function(){return null==this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))},nt.prototype.equals=function(t){return t==this||(this.isInfinity()?t.isInfinity():t.isInfinity()?this.isInfinity():!!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO)&&t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(x.ZERO))},nt.prototype.isInfinity=function(){return null==this.x&&null==this.y||this.z.equals(x.ZERO)&&!this.y.toBigInteger().equals(x.ZERO)},nt.prototype.negate=function(){return new nt(this.curve,this.x,this.y.negate(),this.z)},nt.prototype.add=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;var e=t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q),r=t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q);if(x.ZERO.equals(r))return x.ZERO.equals(e)?this.twice():this.curve.getInfinity();var i=new x("3"),n=this.x.toBigInteger(),s=this.y.toBigInteger();t.x.toBigInteger(),t.y.toBigInteger();var a=r.square(),o=a.multiply(r),h=n.multiply(a),u=e.square().multiply(this.z),c=u.subtract(h.shiftLeft(1)).multiply(t.z).subtract(o).multiply(r).mod(this.curve.q),l=h.multiply(i).multiply(e).subtract(s.multiply(o)).subtract(u.multiply(e)).multiply(t.z).add(e.multiply(o)).mod(this.curve.q),f=o.multiply(this.z).multiply(t.z).mod(this.curve.q);return new nt(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),f)},nt.prototype.twice=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=new x("3"),e=this.x.toBigInteger(),r=this.y.toBigInteger(),i=r.multiply(this.z),n=i.multiply(r).mod(this.curve.q),s=this.curve.a.toBigInteger(),a=e.square().multiply(t);x.ZERO.equals(s)||(a=a.add(this.z.square().multiply(s)));var o=(a=a.mod(this.curve.q)).square().subtract(e.shiftLeft(3).multiply(n)).shiftLeft(1).multiply(i).mod(this.curve.q),h=a.multiply(t).multiply(e).subtract(n.shiftLeft(1)).shiftLeft(2).multiply(n).subtract(a.square().multiply(a)).mod(this.curve.q),u=i.square().multiply(i).shiftLeft(3).mod(this.curve.q);return new nt(this.curve,this.curve.fromBigInteger(o),this.curve.fromBigInteger(h),u)},nt.prototype.multiply=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new x("3")),n=this.negate(),s=this,a=this.curve.q.subtract(t),o=a.multiply(new x("3")),h=new nt(this.curve,this.x,this.y),u=h.negate();for(e=i.bitLength()-2;e>0;--e){s=s.twice();var c=i.testBit(e);c!=r.testBit(e)&&(s=s.add(c?this:n))}for(e=o.bitLength()-2;e>0;--e){h=h.twice();var l=o.testBit(e);l!=a.testBit(e)&&(h=h.add(l?h:u))}return s},nt.prototype.multiplyTwo=function(t,e,r){var i;i=t.bitLength()>r.bitLength()?t.bitLength()-1:r.bitLength()-1;for(var n=this.curve.getInfinity(),s=this.add(e);i>=0;)n=n.twice(),t.testBit(i)?n=r.testBit(i)?n.add(s):n.add(this):r.testBit(i)&&(n=n.add(e)),--i;return n},st.prototype.getQ=function(){return this.q},st.prototype.getA=function(){return this.a},st.prototype.getB=function(){return this.b},st.prototype.equals=function(t){return t==this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)},st.prototype.getInfinity=function(){return this.infinity},st.prototype.fromBigInteger=function(t){return new it(this.q,t)},st.prototype.decodePointHex=function(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var e=t.substr(0,2);t.substr(2);var r=this.fromBigInteger(new x(o,16)),i=this.getA(),n=this.getB(),s=r.square().add(i).multiply(r).add(n).sqrt();return"03"==e&&(s=s.negate()),new nt(this,r,s);case 4:case 6:case 7:var a=(t.length-2)/2,o=t.substr(2,a),h=t.substr(a+2,a);return new nt(this,this.fromBigInteger(new x(o,16)),this.fromBigInteger(new x(h,16)));default:return null}},
|
|
21
|
+
/*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib
|
|
22
|
+
*/
|
|
23
|
+
it.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)},nt.prototype.getEncoded=function(t){var e=function(t,e){var r=t.toByteArrayUnsigned();if(e<r.length)r=r.slice(r.length-e);else for(;e>r.length;)r.unshift(0);return r},r=this.getX().toBigInteger(),i=this.getY().toBigInteger(),n=e(r,32);return t?i.isEven()?n.unshift(2):n.unshift(3):(n.unshift(4),n=n.concat(e(i,32))),n},nt.decodeFrom=function(t,e){var r=e.length-1,i=e.slice(1,1+r/2),n=e.slice(1+r/2,1+r);i.unshift(0),n.unshift(0);var s=new x(i),a=new x(n);return new nt(t,t.fromBigInteger(s),t.fromBigInteger(a))},nt.decodeFromHex=function(t,e){e.substr(0,2);var r=e.length-2,i=e.substr(2,r/2),n=e.substr(2+r/2,r/2),s=new x(i,16),a=new x(n,16);return new nt(t,t.fromBigInteger(s),t.fromBigInteger(a))},nt.prototype.add2D=function(t){if(this.isInfinity())return t;if(t.isInfinity())return this;if(this.x.equals(t.x))return this.y.equals(t.y)?this.twice():this.curve.getInfinity();var e=t.x.subtract(this.x),r=t.y.subtract(this.y).divide(e),i=r.square().subtract(this.x).subtract(t.x),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new nt(this.curve,i,n)},nt.prototype.twice2D=function(){if(this.isInfinity())return this;if(0==this.y.toBigInteger().signum())return this.curve.getInfinity();var t=this.curve.fromBigInteger(x.valueOf(2)),e=this.curve.fromBigInteger(x.valueOf(3)),r=this.x.square().multiply(e).add(this.curve.a).divide(this.y.multiply(t)),i=r.square().subtract(this.x.multiply(t)),n=r.multiply(this.x.subtract(i)).subtract(this.y);return new nt(this.curve,i,n)},nt.prototype.multiply2D=function(t){if(this.isInfinity())return this;if(0==t.signum())return this.curve.getInfinity();var e,r=t,i=r.multiply(new x("3")),n=this.negate(),s=this;for(e=i.bitLength()-2;e>0;--e){s=s.twice();var a=i.testBit(e);a!=r.testBit(e)&&(s=s.add2D(a?this:n))}return s},nt.prototype.isOnCurve=function(){var t=this.getX().toBigInteger(),e=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),i=this.curve.getB().toBigInteger(),n=this.curve.getQ(),s=e.multiply(e).mod(n),a=t.multiply(t).multiply(t).add(r.multiply(t)).add(i).mod(n);return s.equals(a)},nt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"},nt.prototype.validate=function(){var t=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var e=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(e.compareTo(x.ONE)<0||e.compareTo(t.subtract(x.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(x.ONE)<0||r.compareTo(t.subtract(x.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(t).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};
|
|
24
|
+
/*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval
|
|
25
|
+
*/
|
|
26
|
+
var at=function(){var t=new RegExp('(?:false|true|null|[\\{\\}\\[\\]]|(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)|(?:"(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))*"))',"g"),e=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),r={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"};function i(t,e,i){return e?r[e]:String.fromCharCode(parseInt(i,16))}var n=new String(""),s=Object.hasOwnProperty;return function(r,a){var o,h,u=r.match(t),c=u[0],l=!1;"{"===c?o={}:"["===c?o=[]:(o=[],l=!0);for(var f=[o],p=1-l,g=u.length;p<g;++p){var d;switch((c=u[p]).charCodeAt(0)){default:(d=f[0])[h||d.length]=+c,h=void 0;break;case 34:if(-1!==(c=c.substring(1,c.length-1)).indexOf("\\")&&(c=c.replace(e,i)),d=f[0],!h){if(!(d instanceof Array)){h=c||n;break}h=d.length}d[h]=c,h=void 0;break;case 91:d=f[0],f.unshift(d[h||d.length]=[]),h=void 0;break;case 93:case 125:f.shift();break;case 102:(d=f[0])[h||d.length]=!1,h=void 0;break;case 110:(d=f[0])[h||d.length]=null,h=void 0;break;case 116:(d=f[0])[h||d.length]=!0,h=void 0;break;case 123:d=f[0],f.unshift(d[h||d.length]={}),h=void 0}}if(l){if(1!==f.length)throw new Error;o=o[0]}else if(f.length)throw new Error;if(a){var v=function(t,e){var r=t[e];if(r&&"object"==typeof r){var i=null;for(var n in r)if(s.call(r,n)&&r!==t){var o=v(r,n);void 0!==o?r[n]=o:(i||(i=[]),i.push(n))}if(i)for(var h=i.length;--h>=0;)delete r[i[h]]}return a.call(t,e,r)};o=v({"":o},"")}return o}}();void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),ot.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){return qt(t)},this.getPEMStringFromHex=function(t,e){return wt(t,e)},this.newObject=function(t){var e=ot.asn1,r=e.ASN1Object,i=e.DERBoolean,n=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,u=e.DEREnumerated,c=e.DERUTF8String,l=e.DERNumericString,f=e.DERPrintableString,p=e.DERTeletexString,g=e.DERIA5String,d=e.DERUTCTime,v=e.DERGeneralizedTime,m=e.DERVisibleString,y=e.DERBMPString,x=e.DERSequence,S=e.DERSet,E=e.DERTaggedObject,w=e.ASN1Util.newObject;if(t instanceof e.ASN1Object)return t;var F=Object.keys(t);if(1!=F.length)throw new Error("key of param shall be only one.");var b=F[0];if(-1==":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+b+":"))throw new Error("undefined key: "+b);if("bool"==b)return new i(t[b]);if("int"==b)return new n(t[b]);if("bitstr"==b)return new s(t[b]);if("octstr"==b)return new a(t[b]);if("null"==b)return new o(t[b]);if("oid"==b)return new h(t[b]);if("enum"==b)return new u(t[b]);if("utf8str"==b)return new c(t[b]);if("numstr"==b)return new l(t[b]);if("prnstr"==b)return new f(t[b]);if("telstr"==b)return new p(t[b]);if("ia5str"==b)return new g(t[b]);if("utctime"==b)return new d(t[b]);if("gentime"==b)return new v(t[b]);if("visstr"==b)return new m(t[b]);if("bmpstr"==b)return new y(t[b]);if("asn1"==b)return new r(t[b]);if("seq"==b){for(var A=t[b],D=[],C=0;C<A.length;C++){var I=w(A[C]);D.push(I)}return new x({array:D})}if("set"==b){for(A=t[b],D=[],C=0;C<A.length;C++){I=w(A[C]);D.push(I)}return new S({array:D})}if("tag"==b){var P=t[b];if("[object Array]"===Object.prototype.toString.call(P)&&3==P.length){var T=w(P[2]);return new E({tag:P[0],explicit:P[1],obj:T})}return new E(P)}},this.jsonToASN1HEX=function(t){return this.newObject(t).tohex()}},ot.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);if(i+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new x(i,2).toString(10),i=""}return e},ot.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new x(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",a=0;a<n;a++)s+="0";i=s+i;for(a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var a=0;a<n.length;a++)i+=r(n[a]);return i},ot.asn1.ASN1Object=function(t){this.params=null,this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n=0,v="+this.hV);var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var r=e.length/2;if(r>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+t.toString(16));return(128+r).toString(16)+e},this.tohex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(t){this.params=t},null!=t&&null!=t.tlv&&(this.hTLV=t.tlv,this.isModified=!1)},ot.asn1.DERAbstractString=function(t){ot.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=mt(this.s).toLowerCase()},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},Gt(ot.asn1.DERAbstractString,ot.asn1.ASN1Object),ot.asn1.DERAbstractTime=function(t){ot.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){var e=t.getTime()+6e4*t.getTimezoneOffset();return new Date(e)},this.formatDate=function(t,e,r){var i=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var a=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var o=n.getMilliseconds();if(0!=o){var h=i(String(o),3);a=a+"."+(h=h.replace(/[0]+$/,""))}}return a+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.setByParam=function(t){this.hV=null,this.hTLV=null,this.params=t},this.getString=function(){},this.setString=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.str=t},this.setByDate=function(t){this.hTLV=null,this.isModified=!0,null==this.params&&(this.params={}),this.params.date=t},this.setByDateValue=function(t,e,r,i,n,s){var a=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(a)},this.getFreshValueHex=function(){return this.hV}},Gt(ot.asn1.DERAbstractTime,ot.asn1.ASN1Object),ot.asn1.DERAbstractStructured=function(t){ot.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},Gt(ot.asn1.DERAbstractStructured,ot.asn1.ASN1Object),ot.asn1.DERBoolean=function(t){ot.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV=0==t?"010100":"0101ff"},Gt(ot.asn1.DERBoolean,ot.asn1.ASN1Object),ot.asn1.DERInteger=function(t){ot.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var e=qt;this.setByBigInteger=function(t){this.isModified=!0,this.params={bigint:t}},this.setByInteger=function(t){this.isModified=!0,this.params=t},this.setValueHex=function(t){this.isModified=!0,this.params={hex:t}},this.getFreshValueHex=function(){var t=this.params,r=null;if(null==t)throw new Error("value not set");if("object"==typeof t&&null!=t.hex)return this.hV=t.hex,this.hV;if("number"==typeof t)r=new x(String(t),10);else if(null!=t.int)r=new x(String(t.int),10);else{if(null==t.bigint)throw new Error("wrong parameter");r=t.bigint}return this.hV=e(r),this.hV},null!=t&&(this.params=t)},Gt(ot.asn1.DERInteger,ot.asn1.ASN1Object),ot.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ot.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.tohex()}ot.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0),t+="0000000".substr(0,e);for(var r="",i=0;i<t.length-1;i+=8){var n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},Gt(ot.asn1.DERBitString,ot.asn1.ASN1Object),ot.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=ot.asn1.ASN1Util.newObject(t.obj);t.hex=e.tohex()}ot.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Gt(ot.asn1.DEROctetString,ot.asn1.DERAbstractString),ot.asn1.DERNull=function(){ot.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Gt(ot.asn1.DERNull,ot.asn1.ASN1Object),ot.asn1.DERObjectIdentifier=function(t){ot.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){var e=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=parseInt(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",a=0;a<n;a++)s+="0";i=s+i;for(a=0;a<i.length-1;a+=7){var o=i.substr(a,7);a!=i.length-7&&(o="1"+o),r+=e(parseInt(o,2))}return r};try{if(!t.match(/^[0-9.]+$/))return null;var i="",n=t.split("."),s=40*parseInt(n[0],10)+parseInt(n[1],10);i+=e(s),n.splice(0,2);for(var a=0;a<n.length;a++)i+=r(n[a]);return i}catch(t){return null}}(t);if(null==e)throw new Error("malformed oid string: "+t);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=ot.asn1.x509.OID.name2oid(t);if(""===e)throw new Error("DERObjectIdentifier oidName undefined: "+t);this.setValueOidString(e)},this.setValueNameOrOid=function(t){t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t)},this.getFreshValueHex=function(){return this.hV},this.setByParam=function(t){"string"==typeof t?this.setValueNameOrOid(t):void 0!==t.oid?this.setValueNameOrOid(t.oid):void 0!==t.name?this.setValueNameOrOid(t.name):void 0!==t.hex&&this.setValueHex(t.hex)},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.DERObjectIdentifier,ot.asn1.ASN1Object),ot.asn1.DEREnumerated=function(t){ot.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=qt(t)},this.setByInteger=function(t){var e=new x(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},Gt(ot.asn1.DEREnumerated,ot.asn1.ASN1Object),ot.asn1.DERUTF8String=function(t){ot.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Gt(ot.asn1.DERUTF8String,ot.asn1.DERAbstractString),ot.asn1.DERNumericString=function(t){ot.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Gt(ot.asn1.DERNumericString,ot.asn1.DERAbstractString),ot.asn1.DERPrintableString=function(t){ot.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Gt(ot.asn1.DERPrintableString,ot.asn1.DERAbstractString),ot.asn1.DERTeletexString=function(t){ot.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Gt(ot.asn1.DERTeletexString,ot.asn1.DERAbstractString),ot.asn1.DERIA5String=function(t){ot.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Gt(ot.asn1.DERIA5String,ot.asn1.DERAbstractString),ot.asn1.DERVisibleString=function(t){ot.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="1a"},Gt(ot.asn1.DERVisibleString,ot.asn1.DERAbstractString),ot.asn1.DERBMPString=function(t){ot.asn1.DERBMPString.superclass.constructor.call(this,t),this.hT="1e"},Gt(ot.asn1.DERBMPString,ot.asn1.DERAbstractString),ot.asn1.DERUTCTime=function(t){ot.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.params=void 0,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{12}Z$/)&&!t.match(/^[0-9]{12}\.[0-9]+Z$/))throw new Error("malformed string for UTCTime: "+t);this.hV=ft(t)}else if(null!=t.str)this.hV=ft(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ft(this.formatDate(e,"utc",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ft(this.formatDate(t.date,"utc",r))}else t instanceof Date&&(this.hV=ft(this.formatDate(t,"utc")));if(null==this.hV)throw new Error("parameter not specified properly for UTCTime");return this.hV},null!=t&&this.setByParam(t)},Gt(ot.asn1.DERUTCTime,ot.asn1.DERAbstractTime),ot.asn1.DERGeneralizedTime=function(t){ot.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.params=t,this.getFreshValueHex=function(){var t=this.params;if(null==this.params&&(t={date:new Date}),"string"==typeof t){if(!t.match(/^[0-9]{14}Z$/)&&!t.match(/^[0-9]{14}\.[0-9]+Z$/))throw new Error("malformed string for GeneralizedTime: "+t);this.hV=ft(t)}else if(null!=t.str)this.hV=ft(t.str);else if(null==t.date&&1==t.millis){var e=new Date;this.hV=ft(this.formatDate(e,"gen",!0))}else if(null!=t.date&&t.date instanceof Date){var r=!0===t.millis;this.hV=ft(this.formatDate(t.date,"gen",r))}else t instanceof Date&&(this.hV=ft(this.formatDate(t,"gen")));if(null==this.hV)throw new Error("parameter not specified properly for GeneralizedTime");return this.hV},null!=t&&this.setByParam(t)},Gt(ot.asn1.DERGeneralizedTime,ot.asn1.DERAbstractTime),ot.asn1.DERSequence=function(t){ot.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].tohex()}return this.hV=t,this.hV}},Gt(ot.asn1.DERSequence,ot.asn1.DERAbstractStructured),ot.asn1.DERSet=function(t){ot.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.tohex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},Gt(ot.asn1.DERSet,ot.asn1.DERAbstractStructured),ot.asn1.DERTaggedObject=function(t){ot.asn1.DERTaggedObject.superclass.constructor.call(this);var e=ot.asn1,r=ct.getV,i=e.ASN1Util.newObject;this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.params={tag:"a0",explicit:!0},this.setASN1Object=function(t,e,r){this.params={tag:e,explicit:t,obj:r}},this.getFreshValueHex=function(){var t=this.params;if(null==t.explicit&&(t.explicit=!0),null!=t.tage&&(t.tag=t.tage,t.explicit=!0),null!=t.tagi&&(t.tag=t.tagi,t.explicit=!1),null!=t.str)this.hV=mt(t.str);else if(null!=t.hex)this.hV=t.hex;else{if(null==t.obj)throw new Error("str, hex nor obj not specified");var n;t.obj instanceof e.ASN1Object?n=t.obj.tohex():"object"==typeof t.obj&&(n=i(t.obj).tohex()),t.explicit?this.hV=n:this.hV=r(n,0)}return null==t.tag&&(t.tag="a0"),this.hT=t.tag,this.hTLV=null,this.isModified=!0,this.hV},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.DERTaggedObject,ot.asn1.ASN1Object);var ot,ht,ut,ct=new function(){};function lt(t){for(var e="",r=0;r<t.length;r++){var i=t[r].toString(16);1==i.length&&(i="0"+i),e+=i}return e}function ft(t){return lt(function(t){for(var e=new Array,r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}(t))}function pt(t){return t=(t=(t=t.replace(/\=/g,"")).replace(/\+/g,"-")).replace(/\//g,"_")}function gt(t){return t.length%4==2?t+="==":t.length%4==3&&(t+="="),t=(t=t.replace(/-/g,"+")).replace(/_/g,"/")}function dt(t){return t.length%2==1&&(t="0"+t),pt(m(t))}function vt(t){return y(gt(t))}function mt(t){return At(Ht(t)).toLowerCase()}function yt(t){try{return decodeURIComponent(Dt(t))}catch(t){return null}}function xt(t){return yt(function(t){for(var e=t.match(/.{1,2}/g),r=[],i=0;i<e.length;i++){var n=parseInt(e[i],16);161<=n&&n<=191?(r.push("c2"),r.push(e[i])):192<=n&&n<=255?(r.push("c3"),r.push((n-64).toString(16))):r.push(e[i])}return r.join("")}(t))}function St(t){for(var e="",r=0;r<t.length-1;r+=2)e+=String.fromCharCode(parseInt(t.substr(r,2),16));return e}function Et(t){for(var e="",r=0;r<t.length;r++)e+=("0"+t.charCodeAt(r).toString(16)).slice(-2);return e}function wt(t,e){return"-----BEGIN "+e+"-----\r\n"+function(t,e){return(t=t.replace(new RegExp("(.{"+e+"})","g"),"$1\r\n")).replace(/\s+$/,"")}(function(t){return m(t)}(t),64)+"\r\n-----END "+e+"-----\r\n"}function Ft(t,e){if(-1==t.indexOf("-----BEGIN "))throw new Error("can't find PEM header");return function(t){return y(t.replace(/[^0-9A-Za-z\/+=]*/g,""))}(t=void 0!==e?(t=t.replace(new RegExp("^[^]*-----BEGIN "+e+"-----"),"")).replace(new RegExp("-----END "+e+"-----[^]*$"),""):(t=t.replace(/^[^]*-----BEGIN [^-]+-----/,"")).replace(/-----END [^-]+-----[^]*$/,""))}function bt(t){return Math.round(function(t){var e,r,i,n,s,a,o,h,u,c;if(t=function(t){return t.match(/^[0-9]{12}Z$/)||t.match(/^[0-9]{12}[.][0-9]*Z$/)?t.match(/^[0-4]/)?"20"+t:"19"+t:t}(t),c=t.match(/^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)(|\.\d+)Z$/))return e=parseInt(c[1]),r=parseInt(c[2])-1,i=parseInt(c[3]),n=parseInt(c[4]),s=parseInt(c[5]),a=parseInt(c[6]),o=0,""!==(h=c[7])&&(u=(h.substr(1)+"00").substr(0,3),o=parseInt(u)),Date.UTC(e,r,i,n,s,a,o);throw new Error("unsupported zulu format: "+t)}(t)/1e3)}function At(t){return t.replace(/%/g,"")}function Dt(t){return t.replace(/(..)/g,"%$1")}function Ct(t){var e="malformed IPv6 address";if(!t.match(/^[0-9A-Fa-f:]+$/))throw e;var r=(t=t.toLowerCase()).split(":").length-1;if(r<2)throw e;var i=":".repeat(7-r+2),n=(t=t.replace("::",i)).split(":");if(8!=n.length)throw e;for(var s=0;s<8;s++)n[s]=("0000"+n[s]).slice(-4);return n.join("")}function It(t){if(!t.match(/^[0-9A-Fa-f]{32}$/))throw new Error("malformed IPv6 address: "+t);var e=(t=t.toLowerCase()).match(/.{1,4}/g);e=e.map(function(t){return t.replace(/^0+/,"")}),e=e.map(function(t){return""==t?"0":t});var r=(t=":"+e.join(":")+":").match(/:(0:){2,}/g);if(null==r)return t.slice(1,-1);var i=r.sort().slice(-1)[0];return"::"!=(t=t.replace(i.substr(0,i.length-1),":")).substr(0,2)&&(t=t.substr(1)),"::"!=t.substr(-2,2)&&(t=t.substr(0,t.length-1)),t}function Pt(t){var e=new Error("malformed hex value");if(!t.match(/^([0-9A-Fa-f][0-9A-Fa-f]){1,}$/))throw e;if(8==t.length){try{return parseInt(t.substr(0,2),16)+"."+parseInt(t.substr(2,2),16)+"."+parseInt(t.substr(4,2),16)+"."+parseInt(t.substr(6,2),16)}catch(t){throw e}}else{if(16!=t.length){if(32==t.length)return It(t);if(64==t.length){try{return It(t.substr(0,32))+"/"+Tt(t.substr(32))}catch(t){throw e}return}return t}try{return Pt(t.substr(0,8))+"/"+Tt(t.substr(8))}catch(t){throw e}}}function Tt(t){var e,r=new Error("malformed mask");try{e=new x(t,16).toString(2)}catch(t){throw r}if(!e.match(/^1*0*$/))throw r;return e.replace(/0+$/,"").length}function Rt(t){var e=new Error("malformed IP address");if(!(t=t.toLowerCase(t)).match(/^[0-9a-f.:/]+$/))throw e;if(!t.match(/^[0-9.]+$/)){var r;if(t.match(/^[0-9.]+\/[0-9]+$/))return Rt((r=t.split("/"))[0])+Nt(parseInt(r[1]),32);if(t.match(/^[0-9a-f:]+$/)&&-1!==t.indexOf(":"))return Ct(t);if(t.match(/^[0-9a-f:]+\/[0-9]+$/)&&-1!==t.indexOf(":"))return Ct((r=t.split("/"))[0])+Nt(parseInt(r[1]),128);throw e}var i=t.split(".");if(4!==i.length)throw e;var n="";try{for(var s=0;s<4;s++){n+=("0"+parseInt(i[s]).toString(16)).slice(-2)}return n}catch(t){throw e}}function Nt(t,e){return 32==e&&0==t?"00000000":128==e&&0==t?"00000000000000000000000000000000":new x(Array(t+1).join("1")+Array(e-t+1).join("0"),2).toString(16)}function Bt(t){var e=t.match(/.{4}/g).map(function(t){var e=parseInt(t.substr(0,2),16),r=parseInt(t.substr(2),16);if(0==e&r<128)return String.fromCharCode(r);if(e<8){var i=128|63&r;return yt((192|(7&e)<<3|(192&r)>>6).toString(16)+i.toString(16))}i=128|(15&e)<<2|(192&r)>>6;var n=128|63&r;return yt((224|(240&e)>>4).toString(16)+i.toString(16)+n.toString(16))});return e.join("")}function Ht(t){for(var e=encodeURIComponent(t),r="",i=0;i<e.length;i++)"%"==e[i]?(r+=e.substr(i,3),i+=2):r=r+"%"+ft(e[i]);return r}function Ot(t){return!(t.length%2!=0||!t.match(/^[0-9a-f]+$/)&&!t.match(/^[0-9A-F]+$/))}function jt(t){return!!t.match(/^[0-9A-Za-z-_.]+$/)}function Vt(t){return t.length%2==1?"0"+t:t.substr(0,1)>"7"?"00"+t:t}function Kt(t,e){if("string"!=typeof t||"string"!=typeof e)throw new Error("arguments shall be string");if(t.length!==e.length)throw new Error("input strings must have the same length");if("function"==typeof Buffer&&void 0!==Y){if(void 0!==Y.timingSafeEqual)return Y.timingSafeEqual(Buffer.from(t),Buffer.from(e));if(void 0!==Y.subtle&&Y.subtle.timingSafeEqual)return Y.subtle.timingSafeEqual(Buffer.from(t),Buffer.from(e))}return function(t,e){if("string"!=typeof t||"string"!=typeof e)throw new Error("arguments shall be string");if(t.length!==e.length)throw new Error("input strings must have the same length");const r=e.slice();for(var i=0,n=0;n<t.length;n++)i|=t.charCodeAt(n)^r.charCodeAt(n);return 0===i}(t,e)}function kt(t){if(!Ot(t))return null;try{var e=[],r=t.substr(0,2),i=parseInt(r,16);e[0]=new String(Math.floor(i/40)),e[1]=new String(i%40);for(var n=t.substr(2),s=[],a=0;a<n.length/2;a++)s.push(parseInt(n.substr(2*a,2),16));var o=[],h="";for(a=0;a<s.length;a++)128&s[a]?h+=Mt((127&s[a]).toString(2),7):(h+=Mt((127&s[a]).toString(2),7),o.push(new String(parseInt(h,2))),h="");var u=e.join(".");return o.length>0&&(u=u+"."+o.join(".")),u}catch(t){return null}}function Lt(t){return qt(new x(String(t),10))}function qt(t){var e=t.toString(16);if("-"!=e.substr(0,1))return e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e),e;var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",n=0;n<r;n++)i+="f";return e=new x(i,16).xor(t).add(x.ONE).toString(16).replace(/^-/,"")}ct.getLblen=function(t,e){if("8"!=t.substr(e+2,1))return 1;var r=parseInt(t.substr(e+3,1));return 0==r?-1:0<r&&r<10?r+1:-2},ct.getL=function(t,e){var r=ct.getLblen(t,e);return r<1?"":t.substr(e+2,2*r)},ct.getVblen=function(t,e){var r;return""==(r=ct.getL(t,e))?-1:("8"===r.substr(0,1)?new x(r.substr(2),16):new x(r,16)).intValue()},ct.getVidx=function(t,e){var r=ct.getLblen(t,e);return r<0?r:e+2*(r+1)},ct.getV=function(t,e){var r=ct.getVidx(t,e),i=ct.getVblen(t,e);return t.substr(r,2*i)},ct.getTLV=function(t,e){return t.substr(e,2)+ct.getL(t,e)+ct.getV(t,e)},ct.getTLVblen=function(t,e){return 2+2*ct.getLblen(t,e)+2*ct.getVblen(t,e)},ct.getNextSiblingIdx=function(t,e){return ct.getVidx(t,e)+2*ct.getVblen(t,e)},ct.getChildIdx=function(t,e){var r,i,n,s=ct,a=[];if((r=s.getVidx(t,e))+(i=2*s.getVblen(t,e))>t.length)throw new Error("too short ASN.1 value");"03"==t.substr(e,2)&&(r+=2,i-=2),n=0;for(var o=r;n<=i;){var h=s.getTLVblen(t,o);if(h<=0)throw new Error("malformed ASN.1: invalid TLV length");if((n+=h)<=i&&a.push(o),o+=h,n>=i)break}return a},ct.getNthChildIdx=function(t,e,r){return ct.getChildIdx(t,e)[r]},ct.getIdxbyList=function(t,e,r,i){var n,s,a=ct;return 0==r.length?void 0!==i&&t.substr(e,2)!==i?-1:e:(n=r.shift())>=(s=a.getChildIdx(t,e)).length?-1:a.getIdxbyList(t,s[n],r,i)},ct.getIdxbyListEx=function(t,e,r,i){var n,s,a=ct;if(0==r.length)return void 0!==i&&t.substr(e,2)!==i?-1:e;n=r.shift(),s=a.getChildIdx(t,e);for(var o=0,h=0;h<s.length;h++){var u=t.substr(s[h],2);if("number"==typeof n&&!a.isContextTag(u)&&o==n||"string"==typeof n&&a.isContextTag(u,n))return a.getIdxbyListEx(t,s[h],r,i);a.isContextTag(u)||o++}return-1},ct.getTLVbyList=function(t,e,r,i){var n=ct,s=n.getIdxbyList(t,e,r,i);return-1==s||s>=t.length?null:n.getTLV(t,s)},ct.getTLVbyListEx=function(t,e,r,i){var n=ct,s=n.getIdxbyListEx(t,e,r,i);return-1==s?null:n.getTLV(t,s)},ct.getVbyList=function(t,e,r,i,n){var s,a,o=ct;return-1==(s=o.getIdxbyList(t,e,r,i))||s>=t.length?null:(a=o.getV(t,s),!0===n&&(a=a.substr(2)),a)},ct.getVbyListEx=function(t,e,r,i,n){var s,a,o=ct;return-1==(s=o.getIdxbyListEx(t,e,r,i))?null:(a=o.getV(t,s),"03"==t.substr(s,2)&&!1!==n&&(a=a.substr(2)),a)},ct.getInt=function(t,e,r){null==r&&(r=-1);try{var i=t.substr(e,2);if("02"!=i&&"03"!=i)return r;var n=ct.getV(t,e);return"02"==i?parseInt(n,16):function(t){if(t.length%2!=0)return-1;if(t=t.toLowerCase(),null==t.match(/^[0-9a-f]+$/))return-1;try{var e=t.substr(0,2);if("00"==e)return parseInt(t.substr(2),16);var r=parseInt(e,16);if(r>7)return-1;var i=t.substr(2),n=parseInt(i,16).toString(2);"0"==n&&(n="00000000"),n=n.slice(0,0-r);var s=parseInt(n,2);return NaN==s?-1:s}catch(t){return-1}}(n)}catch(t){return r}},ct.getOID=function(t,e,r){null==r&&(r=null);try{return"06"!=t.substr(e,2)?r:kt(ct.getV(t,e))}catch(t){return r}},ct.getOIDName=function(t,e,r){null==r&&(r=null);try{var i=ct.getOID(t,e,r);if(i==r)return r;var n=ot.asn1.x509.OID.oid2name(i);return""==n?i:n}catch(t){return r}},ct.getString=function(t,e,r){null==r&&(r=null);try{return St(ct.getV(t,e))}catch(t){return r}},ct.hextooidstr=function(t){var e=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},r=[],i=t.substr(0,2),n=parseInt(i,16);r[0]=new String(Math.floor(n/40)),r[1]=new String(n%40);for(var s=t.substr(2),a=[],o=0;o<s.length/2;o++)a.push(parseInt(s.substr(2*o,2),16));var h=[],u="";for(o=0;o<a.length;o++)128&a[o]?u+=e((127&a[o]).toString(2),7):(u+=e((127&a[o]).toString(2),7),h.push(new String(parseInt(u,2))),u="");var c=r.join(".");return h.length>0&&(c=c+"."+h.join(".")),c},ct.dump=function(t,e,r,i){var n=ct,s=n.getV,a=n.dump,o=n.getChildIdx,h=t;t instanceof ot.asn1.ASN1Object&&(h=t.tohex());var u=function(t,e){return t.length<=2*e?t:t.substr(0,e)+"..(total "+t.length/2+"bytes).."+t.substr(t.length-e,e)};void 0===e&&(e={ommit_long_octet:32}),void 0===r&&(r=0),void 0===i&&(i="");var c,l=e.ommit_long_octet;if("01"==(c=h.substr(r,2)))return"00"==(f=s(h,r))?i+"BOOLEAN FALSE\n":i+"BOOLEAN TRUE\n";if("02"==c)return i+"INTEGER "+u(f=s(h,r),l)+"\n";if("03"==c){var f=s(h,r);if(n.isASN1HEX(f.substr(2))){var p=i+"BITSTRING, encapsulates\n";return p+=a(f.substr(2),e,0,i+" ")}return i+"BITSTRING "+u(f,l)+"\n"}if("04"==c){f=s(h,r);if(n.isASN1HEX(f)){p=i+"OCTETSTRING, encapsulates\n";return p+=a(f,e,0,i+" ")}return i+"OCTETSTRING "+u(f,l)+"\n"}if("05"==c)return i+"NULL\n";if("06"==c){var g=s(h,r),d=ot.asn1.ASN1Util.oidHexToInt(g),v=ot.asn1.x509.OID.oid2name(d),m=d.replace(/\./g," ");return""!=v?i+"ObjectIdentifier "+v+" ("+m+")\n":i+"ObjectIdentifier ("+m+")\n"}if("0a"==c)return i+"ENUMERATED "+parseInt(s(h,r))+"\n";if("0c"==c)return i+"UTF8String '"+yt(s(h,r))+"'\n";if("13"==c)return i+"PrintableString '"+yt(s(h,r))+"'\n";if("14"==c)return i+"TeletexString '"+yt(s(h,r))+"'\n";if("16"==c)return i+"IA5String '"+yt(s(h,r))+"'\n";if("17"==c)return i+"UTCTime "+yt(s(h,r))+"\n";if("18"==c)return i+"GeneralizedTime "+yt(s(h,r))+"\n";if("1a"==c)return i+"VisualString '"+yt(s(h,r))+"'\n";if("1e"==c)return i+"BMPString '"+Bt(s(h,r))+"'\n";if("30"==c){if("3000"==h.substr(r,4))return i+"SEQUENCE {}\n";p=i+"SEQUENCE\n";var y=e;if((2==(E=o(h,r)).length||3==E.length)&&"06"==h.substr(E[0],2)&&"04"==h.substr(E[E.length-1],2)){v=n.oidname(s(h,E[0]));var x=JSON.parse(JSON.stringify(e));x.x509ExtName=v,y=x}for(var S=0;S<E.length;S++)p+=a(h,y,E[S],i+" ");return p}if("31"==c){p=i+"SET\n";var E=o(h,r);for(S=0;S<E.length;S++)p+=a(h,e,E[S],i+" ");return p}if(128&(c=parseInt(c,16))){var w=31&c;if(32&c){for(p=i+"["+w+"]\n",E=o(h,r),S=0;S<E.length;S++)p+=a(h,e,E[S],i+" ");return p}f=s(h,r);if(ct.isASN1HEX(f)){var p=i+"["+w+"]\n";return p+=a(f,e,0,i+" ")}return("68747470"==f.substr(0,8)||"subjectAltName"===e.x509ExtName&&2==w)&&(f=yt(f)),p=i+"["+w+"] "+f+"\n"}return i+"UNKNOWN("+c+") "+s(h,r)+"\n"},ct.parse=function(t){var e=ct,r=e.parse,i=e.isASN1HEX,n=e.getV,s=e.getTLV,a=e.getChildIdx,o=ot.asn1,h=o.ASN1Util.oidHexToInt,u=o.x509.OID.oid2name,c=yt,l=Bt,f=xt,p={"0c":"utf8str",12:"numstr",13:"prnstr",14:"telstr",16:"ia5str",17:"utctime",18:"gentime","1a":"visstr","1e":"bmpstr",30:"seq",31:"set"},g=t.substr(0,2),d={},v=n(t,0);if("01"==g)return"0101ff"==t?{bool:!0}:{bool:!1};if("02"==g)return{int:{hex:v}};if("03"==g)try{if("00"!=v.substr(0,2))throw"not encap";var m=v.substr(2);if(!i(m))throw"not encap";return{bitstr:{obj:r(m)}}}catch(t){var y=null;return v.length<=10&&(y=function(t){if("string"!=typeof t)return null;if(t.length%2!=0)return null;if(!t.match(/^[0-9a-f]+$/))return null;try{var e=parseInt(t.substr(0,2),16);if(e<0||7<e)return null;for(var r=t.substr(2),i="",n=0;n<r.length;n+=2){var s=r.substr(n,2),a=parseInt(s,16).toString(2);i+=a=("0000000"+a).slice(-8)}return i.substr(0,i.length-e)}catch(t){return null}}(v)),null==y?{bitstr:{hex:v}}:{bitstr:{bin:y}}}else if("04"==g)try{if(!i(v))throw"not encap";return{octstr:{obj:r(v)}}}catch(t){return{octstr:{hex:v}}}else{if("05"==g)return{null:""};if("06"==g){var x=h(v),S=u(x);return""==S?{oid:x}:{oid:S}}if("0a"==g)return v.length>4?{enum:{hex:v}}:{enum:parseInt(v,16)};if("30"==g||"31"==g)return d[p[g]]=function(t){for(var e=[],i=a(t,0),n=0;n<i.length;n++){var o=i[n],h=s(t,o),u=r(h);e.push(u)}return e}(t),d;if("14"==g){var E=f(v);return d[p[g]]={str:E},d}if("1e"==g){E=l(v);return d[p[g]]={str:E},d}if(-1!=":0c:12:13:16:17:18:1a:".indexOf(g)){E=c(v);return d[p[g]]={str:E},d}if(g.match(/^8[0-9]$/))return null==(E=c(v))|""==E||null!=E.match(/[\x00-\x1F\x7F-\x9F]/)||null!=E.match(/[\u0000-\u001F\u0080–\u009F]/)?{tag:{tag:g,explicit:!1,hex:v}}:{tag:{tag:g,explicit:!1,str:E}};if(!g.match(/^a[0-9]$/)){var w=new ot.asn1.ASN1Object;return w.hV=v,{asn1:{tlv:g+w.getLengthHexFromValue()+v}}}try{if(!i(v))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(v)}}}catch(t){return{tag:{tag:g,explicit:!0,hex:v}}}}},ct.isContextTag=function(t,e){var r,i;t=t.toLowerCase();try{r=parseInt(t,16)}catch(t){return-1}if(void 0===e)return 128==(192&r);try{return null!=e.match(/^\[[0-9]+\]$/)&&(!((i=parseInt(e.substr(1,e.length-1),10))>31)&&(128==(192&r)&&(31&r)==i))}catch(t){return!1}},ct.isASN1HEX=function(t){var e=ct;if(t.length%2==1)return!1;var r=e.getVblen(t,0),i=t.substr(0,2),n=e.getL(t,0);return t.length-i.length-n.length==2*r},ct.checkStrictDER=function(t,e,r,i,n){var s=ct;if(void 0===r){if("string"!=typeof t)throw new Error("not hex string");if(t=t.toLowerCase(),!ot.lang.String.isHex(t))throw new Error("not hex string");r=t.length,n=(i=t.length/2)<128?1:Math.ceil(i.toString(16))+1}if(s.getL(t,e).length>2*n)throw new Error("L of TLV too long: idx="+e);var a=s.getVblen(t,e);if(a>i)throw new Error("value of L too long than hex: idx="+e);var o=s.getTLV(t,e),h=o.length-2-s.getL(t,e).length;if(h!==2*a)throw new Error("V string length and L's value not the same:"+h+"/"+2*a);if(0===e&&t.length!=o.length)throw new Error("total length and TLV length unmatch:"+t.length+"!="+o.length);var u=t.substr(e,2);if("02"===u){var c=s.getVidx(t,e);if("00"==t.substr(c,2)&&t.charCodeAt(c+2)<56)throw new Error("not least zeros for DER INTEGER")}if(32&parseInt(u,16)){for(var l=s.getVblen(t,e),f=0,p=s.getChildIdx(t,e),g=0;g<p.length;g++){f+=s.getTLV(t,p[g]).length,s.checkStrictDER(t,p[g],r,i,n)}if(2*l!=f)throw new Error("sum of children's TLV length and L unmatch: "+2*l+"!="+f)}},ct.oidname=function(t){var e=ot.asn1;ot.lang.String.isHex(t)&&(t=e.ASN1Util.oidHexToInt(t));var r=e.x509.OID.oid2name(t);return""===r&&(r=t),r},void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),void 0!==ot.asn1.x509&&ot.asn1.x509||(ot.asn1.x509={}),ot.asn1.x509.Certificate=function(t){ot.asn1.x509.Certificate.superclass.constructor.call(this);var e=ot.asn1,r=e.DERBitString,i=e.DERSequence,n=e.x509,s=n.TBSCertificate,a=n.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.sigalg;null!=t.sigalg.name&&(e=t.sigalg.name);var r=t.tbsobj.tohex(),i=new ot.crypto.Signature({alg:e});i.init(t.cakey),i.updateHex(r),t.sighex=i.sign()},this.getPEM=function(){return wt(this.tohex(),"CERTIFICATE")},this.tohex=function(){var t=this.params;if(null!=t.tbsobj&&null!=t.tbsobj||(t.tbsobj=new s(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new a({name:t.sigalg})),e.push(new r({hex:"00"+t.sighex})),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Gt(ot.asn1.x509.Certificate,ot.asn1.ASN1Object),ot.asn1.x509.TBSCertificate=function(t){ot.asn1.x509.TBSCertificate.superclass.constructor.call(this);var e=ot.asn1,r=e.x509,i=e.DERTaggedObject,n=e.DERInteger,s=e.DERSequence,a=r.AlgorithmIdentifier,o=r.Time,h=r.X500Name,u=r.Extensions,c=r.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=[],e=this.params;if(null!=e.version||1!=e.version){var r=2;null!=e.version&&(r=e.version-1);var l=new i({obj:new n({int:r})});t.push(l)}return t.push(new n(e.serial)),t.push(new a({name:e.sigalg})),t.push(new h(e.issuer)),t.push(new s({array:[new o(e.notbefore),new o(e.notafter)]})),t.push(new h(e.subject)),t.push(new c(zt.getKey(e.sbjpubkey))),void 0!==e.ext&&e.ext.length>0&&t.push(new i({tag:"a3",obj:new u(e.ext)})),new ot.asn1.DERSequence({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.TBSCertificate,ot.asn1.ASN1Object),ot.asn1.x509.Extensions=function(t){ot.asn1.x509.Extensions.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,i=e.x509;this.aParam=[],this.setByParam=function(t){this.aParam=t},this.tohex=function(){for(var t=[],e=0;e<this.aParam.length;e++){var n=this.aParam[e],s=n.extname,a=null;if(null!=n.extn)a=new i.PrivateExtension(n);else if("subjectKeyIdentifier"==s)a=new i.SubjectKeyIdentifier(n);else if("keyUsage"==s)a=new i.KeyUsage(n);else if("subjectAltName"==s)a=new i.SubjectAltName(n);else if("issuerAltName"==s)a=new i.IssuerAltName(n);else if("basicConstraints"==s)a=new i.BasicConstraints(n);else if("nameConstraints"==s)a=new i.NameConstraints(n);else if("cRLDistributionPoints"==s)a=new i.CRLDistributionPoints(n);else if("certificatePolicies"==s)a=new i.CertificatePolicies(n);else if("policyMappings"==s)a=new i.PolicyMappings(n);else if("policyConstraints"==s)a=new i.PolicyConstraints(n);else if("inhibitAnyPolicy"==s)a=new i.InhibitAnyPolicy(n);else if("authorityKeyIdentifier"==s)a=new i.AuthorityKeyIdentifier(n);else if("extKeyUsage"==s)a=new i.ExtKeyUsage(n);else if("authorityInfoAccess"==s)a=new i.AuthorityInfoAccess(n);else if("cRLNumber"==s)a=new i.CRLNumber(n);else if("cRLReason"==s)a=new i.CRLReason(n);else if("ocspNonce"==s)a=new i.OCSPNonce(n);else if("ocspNoCheck"==s)a=new i.OCSPNoCheck(n);else if("adobeTimeStamp"==s)a=new i.AdobeTimeStamp(n);else{if("subjectDirectoryAttributes"!=s)throw new Error("extension not supported:"+JSON.stringify(n));a=new i.SubjectDirectoryAttributes(n)}null!=a&&t.push(a)}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.x509.Extensions,ot.asn1.ASN1Object),ot.asn1.x509.Extension=function(t){ot.asn1.x509.Extension.superclass.constructor.call(this);var e=ot.asn1,r=e.DERObjectIdentifier,i=e.DEROctetString,n=e.DERBoolean,s=e.DERSequence;this.tohex=function(){var t=new r({oid:this.oid}),e=new i({hex:this.getExtnValueHex()}),a=new Array;return a.push(t),this.critical&&a.push(new n),a.push(e),new s({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.critical=!1,void 0!==t&&void 0!==t.critical&&(this.critical=t.critical)},Gt(ot.asn1.x509.Extension,ot.asn1.ASN1Object),ot.asn1.x509.KeyUsage=function(t){ot.asn1.x509.KeyUsage.superclass.constructor.call(this,t);var e=Error,r={digitalSignature:0,nonRepudiation:1,keyEncipherment:2,dataEncipherment:3,keyAgreement:4,keyCertSign:5,cRLSign:6,encipherOnly:7,decipherOnly:8};this.getExtnValueHex=function(){var t=this.getBinValue();return this.asn1ExtnValue=new ot.asn1.DERBitString({bin:t}),this.asn1ExtnValue.tohex()},this.getBinValue=function(){var t=this.params;if("object"!=typeof t||"object"!=typeof t.names&&"string"!=typeof t.bin)throw new e("parameter not yet set");if(null!=t.names)return Ut(t.names,r);if(null!=t.bin)return t.bin;throw new e("parameter not set properly")},this.oid="2.5.29.15",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.KeyUsage,ot.asn1.x509.Extension),ot.asn1.x509.BasicConstraints=function(t){ot.asn1.x509.BasicConstraints.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERBoolean,i=e.DERInteger,n=e.DERSequence;this.getExtnValueHex=function(){var t=new Array;this.cA&&t.push(new r),this.pathLen>-1&&t.push(new i({int:this.pathLen}));var e=new n({array:t});return this.asn1ExtnValue=e,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,void 0!==t&&(void 0!==t.cA&&(this.cA=t.cA),void 0!==t.pathLen&&(this.pathLen=t.pathLen))},Gt(ot.asn1.x509.BasicConstraints,ot.asn1.x509.Extension),ot.asn1.x509.CRLDistributionPoints=function(t){ot.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,t);var e=ot.asn1,r=e.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(t){for(var i=[],n=0;n<t.length;n++)if(t[n]instanceof ot.asn1.ASN1Object)i.push(t[n]);else{var s=new r.DistributionPoint(t[n]);i.push(s)}this.asn1ExtnValue=new e.DERSequence({array:i})},this.setByOneURI=function(t){var e=new r.DistributionPoint({fulluri:t});this.setByDPArray([e])},this.oid="2.5.29.31",void 0!==t&&(void 0!==t.array?this.setByDPArray(t.array):void 0!==t.uri&&this.setByOneURI(t.uri))},Gt(ot.asn1.x509.CRLDistributionPoints,ot.asn1.x509.Extension),ot.asn1.x509.DistributionPoint=function(t){ot.asn1.x509.DistributionPoint.superclass.constructor.call(this);var e=ot.asn1,r=e.x509.DistributionPointName;this.tohex=function(){var t=new e.DERSequence;if(null!=this.asn1DP){var r=new e.DERTaggedObject({explicit:!0,tag:"a0",obj:this.asn1DP});t.appendASN1Object(r)}return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.dpobj?this.asn1DP=t.dpobj:void 0!==t.dpname?this.asn1DP=new r(t.dpname):void 0!==t.fulluri&&(this.asn1DP=new r({full:[{uri:t.fulluri}]})))},Gt(ot.asn1.x509.DistributionPoint,ot.asn1.ASN1Object),ot.asn1.x509.DistributionPointName=function(t){ot.asn1.x509.DistributionPointName.superclass.constructor.call(this);var e=ot.asn1,r=e.DERTaggedObject;if(this.tohex=function(){if("full"!=this.type)throw new Error("currently type shall be 'full': "+this.type);return this.asn1Obj=new r({explicit:!1,tag:this.tag,obj:this.asn1V}),this.hTLV=this.asn1Obj.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t)if(e.x509.GeneralNames.prototype.isPrototypeOf(t))this.type="full",this.tag="a0",this.asn1V=t;else{if(void 0===t.full)throw new Error("This class supports GeneralNames only as argument");this.type="full",this.tag="a0",this.asn1V=new e.x509.GeneralNames(t.full)}},Gt(ot.asn1.x509.DistributionPointName,ot.asn1.ASN1Object),ot.asn1.x509.CertificatePolicies=function(t){ot.asn1.x509.CertificatePolicies.superclass.constructor.call(this,t);var e=ot.asn1,r=e.x509,i=e.DERSequence,n=r.PolicyInformation;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++)t.push(new n(this.params.array[e]));var r=new i({array:t});return this.asn1ExtnValue=r,this.asn1ExtnValue.tohex()},this.oid="2.5.29.32",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.CertificatePolicies,ot.asn1.x509.Extension),ot.asn1.x509.PolicyInformation=function(t){ot.asn1.x509.PolicyInformation.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=e.x509.PolicyQualifierInfo;this.params=null,this.tohex=function(){if(void 0===this.params.policyoid&&void 0===this.params.array)throw new Error("parameter oid and array missing");var t=[new i(this.params.policyoid)];if(void 0!==this.params.array){for(var e=[],s=0;s<this.params.array.length;s++)e.push(new n(this.params.array[s]));e.length>0&&t.push(new r({array:e}))}return new r({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.PolicyInformation,ot.asn1.ASN1Object),ot.asn1.x509.PolicyQualifierInfo=function(t){ot.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERSequence,i=e.DERIA5String,n=e.DERObjectIdentifier,s=e.x509.UserNotice;this.params=null,this.tohex=function(){return void 0!==this.params.cps?new r({array:[new n({oid:"1.3.6.1.5.5.7.2.1"}),new i({str:this.params.cps})]}).tohex():null!=this.params.unotice?new r({array:[new n({oid:"1.3.6.1.5.5.7.2.2"}),new s(this.params.unotice)]}).tohex():void 0},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.PolicyQualifierInfo,ot.asn1.ASN1Object),ot.asn1.x509.UserNotice=function(t){ot.asn1.x509.UserNotice.superclass.constructor.call(this,t);var e=ot.asn1.DERSequence,r=ot.asn1.x509.DisplayText,i=ot.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var t=[];return void 0!==this.params.noticeref&&t.push(new i(this.params.noticeref)),void 0!==this.params.exptext&&t.push(new r(this.params.exptext)),new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.UserNotice,ot.asn1.ASN1Object),ot.asn1.x509.NoticeReference=function(t){ot.asn1.x509.NoticeReference.superclass.constructor.call(this,t);var e=ot.asn1.DERSequence,r=ot.asn1.DERInteger,i=ot.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var t=[];if(void 0!==this.params.org&&t.push(new i(this.params.org)),void 0!==this.params.noticenum){for(var n=[],s=this.params.noticenum,a=0;a<s.length;a++)n.push(new r(s[a]));t.push(new e({array:n}))}if(0==t.length)throw new Error("parameter is empty");return new e({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.NoticeReference,ot.asn1.ASN1Object),ot.asn1.x509.DisplayText=function(t){ot.asn1.x509.DisplayText.superclass.constructor.call(this,t),this.hT="0c",void 0!==t&&("ia5"===t.type?this.hT="16":"vis"===t.type?this.hT="1a":"bmp"===t.type&&(this.hT="1e"))},Gt(ot.asn1.x509.DisplayText,ot.asn1.DERAbstractString),ot.asn1.x509.PolicyMappings=function(t){ot.asn1.x509.PolicyMappings.superclass.constructor.call(this,t);var e=ot.asn1.ASN1Util.newObject;this.params=null,this.getExtnValueHex=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var n=t.array[i];r.push({seq:[{oid:n[0]},{oid:n[1]}]})}return this.asn1ExtnValue=e({seq:r}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.33",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.PolicyMappings,ot.asn1.x509.Extension),ot.asn1.x509.PolicyConstraints=function(t){ot.asn1.x509.PolicyConstraints.superclass.constructor.call(this,t);var e=ot.asn1.ASN1Util.newObject;this.params=null,this.getExtnValueHex=function(){var t=this.params,r=[];return null!=t.reqexp&&r.push({tag:{tagi:"80",obj:{int:t.reqexp}}}),null!=t.inhibit&&r.push({tag:{tagi:"81",obj:{int:t.inhibit}}}),this.asn1ExtnValue=e({seq:r}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.36",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.PolicyConstraints,ot.asn1.x509.Extension),ot.asn1.x509.InhibitAnyPolicy=function(t){ot.asn1.x509.InhibitAnyPolicy.superclass.constructor.call(this,t);var e=ot.asn1.ASN1Util.newObject;this.params=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=e({int:this.params.skip}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.54",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.InhibitAnyPolicy,ot.asn1.x509.Extension),ot.asn1.x509.NameConstraints=function(t){ot.asn1.x509.NameConstraints.superclass.constructor.call(this,t);var e=ot.asn1,r=e.x509,i=e.ASN1Util.newObject,n=r.GeneralSubtree;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[];if(null!=t.permit&&null!=t.permit.length){for(var r=[],s=0;s<t.permit.length;s++)r.push(new n(t.permit[s]));e.push({tag:{tagi:"a0",obj:{seq:r}}})}if(null!=t.exclude&&null!=t.exclude.length){var a=[];for(s=0;s<t.exclude.length;s++)a.push(new n(t.exclude[s]));e.push({tag:{tagi:"a1",obj:{seq:a}}})}return this.asn1ExtnValue=i({seq:e}),this.asn1ExtnValue.tohex()},this.oid="2.5.29.30",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.NameConstraints,ot.asn1.x509.Extension),ot.asn1.x509.GeneralSubtree=function(t){ot.asn1.x509.GeneralSubtree.superclass.constructor.call(this);var e=ot.asn1,r=e.x509.GeneralName,i=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,e=[new r(t)];return null!=t.min&&e.push({tag:{tagi:"80",obj:{int:t.min}}}),null!=t.max&&e.push({tag:{tagi:"81",obj:{int:t.max}}}),i({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.GeneralSubtree,ot.asn1.ASN1Object),ot.asn1.x509.ExtKeyUsage=function(t){ot.asn1.x509.ExtKeyUsage.superclass.constructor.call(this,t);var e=ot.asn1;this.setPurposeArray=function(t){this.asn1ExtnValue=new e.DERSequence;for(var r=0;r<t.length;r++){var i=new e.DERObjectIdentifier(t[r]);this.asn1ExtnValue.appendASN1Object(i)}},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.37",void 0!==t&&void 0!==t.array&&this.setPurposeArray(t.array)},Gt(ot.asn1.x509.ExtKeyUsage,ot.asn1.x509.Extension),ot.asn1.x509.AuthorityKeyIdentifier=function(t){ot.asn1.x509.AuthorityKeyIdentifier.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERTaggedObject,i=e.x509.GeneralNames;this.asn1KID=null,this.asn1CertIssuer=null,this.asn1CertSN=null,this.getExtnValueHex=function(){var t=new Array;this.asn1KID&&t.push(new r({explicit:!1,tag:"80",obj:this.asn1KID})),this.asn1CertIssuer&&t.push(new r({explicit:!1,tag:"a1",obj:new i([{dn:this.asn1CertIssuer}])})),this.asn1CertSN&&t.push(new r({explicit:!1,tag:"82",obj:this.asn1CertSN}));var n=new e.DERSequence({array:t});return this.asn1ExtnValue=n,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new ot.asn1.DEROctetString(t);else if("object"==typeof t&&ot.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN ")){var e=t;"string"==typeof t&&(e=zt.getKey(t));var r=zt.getKeyID(e);this.asn1KID=new ot.asn1.DEROctetString({hex:r})}},this.setCertIssuerByParam=function(t){void 0!==t.str||void 0!==t.ldapstr||void 0!==t.hex||void 0!==t.certsubject||void 0!==t.certissuer?this.asn1CertIssuer=new ot.asn1.x509.X500Name(t):"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&-1!=t.indexOf("CERTIFICATE")&&(this.asn1CertIssuer=new ot.asn1.x509.X500Name({certissuer:t}))},this.setCertSNByParam=function(t){if(void 0!==t.str||void 0!==t.bigint||void 0!==t.hex)this.asn1CertSN=new ot.asn1.DERInteger(t);else if("string"==typeof t&&-1!=t.indexOf("BEGIN ")&&t.indexOf("CERTIFICATE")){var e=new $t;e.readCertPEM(t);var r=e.getSerialNumberHex();this.asn1CertSN=new ot.asn1.DERInteger({hex:r})}},this.oid="2.5.29.35",void 0!==t&&(void 0!==t.kid&&this.setKIDByParam(t.kid),void 0!==t.issuer&&this.setCertIssuerByParam(t.issuer),void 0!==t.sn&&this.setCertSNByParam(t.sn),void 0!==t.issuersn&&"string"==typeof t.issuersn&&-1!=t.issuersn.indexOf("BEGIN ")&&t.issuersn.indexOf("CERTIFICATE")&&(this.setCertSNByParam(t.issuersn),this.setCertIssuerByParam(t.issuersn)))},Gt(ot.asn1.x509.AuthorityKeyIdentifier,ot.asn1.x509.Extension),ot.asn1.x509.SubjectKeyIdentifier=function(t){ot.asn1.x509.SubjectKeyIdentifier.superclass.constructor.call(this,t);var e=ot.asn1.DEROctetString;this.asn1KID=null,this.getExtnValueHex=function(){return this.asn1ExtnValue=this.asn1KID,this.asn1ExtnValue.tohex()},this.setKIDByParam=function(t){if(void 0!==t.str||void 0!==t.hex)this.asn1KID=new e(t);else if("object"==typeof t&&ot.crypto.Util.isKey(t)||"string"==typeof t&&-1!=t.indexOf("BEGIN")){var r=t;"string"==typeof t&&(r=zt.getKey(t));var i=zt.getKeyID(r);this.asn1KID=new ot.asn1.DEROctetString({hex:i})}},this.oid="2.5.29.14",void 0!==t&&void 0!==t.kid&&this.setKIDByParam(t.kid)},Gt(ot.asn1.x509.SubjectKeyIdentifier,ot.asn1.x509.Extension),ot.asn1.x509.AuthorityInfoAccess=function(t){ot.asn1.x509.AuthorityInfoAccess.superclass.constructor.call(this,t),this.setAccessDescriptionArray=function(t){for(var e=new Array,r=ot.asn1,i=r.DERSequence,n=r.DERObjectIdentifier,s=r.x509.GeneralName,a=0;a<t.length;a++){var o,h=t[a];if(void 0!==h.ocsp)o=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.1"}),new s({uri:h.ocsp})]});else{if(void 0===h.caissuer)throw new Error("unknown AccessMethod parameter: "+JSON.stringify(h));o=new i({array:[new n({oid:"1.3.6.1.5.5.7.48.2"}),new s({uri:h.caissuer})]})}e.push(o)}this.asn1ExtnValue=new i({array:e})},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.1.1",void 0!==t&&void 0!==t.array&&this.setAccessDescriptionArray(t.array)},Gt(ot.asn1.x509.AuthorityInfoAccess,ot.asn1.x509.Extension),ot.asn1.x509.SubjectAltName=function(t){ot.asn1.x509.SubjectAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new ot.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.17",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Gt(ot.asn1.x509.SubjectAltName,ot.asn1.x509.Extension),ot.asn1.x509.IssuerAltName=function(t){ot.asn1.x509.IssuerAltName.superclass.constructor.call(this,t),this.setNameArray=function(t){this.asn1ExtnValue=new ot.asn1.x509.GeneralNames(t)},this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.oid="2.5.29.18",void 0!==t&&void 0!==t.array&&this.setNameArray(t.array)},Gt(ot.asn1.x509.IssuerAltName,ot.asn1.x509.Extension),ot.asn1.x509.SubjectDirectoryAttributes=function(t){ot.asn1.x509.SubjectDirectoryAttributes.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERSequence,i=e.ASN1Util.newObject,n=e.x509.OID.name2oid;this.params=null,this.getExtnValueHex=function(){for(var t=[],e=0;e<this.params.array.length;e++){var s=this.params.array[e];if(null==s.attr||null==s.array){var a={seq:[{oid:"1.2.3.4"},{set:[{utf8str:"DE"}]}]};if("dateOfBirth"==s.attr)a.seq[0].oid=n(s.attr),a.seq[1].set[0]={gentime:s.str};else if("placeOfBirth"==s.attr)a.seq[0].oid=n(s.attr),a.seq[1].set[0]={utf8str:s.str};else if("gender"==s.attr)a.seq[0].oid=n(s.attr),a.seq[1].set[0]={prnstr:s.str};else if("countryOfCitizenship"==s.attr)a.seq[0].oid=n(s.attr),a.seq[1].set[0]={prnstr:s.str};else{if("countryOfResidence"!=s.attr)throw new Error("unsupported attribute: "+s.attr);a.seq[0].oid=n(s.attr),a.seq[1].set[0]={prnstr:s.str}}t.push(new i(a))}else{var o={seq:[{oid:s.attr},{set:s.array}]};t.push(i(o))}}var h=new r({array:t});return this.asn1ExtnValue=h,this.asn1ExtnValue.tohex()},this.oid="2.5.29.9",void 0!==t&&(this.params=t)},Gt(ot.asn1.x509.SubjectDirectoryAttributes,ot.asn1.x509.Extension),ot.asn1.x509.PrivateExtension=function(t){ot.asn1.x509.PrivateExtension.superclass.constructor.call(this,t);var e=ot,r=e.lang.String.isHex,i=e.asn1,n=i.x509.OID.name2oid,s=i.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.oid=n(t.extname),this.params=t},this.getExtnValueHex=function(){if(null==this.params.extname||null==this.params.extn)throw new Error("extname or extnhex not specified");var t=this.params.extn;if("string"==typeof t&&r(t))return t;if("object"==typeof t)try{return s(t).tohex()}catch(t){}throw new Error("unsupported extn value")},null!=t&&this.setByParam(t)},Gt(ot.asn1.x509.PrivateExtension,ot.asn1.x509.Extension),ot.asn1.x509.CRL=function(t){ot.asn1.x509.CRL.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,i=e.DERBitString,n=e.x509,s=n.AlgorithmIdentifier,a=n.TBSCertList;this.params=void 0,this.setByParam=function(t){this.params=t},this.sign=function(){var t=new a(this.params).tohex(),e=new ot.crypto.Signature({alg:this.params.sigalg});e.init(this.params.cakey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return wt(this.tohex(),"X509 CRL")},this.tohex=function(){var t=this.params;if(null==t.tbsobj&&(t.tbsobj=new a(t)),null==t.sighex&&null!=t.cakey&&this.sign(),null==t.sighex)throw new Error("sighex or cakey parameter not defined");var e=[];return e.push(t.tbsobj),e.push(new s({name:t.sigalg})),e.push(new i({hex:"00"+t.sighex})),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&(this.params=t)},Gt(ot.asn1.x509.CRL,ot.asn1.ASN1Object),ot.asn1.x509.TBSCertList=function(t){ot.asn1.x509.TBSCertList.superclass.constructor.call(this);var e=ot.asn1,r=e.DERInteger,i=e.DERSequence,n=e.DERTaggedObject,s=e.x509,a=s.AlgorithmIdentifier,o=s.Time,h=s.Extensions,u=s.X500Name;this.params=null,this.setByParam=function(t){this.params=t},this.getRevCertSequence=function(){for(var t=[],e=this.params.revcert,n=0;n<e.length;n++){var s=[new r(e[n].sn),new o(e[n].date)];null!=e[n].ext&&s.push(new h(e[n].ext)),t.push(new i({array:s}))}return new i({array:t})},this.tohex=function(){var t=[],e=this.params;if(null!=e.version){var s=e.version-1,c=new r({int:s});t.push(c)}if(t.push(new a({name:e.sigalg})),t.push(new u(e.issuer)),t.push(new o(e.thisupdate)),null!=e.nextupdate&&t.push(new o(e.nextupdate)),null!=e.revcert&&t.push(this.getRevCertSequence()),null!=e.ext){var l=new h(e.ext);t.push(new n({tag:"a0",explicit:!0,obj:l}))}return new i({array:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.TBSCertList,ot.asn1.ASN1Object),ot.asn1.x509.CRLEntry=function(t){ot.asn1.x509.CRLEntry.superclass.constructor.call(this);var e=ot.asn1;this.setCertSerial=function(t){this.sn=new e.DERInteger(t)},this.setRevocationDate=function(t){this.time=new e.x509.Time(t)},this.tohex=function(){var t=new e.DERSequence({array:[this.sn,this.time]});return this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.time&&this.setRevocationDate(t.time),void 0!==t.sn&&this.setCertSerial(t.sn))},Gt(ot.asn1.x509.CRLEntry,ot.asn1.ASN1Object),ot.asn1.x509.CRLNumber=function(t){ot.asn1.x509.CRLNumber.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ot.asn1.DERInteger(this.params.num),this.asn1ExtnValue.tohex()},this.oid="2.5.29.20",null!=t&&(this.params=t)},Gt(ot.asn1.x509.CRLNumber,ot.asn1.x509.Extension),ot.asn1.x509.CRLReason=function(t){ot.asn1.x509.CRLReason.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ot.asn1.DEREnumerated(this.params.code),this.asn1ExtnValue.tohex()},this.oid="2.5.29.21",null!=t&&(this.params=t)},Gt(ot.asn1.x509.CRLReason,ot.asn1.x509.Extension),ot.asn1.x509.OCSPNonce=function(t){ot.asn1.x509.OCSPNonce.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ot.asn1.DEROctetString(this.params),this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.2",null!=t&&(this.params=t)},Gt(ot.asn1.x509.OCSPNonce,ot.asn1.x509.Extension),ot.asn1.x509.OCSPNoCheck=function(t){ot.asn1.x509.OCSPNoCheck.superclass.constructor.call(this,t),this.params=void 0,this.getExtnValueHex=function(){return this.asn1ExtnValue=new ot.asn1.DERNull,this.asn1ExtnValue.tohex()},this.oid="1.3.6.1.5.5.7.48.1.5",null!=t&&(this.params=t)},Gt(ot.asn1.x509.OCSPNoCheck,ot.asn1.x509.Extension),ot.asn1.x509.AdobeTimeStamp=function(t){ot.asn1.x509.AdobeTimeStamp.superclass.constructor.call(this,t);var e=ot.asn1,r=e.DERInteger,i=e.DERBoolean,n=e.DERSequence,s=e.x509.GeneralName;this.params=null,this.getExtnValueHex=function(){var t=this.params,e=[new r(1)];return e.push(new s({uri:t.uri})),null!=t.reqauth&&e.push(new i(t.reqauth)),this.asn1ExtnValue=new n({array:e}),this.asn1ExtnValue.tohex()},this.oid="1.2.840.113583.1.1.9.1",void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.AdobeTimeStamp,ot.asn1.x509.Extension),ot.asn1.x509.X500Name=function(t){ot.asn1.x509.X500Name.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ot.asn1,r=e.x509,i=r.RDN;this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.split("/");r.shift();for(var n=[],s=0;s<r.length;s++)if(r[s].match(/^[^=]+=.+$/))n.push(r[s]);else{var a=n.length-1;n[a]=n[a]+"/"+r[s]}for(s=0;s<n.length;s++)this.asn1Array.push(new i({str:n[s],rule:this.sRule}))},this.setByLdapString=function(t,e){void 0!==e&&(this.sRule=e);var i=r.X500Name.ldapToCompat(t);this.setByString(i,e)},this.setByObject=function(t,e){for(var r in void 0!==e&&(this.sRule=e),t)if(t.hasOwnProperty(r)){var n=new i({str:r+"="+t[r],rule:this.sRule});this.asn1Array?this.asn1Array.push(n):this.asn1Array=[n]}},this.setByParam=function(t){var e;(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.array)?this.paramArray=t.array:void 0!==t.str?this.setByString(t.str):void 0!==t.ldapstr?this.setByLdapString(t.ldapstr):void 0!==t.hex?this.hTLV=t.hex:void 0!==t.certissuer?((e=new $t).readCertPEM(t.certissuer),this.hTLV=e.getIssuerHex()):void 0!==t.certsubject?((e=new $t).readCertPEM(t.certsubject),this.hTLV=e.getSubjectHex()):"object"==typeof t&&void 0===t.certsubject&&void 0===t.certissuer&&this.setByObject(t)},this.tohex=function(){if("string"==typeof this.hTLV)return this.hTLV;if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r={array:this.paramArray[t]};"utf8"!=this.sRule&&(r.rule=this.sRule);var n=new i(r);this.asn1Array.push(n)}var s=new e.DERSequence({array:this.asn1Array});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.X500Name,ot.asn1.ASN1Object),ot.asn1.x509.X500Name.compatToLDAP=function(t){if("/"!==t.substr(0,1))throw"malformed input";var e=(t=t.substr(1)).split("/");return e.reverse(),e=e.map(function(t){return t.replace(/,/,"\\,")}),e.join(",")},ot.asn1.x509.X500Name.onelineToLDAP=function(t){return ot.asn1.x509.X500Name.compatToLDAP(t)},ot.asn1.x509.X500Name.ldapToCompat=function(t){for(var e=t.split(","),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var a=(i.pop()+","+s).replace(/\\,/g,",");i.push(a),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}return i=i.map(function(t){return t.replace("/","\\/")}),i.reverse(),"/"+i.join("/")},ot.asn1.x509.X500Name.ldapToOneline=function(t){return ot.asn1.x509.X500Name.ldapToCompat(t)},ot.asn1.x509.RDN=function(t){ot.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var e=ot.asn1.x509.AttributeTypeAndValue;this.setByParam=function(t){void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.str&&this.addByMultiValuedString(t.str),void 0!==t.array&&(this.paramArray=t.array)},this.addByString=function(t){this.asn1Array.push(new ot.asn1.x509.AttributeTypeAndValue({str:t,rule:this.sRule}))},this.addByMultiValuedString=function(t){for(var e=ot.asn1.x509.RDN.parseString(t),r=0;r<e.length;r++)this.addByString(e[r])},this.tohex=function(){if(0==this.asn1Array.length&&this.paramArray.length>0)for(var t=0;t<this.paramArray.length;t++){var r=this.paramArray[t];void 0!==r.rule&&"utf8"!=this.sRule&&(r.rule=this.sRule);var i=new e(r);this.asn1Array.push(i)}var n=new ot.asn1.DERSet({array:this.asn1Array});return this.TLV=n.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.RDN,ot.asn1.ASN1Object),ot.asn1.x509.RDN.parseString=function(t){for(var e=t.split(/\+/),r=!1,i=[],n=0;e.length>0;n++){var s=e.shift();if(!0===r){var a=(i.pop()+"+"+s).replace(/\\\+/g,"+");i.push(a),r=!1}else i.push(s);"\\"===s.substr(-1,1)&&(r=!0)}var o=!1,h=[];for(n=0;i.length>0;n++){s=i.shift();if(!0===o){var u=h.pop();if(s.match(/"$/)){a=(u+"+"+s).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(a),o=!1}else h.push(u+"+"+s)}else h.push(s);s.match(/^[^=]+="/)&&(o=!0)}return h},ot.asn1.x509.AttributeTypeAndValue=function(t){ot.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var e=ot,r=e.asn1,i=r.DERSequence,n=r.DERUTF8String,s=r.DERPrintableString,a=r.DERTeletexString,o=r.DERIA5String,h=r.DERVisibleString,u=r.DERBMPString,c=e.lang.String.isMail,l=e.lang.String.isPrintable;this.setByParam=function(t){if(void 0!==t.rule&&(this.sRule=t.rule),void 0!==t.ds&&(this.dsType=t.ds),void 0===t.value&&void 0!==t.str){var e=t.str.match(/^([^=]+)=(.+)$/);if(!e)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.sType=e[1],this.sValue=e[2]}else this.sType=t.type,this.sValue=t.value},this.setByString=function(t,e){void 0!==e&&(this.sRule=e);var r=t.match(/^([^=]+)=(.+)$/);if(!r)throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr);this.setByAttrTypeAndValueStr(r[1],r[2])},this._getDsType=function(){var t=this.sType,e=this.sValue,r=this.sRule;return"prn"===r?"CN"==t&&c(e)?"ia5":l(e)?"prn":"utf8":"utf8"===r?"CN"==t&&c(e)?"ia5":"C"==t?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(t,e,r){void 0!==r&&(this.sRule=r),this.sType=t,this.sValue=e},this.getValueObj=function(t,e){if("utf8"==t)return new n({str:e});if("prn"==t)return new s({str:e});if("tel"==t)return new a({str:e});if("ia5"==t)return new o({str:e});if("vis"==t)return new h({str:e});if("bmp"==t)return new u({str:e});throw new Error("unsupported directory string type: type="+t+" value="+e)},this.tohex=function(){null==this.dsType&&(this.dsType=this._getDsType());var t=ot.asn1.x509.OID.atype2obj(this.sType),e=this.getValueObj(this.dsType,this.sValue),r=new i({array:[t,e]});return this.TLV=r.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.AttributeTypeAndValue,ot.asn1.ASN1Object),ot.asn1.x509.SubjectPublicKeyInfo=function(t){ot.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var e=ot.asn1,r=e.DERInteger,i=e.DERBitString,n=e.DERObjectIdentifier,s=e.DERSequence,a=e.ASN1Util.newObject,o=e.x509.AlgorithmIdentifier;this.getASN1Object=function(){if(null==this.asn1AlgId||null==this.asn1SubjPKey)throw"algId and/or subjPubKey not set";return new s({array:[this.asn1AlgId,this.asn1SubjPKey]})},this.tohex=function(){var t=this.getASN1Object();return this.hTLV=t.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(t){try{if(t instanceof rt){var e=a({seq:[{int:{bigint:t.n}},{int:{int:t.e}}]}).tohex();this.asn1AlgId=new o({name:"rsaEncryption"}),this.asn1SubjPKey=new i({hex:"00"+e})}}catch(t){}try{if(t instanceof ot.crypto.ECDSA){var s=new n({name:t.curveName});this.asn1AlgId=new o({name:"ecPublicKey",asn1params:s}),this.asn1SubjPKey=new i({hex:"00"+t.pubKeyHex})}}catch(t){}try{if(t instanceof ot.crypto.DSA){s=new a({seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]});this.asn1AlgId=new o({name:"dsa",asn1params:s});var h=new r({bigint:t.y});this.asn1SubjPKey=new i({hex:"00"+h.tohex()})}}catch(t){}},void 0!==t&&this.setPubKey(t)},Gt(ot.asn1.x509.SubjectPublicKeyInfo,ot.asn1.ASN1Object),ot.asn1.x509.Time=function(t){ot.asn1.x509.Time.superclass.constructor.call(this);var e=ot.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(t){this.timeParams=t},this.setByParam=function(t){this.params=t},this.getType=function(t){return t.match(/^[0-9]{12}Z$/)?"utc":t.match(/^[0-9]{14}Z$/)?"gen":t.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":t.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var t=this.params,e=null;if("string"==typeof t&&(t={str:t}),null==t||!t.str||null!=t.type&&null!=t.type||(t.type=this.getType(t.str)),null!=t&&t.str?("utc"==t.type&&(e=new r(t.str)),"gen"==t.type&&(e=new i(t.str))):e="gen"==this.type?new i:new r,null==e)throw new Error("wrong setting for Time");return this.TLV=e.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},ot.asn1.x509.Time_bak=function(t){ot.asn1.x509.Time_bak.superclass.constructor.call(this);var e=ot.asn1,r=e.DERUTCTime,i=e.DERGeneralizedTime;this.setTimeParams=function(t){this.timeParams=t},this.tohex=function(){var t=null;return t=null!=this.timeParams?"utc"==this.type?new r(this.timeParams):new i(this.timeParams):"utc"==this.type?new r:new i,this.TLV=t.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",void 0!==t&&(void 0!==t.type?this.type=t.type:void 0!==t.str&&(t.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),t.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=t)},Gt(ot.asn1.x509.Time,ot.asn1.ASN1Object),ot.asn1.x509.AlgorithmIdentifier=function(t){ot.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var e=ot.asn1,r=e.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(null===this.nameAlg&&null===this.asn1Alg)throw new Error("algorithm not specified");if(null!==this.nameAlg){var t=null;for(var i in r)i===this.nameAlg&&(t=r[i]);if(null!==t)return this.hTLV=t,this.hTLV}null!==this.nameAlg&&null===this.asn1Alg&&(this.asn1Alg=e.x509.OID.name2obj(this.nameAlg));var n=[this.asn1Alg];null!==this.asn1Params&&n.push(this.asn1Params);var s=new e.DERSequence({array:n});return this.hTLV=s.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&(void 0!==t.name&&(this.nameAlg=t.name),void 0!==t.asn1params&&(this.asn1Params=t.asn1params),void 0!==t.paramempty&&(this.paramEmpty=t.paramempty)),null===this.asn1Params&&!1===this.paramEmpty&&null!==this.nameAlg){void 0!==this.nameAlg.name&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();"withdsa"!==i.substr(-7,7)&&"withecdsa"!==i.substr(-9,9)&&(this.asn1Params=new e.DERNull)}},Gt(ot.asn1.x509.AlgorithmIdentifier,ot.asn1.ASN1Object),ot.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"},ot.asn1.x509.GeneralName=function(t){ot.asn1.x509.GeneralName.superclass.constructor.call(this);var e=ot.asn1,r=e.x509,i=r.X500Name,n=r.OtherName,s=e.DERIA5String,a=e.DEROctetString,o=e.DERTaggedObject,h=e.ASN1Object,u=Error;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t,e,r=this.params,c=!1;if(void 0!==r.other)t="a0",e=new n(r.other);else if(void 0!==r.rfc822)t="81",e=new s({str:r.rfc822});else if(void 0!==r.dns)t="82",e=new s({str:r.dns});else if(void 0!==r.dn)t="a4",c=!0,e="string"==typeof r.dn?new i({str:r.dn}):r.dn instanceof ot.asn1.x509.X500Name?r.dn:new i(r.dn);else if(void 0!==r.ldapdn)t="a4",c=!0,e=new i({ldapstr:r.ldapdn});else if(void 0!==r.certissuer||void 0!==r.certsubj){var l,f;t="a4",c=!0;var p=null;if(void 0!==r.certsubj?(l=!1,f=r.certsubj):(l=!0,f=r.certissuer),f.match(/^[0-9A-Fa-f]+$/),-1!=f.indexOf("-----BEGIN ")&&(p=Ft(f)),null==p)throw new Error("certsubj/certissuer not cert");var g,d=new $t;d.hex=p,g=l?d.getIssuerHex():d.getSubjectHex(),(e=new h).hTLV=g}else if(void 0!==r.uri)t="86",e=new s({str:r.uri});else{if(void 0===r.ip)throw new u("improper params");var v;t="87";var m=r.ip;try{if(m.match(/^[0-9a-f]+$/)){var y=m.length;if(8!=y&&16!=y&&32!=y&&64!=y)throw"err";v=m}else v=Rt(m)}catch(t){throw new u("malformed IP address: "+r.ip+":"+t.message)}e=new a({hex:v})}return new o({tag:t,explicit:c,obj:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.GeneralName,ot.asn1.ASN1Object),ot.asn1.x509.GeneralNames=function(t){ot.asn1.x509.GeneralNames.superclass.constructor.call(this);var e=ot.asn1;this.setByParamArray=function(t){for(var r=0;r<t.length;r++){var i=new e.x509.GeneralName(t[r]);this.asn1Array.push(i)}},this.tohex=function(){return new e.DERSequence({array:this.asn1Array}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.asn1Array=new Array,void 0!==t&&this.setByParamArray(t)},Gt(ot.asn1.x509.GeneralNames,ot.asn1.ASN1Object),ot.asn1.x509.OtherName=function(t){ot.asn1.x509.OtherName.superclass.constructor.call(this);var e=ot.asn1,r=e.DERObjectIdentifier,i=e.DERSequence,n=e.ASN1Util.newObject;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null==t.oid||null==t.value)throw new Error("oid or value not specified");var e=new r({oid:t.oid}),s=n({tag:{tag:"a0",explicit:!0,obj:t.value}});return new i({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.x509.OtherName,ot.asn1.ASN1Object),ot.asn1.x509.OID=new function(){var t=ot.asn1.DERObjectIdentifier;this.name2oidList={"aes128-CBC":"2.16.840.1.101.3.4.1.2","aes256-CBC":"2.16.840.1.101.3.4.1.42",sha1:"1.3.14.3.2.26",sha256:"2.16.840.1.101.3.4.2.1",sha384:"2.16.840.1.101.3.4.2.2",sha512:"2.16.840.1.101.3.4.2.3",sha224:"2.16.840.1.101.3.4.2.4",md5:"1.2.840.113549.2.5",md2:"1.3.14.7.2.2.1",ripemd160:"1.3.36.3.2.1",hmacWithSHA1:"1.2.840.113549.2.7",hmacWithSHA224:"1.2.840.113549.2.8",hmacWithSHA256:"1.2.840.113549.2.9",hmacWithSHA384:"1.2.840.113549.2.10",hmacWithSHA512:"1.2.840.113549.2.11",MD2withRSA:"1.2.840.113549.1.1.2",MD4withRSA:"1.2.840.113549.1.1.3",MD5withRSA:"1.2.840.113549.1.1.4",SHA1withRSA:"1.2.840.113549.1.1.5","pkcs1-MGF":"1.2.840.113549.1.1.8",rsaPSS:"1.2.840.113549.1.1.10",SHA224withRSA:"1.2.840.113549.1.1.14",SHA256withRSA:"1.2.840.113549.1.1.11",SHA384withRSA:"1.2.840.113549.1.1.12",SHA512withRSA:"1.2.840.113549.1.1.13",SHA1withECDSA:"1.2.840.10045.4.1",SHA224withECDSA:"1.2.840.10045.4.3.1",SHA256withECDSA:"1.2.840.10045.4.3.2",SHA384withECDSA:"1.2.840.10045.4.3.3",SHA512withECDSA:"1.2.840.10045.4.3.4",dsa:"1.2.840.10040.4.1",SHA1withDSA:"1.2.840.10040.4.3",SHA224withDSA:"2.16.840.1.101.3.4.3.1",SHA256withDSA:"2.16.840.1.101.3.4.3.2",rsaEncryption:"1.2.840.113549.1.1.1",commonName:"2.5.4.3",countryName:"2.5.4.6",localityName:"2.5.4.7",stateOrProvinceName:"2.5.4.8",streetAddress:"2.5.4.9",organizationName:"2.5.4.10",organizationalUnitName:"2.5.4.11",domainComponent:"0.9.2342.19200300.100.1.25",userId:"0.9.2342.19200300.100.1.1",surname:"2.5.4.4",givenName:"2.5.4.42",title:"2.5.4.12",distinguishedName:"2.5.4.49",emailAddress:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3",subjectDirectoryAttributes:"2.5.29.9",subjectKeyIdentifier:"2.5.29.14",keyUsage:"2.5.29.15",subjectAltName:"2.5.29.17",issuerAltName:"2.5.29.18",basicConstraints:"2.5.29.19",cRLNumber:"2.5.29.20",cRLReason:"2.5.29.21",nameConstraints:"2.5.29.30",cRLDistributionPoints:"2.5.29.31",certificatePolicies:"2.5.29.32",anyPolicy:"2.5.29.32.0",policyMappings:"2.5.29.33",authorityKeyIdentifier:"2.5.29.35",policyConstraints:"2.5.29.36",extKeyUsage:"2.5.29.37",inhibitAnyPolicy:"2.5.29.54",authorityInfoAccess:"1.3.6.1.5.5.7.1.1",ocsp:"1.3.6.1.5.5.7.48.1",ocspBasic:"1.3.6.1.5.5.7.48.1.1",ocspNonce:"1.3.6.1.5.5.7.48.1.2",ocspNoCheck:"1.3.6.1.5.5.7.48.1.5",caIssuers:"1.3.6.1.5.5.7.48.2",anyExtendedKeyUsage:"2.5.29.37.0",serverAuth:"1.3.6.1.5.5.7.3.1",clientAuth:"1.3.6.1.5.5.7.3.2",codeSigning:"1.3.6.1.5.5.7.3.3",emailProtection:"1.3.6.1.5.5.7.3.4",timeStamping:"1.3.6.1.5.5.7.3.8",ocspSigning:"1.3.6.1.5.5.7.3.9",smtpUTF8Mailbox:"1.3.6.1.5.5.7.8.9",dateOfBirth:"1.3.6.1.5.5.7.9.1",placeOfBirth:"1.3.6.1.5.5.7.9.2",gender:"1.3.6.1.5.5.7.9.3",countryOfCitizenship:"1.3.6.1.5.5.7.9.4",countryOfResidence:"1.3.6.1.5.5.7.9.5",ecPublicKey:"1.2.840.10045.2.1","P-256":"1.2.840.10045.3.1.7",secp256r1:"1.2.840.10045.3.1.7",secp256k1:"1.3.132.0.10",secp384r1:"1.3.132.0.34",secp521r1:"1.3.132.0.35",pkcs5PBES2:"1.2.840.113549.1.5.13",pkcs5PBKDF2:"1.2.840.113549.1.5.12","des-EDE3-CBC":"1.2.840.113549.3.7",data:"1.2.840.113549.1.7.1","signed-data":"1.2.840.113549.1.7.2","enveloped-data":"1.2.840.113549.1.7.3","digested-data":"1.2.840.113549.1.7.5","encrypted-data":"1.2.840.113549.1.7.6","authenticated-data":"1.2.840.113549.1.9.16.1.2",tstinfo:"1.2.840.113549.1.9.16.1.4",signingCertificate:"1.2.840.113549.1.9.16.2.12",timeStampToken:"1.2.840.113549.1.9.16.2.14",signaturePolicyIdentifier:"1.2.840.113549.1.9.16.2.15",etsArchiveTimeStamp:"1.2.840.113549.1.9.16.2.27",signingCertificateV2:"1.2.840.113549.1.9.16.2.47",etsArchiveTimeStampV2:"1.2.840.113549.1.9.16.2.48",extensionRequest:"1.2.840.113549.1.9.14",contentType:"1.2.840.113549.1.9.3",messageDigest:"1.2.840.113549.1.9.4",signingTime:"1.2.840.113549.1.9.5",counterSignature:"1.2.840.113549.1.9.6",archiveTimeStampV3:"0.4.0.1733.2.4",pdfRevocationInfoArchival:"1.2.840.113583.1.1.8",adobeTimeStamp:"1.2.840.113583.1.1.9.1",smimeMailboxLegacy:"2.23.140.1.5.1.1",smimeMailboxMulti:"2.23.140.1.5.1.2",smimeMailboxStrict:"2.23.140.1.5.1.3",smimeOrganizationLegacy:"2.23.140.1.5.2.1",smimeOrganizationMulti:"2.23.140.1.5.2.2",smimeOrganizationStrict:"2.23.140.1.5.2.3",smimeSponsorLegacy:"2.23.140.1.5.3.1",smimeSponsorMulti:"2.23.140.1.5.3.2",smimeSponsorStrict:"2.23.140.1.5.3.3",smimeIndividualLegacy:"2.23.140.1.5.4.1",smimeIndividualMulti:"2.23.140.1.5.4.2",smimeIndividualStrict:"2.23.140.1.5.4.3"},this.atype2oidList={CN:"2.5.4.3",L:"2.5.4.7",ST:"2.5.4.8",O:"2.5.4.10",OU:"2.5.4.11",C:"2.5.4.6",STREET:"2.5.4.9",DC:"0.9.2342.19200300.100.1.25",UID:"0.9.2342.19200300.100.1.1",SN:"2.5.4.4",T:"2.5.4.12",GN:"2.5.4.42",DN:"2.5.4.49",E:"1.2.840.113549.1.9.1",description:"2.5.4.13",businessCategory:"2.5.4.15",postalCode:"2.5.4.17",serialNumber:"2.5.4.5",uniqueIdentifier:"2.5.4.45",organizationIdentifier:"2.5.4.97",jurisdictionOfIncorporationL:"1.3.6.1.4.1.311.60.2.1.1",jurisdictionOfIncorporationSP:"1.3.6.1.4.1.311.60.2.1.2",jurisdictionOfIncorporationC:"1.3.6.1.4.1.311.60.2.1.3"},this.objCache={},this.name2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];if(void 0===this.name2oidList[e])throw"Name of ObjectIdentifier not defined: "+e;var r=this.name2oidList[e],i=new t({oid:r});return this.objCache[e]=i,i},this.atype2obj=function(e){if(void 0!==this.objCache[e])return this.objCache[e];var r;if(e.match(/^\d+\.\d+\.[0-9.]+$/))r=e;else if(void 0!==this.atype2oidList[e])r=this.atype2oidList[e];else{if(void 0===this.name2oidList[e])throw new Error("AttributeType name undefined: "+e);r=this.name2oidList[e]}var i=new t({oid:r});return this.objCache[e]=i,i},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var e in t)this.name2oidList[e]=t[e]},this.checkOIDs=function(t){try{var e=Object.keys(t);return 0!=e.length&&(e.map(function(t,e,r){if(!this[t].match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch(t){return!1}}},ot.asn1.x509.OID.oid2name=function(t){var e=ot.asn1.x509.OID.name2oidList;for(var r in e)if(e[r]==t)return r;return""},ot.asn1.x509.OID.oid2atype=function(t){var e=ot.asn1.x509.OID.atype2oidList;for(var r in e)if(e[r]==t)return r;return t},ot.asn1.x509.OID.name2oid=function(t){if(t.match(/^[0-9.]+$/))return t;var e=ot.asn1.x509.OID.name2oidList;return void 0===e[t]?"":e[t]},ot.asn1.x509.X509Util={},ot.asn1.x509.X509Util.newCertPEM=function(t){return new(0,ot.asn1.x509.Certificate)(t).getPEM()},void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),void 0!==ot.asn1.cms&&ot.asn1.cms||(ot.asn1.cms={}),ot.asn1.cms.Attribute=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.DERSet,s=r.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(t){this.params=t},this.getValueArray=function(){throw new e("not yet implemented abstract")},this.tohex=function(){var t=new s({oid:this.typeOid}),e=new n({array:this.getValueArray()});return new i({array:[t,e]}).tohex()},this.getEncodedHex=function(){return this.tohex()}},Gt(ot.asn1.cms.Attribute,ot.asn1.ASN1Object),ot.asn1.cms.ContentType=function(t){var e=ot.asn1;e.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){return[new e.DERObjectIdentifier(this.params.type)]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.ContentType,ot.asn1.cms.Attribute),ot.asn1.cms.MessageDigest=function(t){var e=ot.asn1,r=e.DEROctetString;e.cms.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){return[new r(this.params)]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.MessageDigest,ot.asn1.cms.Attribute),ot.asn1.cms.SigningTime=function(t){var e=ot.asn1;e.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){return[new e.x509.Time(this.params)]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SigningTime,ot.asn1.cms.Attribute),ot.asn1.cms.SigningCertificate=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.cms,s=n.ESSCertID;n.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,n=[],a=0;a<r.length;a++){var o=r[a];0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ct.isASN1HEX(o)||(o={cert:o}),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),n.push(new s(o))}var h=new i({array:n});return[new i({array:[h]})]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SigningCertificate,ot.asn1.cms.Attribute),ot.asn1.cms.ESSCertID=function(t){ot.asn1.cms.ESSCertID.superclass.constructor.call(this);var e=Error,r=ot,i=r.asn1,n=i.DEROctetString,s=i.DERSequence,a=i.cms.IssuerSerial;this.params=null,this.getCertHash=function(t,i){if(null!=t.hash)return t.hash;if("string"==typeof t&&-1==t.indexOf("-----BEGIN")&&!ct.isASN1HEX(t))return t;var n,s,a;if("string"==typeof t)n=t;else{if(null==t.cert)throw new e("hash nor cert unspecified");n=t.cert}if(s=-1!=n.indexOf("-----BEGIN")?Ft(n):n,"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?s=Ft(t):ct.isASN1HEX(t)&&(s=t)),null!=t.alg)a=t.alg;else{if(null==i)throw new e("hash alg unspecified");a=i}return r.crypto.Util.hashHex(s,a)},this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha1"),r=[];return r.push(new n({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&r.push(new a(t)),new s({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.ESSCertID,ot.asn1.ASN1Object),ot.asn1.cms.SigningCertificateV2=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.cms,s=n.ESSCertIDv2;n.SigningCertificateV2.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.47",this.getValueArray=function(){if(null==this.params||null==this.params||null==this.params.array)throw new e("parameter 'array' not specified");for(var r=this.params.array,n=[],a=0;a<r.length;a++){var o=r[a];null==t.alg&&0!=t.hasis||"string"!=typeof o||-1==o.indexOf("-----BEGIN")&&!ct.isASN1HEX(o)||(o={cert:o}),null==o.alg&&null!=t.alg&&(o.alg=t.alg),0!=o.hasis&&0==t.hasis&&(o.hasis=!1),n.push(new s(o))}var h=new i({array:n});return[new i({array:[h]})]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SigningCertificateV2,ot.asn1.cms.Attribute),ot.asn1.cms.ESSCertIDv2=function(t){ot.asn1.cms.ESSCertIDv2.superclass.constructor.call(this);var e=ot.asn1,r=e.DEROctetString,i=e.DERSequence,n=e.cms.IssuerSerial,s=e.x509.AlgorithmIdentifier;this.params=null,this.tohex=function(){var t=this.params,e=this.getCertHash(t,"sha256"),a=[];return null!=t.alg&&"sha256"!=t.alg&&a.push(new s({name:t.alg})),a.push(new r({hex:e})),("string"==typeof t&&-1!=t.indexOf("-----BEGIN")||null!=t.cert&&0!=t.hasis||null!=t.issuer&&null!=t.serial)&&a.push(new n(t)),new i({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.ESSCertIDv2,ot.asn1.cms.ESSCertID),ot.asn1.cms.IssuerSerial=function(t){var e=Error,r=ot.asn1,i=r.DERInteger,n=r.DERSequence,s=r.cms,a=r.x509.GeneralNames,o=$t;s.IssuerSerial.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.tohex=function(){var t,r,s=this.params;if("string"==typeof s&&-1!=s.indexOf("-----BEGIN")||null!=s.cert){var h;h=null!=s.cert?s.cert:s;var u=new o;u.readCertPEM(h),t=u.getIssuer(),r={hex:u.getSerialNumberHex()}}else{if(null==s.issuer||!s.serial)throw new e("cert or issuer and serial parameter not specified");t=s.issuer,r=s.serial}var c=new a([{dn:t}]),l=new i(r);return new n({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.IssuerSerial,ot.asn1.ASN1Object),ot.asn1.cms.SignerIdentifier=function(t){var e=ot.asn1.cms,r=e.IssuerAndSerialNumber,i=e.SubjectKeyIdentifier;e.SignerIdentifier.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("isssn"==t.type)return new r(t).tohex();if("skid"==t.type)return new i(t).tohex();throw new Error("wrong property for isssn or skid")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SignerIdentifier,ot.asn1.ASN1Object),ot.asn1.cms.IssuerAndSerialNumber=function(t){var e=ot.asn1,r=e.DERInteger,i=e.DERSequence,n=e.cms,s=e.x509.X500Name,a=$t,o=Error;n.IssuerAndSerialNumber.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t,e,n=this.params;if("string"==typeof n&&-1!=n.indexOf("-----BEGIN")||null!=n.cert){var h;h=null!=n.cert?n.cert:n;var u=new a;u.readCertPEM(h),t=u.getIssuer(),e={hex:u.getSerialNumberHex()}}else{if(null==n.issuer||!n.serial)throw new o("cert or issuer and serial parameter not specified");t=n.issuer,e=n.serial}var c=new s(t),l=new r(e);return new i({array:[c,l]}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.IssuerAndSerialNumber,ot.asn1.ASN1Object),ot.asn1.cms.SubjectKeyIdentifier=function(t){var e=ot.asn1,r=e.ASN1Util.newObject,i=e.cms,n=$t,s=Error;i.SubjectKeyIdentifier.superclass.constructor.call(this),this.tohex=function(){var t,e=this.params;if(null==e.cert&&null==e.skid)throw new s("property cert nor skid undefined");null!=e.cert?t=new n(e.cert).getExtSubjectKeyIdentifier().kid.hex:null!=e.skid&&(t=e.skid);return r({tag:{tage:"a0",obj:{octstr:{hex:t}}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SubjectKeyIdentifier,ot.asn1.ASN1Object),ot.asn1.cms.AttributeList=function(t){var e=Error,r=ot.asn1,i=r.DERSet,n=r.cms;n.AttributeList.superclass.constructor.call(this),this.params=null,this.hTLV=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if(null!=this.hTLV)return this.hTLV;var r=!0;null!=t.sortflag&&(r=t.sortflag);for(var s=t.array,a=[],o=0;o<s.length;o++){var h=s[o],u=h.attr;if("contentType"==u)a.push(new n.ContentType(h));else if("messageDigest"==u)a.push(new n.MessageDigest(h));else if("signingTime"==u)a.push(new n.SigningTime(h));else if("signingCertificate"==u)a.push(new n.SigningCertificate(h));else if("signingCertificateV2"==u)a.push(new n.SigningCertificateV2(h));else if("signaturePolicyIdentifier"==u)a.push(new ot.asn1.cades.SignaturePolicyIdentifier(h));else{if("signatureTimeStamp"!=u&&"timeStampToken"!=u)throw new e("unknown attr: "+u);a.push(new ot.asn1.cades.SignatureTimeStamp(h))}}var c=new i({array:a,sortflag:r});return this.hTLV=c.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.AttributeList,ot.asn1.ASN1Object),ot.asn1.cms.SignerInfo=function(t){var e=Error,r=ot,i=r.asn1,n=i.DERInteger,s=i.DEROctetString,a=i.DERSequence,o=i.DERTaggedObject,h=i.cms,u=h.SignerIdentifier,c=h.AttributeList,l=i.x509.AlgorithmIdentifier,f=r.crypto,p=zt;h.SignerInfo.superclass.constructor.call(this),this.params=null,this.sign=function(){var t=this.params,e=t.sigalg,r=new c(t.sattrs).tohex(),i=p.getKey(t.signkey),n=new f.Signature({alg:e});n.init(i),n.updateHex(r);var s=n.sign();t.sighex=s},this.tohex=function(){var t=this.params,r=[];if(r.push(new n({int:t.version})),r.push(new u(t.id)),r.push(new l({name:t.hashalg})),null!=t.sattrs){var i=new c(t.sattrs);try{r.push(new o({tag:"a0",explicit:!1,obj:i}))}catch(t){throw new e("si sattr error: "+t)}}if(null!=t.sigalgfield?r.push(new l({name:t.sigalgfield})):r.push(new l({name:t.sigalg})),null==t.sighex&&null!=t.signkey&&this.sign(),r.push(new s({hex:t.sighex})),null!=t.uattrs){i=new c(t.uattrs);try{r.push(new o({tag:"a1",explicit:!1,obj:i}))}catch(t){throw new e("si uattr error: "+t)}}return new a({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SignerInfo,ot.asn1.ASN1Object),ot.asn1.cms.EncapsulatedContentInfo=function(t){var e=ot.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier,s=e.DEROctetString;e.cms.EncapsulatedContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new n(t.type)),null!=t.content&&(null!=t.content.hex||null!=t.content.str)&&1!=t.isDetached){var a=new s(t.content),o=new r({tag:"a0",explicit:!0,obj:a});e.push(o)}return new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.EncapsulatedContentInfo,ot.asn1.ASN1Object),ot.asn1.cms.ContentInfo=function(t){var e=ot.asn1,r=e.DERTaggedObject,i=e.DERSequence,n=e.DERObjectIdentifier;ot.asn1.cms.ContentInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];e.push(new n(t.type));var s=new r({tag:"a0",explicit:!0,obj:t.obj});return e.push(s),new i({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.ContentInfo,ot.asn1.ASN1Object),ot.asn1.cms.SignedData=function(t){var e=ot.asn1,r=e.DERInteger,i=e.DERSet,n=e.DERSequence,s=e.cms,a=s.EncapsulatedContentInfo,o=s.SignerInfo,h=s.ContentInfo,u=s.CertificateSet,c=s.RevocationInfoChoices,l=e.x509.AlgorithmIdentifier;ot.asn1.cms.SignedData.superclass.constructor.call(this),this.params=null,this.checkAndFixParam=function(){var t=this.params;this._setDigestAlgs(t),this._setContentTypeByEContent(t),this._setMessageDigestByEContent(t),this._setSignerInfoVersion(t),this._setSignedDataVersion(t)},this._setDigestAlgs=function(t){for(var e={},r=t.sinfos,i=0;i<r.length;i++){e[r[i].hashalg]=1}t.hashalgs=Object.keys(e).sort()},this._setContentTypeByEContent=function(t){for(var e=t.econtent.type,r=t.sinfos,i=0;i<r.length;i++){var n=r[i];this._getAttrParamByName(n,"contentType").type=e}},this._setMessageDigestByEContent=function(t){var e=t.econtent,r=e.content.hex;null==r&&"data"==e.type&&null!=e.content.str&&(r=Et(e.content.str));for(var i=t.sinfos,n=0;n<i.length;n++){var s=i[n],a=s.hashalg,o=this._getAttrParamByName(s,"messageDigest"),h=ot.crypto.Util.hashHex(r,a);o.hex=h}},this._getAttrParamByName=function(t,e){for(var r=t.sattrs.array,i=0;i<r.length;i++)if(r[i].attr==e)return r[i]},this._setSignerInfoVersion=function(t){for(var e=t.sinfos,r=0;r<e.length;r++){var i=e[r],n=1;"skid"==i.id.type&&(n=3),i.version=n}},this._setSignedDataVersion=function(t){var e=this._getSignedDataVersion(t);t.version=e},this._getSignedDataVersion=function(t){if(null!=t.revinfos)for(var e=t.revinfos,r=0;r<e.length;r++){if(null!=e[r].ocsp)return 5}var i=t.sinfos;for(r=0;r<i.length;r++){if(3==t.sinfos[r].version)return 3}return"data"!=t.econtent.type?3:1},this.tohex=function(){var t=this.params;null!=this.getEncodedHexPrepare&&this.getEncodedHexPrepare(),1!=t.fixed&&this.checkAndFixParam();var e=[];e.push(new r({int:t.version}));for(var s=[],h=0;h<t.hashalgs.length;h++){var f=t.hashalgs[h];s.push(new l({name:f}))}e.push(new i({array:s})),e.push(new a(t.econtent)),null!=t.certs&&e.push(new u(t.certs)),null!=t.revinfos&&e.push(new c(t.revinfos));var p=[];for(h=0;h<t.sinfos.length;h++){var g=t.sinfos[h];p.push(new o(g))}return e.push(new i({array:p})),new n({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.getContentInfo=function(){return new h({type:"signed-data",obj:this})},this.getContentInfoEncodedHex=function(){return this.getContentInfo().tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.SignedData,ot.asn1.ASN1Object),ot.asn1.cms.CertificateSet=function(t){ot.asn1.cms.CertificateSet.superclass.constructor.call(this);var e=Error,r=ot.asn1,i=r.DERTaggedObject,n=r.DERSet,s=r.ASN1Object;this.params=null,this.tohex=function(){var t,r=this.params,a=[];if(r instanceof Array)t=r;else{if(null==r.array)throw new e("cert array not specified");t=r.array}for(var o=0;o<t.length;o++){var h=Ft(t[o]),u=new s;u.hTLV=h,a.push(u)}var c={array:a};0==r.sortflag&&(c.sortflag=!1);var l=new n(c);return new i({tag:"a0",explicit:!1,obj:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.CertificateSet,ot.asn1.ASN1Object),ot.asn1.cms.RevocationInfoChoices=function(t){ot.asn1.cms.RevocationInfoChoices.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!t instanceof Array)throw new Error("params is not array");for(var e=[],r=0;r<t.length;r++)e.push(new ot.asn1.cms.RevocationInfoChoice(t[r]));return ot.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:{set:e}}}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.RevocationInfoChoices,ot.asn1.ASN1Object),ot.asn1.cms.RevocationInfoChoice=function(t){ot.asn1.cms.RevocationInfoChoice.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null!=t.crl&&"string"==typeof t.crl){var e=t.crl;return-1!=t.crl.indexOf("-----BEGIN")&&(e=Ft(t.crl)),e}if(null!=t.ocsp)return ot.asn1.ASN1Util.newObject({tag:{tagi:"a1",obj:new ot.asn1.cms.OtherRevocationFormat(t)}}).tohex();throw new Error("property crl or ocsp undefined")},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.RevocationInfoChoice,ot.asn1.ASN1Object),ot.asn1.cms.OtherRevocationFormat=function(t){ot.asn1.cms.OtherRevocationFormat.superclass.constructor.call(this);var e=Error,r=ot,i=r.asn1.ASN1Util.newObject,n=r.lang.String.isHex;this.params=null,this.tohex=function(){var t=this.params;if(null==t.ocsp)throw new e("property ocsp not specified");if(!n(t.ocsp)||!ct.isASN1HEX(t.ocsp))throw new e("ocsp value not ASN.1 hex string");return i({seq:[{oid:"1.3.6.1.5.5.7.16.2"},{asn1:{tlv:t.ocsp}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cms.OtherRevocationFormat,ot.asn1.ASN1Object),ot.asn1.cms.CMSUtil=new function(){},ot.asn1.cms.CMSUtil.newSignedData=function(t){return new ot.asn1.cms.SignedData(t)},ot.asn1.cms.CMSUtil.verifySignedData=function(t){var e=ot,r=e.lang.String.isHex,i=ct,n=i.getVbyList,s=i.getTLVbyList,a=i.getIdxbyList,o=i.getChildIdx,h=i.getTLV,u=i.oidname,c=e.crypto.Util.hashHex;void 0===t.cms&&r(t.cms);var l=t.cms,f=function(t,e){var r=e.idx;e.signerid_issuer1=s(t,r,[1,0],"30"),e.signerid_serial1=n(t,r,[1,1],"02"),e.hashalg=u(n(t,r,[2,0],"06"));var i=a(t,r,[3],"a0");e.idxSignedAttrs=i,p(t,e,i);var h=o(t,r).length;if(h<6)throw"malformed SignerInfo";e.sigalg=u(n(t,r,[h-2,0],"06")),e.sigval=n(t,r,[h-1],"04")},p=function(t,e,r){var i=o(t,r);e.signedAttrIdxList=i;for(var s=0;s<i.length;s++){var a,h=i[s],u=n(t,h,[0],"06");"2a864886f70d010905"===u?(a=yt(n(t,h,[1,0])),e.saSigningTime=a):"2a864886f70d010904"===u&&(a=n(t,h,[1,0],"04"),e.saMessageDigest=a)}},g=function(t,e,r,i){r.verifyDetail={};var n=r.verifyDetail,s=e.parse.econtent,a=r.hashalg,u=r.saMessageDigest;n.validMessageDigest=!1,c(s,a)===u&&(n.validMessageDigest=!0),function(t,e,r){var i,n=e.parse.certsIdx;if(void 0===e.certs){i=[],e.certkeys=[];for(var s=o(t,n),a=0;a<s.length;a++){var u=h(t,s[a]),c=new $t;c.readCertHex(u),i[a]=c,e.certkeys[a]=c.getPublicKey()}e.certs=i}else i=e.certs;for(e.cccc=i.length,e.cccci=s.length,a=0;a<i.length;a++){var l=c.getIssuerHex(),f=c.getSerialNumberHex();r.signerid_issuer1===l&&r.signerid_serial1===f&&(r.certkey_idx=a)}}(t,e,r),n.validSignatureValue=!1;var l=r.sigalg,f="31"+h(t,r.idxSignedAttrs).substr(2);r.signedattrshex=f;var p=e.certs[r.certkey_idx].getPublicKey(),g=new ot.crypto.Signature({alg:l});g.init(p),g.updateHex(f);var d=g.verify(r.sigval);n.validSignatureValue_isValid=d,!0===d&&(n.validSignatureValue=!0),r.isValid=!1,n.validMessageDigest&&n.validSignatureValue&&(r.isValid=!0)},d={isValid:!1,parse:{}};return function(t,e){if("2a864886f70d010702"!==n(t,0,[0],"06"))return e;e.cmsType="signedData",e.econtent=n(t,0,[1,0,2,1,0]),function(t,e){for(var r,i=3;i<6;i++)if(void 0!==(r=a(t,0,[1,0,i]))){var n=t.substr(r,2);"a0"===n&&(e.certsIdx=r),"a1"===n&&(e.revinfosIdx=r),"31"===n&&(e.signerinfosIdx=r)}}(t,e),e.signerInfos=[],function(t,e){var r=e.signerinfosIdx;if(void 0!==r){var i=o(t,r);e.signerInfoIdxList=i;for(var n=0;n<i.length;n++){var s={idx:i[n]};f(t,s),e.signerInfos.push(s)}}}(t,e)}(l,d.parse),function(t,e){for(var r=e.parse.signerInfos,i=r.length,n=!0,s=0;s<i;s++){var a=r[s];g(t,e,a),a.isValid||(n=!1)}e.isValid=n}(l,d),d},ot.asn1.cms.CMSParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,a=i.getTLVbyList,o=i.getTLVbyListEx,h=i.getVbyList,u=i.getVbyListEx,c=i.getChildIdx;this.getCMSSignedData=function(t){var e=a(t,0,[1,0]);return this.getSignedData(e)},this.getSignedData=function(t){var e=c(t,0),r={},i=n(t,e[0]),a=parseInt(i,16);r.version=a;var h=s(t,e[1]);r.hashalgs=this.getHashAlgArray(h);var u=s(t,e[2]);r.econtent=this.getEContent(u);var l=o(t,0,["[0]"]);null!=l&&(r.certs=this.getCertificateSet(l)),o(t,0,["[1]"]);var f=o(t,0,[3]);return r.sinfos=this.getSignerInfos(f),r},this.getHashAlgArray=function(t){for(var r=c(t,0),i=new e,n=[],a=0;a<r.length;a++){var o=s(t,r[a]),h=i.getAlgorithmIdentifierName(o);n.push(h)}return n},this.getEContent=function(t){var e={},r=h(t,0,[0]),i=h(t,0,[1,0]);return e.type=ot.asn1.x509.OID.oid2name(ct.hextooidstr(r)),e.content={hex:i},e},this.getSignerInfos=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),a=this.getSignerInfo(n);e.push(a)}return e},this.getSignerInfo=function(t){var e={},n=c(t,0),a=i.getInt(t,n[0],-1);-1!=a&&(e.version=a);var h=s(t,n[1]),l=this.getIssuerAndSerialNumber(h);e.id=l;var f=s(t,n[2]),p=r.getAlgorithmIdentifierName(f);e.hashalg=p;var g=o(t,0,["[0]"]);if(null!=g){var d=this.getAttributeList(g);e.sattrs=d}var v=o(t,0,[3]),m=r.getAlgorithmIdentifierName(v);e.sigalg=m;var y=u(t,0,[4]);e.sighex=y;var x=o(t,0,["[1]"]);if(null!=x){var S=this.getAttributeList(x);e.uattrs=S}return e},this.getSignerIdentifier=function(t){if("30"==t.substr(0,2))return this.getIssuerAndSerialNumber(t);throw new Error("SKID of signerIdentifier not supported")},this.getIssuerAndSerialNumber=function(t){var e={type:"isssn"},i=c(t,0),a=s(t,i[0]);e.issuer=r.getX500Name(a);var o=n(t,i[1]);return e.serial={hex:o},e},this.getAttributeList=function(t){for(var e=[],r=c(t,0),i=0;i<r.length;i++){var n=s(t,r[i]),a=this.getAttribute(n);e.push(a)}return{array:e}},this.getAttribute=function(t){var e={},r=c(t,0),n=i.getOID(t,r[0]),a=ot.asn1.x509.OID.oid2name(n);e.attr=a;var o=s(t,r[1]),h=c(o,0);if(1==h.length)e.valhex=s(o,h[0]);else{for(var u=[],l=0;l<h.length;l++)u.push(s(o,h[l]));e.valhex=u}return"contentType"==a?this.setContentType(e):"messageDigest"==a?this.setMessageDigest(e):"signingTime"==a?this.setSigningTime(e):"signingCertificate"==a?this.setSigningCertificate(e):"signingCertificateV2"==a?this.setSigningCertificateV2(e):"signaturePolicyIdentifier"==a&&this.setSignaturePolicyIdentifier(e),e},this.setContentType=function(t){var e=i.getOIDName(t.valhex,0,null);null!=e&&(t.type=e,delete t.valhex)},this.setSigningTime=function(t){var e=yt(n(t.valhex,0));t.str=e,delete t.valhex},this.setMessageDigest=function(t){var e=n(t.valhex,0);t.hex=e,delete t.valhex},this.setSigningCertificate=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=c(r,0),n=[],a=0;a<i.length;a++){var o=s(r,i[a]),h=this.getESSCertID(o);n.push(h)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.setSignaturePolicyIdentifier=function(t){var r=c(t.valhex,0);if(r.length>0){var a=i.getOID(t.valhex,r[0]);t.oid=a}if(r.length>1){var o=new e,h=c(t.valhex,r[1]),u=s(t.valhex,h[0]),l=o.getAlgorithmIdentifierName(u);t.alg=l;var f=n(t.valhex,h[1]);t.hash=f}delete t.valhex},this.setSigningCertificateV2=function(t){var e=c(t.valhex,0);if(e.length>0){for(var r=s(t.valhex,e[0]),i=c(r,0),n=[],a=0;a<i.length;a++){var o=s(r,i[a]),h=this.getESSCertIDv2(o);n.push(h)}t.array=n}if(e.length>1){var u=s(t.valhex,e[1]);t.polhex=u}delete t.valhex},this.getESSCertID=function(t){var e={},r=c(t,0);if(r.length>0){var i=n(t,r[0]);e.hash=i}if(r.length>1){var a=s(t,r[1]),o=this.getIssuerSerial(a);null!=o.serial&&(e.serial=o.serial),null!=o.issuer&&(e.issuer=o.issuer)}return e},this.getESSCertIDv2=function(e){var i={},a=c(e,0);if(a.length<1||3<a.length)throw new t("wrong number of elements");var o=0;if("30"==e.substr(a[0],2)){var h=s(e,a[0]);i.alg=r.getAlgorithmIdentifierName(h),o++}else i.alg="sha256";var u=n(e,a[o]);if(i.hash=u,a.length>o+1){var l=s(e,a[o+1]),f=this.getIssuerSerial(l);i.issuer=f.issuer,i.serial=f.serial}return i},this.getIssuerSerial=function(t){var e={},i=c(t,0),a=s(t,i[0]),o=r.getGeneralNames(a)[0].dn;e.issuer=o;var h=n(t,i[1]);return e.serial={hex:h},e},this.getCertificateSet=function(t){for(var e=c(t,0),r=[],i=0;i<e.length;i++){var n=s(t,e[i]);if("30"==n.substr(0,2)){var a=wt(n,"CERTIFICATE");r.push(a)}}return{array:r,sortflag:!1}}},void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),void 0!==ot.asn1.tsp&&ot.asn1.tsp||(ot.asn1.tsp={}),ot.asn1.tsp.TimeStampToken=function(t){var e=ot.asn1.tsp;e.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var t=new e.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=t.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.TimeStampToken,ot.asn1.cms.SignedData),ot.asn1.tsp.TSTInfo=function(t){var e=ot.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=e.DERGeneralizedTime,a=e.DERObjectIdentifier,o=e.DERTaggedObject,h=e.tsp,u=h.MessageImprint,c=h.Accuracy,l=e.x509.GeneralName;if(h.TSTInfo.superclass.constructor.call(this),this.dVersion=new i({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var t=[this.dVersion];if(null==this.dPolicy)throw new Error("policy shall be specified.");if(t.push(this.dPolicy),null==this.dMessageImprint)throw new Error("messageImprint shall be specified.");if(t.push(this.dMessageImprint),null==this.dSerial)throw new Error("serialNumber shall be specified.");if(t.push(this.dSerial),null==this.dGenTime)throw new Error("genTime shall be specified.");t.push(this.dGenTime),null!=this.dAccuracy&&t.push(this.dAccuracy),null!=this.dOrdering&&t.push(this.dOrdering),null!=this.dNonce&&t.push(this.dNonce),null!=this.dTsa&&t.push(this.dTsa);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){if("string"==typeof t.policy){if(!t.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new a({oid:t.policy})}void 0!==t.messageImprint&&(this.dMessageImprint=new u(t.messageImprint)),void 0!==t.serial&&(this.dSerial=new i(t.serial)),void 0!==t.genTime&&(this.dGenTime=new s(t.genTime)),void 0!==t.accuracy&&(this.dAccuracy=new c(t.accuracy)),void 0!==t.ordering&&1==t.ordering&&(this.dOrdering=new n),void 0!==t.nonce&&(this.dNonce=new i(t.nonce)),void 0!==t.tsa&&(this.dTsa=new o({tag:"a0",explicit:!0,obj:new l({dn:t.tsa})}))}},Gt(ot.asn1.tsp.TSTInfo,ot.asn1.ASN1Object),ot.asn1.tsp.Accuracy=function(t){var e=ot.asn1,r=e.ASN1Util.newObject;e.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return null!=t.seconds&&"number"==typeof t.seconds&&e.push({int:t.seconds}),null!=t.millis&&"number"==typeof t.millis&&e.push({tag:{tagi:"80",obj:{int:t.millis}}}),null!=t.micros&&"number"==typeof t.micros&&e.push({tag:{tagi:"81",obj:{int:t.micros}}}),r({seq:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.Accuracy,ot.asn1.ASN1Object),ot.asn1.tsp.MessageImprint=function(t){var e=ot.asn1,r=e.DERSequence,i=e.DEROctetString,n=e.x509.AlgorithmIdentifier;e.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=new n({name:t.alg}),s=new i({hex:t.hash});return new r({array:[e,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.tsp.MessageImprint,ot.asn1.ASN1Object),ot.asn1.tsp.TimeStampReq=function(t){var e=ot.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERBoolean,s=e.DERObjectIdentifier,a=e.tsp,o=a.MessageImprint;a.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i({int:1})),t.messageImprint instanceof ot.asn1.ASN1Object?e.push(t.messageImprint):e.push(new o(t.messageImprint)),null!=t.policy&&e.push(new s(t.policy)),null!=t.nonce&&e.push(new i(t.nonce)),1==t.certreq&&e.push(new n),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.TimeStampReq,ot.asn1.ASN1Object),ot.asn1.tsp.TimeStampResp=function(t){var e=ot.asn1,r=e.DERSequence,i=e.tsp,n=i.PKIStatusInfo;i.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,s=[];if(null!=t.econtent||null!=t.tst)if(null!=t.statusinfo?s.push(new n(t.statusinfo)):s.push(new n("granted")),null!=t.econtent)s.push(new i.TimeStampToken(t).getContentInfo());else{if(!(t.tst instanceof e.ASN1Object))throw new Error("improper member tst value");s.push(t.tst)}else{if(null==t.statusinfo)throw new Error("parameter for token nor statusinfo not specified");s.push(new n(t.statusinfo))}return new r({array:s}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.TimeStampResp,ot.asn1.ASN1Object),ot.asn1.tsp.PKIStatusInfo=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.tsp,s=n.PKIStatus,a=n.PKIFreeText,o=n.PKIFailureInfo;n.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if("string"==typeof t)r.push(new s(t));else{if(null==t.status)throw new e("property 'status' unspecified");r.push(new s(t.status)),null!=t.statusstr&&r.push(new a(t.statusstr)),null!=t.failinfo&&r.push(new o(t.failinfo))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.PKIStatusInfo,ot.asn1.ASN1Object),ot.asn1.tsp.PKIStatus=function(t){var e=Error,r=ot.asn1,i=r.DERInteger;r.tsp.PKIStatus.superclass.constructor.call(this);var n={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var t,r=this.params;if("string"==typeof r)try{t=n[r]}catch(t){throw new e("undefined name: "+r)}else{if("number"!=typeof r)throw new e("unsupported params");t=r}return new i({int:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.PKIStatus,ot.asn1.ASN1Object),ot.asn1.tsp.PKIFreeText=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.DERUTF8String;r.tsp.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(!(t instanceof Array))throw new e("wrong params: not array");for(var r=[],s=0;s<t.length;s++)r.push(new n({str:t[s]}));return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.PKIFreeText,ot.asn1.ASN1Object),ot.asn1.tsp.PKIFailureInfo=function(t){var e=Error,r=ot.asn1,i=r.DERBitString,n=r.tsp.PKIFailureInfo,s={badAlg:0,badRequest:2,badDataFormat:5,timeNotAvailable:14,unacceptedPolicy:15,unacceptedExtension:16,addInfoNotAvailable:17,systemFailure:25};n.superclass.constructor.call(this),this.params=null,this.getBinValue=function(){var t=this.params,r=0;if("number"==typeof t&&0<=t&&t<=25){for(var i=(r|=1<<t).toString(2),n="",a=i.length-1;a>=0;a--)n+=i[a];return n}if("string"==typeof t&&null!=s[t])return Ut([t],s);if("object"==typeof t&&null!=t.length)return Ut(t,s);throw new e("wrong params")},this.tohex=function(){var t=this.getBinValue();return new i({bin:t}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.tsp.PKIFailureInfo,ot.asn1.ASN1Object),ot.asn1.tsp.AbstractTSAAdapter=function(t){this.getTSTHex=function(t,e){throw"not implemented yet"}},ot.asn1.tsp.SimpleTSAAdapter=function(t){var e=ot,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(t,e){var n=i(t,e);this.params.econtent.content.messageImprint={alg:e,hash:n},this.params.econtent.content.serial={int:this.serial++};var s=Math.floor(1e9*Math.random());return this.params.econtent.content.nonce={int:s},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.tsp.SimpleTSAAdapter,ot.asn1.tsp.AbstractTSAAdapter),ot.asn1.tsp.FixedTSAAdapter=function(t){var e=ot,r=e.asn1.tsp,i=e.crypto.Util.hashHex;r.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(t,e){var n=i(t,e);return this.params.econtent.content.messageImprint={alg:e,hash:n},new r.TimeStampToken(this.params).getContentInfoEncodedHex()},void 0!==t&&(this.params=t)},Gt(ot.asn1.tsp.FixedTSAAdapter,ot.asn1.tsp.AbstractTSAAdapter),ot.asn1.tsp.TSPUtil=new function(){},ot.asn1.tsp.TSPUtil.newTimeStampToken=function(t){return new ot.asn1.tsp.TimeStampToken(t)},ot.asn1.tsp.TSPUtil.parseTimeStampReq=function(t){return(new ot.asn1.tsp.TSPParser).getTimeStampReq(t)},ot.asn1.tsp.TSPUtil.parseMessageImprint=function(t){return(new ot.asn1.tsp.TSPParser).getMessageImprint(t)},ot.asn1.tsp.TSPParser=function(){var t=new $t,e=ct,r=e.getV,i=e.getTLV,n=e.getIdxbyList,s=e.getChildIdx,a=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],o={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(t){var e=s(t,0);if(1==e.length)return this.getPKIStatusInfo(i(t,e[0]));if(e.length>1){var r=this.getPKIStatusInfo(i(t,e[0])),n=i(t,e[1]),a=this.getToken(n);return a.statusinfo=r,a}},this.getToken=function(t){var e=(new ot.asn1.cms.CMSParser).getCMSSignedData(t);return this.setTSTInfo(e),e},this.setTSTInfo=function(t){var e=t.econtent;if("tstinfo"==e.type){var r=e.content.hex,i=this.getTSTInfo(r);e.content=i}},this.getTSTInfo=function(e){var n={},a=s(e,0),o=r(e,a[1]);n.policy=kt(o);var h=i(e,a[2]);n.messageImprint=this.getMessageImprint(h);var u=r(e,a[3]);n.serial={hex:u};var c=r(e,a[4]);n.genTime={str:yt(c)};var l=0;if(a.length>5&&"30"==e.substr(a[5],2)){var f=i(e,a[5]);n.accuracy=this.getAccuracy(f),l++}a.length>5+l&&"01"==e.substr(a[5+l],2)&&("ff"==r(e,a[5+l])&&(n.ordering=!0),l++);if(a.length>5+l&&"02"==e.substr(a[5+l],2)){var p=r(e,a[5+l]);n.nonce={hex:p},l++}if(a.length>5+l&&"a0"==e.substr(a[5+l],2)){var g=i(e,a[5+l]);g="30"+g.substr(2),pGeneralNames=t.getGeneralNames(g);var d=pGeneralNames[0].dn;n.tsa=d,l++}if(a.length>5+l&&"a1"==e.substr(a[5+l],2)){var v=i(e,a[5+l]);v="30"+v.substr(2);var m=t.getExtParamArray(v);n.ext=m,l++}return n},this.getAccuracy=function(t){for(var e={},i=s(t,0),n=0;n<i.length;n++){var a=t.substr(i[n],2),o=r(t,i[n]),h=parseInt(o,16);"02"==a?e.seconds=h:"80"==a?e.millis=h:"81"==a&&(e.micros=h)}return e},this.getMessageImprint=function(t){if("30"!=t.substr(0,2))throw new Error("head of messageImprint hex shall be x30");var i={};s(t,0);var a=n(t,0,[0,0]),o=r(t,a),h=e.hextooidstr(o),u=ot.asn1.x509.OID.oid2name(h);if(""==u)throw new Error("hashAlg name undefined: "+h);var c=u,l=n(t,0,[1]);return i.alg=c,i.hash=r(t,l),i},this.getPKIStatusInfo=function(t){var e={},n=s(t,0),o=0;try{var h=r(t,n[0]),u=parseInt(h,16);e.status=a[u]}catch(t){}if(n.length>1&&"30"==t.substr(n[1],2)){var c=i(t,n[1]);e.statusstr=this.getPKIFreeText(c),o++}if(n.length>o&&"03"==t.substr(n[1+o],2)){var l=i(t,n[1+o]);e.failinfo=this.getPKIFailureInfo(l)}return e},this.getPKIFreeText=function(t){for(var r=[],i=s(t,0),n=0;n<i.length;n++)r.push(e.getString(t,i[n]));return r},this.getPKIFailureInfo=function(t){var r=e.getInt(t,0);return null!=o[r]?o[r]:r},this.getTimeStampReq=function(t){var n={certreq:!1},a=s(t,0);if(a.length<2)throw new Error("TimeStampReq must have at least 2 items");var o=i(t,a[1]);n.messageImprint=ot.asn1.tsp.TSPUtil.parseMessageImprint(o);for(var h=2;h<a.length;h++){var u=a[h],c=t.substr(u,2);if("06"==c){var l=r(t,u);n.policy=e.hextooidstr(l)}"02"==c&&(n.nonce=r(t,u)),"01"==c&&(n.certreq=!0)}return n}},void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),void 0!==ot.asn1.cades&&ot.asn1.cades||(ot.asn1.cades={}),ot.asn1.cades.SignaturePolicyIdentifier=function(t){var e=ot.asn1.cades,r=e.SignaturePolicyId;e.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new r(this.params)]},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.SignaturePolicyIdentifier,ot.asn1.cms.Attribute),ot.asn1.cades.SignaturePolicyId=function(t){var e=ot.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=e.cades,s=n.SignaturePolicyId,a=n.OtherHashAlgAndValue;s.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,e=[];return e.push(new i(t.oid)),e.push(new a(t)),new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.SignaturePolicyId,ot.asn1.ASN1Object),ot.asn1.cades.OtherHashAlgAndValue=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.DEROctetString,s=r.x509.AlgorithmIdentifier;r.cades.OtherHashAlgAndValue.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if(null==t.alg)throw new e("property 'alg' not specified");if(null==t.hash&&null==t.cert)throw new e("property 'hash' nor 'cert' not specified");var r=null;if(null!=t.hash)r=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var a=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(a=Ft(t.cert)),r=ot.crypto.Util.hashHex(a,t.alg)}var o=[];return o.push(new s({name:t.alg})),o.push(new n({hex:r})),new i({array:o}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.OtherHashAlgAndValue,ot.asn1.ASN1Object),ot.asn1.cades.OtherHashValue=function(t){ot.asn1.cades.OtherHashValue.superclass.constructor.call(this);var e=Error,r=ot.asn1.DEROctetString;this.params=null,this.tohex=function(){var t=this.params;if(null==t.hash&&null==t.cert)throw new e("hash or cert not specified");var i=null;if(null!=t.hash)i=t.hash;else if(null!=t.cert){if("string"!=typeof t.cert)throw new e("cert not string");var n=t.cert;-1!=t.cert.indexOf("-----BEGIN")&&(n=Ft(t.cert)),i=ot.crypto.Util.hashHex(n,"sha1")}return new r({hex:i}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.OtherHashValue,ot.asn1.ASN1Object),ot.asn1.cades.SignatureTimeStamp=function(t){var e=Error,r=ot,i=r.lang.String.isHex,n=r.asn1,s=n.ASN1Object;n.cades.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var t=this.params;if(null!=t.tst){if(i(t.tst))return(r=new s).hTLV=t.tst,[r];if(t.tst instanceof s)return[t.tst];throw new e("params.tst has wrong value")}if(null!=t.res){var r,n=t.res;if(n instanceof s&&(n=n.tohex()),"string"!=typeof n||!i(n))throw new e("params.res has wrong value");return ct.getTLVbyList(n,0,[1]),(r=new s).hTLV=t.tst,[r]}},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.SignatureTimeStamp,ot.asn1.cms.Attribute),ot.asn1.cades.CompleteCertificateRefs=function(t){var e=Error,r=ot,i=r.asn1,n=i.DERSequence,s=i.cades,a=s.OtherCertID,o=r.lang.String.isHex;s.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var t=this.params,r=[],i=0;i<t.array.length;i++){var s=t.array[i];if("string"==typeof s)if(-1!=s.indexOf("-----BEGIN"))s={cert:s};else{if(!o(s))throw new e("unsupported value: "+s);s={hash:s}}null!=t.alg&&null==s.alg&&(s.alg=t.alg),null!=t.hasis&&null==s.hasis&&(s.hasis=t.hasis);var h=new a(s);r.push(h)}return[new n({array:r})]},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.CompleteCertificateRefs,ot.asn1.cms.Attribute),ot.asn1.cades.OtherCertID=function(t){var e=ot.asn1,r=e.DERSequence,i=e.cms.IssuerSerial,n=e.cades,s=n.OtherHashValue,a=n.OtherHashAlgAndValue;n.OtherCertID.superclass.constructor.call(this),this.params=t,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:_isHex(t)&&(t={hash:t}));var e=[],n=null;if(n=null!=t.alg?new a(t):new s(t),e.push(n),null!=t.cert&&1==t.hasis||null!=t.issuer&&null!=t.serial){var o=new i(t);e.push(o)}return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.OtherCertID,ot.asn1.ASN1Object),ot.asn1.cades.OtherHash=function(t){var e=ot,r=e.asn1.cades,i=r.OtherHashAlgAndValue,n=r.OtherHashValue,s=e.lang.String.isHex;r.OtherHash.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?t={cert:t}:s(t)&&(t={hash:t}));return(null!=t.alg?new i(t):new n(t)).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.cades.OtherHash,ot.asn1.ASN1Object),ot.asn1.cades.CAdESUtil=new function(){},ot.asn1.cades.CAdESUtil.parseSignedDataForAddingUnsigned=function(t){return(new ot.asn1.cms.CMSParser).getCMSSignedData(t)},ot.asn1.cades.CAdESUtil.parseSignerInfoForAddingUnsigned=function(t,e,r){var i=ct,n=i.getChildIdx,s=i.getTLV,a=i.getV,o=ot.asn1,h=o.ASN1Object,u=o.cms,c=u.AttributeList,l=u.SignerInfo,f={},p=n(t,e);if(6!=p.length)throw"not supported items for SignerInfo (!=6)";var g=p.shift();f.version=s(t,g);var d=p.shift();f.si=s(t,d);var v=p.shift();f.digalg=s(t,v);var m=p.shift();f.sattrs=s(t,m);var y=p.shift();f.sigalg=s(t,y);var x=p.shift();f.sig=s(t,x),f.sigval=a(t,x);var S=null;return f.obj=new l,(S=new h).hTLV=f.version,f.obj.dCMSVersion=S,(S=new h).hTLV=f.si,f.obj.dSignerIdentifier=S,(S=new h).hTLV=f.digalg,f.obj.dDigestAlgorithm=S,(S=new h).hTLV=f.sattrs,f.obj.dSignedAttrs=S,(S=new h).hTLV=f.sigalg,f.obj.dSigAlg=S,(S=new h).hTLV=f.sig,f.obj.dSig=S,f.obj.dUnsignedAttrs=new c,f},void 0!==ot.asn1.csr&&ot.asn1.csr||(ot.asn1.csr={}),ot.asn1.csr.CertificationRequest=function(t){var e=ot.asn1,r=e.DERBitString,i=e.DERSequence,n=e.csr,s=n.CertificationRequestInfo;n.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(t){this.params=t},this.sign=function(){var t=new s(this.params).tohex(),e=new ot.crypto.Signature({alg:this.params.sigalg});e.init(this.params.sbjprvkey),e.updateHex(t);var r=e.sign();this.params.sighex=r},this.getPEM=function(){return wt(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var t=this.params,e=new ot.asn1.csr.CertificationRequestInfo(this.params),n=new ot.asn1.x509.AlgorithmIdentifier({name:t.sigalg});if(null==t.sighex&&null!=t.sbjprvkey&&this.sign(),null==t.sighex)throw new Error("sighex or sbjprvkey parameter not defined");var s=new r({hex:"00"+t.sighex});return new i({array:[e,n,s]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.csr.CertificationRequest,ot.asn1.ASN1Object),ot.asn1.csr.CertificationRequestInfo=function(t){var e=ot.asn1,r=e.DERSequence,i=e.DERInteger,n=e.DERUTF8String,s=e.DERTaggedObject,a=e.ASN1Util.newObject,o=e.csr,h=e.x509,u=h.X500Name,c=h.Extensions,l=h.SubjectPublicKeyInfo;o.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(t){null!=t&&(this.params=t)},this.tohex=function(){var t=this.params,e=[];if(e.push(new i({int:0})),e.push(new u(t.subject)),e.push(new l(zt.getKey(t.sbjpubkey))),null!=t.attrs){var o=function(t){for(var e=Error,r=ot.asn1.x509.Extensions,i=[],n=0;n<t.length;n++){var s=t[n],a=s.attr;if("extensionRequest"==a){var o={seq:[{oid:"1.2.840.113549.1.9.14"},{set:[new r(s.ext)]}]};i.push(o)}else if("unstructuredName"==a){o={seq:[{oid:"1.2.840.113549.1.9.2"},{set:s.names}]};i.push(o)}else{if("challengePassword"!=a)throw new e("unknown CSR attribute");o={seq:[{oid:"1.2.840.113549.1.9.7"},{set:[{utf8str:s.password}]}]};i.push(o)}}return{set:i}}(t.attrs),h=a({tag:{tage:"a0",obj:o}});e.push(h)}else if(null!=t.extreq){var f=new c(t.extreq);h=a({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[f]}]}}});e.push(h)}else e.push(new s({tag:"a0",explicit:!1,obj:new n({str:""})}));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},null!=t&&this.setByParam(t)},Gt(ot.asn1.csr.CertificationRequestInfo,ot.asn1.ASN1Object),ot.asn1.csr.AttributeList=function(t){},Gt(ot.asn1.csr.AttributeList,ot.asn1.ASN1Object),ot.asn1.csr.CSRUtil=new function(){},ot.asn1.csr.CSRUtil.newCSRPEM=function(t){return new ot.asn1.csr.CertificationRequest(t).getPEM()},ot.asn1.csr.CSRUtil.getParam=function(t,e){var r=ct,i=r.getV,n=r.getIdxbyList,s=r.getTLVbyList,a=r.getTLVbyListEx,o=r.getVbyListEx,h={};if(-1==t.indexOf("-----BEGIN CERTIFICATE REQUEST"))throw new Error("argument is not PEM file");var u=Ft(t,"CERTIFICATE REQUEST");e&&(h.tbs=s(u,0,[0]));try{var c=a(u,0,[0,1]);if("3000"==c)h.subject={};else{var l=new $t;h.subject=l.getX500Name(c)}}catch(t){}var f=a(u,0,[0,2]),p=zt.getKey(f,null,"pkcs8pub");h.sbjpubkey=zt.getPEM(p,"PKCS8PUB");var g=function(t){var e=n(t,0,[0,3,0,0],"06");return"2a864886f70d01090e"!=i(t,e)?null:s(t,0,[0,3,0,1,0],"30")}(u);l=new $t;null!=g&&(h.extreq=l.getExtParamArray(g));try{var d=a(u,0,[1],"30");l=new $t;h.sigalg=l.getAlgorithmIdentifierName(d)}catch(t){}try{var v=o(u,0,[2]);h.sighex=v}catch(t){}return h},ot.asn1.csr.CSRUtil.verifySignature=function(t){try{var e=null;if("string"==typeof t&&-1!=t.indexOf("-----BEGIN CERTIFICATE REQUEST")?e=ot.asn1.csr.CSRUtil.getParam(t,!0):"object"==typeof t&&null!=t.sbjpubkey&&null!=t.sigalg&&null!=t.sighex&&null!=t.tbs&&(e=t),null==e)return!1;var r=new ot.crypto.Signature({alg:e.sigalg});return r.init(e.sbjpubkey),r.updateHex(e.tbs),r.verify(e.sighex)}catch(t){return alert(t),!1}},void 0!==ot&&ot||(ot={}),void 0!==ot.asn1&&ot.asn1||(ot.asn1={}),void 0!==ot.asn1.ocsp&&ot.asn1.ocsp||(ot.asn1.ocsp={}),ot.asn1.ocsp.DEFAULT_HASH="sha1",ot.asn1.ocsp.OCSPResponse=function(t){ot.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var e=ot.asn1.ASN1Util.newObject,r=ot.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var t=this.params.resstatus;return"number"==typeof t?t:"string"!=typeof t?-1:i.indexOf(t)},this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params,i=this._getStatusCode();if(-1==i)throw new Error("responseStatus not supported: "+t.resstatus);if(0!=i)return e({seq:[{enum:{int:i}}]}).tohex();var n=new r(t);return e({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:n}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.OCSPResponse,ot.asn1.ASN1Object),ot.asn1.ocsp.ResponseBytes=function(t){ot.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,i=e.DERObjectIdentifier,n=e.DEROctetString,s=e.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(t){this.params=t},this.tohex=function(){var t=this.params;if("ocspBasic"!=t.restype)throw new Error("not supported responseType: "+t.restype);var e=new s(t),a=[];return a.push(new i({name:"ocspBasic"})),a.push(new n({hex:e.tohex()})),new r({array:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.ResponseBytes,ot.asn1.ASN1Object),ot.asn1.ocsp.BasicOCSPResponse=function(t){ot.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var e=Error,r=ot.asn1,i=r.ASN1Object,n=r.DERSequence,s=r.DERTaggedObject,a=r.DERBitString,o=r.x509.AlgorithmIdentifier,h=r.ocsp;_SingleResponseList=h.SingleResponseList,_ResponseData=h.ResponseData,this.params=null,this.setByParam=function(t){this.params=t},this.sign=function(){var t=this.params,e=t.tbsresp.tohex(),r=new ot.crypto.Signature({alg:t.sigalg});r.init(t.reskey),r.updateHex(e),t.sighex=r.sign()},this.tohex=function(){var t=this.params;null==t.tbsresp&&(t.tbsresp=new _ResponseData(t)),null==t.sighex&&null!=t.reskey&&this.sign();var r=[];if(r.push(t.tbsresp),r.push(new o({name:t.sigalg})),r.push(new a({hex:"00"+t.sighex})),null!=t.certs&&null!=t.certs.length){for(var h=[],u=0;u<t.certs.length;u++){var c=t.certs[u],l=null;if(ct.isASN1HEX(c))l=c;else{if(!c.match(/-----BEGIN/))throw new e("certs["+u+"] not hex or PEM");l=Ft(c)}h.push(new i({tlv:l}))}var f=new n({array:h});r.push(new s({tag:"a0",explicit:!0,obj:f}))}return new n({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.BasicOCSPResponse,ot.asn1.ASN1Object),ot.asn1.ocsp.ResponseData=function(t){ot.asn1.ocsp.ResponseData.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,i=e.DERGeneralizedTime,n=e.DERTaggedObject,s=e.x509.Extensions,a=e.ocsp,o=a.ResponderID;_SingleResponseList=a.SingleResponseList,this.params=null,this.tohex=function(){var t=this.params,e=[];if(e.push(new o(t.respid)),e.push(new i(t.prodat)),e.push(new _SingleResponseList(t.array)),null!=t.ext){var a=new s(t.ext);e.push(new n({tag:"a1",explicit:!0,obj:a}))}return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.ResponseData,ot.asn1.ASN1Object),ot.asn1.ocsp.ResponderID=function(t){ot.asn1.ocsp.ResponderID.superclass.constructor.call(this);var e=ot,r=e.asn1,i=r.ASN1Util.newObject,n=r.x509.X500Name,s=e.lang.String.isHex,a=Error;this.params=null,this.tohex=function(){var t=this.params;if(null!=t.key){var e,r=null;if("string"==typeof t.key){if(s(t.key)&&(r=t.key),t.key.match(/-----BEGIN CERTIFICATE/))null!=(e=new $t(t.key).getExtSubjectKeyIdentifier())&&(r=e.kid.hex)}else if(t.key instanceof $t)null!=(e=t.key.getExtSubjectKeyIdentifier())&&(r=e.kid.hex);if(null==r)throw new a("wrong key member value");return i({tag:{tag:"a2",explicit:!0,obj:{octstr:{hex:r}}}}).tohex()}if(null!=t.name){var o=null;if("string"==typeof t.name&&t.name.match(/-----BEGIN CERTIFICATE/))o=new $t(t.name).getSubject();else t.name instanceof $t?o=t.name.getSubject():"object"!=typeof t.name||null==t.name.array&&null==t.name.str||(o=t.name);if(null==o)throw new a("wrong name member value");return i({tag:{tag:"a1",explicit:!0,obj:new n(o)}}).tohex()}throw new a("key or name not specified")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.ResponderID,ot.asn1.ASN1Object),ot.asn1.ocsp.SingleResponseList=function(t){ot.asn1.ocsp.SingleResponseList.superclass.constructor.call(this);var e=ot.asn1,r=e.DERSequence,i=e.ocsp.SingleResponse;this.params=null,this.tohex=function(){var t=this.params;if("object"!=typeof t||null==t.length)throw new Error("params not specified properly");for(var e=[],n=0;n<t.length;n++)e.push(new i(t[n]));return new r({array:e}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.SingleResponseList,ot.asn1.ASN1Object),ot.asn1.ocsp.SingleResponse=function(t){var e=Error,r=ot.asn1,i=r.DERSequence,n=r.DERGeneralizedTime,s=r.DERTaggedObject,a=r.ocsp,o=a.CertID,h=a.CertStatus,u=r.x509.Extensions;a.SingleResponse.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params,r=[];if(null==t.certid)throw new e("certid unspecified");if(null==t.status)throw new e("status unspecified");if(null==t.thisupdate)throw new e("thisupdate unspecified");if(r.push(new o(t.certid)),r.push(new h(t.status)),r.push(new n(t.thisupdate)),null!=t.nextupdate){var a=new n(t.nextupdate);r.push(new s({tag:"a0",explicit:!0,obj:a}))}if(null!=t.ext){var c=new u(t.ext);r.push(new s({tag:"a1",explicit:!0,obj:c}))}return new i({array:r}).tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.SingleResponse,ot.asn1.ASN1Object),ot.asn1.ocsp.CertID=function(t){var e=ot,r=e.asn1,i=r.DEROctetString,n=r.DERInteger,s=r.DERSequence,a=r.x509.AlgorithmIdentifier,o=r.ocsp,h=e.crypto.Util.hashHex,u=$t,c=ct.getVbyList;o.CertID.superclass.constructor.call(this),this.DEFAULT_HASH="sha1",this.params=null,this.setByValue=function(t,e,r,i){null==i&&(i=this.DEFAULT_HASH),this.params={alg:i,issname:t,isskey:e,sbjsn:r}},this.setByCert=function(t,e,r){null==r&&(r=this.DEFAULT_HASH),this.params={alg:r,issuerCert:t,subjectCert:e}},this.getParamByCerts=function(t,e,r){null==r&&(r=this.DEFAULT_HASH);var i=new u(t),n=new u(e),s=h(i.getSubjectHex(),r),a=i.getPublicKeyHex();return{alg:r,issname:s,isskey:h(c(a,0,[1],"03",!0),r),sbjsn:n.getSerialNumberHex()}},this.tohex=function(){if("object"!=typeof this.params)throw new Error("params not set");var t,e,r,o,h=this.params;if(o=null==h.alg?this.DEFAULT_HASH:h.alg,null!=h.issuerCert&&null!=h.subjectCert){var u=this.getParamByCerts(h.issuerCert,h.subjectCert,o);t=u.issname,e=u.isskey,r=u.sbjsn}else{if(null==h.issname||null==h.isskey||null==h.sbjsn)throw new Error("required param members not defined");t=h.issname,e=h.isskey,r=h.sbjsn}var c=new a({name:o}),l=new i({hex:t}),f=new i({hex:e}),p=new n({hex:r}),g=new s({array:[c,l,f,p]});return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.CertID,ot.asn1.ASN1Object),ot.asn1.ocsp.CertStatus=function(t){ot.asn1.ocsp.CertStatus.superclass.constructor.call(this),this.params=null,this.tohex=function(){var t=this.params;if("good"==t.status)return"8000";if("unknown"==t.status)return"8200";if("revoked"==t.status){var e=[{gentime:{str:t.time}}];null!=t.reason&&e.push({tag:{tag:"a0",explicit:!0,obj:{enum:{int:t.reason}}}});var r={tag:"a1",explicit:!1,obj:{seq:e}};return ot.asn1.ASN1Util.newObject({tag:r}).tohex()}throw new Error("bad status")},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(t){this.params=t},void 0!==t&&this.setByParam(t)},Gt(ot.asn1.ocsp.CertStatus,ot.asn1.ASN1Object),ot.asn1.ocsp.Request=function(t){var e=ot.asn1,r=e.DERSequence,i=e.ocsp;if(i.Request.superclass.constructor.call(this),this.dReqCert=null,this.dExt=null,this.tohex=function(){var t=[];if(null===this.dReqCert)throw"reqCert not set";t.push(this.dReqCert);var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t){var n=new i.CertID(t);this.dReqCert=n}},Gt(ot.asn1.ocsp.Request,ot.asn1.ASN1Object),ot.asn1.ocsp.TBSRequest=function(t){var e=ot.asn1,r=e.DERSequence,i=e.ocsp;i.TBSRequest.superclass.constructor.call(this),this.version=0,this.dRequestorName=null,this.dRequestList=[],this.dRequestExt=null,this.setRequestListByParam=function(t){for(var e=[],r=0;r<t.length;r++){var n=new i.Request(t[0]);e.push(n)}this.dRequestList=e},this.tohex=function(){var t=[];if(0!==this.version)throw"not supported version: "+this.version;if(null!==this.dRequestorName)throw"requestorName not supported";var e=new r({array:this.dRequestList});if(t.push(e),null!==this.dRequestExt)throw"requestExtensions not supported";var i=new r({array:t});return this.hTLV=i.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList&&this.setRequestListByParam(t.reqList)},Gt(ot.asn1.ocsp.TBSRequest,ot.asn1.ASN1Object),ot.asn1.ocsp.OCSPRequest=function(t){var e=ot.asn1,r=e.DERSequence,i=e.ocsp;if(i.OCSPRequest.superclass.constructor.call(this),this.dTbsRequest=null,this.dOptionalSignature=null,this.tohex=function(){var t=[];if(null===this.dTbsRequest)throw"tbsRequest not set";if(t.push(this.dTbsRequest),null!==this.dOptionalSignature)throw"optionalSignature not supported";var e=new r({array:t});return this.hTLV=e.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},void 0!==t&&void 0!==t.reqList){var n=new i.TBSRequest(t);this.dTbsRequest=n}},Gt(ot.asn1.ocsp.OCSPRequest,ot.asn1.ASN1Object),ot.asn1.ocsp.OCSPUtil={},ot.asn1.ocsp.OCSPUtil.getRequestHex=function(t,e,r){var i=ot.asn1.ocsp;void 0===r&&(r=i.DEFAULT_HASH);var n={alg:r,issuerCert:t,subjectCert:e};return new i.OCSPRequest({reqList:[n]}).tohex()},ot.asn1.ocsp.OCSPUtil.getOCSPResponseInfo=function(t){var e=ct,r=e.getVbyList,i=e.getVbyListEx,n=e.getIdxbyList,s=e.getV,a={};try{var o=i(t,0,[0],"0a");a.responseStatus=parseInt(o,16)}catch(t){}if(0!==a.responseStatus)return a;try{var h=n(t,0,[1,0,1,0,0,2,0,1]);"80"===t.substr(h,2)?a.certStatus="good":"a1"===t.substr(h,2)?(a.certStatus="revoked",a.revocationTime=yt(r(t,h,[0]))):"82"===t.substr(h,2)&&(a.certStatus="unknown")}catch(t){}try{var u=n(t,0,[1,0,1,0,0,2,0,2]);a.thisUpdate=yt(s(t,u))}catch(t){}try{var c=n(t,0,[1,0,1,0,0,2,0,3]);"a0"===t.substr(c,2)&&(a.nextUpdate=yt(r(t,c,[0])))}catch(t){}return a},ot.asn1.ocsp.OCSPParser=function(){var t=Error,e=$t,r=new e,i=ct,n=i.getV,s=i.getTLV,a=i.getIdxbyList,o=i.getVbyList,h=i.getTLVbyList,u=i.getVbyListEx,c=i.getTLVbyListEx,l=i.getChildIdx;this.getOCSPRequest=function(e){var r=l(e,0);if(1!=r.length&&2!=r.length)throw new t("wrong number elements: "+r.length);return this.getTBSRequest(s(e,r[0]))},this.getTBSRequest=function(t){var e={},i=c(t,0,[0],"30");e.array=this.getRequestList(i);var n=c(t,0,["[2]",0],"30");return null!=n&&(e.ext=r.getExtParamArray(n)),e},this.getRequestList=function(t){for(var e=[],r=l(t,0),i=0;i<r.length;i++){t=s(t,r[i]);e.push(this.getRequest(t))}return e},this.getRequest=function(e){var i=l(e,0);if(1!=i.length&&2!=i.length)throw new t("wrong number elements: "+i.length);var n=this.getCertID(s(e,i[0]));if(2==i.length){var o=a(e,0,[1,0]);n.ext=r.getExtParamArray(s(e,o))}return n},this.getCertID=function(r){var i=l(r,0);if(4!=i.length)throw new t("wrong number elements: "+i.length);var a=new e,o={};return o.alg=a.getAlgorithmIdentifierName(s(r,i[0])),o.issname=n(r,i[1]),o.isskey=n(r,i[2]),o.sbjsn=n(r,i[3]),o},this.getOCSPResponse=function(t){var e,r=l(t,0),i=n(t,r[0]),s=parseInt(i);if(1==r.length)return{resstatus:s};var a=h(t,0,[1,0]);return(e=this.getResponseBytes(a)).resstatus=s,e},this.getResponseBytes=function(t){var e,r=l(t,0),i=h(t,0,[1,0]);e=this.getBasicOCSPResponse(i);var s=n(t,r[0]);return e.restype=ot.asn1.x509.OID.oid2name(kt(s)),e},this.getBasicOCSPResponse=function(t){var e,r=l(t,0);e=this.getResponseData(s(t,r[0]));var i=new $t;e.alg=i.getAlgorithmIdentifierName(s(t,r[1]));var a=n(t,r[2]);e.sighex=a.substr(2);var o=u(t,0,["[0]"]);if(null!=o){for(var h=l(o,0),c=[],f=0;f<h.length;f++){var p=s(o,h[f]);c.push(p)}e.certs=c}return e},this.getResponseData=function(t){var e=l(t,0),r=e.length,i={},a=0;"a0"==t.substr(e[0],2)&&a++,i.respid=this.getResponderID(s(t,e[a++]));var o=n(t,e[a++]);if(i.prodat=yt(o),i.array=this.getSingleResponseList(s(t,e[a++])),"a1"==t.substr(e[r-1],2)){var u=h(t,e[r-1],[0]),c=new $t;i.ext=c.getExtParamArray(u)}return i},this.getResponderID=function(t){var e={};if("a2"==t.substr(0,2)){var r=o(t,0,[0]);e.key=r}if("a1"==t.substr(0,2)){var i=h(t,0,[0]),n=new $t;e.name=n.getX500Name(i)}return e},this.getSingleResponseList=function(t){for(var e=l(t,0),r=[],i=0;i<e.length;i++){var n=this.getSingleResponse(s(t,e[i]));r.push(n)}return r},this.getSingleResponse=function(t){var e=l(t,0),r={},i=this.getCertID(s(t,e[0]));r.certid=i;var a=this.getCertStatus(s(t,e[1]));if(r.status=a,"18"==t.substr(e[2],2)){var u=n(t,e[2]);r.thisupdate=yt(u)}for(var c=3;c<e.length;c++){if("a0"==t.substr(e[c],2)){var f=o(t,e[c],[0],"18");r.nextupdate=yt(f)}if("a1"==t.substr(e[c],2)){var p=new $t,g=h(t,0,[c,0]);r.ext=p.getExtParamArray(g)}}return r},this.getCertStatus=function(t){var e={};if("8000"==t)return{status:"good"};if("8200"==t)return{status:"unknown"};if("a1"==t.substr(0,2)){e.status="revoked";var r=yt(o(t,0,[0]));e.time=r}return e}},void 0!==ot&&ot||(ot={}),void 0!==ot.lang&&ot.lang||(ot.lang={}),ot.lang.String=function(){},"function"==typeof Buffer?(ht=function(t){return pt(Buffer.from(t,"utf8").toString("base64"))},ut=function(t){return Buffer.from(gt(t),"base64").toString("utf8")}):(ht=function(t){return dt(At(Ht(t)))},ut=function(t){return decodeURIComponent(Dt(vt(t)))}),ot.lang.String.isInteger=function(t){return!!t.match(/^[0-9]+$/)||!!t.match(/^-[0-9]+$/)},ot.lang.String.isHex=function(t){return Ot(t)},ot.lang.String.isBase64=function(t){return!(!(t=t.replace(/\s+/g,"")).match(/^[0-9A-Za-z+\/]+={0,3}$/)||t.length%4!=0)},ot.lang.String.isBase64URL=function(t){return!t.match(/[+/=]/)&&(t=gt(t),ot.lang.String.isBase64(t))},ot.lang.String.isIntegerArray=function(t){return!!(t=t.replace(/\s+/g,"")).match(/^\[[0-9,]+\]$/)},ot.lang.String.isPrintable=function(t){return null!==t.match(/^[0-9A-Za-z '()+,-./:=?]*$/)},ot.lang.String.isIA5=function(t){return null!==t.match(/^[\x20-\x21\x23-\x7f]*$/)},ot.lang.String.isMail=function(t){return null!==t.match(/^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}\.[A-Za-z0-9]{1,}$/)};var Mt=function(t,e,r){return null==r&&(r="0"),t.length>=e?t:new Array(e-t.length+1).join(r)+t};function Ut(t,e){for(var r=0,i=0;i<t.length;i++)r|=1<<e[t[i]];var n=r.toString(2),s="";for(i=n.length-1;i>=0;i--)s+=n[i];return s}function _t(t,e,r){if("object"==typeof t){e=String(e).split(".");for(var i=0;i<e.length&&t;i++){var n=e[i];n.match(/^[0-9]+$/)&&(n=parseInt(n)),t=t[n]}return t||!1===t?t:r}}function Gt(t,e){var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e)}void 0!==ot&&ot||(ot={}),void 0!==ot.crypto&&ot.crypto||(ot.crypto={}),ot.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:g.algo.MD5,sha1:g.algo.SHA1,sha224:g.algo.SHA224,sha256:g.algo.SHA256,sha384:g.algo.SHA384,sha512:g.algo.SHA512,ripemd160:g.algo.RIPEMD160},this.getDigestInfoHex=function(t,e){if(void 0===this.DIGESTINFOHEAD[e])throw"alg not supported in Util.DIGESTINFOHEAD: "+e;return this.DIGESTINFOHEAD[e]+t},this.getPaddedDigestInfoHex=function(t,e,r){var i=this.getDigestInfoHex(t,e),n=r/4;if(i.length+22>n)throw"key is too short for SigAlg: keylen="+r+","+e;for(var s="0001",a="00"+i,o="",h=n-4-a.length,u=0;u<h;u+=2)o+="ff";return s+o+a},this.hashString=function(t,e){return new ot.crypto.MessageDigest({alg:e}).digestString(t)},this.hashHex=function(t,e){return new ot.crypto.MessageDigest({alg:e}).digestHex(t)},this.sha1=function(t){return this.hashString(t,"sha1")},this.sha256=function(t){return this.hashString(t,"sha256")},this.sha256Hex=function(t){return this.hashHex(t,"sha256")},this.sha512=function(t){return this.hashString(t,"sha512")},this.sha512Hex=function(t){return this.hashHex(t,"sha512")},this.isKey=function(t){return t instanceof rt||t instanceof ot.crypto.DSA||t instanceof ot.crypto.ECDSA}},ot.crypto.Util.md5=function(t){return new ot.crypto.MessageDigest({alg:"md5",prov:"cryptojs"}).digestString(t)},ot.crypto.Util.ripemd160=function(t){return new ot.crypto.MessageDigest({alg:"ripemd160",prov:"cryptojs"}).digestString(t)},ot.crypto.Util.SECURERANDOMGEN=new tt,ot.crypto.Util.getRandomHexOfNbytes=function(t){var e=new Array(t);return ot.crypto.Util.SECURERANDOMGEN.nextBytes(e),lt(e)},ot.crypto.Util.getRandomBigIntegerOfNbytes=function(t){return new x(ot.crypto.Util.getRandomHexOfNbytes(t),16)},ot.crypto.Util.getRandomHexOfNbits=function(t){var e=t%8,r=new Array((t-e)/8+1);return ot.crypto.Util.SECURERANDOMGEN.nextBytes(r),r[0]=(255<<e&255^255)&r[0],lt(r)},ot.crypto.Util.getRandomBigIntegerOfNbits=function(t){return new x(ot.crypto.Util.getRandomHexOfNbits(t),16)},ot.crypto.Util.getRandomBigIntegerZeroToMax=function(t){for(var e=t.bitLength();;){var r=ot.crypto.Util.getRandomBigIntegerOfNbits(e);if(t.compareTo(r)>=0)return r}},ot.crypto.Util.getRandomBigIntegerMinToMax=function(t,e){var r=t.compareTo(e);if(r>0)throw"biMin is greater than biMax";if(0==r)return t;var i=e.subtract(t);return ot.crypto.Util.getRandomBigIntegerZeroToMax(i).add(t)},ot.crypto.MessageDigest=function(t){this.setAlgAndProvider=function(t,e){if(null!==(t=ot.crypto.MessageDigest.getCanonicalAlgName(t))&&void 0===e&&(e=ot.crypto.Util.DEFAULTPROVIDER[t]),-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(t)&&"cryptojs"==e){try{this.md=ot.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[t].create()}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.md.update(e)},this.digest=function(){return this.md.finalize().toString(g.enc.Hex)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}if(-1!=":sha256:".indexOf(t)&&"sjcl"==e){try{this.md=new sjcl.hash.sha256}catch(e){throw"setAlgAndProvider hash alg set fail alg="+t+"/"+e}this.updateString=function(t){this.md.update(t)},this.updateHex=function(t){var e=sjcl.codec.hex.toBits(t);this.md.update(e)},this.digest=function(){var t=this.md.finalize();return sjcl.codec.hex.fromBits(t)},this.digestString=function(t){return this.updateString(t),this.digest()},this.digestHex=function(t){return this.updateHex(t),this.digest()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digest=function(){throw"digest() not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algName+"/"+this.provName},this.digestHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algName+"/"+this.provName},void 0!==t&&void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=ot.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName))},ot.crypto.MessageDigest.getCanonicalAlgName=function(t){return"string"==typeof t&&(t=(t=t.toLowerCase()).replace(/-/,"")),t},ot.crypto.MessageDigest.getHashLength=function(t){var e=ot.crypto.MessageDigest,r=e.getCanonicalAlgName(t);if(void 0===e.HASHLENGTH[r])throw"not supported algorithm: "+t;return e.HASHLENGTH[r]},ot.crypto.MessageDigest.HASHLENGTH={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,ripemd160:20},ot.crypto.Mac=function(t){this.setAlgAndProvider=function(t,e){if(null==(t=t.toLowerCase())&&(t="hmacsha1"),"hmac"!=(t=t.toLowerCase()).substr(0,4))throw"setAlgAndProvider unsupported HMAC alg: "+t;void 0===e&&(e=ot.crypto.Util.DEFAULTPROVIDER[t]),this.algProv=t+"/"+e;var r=t.substr(4);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(r)&&"cryptojs"==e){try{var i=ot.crypto.Util.CRYPTOJSMESSAGEDIGESTNAME[r];this.mac=g.algo.HMAC.create(i,this.pass)}catch(t){throw"setAlgAndProvider hash alg set fail hashAlg="+r+"/"+t}this.updateString=function(t){this.mac.update(t)},this.updateHex=function(t){var e=g.enc.Hex.parse(t);this.mac.update(e)},this.doFinal=function(){return this.mac.finalize().toString(g.enc.Hex)},this.doFinalString=function(t){return this.updateString(t),this.doFinal()},this.doFinalHex=function(t){return this.updateHex(t),this.doFinal()}}},this.updateString=function(t){throw"updateString(str) not supported for this alg/prov: "+this.algProv},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg/prov: "+this.algProv},this.doFinal=function(){throw"digest() not supported for this alg/prov: "+this.algProv},this.doFinalString=function(t){throw"digestString(str) not supported for this alg/prov: "+this.algProv},this.doFinalHex=function(t){throw"digestHex(hex) not supported for this alg/prov: "+this.algProv},this.setPassword=function(t){if("string"==typeof t){var e=t;return t.length%2!=1&&t.match(/^[0-9A-Fa-f]+$/)||(e=Et(t)),void(this.pass=g.enc.Hex.parse(e))}if("object"!=typeof t)throw"KJUR.crypto.Mac unsupported password type: "+t;e=null;if(void 0!==t.hex){if(t.hex.length%2!=0||!t.hex.match(/^[0-9A-Fa-f]+$/))throw"Mac: wrong hex password: "+t.hex;e=t.hex}if(void 0!==t.utf8&&(e=mt(t.utf8)),void 0!==t.rstr&&(e=Et(t.rstr)),void 0!==t.b64&&(e=y(t.b64)),void 0!==t.b64u&&(e=vt(t.b64u)),null==e)throw"KJUR.crypto.Mac unsupported password type: "+t;this.pass=g.enc.Hex.parse(e)},void 0!==t&&(void 0!==t.pass&&this.setPassword(t.pass),void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov&&(this.provName=ot.crypto.Util.DEFAULTPROVIDER[this.algName]),this.setAlgAndProvider(this.algName,this.provName)))},ot.crypto.Signature=function(t){var e=null;if(this._setAlgNames=function(){var t=this.algName.match(/^(.+)with(.+)$/);t&&(this.mdAlgName=t[1].toLowerCase(),this.pubkeyAlgName=t[2].toLowerCase(),"rsaandmgf1"==this.pubkeyAlgName&&"sha"==this.mdAlgName&&(this.mdAlgName="sha1"))},this._zeroPaddingOfSignature=function(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t},this.setAlgAndProvider=function(t,e){if(this._setAlgNames(),"cryptojs/jsrsa"!=e)throw new Error("provider not supported: "+e);if(-1!=":md5:sha1:sha224:sha256:sha384:sha512:ripemd160:".indexOf(this.mdAlgName)){try{this.md=new ot.crypto.MessageDigest({alg:this.mdAlgName})}catch(t){throw new Error("setAlgAndProvider hash alg set fail alg="+this.mdAlgName+"/"+t)}this.init=function(t,e){var r=null;try{r=void 0===e?zt.getKey(t):zt.getKey(t,e)}catch(t){throw"init failed:"+t}if(!0===r.isPrivate)this.prvKey=r,this.state="SIGN";else{if(!0!==r.isPublic)throw"init failed.:"+r;this.pubKey=r,this.state="VERIFY"}},this.updateString=function(t){this.md.updateString(t)},this.updateHex=function(t){this.md.updateHex(t)},this.sign=function(){if(this.sHashHex=this.md.digest(),void 0===this.prvKey&&void 0!==this.ecprvhex&&void 0!==this.eccurvename&&void 0!==ot.crypto.ECDSA&&(this.prvKey=new ot.crypto.ECDSA({curve:this.eccurvename,prv:this.ecprvhex})),this.prvKey instanceof rt&&"rsaandmgf1"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHashPSS(this.sHashHex,this.mdAlgName,this.pssSaltLen);else if(this.prvKey instanceof rt&&"rsa"===this.pubkeyAlgName)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex,this.mdAlgName);else if(this.prvKey instanceof ot.crypto.ECDSA)this.hSign=this.prvKey.signWithMessageHash(this.sHashHex);else{if(!(this.prvKey instanceof ot.crypto.DSA))throw"Signature: unsupported private key alg: "+this.pubkeyAlgName;this.hSign=this.prvKey.signWithMessageHash(this.sHashHex)}return this.hSign},this.signString=function(t){return this.updateString(t),this.sign()},this.signHex=function(t){return this.updateHex(t),this.sign()},this.verify=function(t){if(this.sHashHex=this.md.digest(),void 0===this.pubKey&&void 0!==this.ecpubhex&&void 0!==this.eccurvename&&void 0!==ot.crypto.ECDSA&&(this.pubKey=new ot.crypto.ECDSA({curve:this.eccurvename,pub:this.ecpubhex})),this.pubKey instanceof rt&&"rsaandmgf1"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHashPSS(this.sHashHex,t,this.mdAlgName,this.pssSaltLen);if(this.pubKey instanceof rt&&"rsa"===this.pubkeyAlgName)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==ot.crypto.ECDSA&&this.pubKey instanceof ot.crypto.ECDSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);if(void 0!==ot.crypto.DSA&&this.pubKey instanceof ot.crypto.DSA)return this.pubKey.verifyWithMessageHash(this.sHashHex,t);throw"Signature: unsupported public key alg: "+this.pubkeyAlgName}}},this.init=function(t,e){throw"init(key, pass) not supported for this alg:prov="+this.algProvName},this.updateString=function(t){throw"updateString(str) not supported for this alg:prov="+this.algProvName},this.updateHex=function(t){throw"updateHex(hex) not supported for this alg:prov="+this.algProvName},this.sign=function(){throw"sign() not supported for this alg:prov="+this.algProvName},this.signString=function(t){throw"digestString(str) not supported for this alg:prov="+this.algProvName},this.signHex=function(t){throw"digestHex(hex) not supported for this alg:prov="+this.algProvName},this.verify=function(t){throw"verify(hSigVal) not supported for this alg:prov="+this.algProvName},this.initParams=t,void 0!==t&&(void 0!==t.alg&&(this.algName=t.alg,void 0===t.prov?this.provName=ot.crypto.Util.DEFAULTPROVIDER[this.algName]:this.provName=t.prov,this.algProvName=this.algName+":"+this.provName,this.setAlgAndProvider(this.algName,this.provName),this._setAlgNames()),void 0!==t.psssaltlen&&(this.pssSaltLen=t.psssaltlen),void 0!==t.prvkeypem)){if(void 0!==t.prvkeypas)throw"both prvkeypem and prvkeypas parameters not supported";try{e=zt.getKey(t.prvkeypem);this.init(e)}catch(t){throw"fatal error to load pem private key: "+t}}},ot.crypto.Cipher=function(t){},ot.crypto.Cipher.encrypt=function(t,e,r,i){if(null!=_t(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=_t(i,"key")&&(n=i.key),null!=_t(i,"enc")&&(hEnc=i.enc);var a,o=g.enc.Hex.parse(n),h=g.enc.Hex.parse(s),u=g.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=g.TripleDES.encrypt(h,o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=g.AES.encrypt(h,o,{iv:u})}return a+""}throw new Error("Cipher.encrypt: unsupported key or algorithm")},ot.crypto.Cipher.decrypt=function(t,e,r,i){if(null!=_t(i,"enclag")&&(r=i.encalg),"string"==typeof r&&"-CBC"==r.substr(-4)){var n=e,s=t;null!=_t(i,"key")&&(n=i.key),null!=_t(i,"enc")&&(s=i.enc);var a,o=g.enc.Hex.parse(n),h=g.enc.Hex.parse(s),u=g.enc.Hex.parse(i.iv);if("des-EDE3-CBC"==r)a=g.TripleDES.decrypt({ciphertext:h},o,{iv:u});else{if("aes128-CBC"!=r&&"aes256-CBC"!=r)throw new Error("unsupported algorithm: "+r);a=g.AES.decrypt({ciphertext:h},o,{iv:u})}return g.enc.Hex.stringify(a)}throw new Error("Cipher.decrypt: unsupported key or algorithm")},ot.crypto.OID=new function(){this.oidhex2name={"2a864886f70d010101":"rsaEncryption","2a8648ce3d0201":"ecPublicKey","2a8648ce380401":"dsa","2a8648ce3d030107":"secp256r1","2b8104001f":"secp192k1","2b81040021":"secp224r1","2b8104000a":"secp256k1","2b81040022":"secp384r1","2b81040023":"secp521r1","2a8648ce380403":"SHA1withDSA","608648016503040301":"SHA224withDSA","608648016503040302":"SHA256withDSA"}},void 0!==ot&&ot||(ot={}),void 0!==ot.crypto&&ot.crypto||(ot.crypto={}),ot.crypto.ECDSA=function(t){var e=Error,r=x,i=nt,n=ot.crypto.ECDSA,s=ot.crypto.ECParameterDB,a=n.getName,o=ct,h=o.getVbyListEx,u=o.isASN1HEX,c=new tt;this.type="EC",this.isPrivate=!1,this.isPublic=!1,this.getBigRandom=function(t){return new r(t.bitLength(),c).mod(t.subtract(r.ONE)).add(r.ONE)},this.setNamedCurve=function(t){this.ecparams=s.getByName(t),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=t},this.setPrivateKeyHex=function(t){this.isPrivate=!0,this.prvKeyHex=t},this.setPublicKeyHex=function(t){this.isPublic=!0,this.pubKeyHex=t},this.getPublicKeyXYHex=function(){var t=this.pubKeyHex;if("04"!==t.substr(0,2))throw"this method supports uncompressed format(04) only";var e=this.ecparams.keycharlen;if(t.length!==2+2*e)throw"malformed public key hex length";var r={};return r.x=t.substr(2,e),r.y=t.substr(2+e),r},this.getShortNISTPCurveName=function(){var t=this.curveName;return"secp256r1"===t||"NIST P-256"===t||"P-256"===t||"prime256v1"===t?"P-256":"secp384r1"===t||"NIST P-384"===t||"P-384"===t?"P-384":"secp521r1"===t||"NIST P-521"===t||"P-521"===t?"P-521":null},this.generateKeyPairHex=function(){var t=this.ecparams.n,e=this.getBigRandom(t),r=this.ecparams.keycharlen,i=("0000000000"+e.toString(16)).slice(-r);return this.setPrivateKeyHex(i),{ecprvhex:i,ecpubhex:this.generatePublicKeyHex()}},this.generatePublicKeyHex=function(){var t=new r(this.prvKeyHex,16),e=this.ecparams.G.multiply(t),i=e.getX().toBigInteger(),n=e.getY().toBigInteger(),s=this.ecparams.keycharlen,a="04"+("0000000000"+i.toString(16)).slice(-s)+("0000000000"+n.toString(16)).slice(-s);return this.setPublicKeyHex(a),a},this.signWithMessageHash=function(t){return this.signHex(t,this.prvKeyHex)},this.signHex=function(t,e){var i=new r(e,16),s=this.ecparams.n,a=new r(t.substring(0,this.ecparams.keycharlen),16);do{var o=this.getBigRandom(s),h=this.ecparams.G.multiply(o).getX().toBigInteger().mod(s)}while(h.compareTo(r.ZERO)<=0);var u=o.modInverse(s).multiply(a.add(i.multiply(h))).mod(s);return n.biRSSigToASN1Sig(h,u)},this.sign=function(t,e){var i=e,n=this.ecparams.n,s=r.fromByteArrayUnsigned(t);do{var a=this.getBigRandom(n),o=this.ecparams.G.multiply(a).getX().toBigInteger().mod(n)}while(o.compareTo(x.ZERO)<=0);var h=a.modInverse(n).multiply(s.add(i.multiply(o))).mod(n);return this.serializeSig(o,h)},this.verifyWithMessageHash=function(t,e){return this.verifyHex(t,e,this.pubKeyHex)},this.verifyHex=function(t,e,s){try{var a,o,h=n.parseSigHex(e);a=h.r,o=h.s;var u=i.decodeFromHex(this.ecparams.curve,s),c=new r(t.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(c,a,o,u)}catch(t){return!1}},this.verify=function(t,e,n){var s,a,o;if(Bitcoin.Util.isArray(e)){var h=this.parseSig(e);s=h.r,a=h.s}else{if("object"!=typeof e||!e.r||!e.s)throw"Invalid value for signature";s=e.r,a=e.s}if(n instanceof nt)o=n;else{if(!Bitcoin.Util.isArray(n))throw"Invalid format for pubkey value, must be byte array or ECPointFp";o=i.decodeFrom(this.ecparams.curve,n)}var u=r.fromByteArrayUnsigned(t);return this.verifyRaw(u,s,a,o)},this.verifyRaw=function(t,e,i,n){var s=this.ecparams.n,a=this.ecparams.G;if(e.compareTo(r.ONE)<0||e.compareTo(s)>=0)return!1;if(i.compareTo(r.ONE)<0||i.compareTo(s)>=0)return!1;var o=i.modInverse(s),h=t.multiply(o).mod(s),u=e.multiply(o).mod(s);return a.multiply(h).add(n.multiply(u)).getX().toBigInteger().mod(s).equals(e)},this.serializeSig=function(t,e){var r=t.toByteArraySigned(),i=e.toByteArraySigned(),n=[];return n.push(2),n.push(r.length),(n=n.concat(r)).push(2),n.push(i.length),(n=n.concat(i)).unshift(n.length),n.unshift(48),n},this.parseSig=function(t){var e;if(48!=t[0])throw new Error("Signature not a valid DERSequence");if(2!=t[e=2])throw new Error("First element in signature must be a DERInteger");var i=t.slice(e+2,e+2+t[e+1]);if(2!=t[e+=2+t[e+1]])throw new Error("Second element in signature must be a DERInteger");var n=t.slice(e+2,e+2+t[e+1]);return e+=2+t[e+1],{r:r.fromByteArrayUnsigned(i),s:r.fromByteArrayUnsigned(n)}},this.parseSigCompact=function(t){if(65!==t.length)throw"Signature has the wrong length";var e=t[0]-27;if(e<0||e>7)throw"Invalid signature type";var i=this.ecparams.n;return{r:r.fromByteArrayUnsigned(t.slice(1,33)).mod(i),s:r.fromByteArrayUnsigned(t.slice(33,65)).mod(i),i:e}},this.readPKCS5PrvKeyHex=function(t){if(!1===u(t))throw new Error("not ASN.1 hex string");var e,r,i;try{e=h(t,0,["[0]",0],"06"),r=h(t,0,[1],"04");try{i=h(t,0,["[1]",0],"03")}catch(t){}}catch(t){throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=a(e),void 0===this.curveName)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(i),this.setPrivateKeyHex(r),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i,n;try{h(t,0,[1,0],"06"),r=h(t,0,[1,1],"06"),i=h(t,0,[2,0,1],"04");try{n=h(t,0,[2,0,"[1]",0],"03")}catch(t){}}catch(t){throw new e("malformed PKCS#8 plain ECC private key")}if(this.curveName=a(r),void 0===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n),this.setPrivateKeyHex(i),this.isPublic=!1},this.readPKCS8PubKeyHex=function(t){if(!1===u(t))throw new e("not ASN.1 hex string");var r,i;try{h(t,0,[0,0],"06"),r=h(t,0,[0,1],"06"),i=h(t,0,[1],"03")}catch(t){throw new e("malformed PKCS#8 ECC public key")}if(this.curveName=a(r),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(i)},this.readCertPubKeyHex=function(t,r){if(!1===u(t))throw new e("not ASN.1 hex string");var i,n;try{i=h(t,0,[0,5,0,1],"06"),n=h(t,0,[0,5,1],"03")}catch(t){throw new e("malformed X.509 certificate ECC public key")}if(this.curveName=a(i),null===this.curveName)throw new e("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(n)},void 0!==t&&void 0!==t.curve&&(this.curveName=t.curve),void 0===this.curveName&&(this.curveName="secp256r1"),this.setNamedCurve(this.curveName),void 0!==t&&(void 0!==t.prv&&this.setPrivateKeyHex(t.prv),void 0!==t.pub&&this.setPublicKeyHex(t.pub))},ot.crypto.ECDSA.parseSigHex=function(t){var e=ot.crypto.ECDSA.parseSigHexInHexRS(t);return{r:new x(e.r,16),s:new x(e.s,16)}},ot.crypto.ECDSA.parseSigHexInHexRS=function(t){var e=ct,r=e.getChildIdx,i=e.getV;if(e.checkStrictDER(t,0),"30"!=t.substr(0,2))throw new Error("signature is not a ASN.1 sequence");var n=r(t,0);if(2!=n.length)throw new Error("signature shall have two elements");var s=n[0],a=n[1];if("02"!=t.substr(s,2))throw new Error("1st item not ASN.1 integer");if("02"!=t.substr(a,2))throw new Error("2nd item not ASN.1 integer");return{r:i(t,s),s:i(t,a)}},ot.crypto.ECDSA.asn1SigToConcatSig=function(t){var e=ot.crypto.ECDSA.parseSigHexInHexRS(t),r=e.r,i=e.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(i.length%2!=0)throw Error("unknown ECDSA sig s length error");"00"==r.substr(0,2)&&(r=r.substr(2)),"00"==i.substr(0,2)&&(i=i.substr(2));var n=Math.max(r.length,i.length);return(r=("000000"+r).slice(-n))+(i=("000000"+i).slice(-n))}if("00"==r.substr(0,2)&&r.length%32==2&&(r=r.substr(2)),"00"==i.substr(0,2)&&i.length%32==2&&(i=i.substr(2)),r.length%32==30&&(r="00"+r),i.length%32==30&&(i="00"+i),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(i.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+i},ot.crypto.ECDSA.concatSigToASN1Sig=function(t){if(t.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var e=t.substr(0,t.length/2),r=t.substr(t.length/2);return ot.crypto.ECDSA.hexRSSigToASN1Sig(e,r)},ot.crypto.ECDSA.hexRSSigToASN1Sig=function(t,e){var r=new x(t,16),i=new x(e,16);return ot.crypto.ECDSA.biRSSigToASN1Sig(r,i)},ot.crypto.ECDSA.biRSSigToASN1Sig=function(t,e){var r=ot.asn1,i=new r.DERInteger({bigint:t}),n=new r.DERInteger({bigint:e});return new r.DERSequence({array:[i,n]}).tohex()},ot.crypto.ECDSA.getName=function(t){return"2b8104001f"===t?"secp192k1":"2a8648ce3d030107"===t?"secp256r1":"2b8104000a"===t?"secp256k1":"2b81040021"===t?"secp224r1":"2b81040022"===t?"secp384r1":"2b81040023"===t?"secp521r1":-1!=="|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(t)?"secp256r1":-1!=="|secp256k1|".indexOf(t)?"secp256k1":-1!=="|secp224r1|NIST P-224|P-224|".indexOf(t)?"secp224r1":-1!=="|secp384r1|NIST P-384|P-384|".indexOf(t)?"secp384r1":-1!=="|secp521r1|NIST P-521|P-521|".indexOf(t)?"secp521r1":null},void 0!==ot&&ot||(ot={}),void 0!==ot.crypto&&ot.crypto||(ot.crypto={}),ot.crypto.ECParameterDB=new function(){var t={},e={};function r(t){return new x(t,16)}this.getByName=function(r){var i=r;if(void 0!==e[i]&&(i=e[r]),void 0!==t[i])return t[i];throw"unregistered EC curve name: "+i},this.regist=function(i,n,s,a,o,h,u,c,l,f,p,g){t[i]={};var d=r(s),v=r(a),m=r(o),y=r(h),x=r(u),S=new st(d,v,m),E=S.decodePointHex("04"+c+l);t[i].name=i,t[i].keylen=n,t[i].keycharlen=2*Math.ceil(n/8),t[i].curve=S,t[i].G=E,t[i].n=y,t[i].h=x,t[i].oid=p,t[i].info=g;for(var w=0;w<f.length;w++)e[f[w]]=i}},ot.crypto.ECParameterDB.regist("secp128r1",128,"FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFDFFFFFFFFFFFFFFFFFFFFFFFC","E87579C11079F43DD824993C2CEE5ED3","FFFFFFFE0000000075A30D1B9038A115","1","161FF7528B899B2D0C28607CA52C5B86","CF5AC8395BAFEB13C02DA292DDED7A83",[],"","secp128r1 : SECG curve over a 128 bit prime field"),ot.crypto.ECParameterDB.regist("secp160k1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFAC73","0","7","0100000000000000000001B8FA16DFAB9ACA16B6B3","1","3B4C382CE37AA192A4019E763036F4F5DD4D7EBB","938CF935318FDCED6BC28286531733C3F03C4FEE",[],"","secp160k1 : SECG curve over a 160 bit prime field"),ot.crypto.ECParameterDB.regist("secp160r1",160,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF7FFFFFFC","1C97BEFC54BD7A8B65ACF89F81D4D4ADC565FA45","0100000000000000000001F4C8F927AED3CA752257","1","4A96B5688EF573284664698968C38BB913CBFC82","23A628553168947D59DCC912042351377AC5FB32",[],"","secp160r1 : SECG curve over a 160 bit prime field"),ot.crypto.ECParameterDB.regist("secp192k1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFEE37","0","3","FFFFFFFFFFFFFFFFFFFFFFFE26F2FC170F69466A74DEFD8D","1","DB4FF10EC057E9AE26B07D0280B7F4341DA5D1B1EAE06C7D","9B2F2F6D9C5628A7844163D015BE86344082AA88D95E2F9D",[]),ot.crypto.ECParameterDB.regist("secp192r1",192,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFC","64210519E59C80E70FA7E9AB72243049FEB8DEECC146B9B1","FFFFFFFFFFFFFFFFFFFFFFFF99DEF836146BC9B1B4D22831","1","188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012","07192B95FFC8DA78631011ED6B24CDD573F977A11E794811",[]),ot.crypto.ECParameterDB.regist("secp224r1",224,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000001","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFE","B4050A850C04B3ABF54132565044B0B7D7BFD8BA270B39432355FFB4","FFFFFFFFFFFFFFFFFFFFFFFFFFFF16A2E0B8F03E13DD29455C5C2A3D","1","B70E0CBD6BB4BF7F321390B94A03C1D356C21122343280D6115C1D21","BD376388B5F723FB4C22DFE6CD4375A05A07476444D5819985007E34",[]),ot.crypto.ECParameterDB.regist("secp256k1",256,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F","0","7","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141","1","79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798","483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8",[]),ot.crypto.ECParameterDB.regist("secp256r1",256,"FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF","FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC","5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B","FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551","1","6B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296","4FE342E2FE1A7F9B8EE7EB4A7C0F9E162BCE33576B315ECECBB6406837BF51F5",["NIST P-256","P-256","prime256v1"]),ot.crypto.ECParameterDB.regist("secp384r1",384,"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFFFF0000000000000000FFFFFFFC","B3312FA7E23EE7E4988E056BE3F82D19181D9C6EFE8141120314088F5013875AC656398D8A2ED19D2A85C8EDD3EC2AEF","FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC7634D81F4372DDF581A0DB248B0A77AECEC196ACCC52973","1","AA87CA22BE8B05378EB1C71EF320AD746E1D3B628BA79B9859F741E082542A385502F25DBF55296C3A545E3872760AB7","3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f",["NIST P-384","P-384"]),ot.crypto.ECParameterDB.regist("secp521r1",521,"1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC","051953EB9618E1C9A1F929A21A0B68540EEA2DA725B99B315F3B8B489918EF109E156193951EC7E937B1652C0BD3BB1BF073573DF883D2C34F1EF451FD46B503F00","1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA51868783BF2F966B7FCC0148F709A5D03BB5C9B8899C47AEBB6FB71E91386409","1","00C6858E06B70404E9CD9E3ECB662395B4429C648139053FB521F828AF606B4D3DBAA14B5E77EFE75928FE1DC127A2FFA8DE3348B3C1856A429BF97E7E31C2E5BD66","011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650",["NIST P-521","P-521"]),void 0!==ot&&ot||(ot={}),void 0!==ot.crypto&&ot.crypto||(ot.crypto={}),ot.crypto.DSA=function(){var t=ct,e=t.getVbyListEx,r=t.isASN1HEX,i=x,n=x.ONE;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(t,e,r,i,n){this.isPrivate=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=n},this.setPrivateHex=function(t,e,r,i,n){var s,a,o,h,u;s=new x(t,16),a=new x(e,16),o=new x(r,16),h="string"==typeof i&&i.length>1?new x(i,16):null,u=new x(n,16),this.setPrivate(s,a,o,h,u)},this.setPublic=function(t,e,r,i){!function(t,e,r,i){if(null==t||null==e||null==r||null==i)throw new Error("invalid DSA public key");if(n.compareTo(e)>=0||e.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(r)>=0||r.compareTo(t)>=0)throw new Error("invalid DSA public key");if(n.compareTo(i)>=0||i.compareTo(t)>=0)throw new Error("invalid DSA public key");if(0!=r.modPow(e,t).compareTo(n))throw new Error("invalid DSA public key")}(t,e,r,i),this.isPublic=!0,this.p=t,this.q=e,this.g=r,this.y=i,this.x=null},this.setPublicHex=function(t,e,r,i){var n,s,a,o;n=new x(t,16),s=new x(e,16),a=new x(r,16),o=new x(i,16),this.setPublic(n,s,a,o)},this.signWithMessageHash=function(t){var e,r,i,n=this.p,s=this.q,a=this.g,o=this.x,h=new x(t.substr(0,s.bitLength()/4),16);do{e=ot.crypto.Util.getRandomBigIntegerMinToMax(x.ONE.add(x.ONE),s.subtract(x.ONE)),r=a.modPow(e,n).mod(s),i=e.modInverse(s).multiply(h.add(o.multiply(r))).mod(s)}while(0==r.compareTo(x.ZERO)||0==i.compareTo(x.ZERO));return ot.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:r}},{int:{bigint:i}}]})},this.verifyWithMessageHash=function(t,e){var r=this.p,i=this.q,n=this.g,s=this.y,a=this.parseASN1Signature(e),o=a[0],h=a[1],u=new x(t.substr(0,i.bitLength()/4),16);if(x.ZERO.compareTo(o)>=0||o.compareTo(i)>=0)throw"invalid DSA signature";if(x.ZERO.compareTo(h)>=0||h.compareTo(i)>=0)throw"invalid DSA signature";var c=h.modInverse(i),l=u.multiply(c).mod(i),f=o.multiply(c).mod(i);return 0==n.modPow(l,r).multiply(s.modPow(f,r)).mod(r).mod(i).compareTo(o)},this.parseASN1Signature=function(t){try{return[new i(e(t,0,[0],"02"),16),new i(e(t,0,[1],"02"),16)]}catch(t){throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(t){var i,n,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1],"02"),n=e(t,0,[2],"02"),s=e(t,0,[3],"02"),a=e(t,0,[4],"02"),o=e(t,0,[5],"02")}catch(t){throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(i,n,s,a,o)},this.readPKCS8PrvKeyHex=function(t){var i,n,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[1,1,0],"02"),n=e(t,0,[1,1,1],"02"),s=e(t,0,[1,1,2],"02"),a=e(t,0,[2,0],"02")}catch(t){throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(i,n,s,null,a)},this.readPKCS8PubKeyHex=function(t){var i,n,s,a;if(!1===r(t))throw new Error("not ASN.1 hex string");try{i=e(t,0,[0,1,0],"02"),n=e(t,0,[0,1,1],"02"),s=e(t,0,[0,1,2],"02"),a=e(t,0,[1,0],"02")}catch(t){throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(i,n,s,a)},this.readCertPubKeyHex=function(t,i){var n,s,a,o;if(!1===r(t))throw new Error("not ASN.1 hex string");try{n=e(t,0,[0,5,0,1,0],"02"),s=e(t,0,[0,5,0,1,1],"02"),a=e(t,0,[0,5,0,1,2],"02"),o=e(t,0,[0,5,1,0],"02")}catch(t){throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(n,s,a,o)}};var zt=function(){var t=function(t,r,i){return e(g.AES,t,r,i)},e=function(t,e,r,i){var n=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(i),o={};o.key=s,o.iv=a,o.ciphertext=n;var h=t.decrypt(o,s,{iv:a});return g.enc.Hex.stringify(h)},r=function(t,e,r){return i(g.AES,t,e,r)},i=function(t,e,r,i){var n=g.enc.Hex.parse(e),s=g.enc.Hex.parse(r),a=g.enc.Hex.parse(i),o=t.encrypt(n,s,{iv:a}),h=g.enc.Hex.parse(o.toString());return g.enc.Base64.stringify(h)},n={"AES-256-CBC":{proc:t,eproc:r,keylen:32,ivlen:16},"AES-192-CBC":{proc:t,eproc:r,keylen:24,ivlen:16},"AES-128-CBC":{proc:t,eproc:r,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:function(t,r,i){return e(g.TripleDES,t,r,i)},eproc:function(t,e,r){return i(g.TripleDES,t,e,r)},keylen:24,ivlen:8},"DES-CBC":{proc:function(t,r,i){return e(g.DES,t,r,i)},eproc:function(t,e,r){return i(g.DES,t,e,r)},keylen:8,ivlen:8}},s=function(t){var e={},r=t.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));r&&(e.cipher=r[1],e.ivsalt=r[2]);var i=t.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));i&&(e.type=i[1]);var n=-1,s=0;-1!=t.indexOf("\r\n\r\n")&&(n=t.indexOf("\r\n\r\n"),s=2),-1!=t.indexOf("\n\n")&&(n=t.indexOf("\n\n"),s=1);var a=t.indexOf("-----END");if(-1!=n&&-1!=a){var o=t.substring(n+2*s,a-s);o=o.replace(/\s+/g,""),e.data=o}return e},a=function(t,e,r){for(var i=r.substring(0,16),s=g.enc.Hex.parse(i),a=g.enc.Utf8.parse(e),o=n[t].keylen+n[t].ivlen,h="",u=null;;){var c=g.algo.MD5.create();if(null!=u&&c.update(u),c.update(a),c.update(s),u=c.finalize(),(h+=g.enc.Hex.stringify(u)).length>=2*o)break}var l={};return l.keyhex=h.substr(0,2*n[t].keylen),l.ivhex=h.substr(2*n[t].keylen,2*n[t].ivlen),l},o=function(t,e,r,i){var s=g.enc.Base64.parse(t),a=g.enc.Hex.stringify(s);return(0,n[e].proc)(a,r,i)};return{version:"1.0.0",parsePKCS5PEM:function(t){return s(t)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(t,e,r){return a(t,e,r)},decryptKeyB64:function(t,e,r,i){return o(t,e,r,i)},getDecryptedKeyHex:function(t,e){var r=s(t),i=r.cipher,n=r.ivsalt,h=r.data,u=a(i,e,n).keyhex;return o(h,i,u,n)},getEncryptedPKCS5PEMFromPrvKeyHex:function(t,e,r,i,s){var o="";if(void 0!==i&&null!=i||(i="AES-256-CBC"),void 0===n[i])throw new Error("KEYUTIL unsupported algorithm: "+i);if(void 0===s||null==s){var h=function(t){var e=g.lib.WordArray.random(t);return g.enc.Hex.stringify(e)}(n[i].ivlen);s=h.toUpperCase()}var u=function(t,e,r,i){return(0,n[e].eproc)(t,r,i)}(e,i,a(i,r,s).keyhex,s);o="-----BEGIN "+t+" PRIVATE KEY-----\r\n";return o+="Proc-Type: 4,ENCRYPTED\r\n",o+="DEK-Info: "+i+","+s+"\r\n",o+="\r\n",o+=u.replace(/(.{64})/g,"$1\r\n"),o+="\r\n-----END "+t+" PRIVATE KEY-----\r\n"},getEncryptedPKCS8PEM:function(t,e,r){return wt(this.getEncryptedPKCS8Hex(t,e,r),"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(t,e,r){var i;(i=null==r||null==r?{}:JSON.parse(JSON.stringify(r))).plain=t,this.initPBES2Param(i),this.encryptPBES2Param(i,e);var n=this.generatePBES2ASN1Param(i);return ot.asn1.ASN1Util.newObject(n).tohex()},initPBES2Param:function(t){var e;(null==_t(t,"encalg")&&(t.encalg="aes256-CBC"),null==_t(t,"iter")&&(t.iter=2048),null==_t(t,"prf")&&(t.prf="hmacWithSHA256"),null==_t(t,"salt")&&(t.salt=g.enc.Hex.stringify(g.lib.WordArray.random(8))),null==_t(t,"enciv"))&&("des-EDE3-CBC"==t.encalg&&(e=8),"aes128-CBC"==t.encalg&&(e=16),"aes256-CBC"==t.encalg&&(e=16),t.enciv=g.enc.Hex.stringify(g.lib.WordArray.random(e)))},encryptPBES2Param:function(t,e){var r=zt.getDKFromPBES2Param(t,e);try{var i=ot.crypto.Cipher.encrypt(t.plain,r,t.encalg,{iv:t.enciv})}catch(e){throw new Error("encrypt error: "+t.plain+" "+r+" "+t.encalg+" "+t.enciv)}t.enc=i},generatePBES2ASN1Param:function(t){var e={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:t.salt}},{int:{hex:Lt(t.iter)}}]}]},{seq:[{oid:t.encalg},{octstr:{hex:t.enciv}}]}]}]},{octstr:{hex:t.enc}}]};return"hmacWithSHA1"!=t.prf&&e.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:t.prf},{null:""}]}),e},parseHexOfEncryptedPKCS8:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={},s=r(t,0);if(2!=s.length)throw new Error("malformed format: SEQUENCE(0).items != 2: "+s.length);n.ciphertext=i(t,s[1]);var a=r(t,s[0]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+a.length);if("2a864886f70d01050d"!=i(t,a[0]))throw new Error("this only supports pkcs5PBES2");var o=r(t,a[1]);if(2!=a.length)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+o.length);var h=r(t,o[1]);if(2!=h.length)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+h.length);if("2a864886f70d0307"!=i(t,h[0]))throw"this only supports TripleDES";n.encryptionSchemeAlg="TripleDES",n.encryptionSchemeIV=i(t,h[1]);var u=r(t,o[0]);if(2!=u.length)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+u.length);if("2a864886f70d01050c"!=i(t,u[0]))throw new Error("this only supports pkcs5PBKDF2");var c=r(t,u[1]);if(c.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+c.length);n.pbkdf2Salt=i(t,c[0]);var l=i(t,c[1]);try{n.pbkdf2Iter=parseInt(l,16)}catch(t){throw new Error("malformed format pbkdf2Iter: "+l)}return n},getPBKDF2KeyHexFromParam:function(t,e){var r=g.enc.Hex.parse(t.pbkdf2Salt),i=t.pbkdf2Iter,n=g.PBKDF2(e,r,{keySize:6,iterations:i});return g.enc.Hex.stringify(n)},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(t,e){var r=Ft(t,"ENCRYPTED PRIVATE KEY"),i=this.parseHexOfEncryptedPKCS8(r),n=zt.getPBKDF2KeyHexFromParam(i,e),s={};s.ciphertext=g.enc.Hex.parse(i.ciphertext);var a=g.enc.Hex.parse(n),o=g.enc.Hex.parse(i.encryptionSchemeIV),h=g.TripleDES.decrypt(s,a,{iv:o});return g.enc.Hex.stringify(h)},parsePBES2:function(t){var e=ct.parse(t);if("pkcs5PBES2"!=_t(e,"seq.0.seq.0.oid")||"pkcs5PBKDF2"!=_t(e,"seq.0.seq.1.seq.0.seq.0.oid"))throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var r=_t(e,"seq.0.seq.1.seq.0.seq.1.seq");if(null==r)throw new Error("PBKDF2 parameter not found");var i=_t(r,"0.octstr.hex"),n=_t(r,"1.int.hex"),s=_t(r,"2.seq.0.oid","hmacWithSHA1"),a=-1;try{a=parseInt(n,16)}catch(t){throw new Error("iter not proper value")}var o=_t(e,"seq.0.seq.1.seq.1.seq.0.oid"),h=_t(e,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),u=_t(e,"seq.1.octstr.hex");if(null==o||null==h||null==u)throw new Error("encalg, enciv or enc is undefined");return{salt:i,iter:a,prf:s,encalg:o,enciv:h,enc:u}},getDKFromPBES2Param:function(t,e){var r={hmacWithSHA1:g.algo.SHA1,hmacWithSHA224:g.algo.SHA224,hmacWithSHA256:g.algo.SHA256,hmacWithSHA384:g.algo.SHA384,hmacWithSHA512:g.algo.SHA512}[t.prf];if(null==r)throw new Error("unsupported prf");var i={"des-EDE3-CBC":6,"aes128-CBC":4,"aes256-CBC":8}[t.encalg];if(null==i)throw new Error("unsupported encalg");var n=g.enc.Hex.parse(t.salt),s=t.iter;try{var a=g.PBKDF2(e,n,{keySize:i,iterations:s,hasher:r});return g.enc.Hex.stringify(a)}catch(r){throw new Error("PBKDF2 error: "+r+" "+JSON.stringify(t)+" "+e)}},getPlainHexFromEncryptedPKCS8PEM:function(t,e){if(-1==t.indexOf("BEGIN ENCRYPTED PRIVATE KEY"))throw new Error("not Encrypted PKCS#8 PEM string");var r,i=Ft(t);try{r=zt.parsePBES2(i)}catch(t){throw new Error("malformed PBES2 format: "+t.message)}var n=zt.getDKFromPBES2Param(r,e);return ot.crypto.Cipher.decrypt(r.enc,n,r.encalg,{iv:r.enciv})},getKeyFromEncryptedPKCS8PEM:function(t,e){var r=this.getPlainHexFromEncryptedPKCS8PEM(t,e);return this.getKeyFromPlainPrivatePKCS8Hex(r)},parsePlainPrivatePKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={algparam:null};if("30"!=t.substr(0,2))throw new Error("malformed plain PKCS8 private key(code:001)");var s=r(t,0);if(s.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if("30"!=t.substr(s[1],2))throw new Error("malformed PKCS8 private key(code:003)");var a=r(t,s[1]);if(2!=a.length)throw new Error("malformed PKCS8 private key(code:004)");if("06"!=t.substr(a[0],2))throw new Error("malformed PKCS8 private key(code:005)");if(n.algoid=i(t,a[0]),"06"==t.substr(a[1],2)&&(n.algparam=i(t,a[1])),"04"!=t.substr(s[2],2))throw new Error("malformed PKCS8 private key(code:006)");return n.keyidx=e.getVidx(t,s[2]),n},getKeyFromPlainPrivatePKCS8PEM:function(t){var e=Ft(t,"PRIVATE KEY");return this.getKeyFromPlainPrivatePKCS8Hex(e)},getKeyFromPlainPrivatePKCS8Hex:function(t){var e,r=this.parsePlainPrivatePKCS8Hex(t);if("2a864886f70d010101"==r.algoid)e=new rt;else if("2a8648ce380401"==r.algoid)e=new ot.crypto.DSA;else{if("2a8648ce3d0201"!=r.algoid)throw new Error("unsupported private key algorithm");e=new ot.crypto.ECDSA}return e.readPKCS8PrvKeyHex(t),e},_getKeyFromPublicPKCS8Hex:function(t){var e,r=ct.getVbyList(t,0,[0,0],"06");if("2a864886f70d010101"===r)e=new rt;else if("2a8648ce380401"===r)e=new ot.crypto.DSA;else{if("2a8648ce3d0201"!==r)throw new Error("unsupported PKCS#8 public key hex");e=new ot.crypto.ECDSA}return e.readPKCS8PubKeyHex(t),e},parsePublicRawRSAKeyHex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={};if("30"!=t.substr(0,2))throw new Error("malformed RSA key(code:001)");var s=r(t,0);if(2!=s.length)throw new Error("malformed RSA key(code:002)");if("02"!=t.substr(s[0],2))throw new Error("malformed RSA key(code:003)");if(n.n=i(t,s[0]),"02"!=t.substr(s[1],2))throw new Error("malformed RSA key(code:004)");return n.e=i(t,s[1]),n},parsePublicPKCS8Hex:function(t){var e=ct,r=e.getChildIdx,i=e.getV,n={algparam:null},s=r(t,0);if(2!=s.length)throw new Error("outer DERSequence shall have 2 elements: "+s.length);var a=s[0];if("30"!=t.substr(a,2))throw new Error("malformed PKCS8 public key(code:001)");var o=r(t,a);if(2!=o.length)throw new Error("malformed PKCS8 public key(code:002)");if("06"!=t.substr(o[0],2))throw new Error("malformed PKCS8 public key(code:003)");if(n.algoid=i(t,o[0]),"06"==t.substr(o[1],2)?n.algparam=i(t,o[1]):"30"==t.substr(o[1],2)&&(n.algparam={},n.algparam.p=e.getVbyList(t,o[1],[0],"02"),n.algparam.q=e.getVbyList(t,o[1],[1],"02"),n.algparam.g=e.getVbyList(t,o[1],[2],"02")),"03"!=t.substr(s[1],2))throw new Error("malformed PKCS8 public key(code:004)");return n.key=i(t,s[1]).substr(2),n}}}();function Wt(t,e){for(var r="",i=e/4-t.length,n=0;n<i;n++)r+="0";return r+t}function Jt(t,e,r){for(var i="",n=0;i.length<e;)i+=St(r(Et(t+String.fromCharCode.apply(String,[(4278190080&n)>>24,(16711680&n)>>16,(65280&n)>>8,255&n])))),n+=1;return i}function Yt(t){for(var e in ot.crypto.Util.DIGESTINFOHEAD){var r=ot.crypto.Util.DIGESTINFOHEAD[e],i=r.length;if(t.substring(0,i)==r)return[e,t.substring(i)]}return[]}function $t(t){var e,r=ct,i=r.getChildIdx,n=r.getV,s=r.parse,a=r.getTLV,o=r.getVbyList,h=r.getVbyListEx,u=r.getTLVbyList,c=r.getTLVbyListEx,l=r.getIdxbyList,f=r.getIdxbyListEx,p=r.getVidx,g=r.getInt,d=r.oidname,v=r.hextooidstr,m=Ft,y=Error;try{e=ot.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV}catch(t){}this.HEX2STAG={"0c":"utf8",13:"prn",16:"ia5","1a":"vis","1e":"bmp"},this.hex=null,this.version=0,this.foffset=0,this.aExtInfo=null,this.getVersion=function(){if(null===this.hex||0!==this.version)return this.version;var t=u(this.hex,0,[0,0]);if("a0"==t.substr(0,2)){var e=u(t,0,[0]),r=g(e,0);if(r<0||2<r)throw new Error("malformed version field");return this.version=r+1,this.version}return this.version=1,this.foffset=-1,1},this.getSerialNumberHex=function(){return h(this.hex,0,[0,0],"02")},this.getSignatureAlgorithmField=function(){var t=c(this.hex,0,[0,1]);return this.getAlgorithmIdentifierName(t)},this.getAlgorithmIdentifierName=function(t){for(var r in e)if(t===e[r])return r;return d(h(t,0,[0],"06"))},this.getIssuer=function(t,e){return this.getX500Name(this.getIssuerHex(),t,e)},this.getIssuerHex=function(){return u(this.hex,0,[0,3+this.foffset],"30")},this.getIssuerString=function(){return this.getIssuer().str},this.getSubject=function(t,e){return this.getX500Name(this.getSubjectHex(),t,e)},this.getSubjectHex=function(){return u(this.hex,0,[0,5+this.foffset],"30")},this.getSubjectString=function(){return this.getSubject().str},this.getNotBefore=function(){var t=o(this.hex,0,[0,4+this.foffset,0]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getNotAfter=function(){var t=o(this.hex,0,[0,4+this.foffset,1]);return t=t.replace(/(..)/g,"%$1"),t=decodeURIComponent(t)},this.getPublicKeyHex=function(){return this.getSPKI()},this.getSPKI=function(){return u(this.hex,0,[0,6+this.foffset],"30")},this.getSPKIValue=function(){var t=this.getSPKI();return null==t?null:o(t,0,[1],"03",!0)},this.getPublicKeyIdx=function(){return l(this.hex,0,[0,6+this.foffset],"30")},this.getPublicKeyContentIdx=function(){var t=this.getPublicKeyIdx();return l(this.hex,t,[1,0],"30")},this.getPublicKey=function(){return zt.getKey(this.getPublicKeyHex(),null,"pkcs8pub")},this.getSignatureAlgorithmName=function(){var t=u(this.hex,0,[1],"30");return this.getAlgorithmIdentifierName(t)},this.getSignatureValueHex=function(){return o(this.hex,0,[2],"03",!0)},this.verifySignature=function(t){var e=this.getSignatureAlgorithmField(),r=this.getSignatureValueHex(),i=u(this.hex,0,[0],"30"),n=new ot.crypto.Signature({alg:e});return n.init(t),n.updateHex(i),n.verify(r)},this.parseExt=function(t){var e,s,a;if(void 0===t){if(a=this.hex,3!==this.version)return-1;e=l(a,0,[0,7,0],"30"),s=i(a,e)}else{a=Ft(t);var h=l(a,0,[0,3,0,0],"06");if("2a864886f70d01090e"!=n(a,h))return void(this.aExtInfo=new Array);e=l(a,0,[0,3,0,1,0],"30"),s=i(a,e),this.hex=a}this.aExtInfo=new Array;for(var u=0;u<s.length;u++){var c={critical:!1},f=0;3===i(a,s[u]).length&&(c.critical=!0,f=1),c.oid=r.hextooidstr(o(a,s[u],[0],"06"));var g=l(a,s[u],[1+f]);c.vidx=p(a,g),this.aExtInfo.push(c)}},this.getExtInfo=function(t){var e=this.aExtInfo,r=t;if(t.match(/^[0-9.]+$/)||(r=ot.asn1.x509.OID.name2oid(t)),""!==r)for(var i=0;i<e.length;i++)if(e[i].oid===r)return e[i]},this.getCriticalExtV=function(t,e,r){if(null!=e)return[e,r];var i=this.getExtInfo(t);return null==i?[null,null]:[a(this.hex,i.vidx),i.critical]},this.getExtBasicConstraints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("basicConstraints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"basicConstraints"};if(e&&(i.critical=!0),"3000"===t)return i;if("30030101ff"===t)return i.cA=!0,i;if("30060101ff02"===t.substr(0,12)){var s=n(t,10),o=parseInt(s,16);return i.cA=!0,i.pathLen=o,i}throw new Error("hExtV parse error: "+t)},this.getExtNameConstraints=function(t,e){var r=this.getCriticalExtV("nameConstraints",t,e);if(t=r[0],e=r[1],null!=t){var n={extname:"nameConstraints"};e&&(n.critical=!0);for(var s=i(t,0),o=0;o<s.length;o++){for(var h=[],u=i(t,s[o]),c=0;c<u.length;c++){var l=a(t,u[c]),f=this.getGeneralSubtree(l);h.push(f)}var p=t.substr(s[o],2);"a0"==p?n.permit=h:"a1"==p&&(n.exclude=h)}return n}},this.getGeneralSubtree=function(t){var e=i(t,0),r=e.length;if(r<1||2<r)throw new Error("wrong num elements");for(var s=this.getGeneralName(a(t,e[0])),o=1;o<r;o++){var h=t.substr(e[o],2),u=n(t,e[o]),c=parseInt(u,16);"80"==h&&(s.min=c),"81"==h&&(s.max=c)}return s},this.getExtKeyUsage=function(t,e){var r=this.getCriticalExtV("keyUsage",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"keyUsage"};return e&&(i.critical=!0),i.names=this.getExtKeyUsageString(t).split(","),i}},this.getExtKeyUsageBin=function(t){if(void 0===t){var e=this.getExtInfo("keyUsage");if(void 0===e)return"";t=a(this.hex,e.vidx)}if(8!=t.length&&10!=t.length)throw new Error("malformed key usage value: "+t);var r="000000000000000"+parseInt(t.substr(6),16).toString(2);return 8==t.length&&(r=r.slice(-8)),10==t.length&&(r=r.slice(-16)),""==(r=r.replace(/0+$/,""))&&(r="0"),r},this.getExtKeyUsageString=function(t){for(var e=this.getExtKeyUsageBin(t),r=new Array,i=0;i<e.length;i++)"1"==e.substr(i,1)&&r.push($t.KEYUSAGE_NAME[i]);return r.join(",")},this.getExtSubjectKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectKeyIdentifier");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectKeyIdentifier"};e&&(i.critical=!0);var s=n(t,0);return i.kid={hex:s},i},this.getExtAuthorityKeyIdentifier=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityKeyIdentifier");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"authorityKeyIdentifier"};e&&(s.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++){var u=t.substr(o[h],2);if("80"===u&&(s.kid={hex:n(t,o[h])}),"a1"===u){var c=a(t,o[h]),l=this.getGeneralNames(c);s.issuer=l[0].dn}"82"===u&&(s.sn={hex:n(t,o[h])})}return s},this.getExtExtKeyUsage=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("extKeyUsage");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var s={extname:"extKeyUsage",array:[]};e&&(s.critical=!0);for(var o=i(t,0),h=0;h<o.length;h++)s.array.push(d(n(t,o[h])));return s},this.getExtExtKeyUsageName=function(){var t=this.getExtInfo("extKeyUsage");if(void 0===t)return t;var e=new Array,r=a(this.hex,t.vidx);if(""===r)return e;for(var s=i(r,0),o=0;o<s.length;o++)e.push(d(n(r,s[o])));return e},this.getExtSubjectAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectAltName");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getExtIssuerAltName=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("issuerAltName");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"issuerAltName",array:[]};return e&&(i.critical=!0),i.array=this.getGeneralNames(t),i},this.getGeneralNames=function(t){for(var e=i(t,0),r=[],n=0;n<e.length;n++){var s=this.getGeneralName(a(t,e[n]));void 0!==s&&r.push(s)}return r},this.getGeneralName=function(t){var e=t.substr(0,2),r=n(t,0),i=St(r);return"81"==e?{rfc822:i}:"82"==e?{dns:i}:"86"==e?{uri:i}:"87"==e?{ip:Pt(r)}:"a4"==e?{dn:this.getX500Name(r)}:"a0"==e?{other:this.getOtherName(t)}:void 0},this.getExtSubjectAltName2=function(){var t,e,r,s=this.getExtInfo("subjectAltName");if(void 0===s)return s;for(var o=new Array,h=a(this.hex,s.vidx),u=i(h,0),c=0;c<u.length;c++)r=h.substr(u[c],2),t=n(h,u[c]),"81"===r&&(e=yt(t),o.push(["MAIL",e])),"82"===r&&(e=yt(t),o.push(["DNS",e])),"84"===r&&(e=$t.hex2dn(t,0),o.push(["DN",e])),"86"===r&&(e=yt(t),o.push(["URI",e])),"87"===r&&(e=Pt(t),o.push(["IP",e]));return o},this.getExtCRLDistributionPoints=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("cRLDistributionPoints");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"cRLDistributionPoints",array:[]};e&&(n.critical=!0);for(var s=i(t,0),o=0;o<s.length;o++){var h=a(t,s[o]);n.array.push(this.getDistributionPoint(h))}return n},this.getDistributionPoint=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),o=a(t,r[n]);"a0"==s&&(e.dpname=this.getDistributionPointName(o))}return e},this.getDistributionPointName=function(t){for(var e={},r=i(t,0),n=0;n<r.length;n++){var s=t.substr(r[n],2),o=a(t,r[n]);"a0"==s&&(e.full=this.getGeneralNames(o))}return e},this.getExtCRLDistributionPointsURI=function(){var t=this.getExtCRLDistributionPoints();if(null==t)return t;for(var e=t.array,r=[],i=0;i<e.length;i++)try{null!=e[i].dpname.full[0].uri&&r.push(e[i].dpname.full[0].uri)}catch(t){}return r},this.getExtAIAInfo=function(){var t=this.getExtInfo("authorityInfoAccess");if(void 0===t)return t;for(var e={ocsp:[],caissuer:[]},r=i(this.hex,t.vidx),n=0;n<r.length;n++){var s=o(this.hex,r[n],[0],"06"),a=o(this.hex,r[n],[1],"86");"2b06010505073001"===s&&e.ocsp.push(yt(a)),"2b06010505073002"===s&&e.caissuer.push(yt(a))}return e},this.getExtAuthorityInfoAccess=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("authorityInfoAccess");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"authorityInfoAccess",array:[]};e&&(n.critical=!0);for(var s=i(t,0),u=0;u<s.length;u++){var c=h(t,s[u],[0],"06"),l=yt(o(t,s[u],[1],"86"));if("2b06010505073001"==c)n.array.push({ocsp:l});else{if("2b06010505073002"!=c)throw new Error("unknown method: "+c);n.array.push({caissuer:l})}}return n},this.getExtCertificatePolicies=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("certificatePolicies");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"certificatePolicies",array:[]};e&&(n.critical=!0);for(var s=i(t,0),o=0;o<s.length;o++){var h=a(t,s[o]),u=this.getPolicyInformation(h);n.array.push(u)}return n},this.getPolicyInformation=function(t){var e={},r=o(t,0,[0],"06");e.policyoid=d(r);var n=f(t,0,[1],"30");if(-1!=n){e.array=[];for(var s=i(t,n),h=0;h<s.length;h++){var u=a(t,s[h]),c=this.getPolicyQualifierInfo(u);e.array.push(c)}}return e},this.getOtherName=function(t){var e={},r=i(t,0),n=o(t,r[0],[],"06"),a=o(t,r[1],[]);return e.oid=d(n),e.value=s(a),e},this.getPolicyQualifierInfo=function(t){var e={},r=o(t,0,[0],"06");if("2b06010505070201"===r){var i=h(t,0,[1],"16");e.cps=St(i)}else if("2b06010505070202"===r){var n=u(t,0,[1],"30");e.unotice=this.getUserNotice(n)}return e},this.getUserNotice=function(t){var e=null;try{return e=r.parse(t),this._asn1ToUnotice(e)}catch(t){return}},this._asn1ToUnotice=function(t){try{for(var e={},r=_t(t,"seq"),i=0;i<r.length;i++){var n=this._asn1ToNoticeRef(r[i]);null!=n&&(e.noticeref=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.exptext=s)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeRef=function(t){try{for(var e={},r=_t(t,"seq"),i=0;i<r.length;i++){var n=this._asn1ToNoticeNum(r[i]);null!=n&&(e.noticenum=n);var s=this.asn1ToDisplayText(r[i]);null!=s&&(e.org=s)}return Object.keys(e).length>0?e:void 0}catch(t){return}},this._asn1ToNoticeNum=function(t){try{for(var e=_t(t,"seq"),r=[],i=0;i<e.length;i++){var n=e[i];r.push(parseInt(_t(n,"int.hex"),16))}return r}catch(t){return}},this.getDisplayText=function(t){var e={};return e.type={"0c":"utf8",16:"ia5","1a":"vis","1e":"bmp"}[t.substr(0,2)],e.str=St(n(t,0)),e},this.asn1ToDisplayText=function(t){return null!=t.utf8str?{type:"utf8",str:t.utf8str.str}:null!=t.ia5str?{type:"ia5",str:t.ia5str.str}:null!=t.visstr?{type:"vis",str:t.visstr.str}:null!=t.bmpstr?{type:"bmp",str:t.bmpstr.str}:null!=t.prnstr?{type:"prn",str:t.prnstr.str}:void 0},this.getExtPolicyMappings=function(t,e){var r=this.getCriticalExtV("policyMappings",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyMappings"};e&&(i.critical=!0);try{for(var n=s(t).seq,a=[],o=0;o<n.length;o++){var h=n[o].seq;a.push([h[0].oid,h[1].oid])}i.array=a}catch(t){throw new y("malformed policyMappings")}return i}},this.getExtPolicyConstraints=function(t,e){var r=this.getCriticalExtV("policyConstraints",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"policyConstraints"};e&&(i.critical=!0);var n=s(t);try{for(var a=n.seq,o=0;o<a.length;o++){var h=a[o].tag;0==h.explicit&&("80"==h.tag&&(i.reqexp=parseInt(h.hex,16)),"81"==h.tag&&(i.inhibit=parseInt(h.hex,16)))}}catch(t){return new y("malformed policyConstraints value")}return i}},this.getExtInhibitAnyPolicy=function(t,e){var r=this.getCriticalExtV("inhibitAnyPolicy",t,e);if(t=r[0],e=r[1],null!=t){var i={extname:"inhibitAnyPolicy"};e&&(i.critical=!0);var n=g(t,0);return-1==n?new y("wrong value"):(i.skip=n,i)}},this.getExtCRLNumber=function(t,e){var r={extname:"cRLNumber"};if(e&&(r.critical=!0),"02"==t.substr(0,2))return r.num={hex:n(t,0)},r;throw new y("hExtV parse error: "+t)},this.getExtCRLReason=function(t,e){var r={extname:"cRLReason"};if(e&&(r.critical=!0),"0a"==t.substr(0,2))return r.code=parseInt(n(t,0),16),r;throw new Error("hExtV parse error: "+t)},this.getExtOcspNonce=function(t,e){var r={extname:"ocspNonce"};e&&(r.critical=!0);var i=n(t,0);return r.hex=i,r},this.getExtOcspNoCheck=function(t,e){var r={extname:"ocspNoCheck"};return e&&(r.critical=!0),r},this.getExtAdobeTimeStamp=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("adobeTimeStamp");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var n={extname:"adobeTimeStamp"};e&&(n.critical=!0);var s=i(t,0);if(s.length>1){var o=a(t,s[1]),h=this.getGeneralName(o);null!=h.uri&&(n.uri=h.uri)}if(s.length>2){var u=a(t,s[2]);"0101ff"==u&&(n.reqauth=!0),"010100"==u&&(n.reqauth=!1)}return n},this.getExtSubjectDirectoryAttributes=function(t,e){if(void 0===t&&void 0===e){var r=this.getExtInfo("subjectDirectoryAttributes");if(void 0===r)return;t=a(this.hex,r.vidx),e=r.critical}var i={extname:"subjectDirectoryAttributes"};e&&(i.critical=!0);try{for(var n=s(t),o=[],h=0;h<n.seq.length;h++){var u=n.seq[h],c=_t(u,"seq.0.oid"),l=_t(u,"seq.1.set");if(null==c||null==l)throw"error";o.push({attr:c,array:l})}return i.array=o,i}catch(t){throw new Error("malformed subjectDirectoryAttributes extension value")}};var x=function(t){var e={};try{var r=t.seq[0].oid,i=ot.asn1.x509.OID.name2oid(r);e.type=ot.asn1.x509.OID.oid2atype(i);var n=t.seq[1];if(null!=n.utf8str)e.ds="utf8",e.value=n.utf8str.str;else if(null!=n.numstr)e.ds="num",e.value=n.numstr.str;else if(null!=n.telstr)e.ds="tel",e.value=n.telstr.str;else if(null!=n.prnstr)e.ds="prn",e.value=n.prnstr.str;else if(null!=n.ia5str)e.ds="ia5",e.value=n.ia5str.str;else if(null!=n.visstr)e.ds="vis",e.value=n.visstr.str;else{if(null==n.bmpstr)throw"error";e.ds="bmp",e.value=n.bmpstr.str}return e}catch(t){throw new Erorr("improper ASN.1 parsed AttrTypeAndValue")}},S=function(t){try{return t.set.map(function(t){return x(t)})}catch(t){throw new Error("improper ASN.1 parsed RDN: "+t)}};this.getX500NameRule=function(t){for(var e=null,r=[],i=0;i<t.length;i++)for(var n=t[i],s=0;s<n.length;s++)r.push(n[s]);for(i=0;i<r.length;i++){var a=r[i],o=a.ds,h=a.value,u=a.type;if("prn"!=o&&"utf8"!=o&&"ia5"!=o)return"mixed";if("ia5"==o){if("CN"!=u)return"mixed";if(ot.lang.String.isMail(h))continue;return"mixed"}if("C"==u){if("prn"==o)continue;return"mixed"}if(null==e)e=o;else if(e!==o)return"mixed"}return null==e?"prn":e},this.getAttrTypeAndValue=function(t){var e=s(t);return x(e)},this.getRDN=function(t){var e=s(t);return S(e)},this.getX500NameArray=function(t){return function(t){try{return t.seq.map(function(t){return S(t)})}catch(t){throw new Error("improper ASN.1 parsed X500Name: "+t)}}(s(t))},this.getX500Name=function(t,e,r){var i=this.getX500NameArray(t),n={str:this.dnarraytostr(i)};return n.array=i,1==r&&(n.hex=t),1==e&&(n.canon=this.c14nRDNArray(i)),n},this.readCertPEM=function(t){this.readCertHex(m(t))},this.readCertHex=function(t){this.hex=t,this.getVersion();try{l(this.hex,0,[0,7],"a3"),this.parseExt()}catch(t){}},this.getParam=function(t){var e={};return null==t&&(t={}),e.version=this.getVersion(),e.serial={hex:this.getSerialNumberHex()},e.sigalg=this.getSignatureAlgorithmField(),e.issuer=this.getIssuer(t.dncanon,t.dnhex),e.notbefore=this.getNotBefore(),e.notafter=this.getNotAfter(),e.subject=this.getSubject(t.dncanon,t.dnhex),e.sbjpubkey=wt(this.getPublicKeyHex(),"PUBLIC KEY"),null!=this.aExtInfo&&this.aExtInfo.length>0&&(e.ext=this.getExtParamArray()),e.sighex=this.getSignatureValueHex(),1==t.tbshex&&(e.tbshex=u(this.hex,0,[0])),1==t.nodnarray&&(delete e.issuer.array,delete e.subject.array),e},this.getExtParamArray=function(t){null==t&&(-1!=f(this.hex,0,[0,"[3]"])&&(t=c(this.hex,0,[0,"[3]",0],"30")));for(var e=[],r=i(t,0),n=0;n<r.length;n++){var s=a(t,r[n]),o=this.getExtParam(s);null!=o&&e.push(o)}return e},this.getExtParam=function(t){var e=i(t,0).length;if(2!=e&&3!=e)throw new Error("wrong number elements in Extension: "+e+" "+t);var r=v(o(t,0,[0],"06")),n=!1;3==e&&"0101ff"==u(t,0,[1])&&(n=!0);var a=u(t,0,[e-1,0]),h=void 0;if("2.5.29.14"==r?h=this.getExtSubjectKeyIdentifier(a,n):"2.5.29.15"==r?h=this.getExtKeyUsage(a,n):"2.5.29.17"==r?h=this.getExtSubjectAltName(a,n):"2.5.29.18"==r?h=this.getExtIssuerAltName(a,n):"2.5.29.19"==r?h=this.getExtBasicConstraints(a,n):"2.5.29.30"==r?h=this.getExtNameConstraints(a,n):"2.5.29.31"==r?h=this.getExtCRLDistributionPoints(a,n):"2.5.29.32"==r?h=this.getExtCertificatePolicies(a,n):"2.5.29.33"==r?h=this.getExtPolicyMappings(a,n):"2.5.29.35"==r?h=this.getExtAuthorityKeyIdentifier(a,n):"2.5.29.36"==r?h=this.getExtPolicyConstraints(a,n):"2.5.29.37"==r?h=this.getExtExtKeyUsage(a,n):"2.5.29.54"==r?h=this.getExtInhibitAnyPolicy(a,n):"1.3.6.1.5.5.7.1.1"==r?h=this.getExtAuthorityInfoAccess(a,n):"2.5.29.20"==r?h=this.getExtCRLNumber(a,n):"2.5.29.21"==r?h=this.getExtCRLReason(a,n):"2.5.29.9"==r?h=this.getExtSubjectDirectoryAttributes(a,n):"1.3.6.1.5.5.7.48.1.2"==r?h=this.getExtOcspNonce(a,n):"1.3.6.1.5.5.7.48.1.5"==r?h=this.getExtOcspNoCheck(a,n):"1.2.840.113583.1.1.9.1"==r?h=this.getExtAdobeTimeStamp(a,n):null!=$t.EXT_PARSER[r]&&(h=$t.EXT_PARSER[r](r,n,a)),null!=h)return h;var c={extname:r,extn:a};try{c.extn=s(a)}catch(t){}return n&&(c.critical=!0),c},this.findExt=function(t,e){for(var r=0;r<t.length;r++)if(t[r].extname==e)return t[r];return null},this.updateExtCDPFullURI=function(t,e){var r=this.findExt(t,"cRLDistributionPoints");if(null!=r&&null!=r.array)for(var i=r.array,n=0;n<i.length;n++)if(null!=i[n].dpname&&null!=i[n].dpname.full)for(var s=i[n].dpname.full,a=0;a<s.length;a++){var o=s[n];null!=o.uri&&(o.uri=e)}},this.updateExtAIAOCSP=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,n=0;n<i.length;n++)null!=i[n].ocsp&&(i[n].ocsp=e)},this.updateExtAIACAIssuer=function(t,e){var r=this.findExt(t,"authorityInfoAccess");if(null!=r&&null!=r.array)for(var i=r.array,n=0;n<i.length;n++)null!=i[n].caissuer&&(i[n].caissuer=e)},this.dnarraytostr=function(t){return"/"+t.map(function(t){return function(t){return t.map(function(t){return function(t){return t.type+"="+t.value}(t).replace(/\+/,"\\+")}).join("+")}(t).replace(/\//,"\\/")}).join("/")},this.setCanonicalizedDN=function(t){var e;if(null!=t.str&&null==t.array){var r=new ot.asn1.x509.X500Name({str:t.str}).tohex();e=this.getX500NameArray(r)}else e=t.array;null==t.canon&&(t.canon=this.c14nRDNArray(e))},this.c14nRDNArray=function(t){for(var e=[],r=0;r<t.length;r++){for(var i=t[r],n=[],s=0;s<i.length;s++){var a=i[s],o=a.value;o=(o=(o=(o=o.replace(/^\s*/,"")).replace(/\s*$/,"")).replace(/\s+/g," ")).toLowerCase(),n.push(a.type.toLowerCase()+"="+o)}e.push(n.join("+"))}return"/"+e.join("/")},this.getInfo=function(){var t,e,r,i=function(t){for(var e="",r=" ",i="\n",n=t.array,s=0;s<n.length;s++){var a=n[s];if(null!=a.dn&&(e+=r+"dn: "+a.dn.str+i),null!=a.ip&&(e+=r+"ip: "+a.ip+i),null!=a.rfc822&&(e+=r+"rfc822: "+a.rfc822+i),null!=a.dns&&(e+=r+"dns: "+a.dns+i),null!=a.uri&&(e+=r+"uri: "+a.uri+i),null!=a.other)e+=r+"other: "+a.other.oid+"="+JSON.stringify(a.other.value).replace(/\"/g,"")+i}return e=e.replace(/\n$/,"")},n=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];if(e+=" policy oid: "+n.policyoid+"\n",void 0!==n.array)for(var s=0;s<n.array.length;s++){var a=n.array[s];void 0!==a.cps&&(e+=" cps: "+a.cps+"\n")}}return e},s=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];try{void 0!==n.dpname.full[0].uri&&(e+=" "+n.dpname.full[0].uri+"\n")}catch(t){}try{void 0!==n.dname.full[0].dn.hex&&(e+=" "+$t.hex2dn(n.dpname.full[0].dn.hex)+"\n")}catch(t){}}return e},a=function(t){for(var e="",r=t.array,i=0;i<r.length;i++){var n=r[i];void 0!==n.caissuer&&(e+=" caissuer: "+n.caissuer+"\n"),void 0!==n.ocsp&&(e+=" ocsp: "+n.ocsp+"\n")}return e};if(t="Basic Fields\n",t+=" serial number: "+this.getSerialNumberHex()+"\n",t+=" signature algorithm: "+this.getSignatureAlgorithmField()+"\n",t+=" issuer: "+this.getIssuerString()+"\n",t+=" notBefore: "+this.getNotBefore()+"\n",t+=" notAfter: "+this.getNotAfter()+"\n",t+=" subject: "+this.getSubjectString()+"\n",t+=" subject public key info: \n",t+=" key algorithm: "+(e=this.getPublicKey()).type+"\n","RSA"===e.type&&(t+=" n="+Vt(e.n.toString(16)).substr(0,16)+"...\n",t+=" e="+Vt(e.e.toString(16))+"\n"),null!=(r=this.aExtInfo)){t+="X509v3 Extensions:\n";for(var o=0;o<r.length;o++){var h=r[o],u=ot.asn1.x509.OID.oid2name(h.oid);""===u&&(u=h.oid);var c="";if(!0===h.critical&&(c="CRITICAL"),t+=" "+u+" "+c+":\n","basicConstraints"===u){var l=this.getExtBasicConstraints();void 0===l.cA?t+=" {}\n":(t+=" cA=true",void 0!==l.pathLen&&(t+=", pathLen="+l.pathLen),t+="\n")}else{var f;if("policyMappings"==u)t+=" "+this.getExtPolicyMappings().array.map(function(t){var e=t;return e[0]+":"+e[1]}).join(", ")+"\n";else if("policyConstraints"==u)t+=" ",null!=(f=this.getExtPolicyConstraints()).reqexp&&(t+=" reqexp="+f.reqexp),null!=f.inhibit&&(t+=" inhibit="+f.inhibit),t+="\n";else if("inhibitAnyPolicy"==u)t+=" skip="+(f=this.getExtInhibitAnyPolicy()).skip+"\n";else if("keyUsage"==u)t+=" "+this.getExtKeyUsageString()+"\n";else if("subjectKeyIdentifier"==u)t+=" "+this.getExtSubjectKeyIdentifier().kid.hex+"\n";else if("authorityKeyIdentifier"==u){var p=this.getExtAuthorityKeyIdentifier();void 0!==p.kid&&(t+=" kid="+p.kid.hex+"\n")}else{if("extKeyUsage"==u)t+=" "+this.getExtExtKeyUsage().array.join(", ")+"\n";else if("subjectAltName"==u)t+=i(this.getExtSubjectAltName())+"\n";else if("cRLDistributionPoints"==u)t+=s(this.getExtCRLDistributionPoints());else if("authorityInfoAccess"==u)t+=a(this.getExtAuthorityInfoAccess());else"certificatePolicies"==u&&(t+=n(this.getExtCertificatePolicies()))}}}}return t+="signature algorithm: "+this.getSignatureAlgorithmName()+"\n",t+="signature: "+this.getSignatureValueHex().substr(0,16)+"...\n"},"string"==typeof t&&(-1!=t.indexOf("-----BEGIN")?this.readCertPEM(t):ot.lang.String.isHex(t)&&this.readCertHex(t))}zt.getKey=function(t,e,r){var i=(v=ct).getChildIdx,n=v.getVbyList,s=ot.crypto,a=s.ECDSA,o=s.DSA,h=rt,u=Ft,c=zt;if(void 0!==h&&t instanceof h)return t;if(void 0!==a&&t instanceof a)return t;if(void 0!==o&&t instanceof o)return t;if(void 0!==t.curve&&void 0!==t.xy&&void 0===t.d)return new a({pub:t.xy,curve:t.curve});if(void 0!==t.curve&&void 0!==t.d)return new a({prv:t.d,curve:t.curve});if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(I=new h).setPublic(t.n,t.e),I;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.co&&void 0===t.qi)return(I=new h).setPrivateEx(t.n,t.e,t.d,t.p,t.q,t.dp,t.dq,t.co),I;if(void 0===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0===t.p)return(I=new h).setPrivate(t.n,t.e,t.d),I;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0===t.x)return(I=new o).setPublic(t.p,t.q,t.g,t.y),I;if(void 0!==t.p&&void 0!==t.q&&void 0!==t.g&&void 0!==t.y&&void 0!==t.x)return(I=new o).setPrivate(t.p,t.q,t.g,t.y,t.x),I;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0===t.d)return(I=new h).setPublic(vt(t.n),vt(t.e)),I;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d&&void 0!==t.p&&void 0!==t.q&&void 0!==t.dp&&void 0!==t.dq&&void 0!==t.qi)return(I=new h).setPrivateEx(vt(t.n),vt(t.e),vt(t.d),vt(t.p),vt(t.q),vt(t.dp),vt(t.dq),vt(t.qi)),I;if("RSA"===t.kty&&void 0!==t.n&&void 0!==t.e&&void 0!==t.d)return(I=new h).setPrivate(vt(t.n),vt(t.e),vt(t.d)),I;if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0===t.d){var l=(C=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+vt(t.x)).slice(-l)+("0000000000"+vt(t.y)).slice(-l);return C.setPublicKeyHex(f),C}if("EC"===t.kty&&void 0!==t.crv&&void 0!==t.x&&void 0!==t.y&&void 0!==t.d){l=(C=new a({curve:t.crv})).ecparams.keycharlen,f="04"+("0000000000"+vt(t.x)).slice(-l)+("0000000000"+vt(t.y)).slice(-l);var p=("0000000000"+vt(t.d)).slice(-l);return C.setPublicKeyHex(f),C.setPrivateKeyHex(p),C}if("pkcs5prv"===r){var g,d=t,v=ct;if(9===(g=i(d,0)).length)(I=new h).readPKCS5PrvKeyHex(d);else if(6===g.length)(I=new o).readPKCS5PrvKeyHex(d);else{if(!(g.length>2&&"04"===d.substr(g[1],2)))throw new Error("unsupported PKCS#1/5 hexadecimal key");(I=new a).readPKCS5PrvKeyHex(d)}return I}if("pkcs8prv"===r)return I=c.getKeyFromPlainPrivatePKCS8Hex(t);if("pkcs8pub"===r)return c._getKeyFromPublicPKCS8Hex(t);if("x509pub"===r)return $t.getPublicKeyFromCertHex(t);if(-1!=t.indexOf("-END CERTIFICATE-",0)||-1!=t.indexOf("-END X509 CERTIFICATE-",0)||-1!=t.indexOf("-END TRUSTED CERTIFICATE-",0))return $t.getPublicKeyFromCertPEM(t);if(-1!=t.indexOf("-END PUBLIC KEY-")){var m=Ft(t,"PUBLIC KEY");return c._getKeyFromPublicPKCS8Hex(m)}if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var y=u(t,"RSA PRIVATE KEY");return c.getKey(y,null,"pkcs5prv")}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){var S=n(R=u(t,"DSA PRIVATE KEY"),0,[1],"02"),E=n(R,0,[2],"02"),w=n(R,0,[3],"02"),F=n(R,0,[4],"02"),b=n(R,0,[5],"02");return(I=new o).setPrivate(new x(S,16),new x(E,16),new x(w,16),new x(F,16),new x(b,16)),I}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1==t.indexOf("4,ENCRYPTED")){y=u(t,"EC PRIVATE KEY");return c.getKey(y,null,"pkcs5prv")}if(-1!=t.indexOf("-END PRIVATE KEY-"))return c.getKeyFromPlainPrivatePKCS8PEM(t);if(-1!=t.indexOf("-END RSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var A=c.getDecryptedKeyHex(t,e),D=new rt;return D.readPKCS5PrvKeyHex(A),D}if(-1!=t.indexOf("-END EC PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var C,I=n(R=c.getDecryptedKeyHex(t,e),0,[1],"04"),P=n(R,0,[2,0],"06"),T=n(R,0,[3,0],"03").substr(2);if(void 0===ot.crypto.OID.oidhex2name[P])throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+P);return(C=new a({curve:ot.crypto.OID.oidhex2name[P]})).setPublicKeyHex(T),C.setPrivateKeyHex(I),C.isPublic=!1,C}if(-1!=t.indexOf("-END DSA PRIVATE KEY-")&&-1!=t.indexOf("4,ENCRYPTED")){var R;S=n(R=c.getDecryptedKeyHex(t,e),0,[1],"02"),E=n(R,0,[2],"02"),w=n(R,0,[3],"02"),F=n(R,0,[4],"02"),b=n(R,0,[5],"02");return(I=new o).setPrivate(new x(S,16),new x(E,16),new x(w,16),new x(F,16),new x(b,16)),I}if(-1!=t.indexOf("-END ENCRYPTED PRIVATE KEY-"))return c.getKeyFromEncryptedPKCS8PEM(t,e);throw new Error("not supported argument")},zt.generateKeypair=function(t,e){if("RSA"==t){var r=e;(a=new rt).generate(r,"10001"),a.isPrivate=!0,a.isPublic=!0;var i=new rt,n=a.n.toString(16),s=a.e.toString(16);return i.setPublic(n,s),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}if("EC"==t){var a,o,h=e,u=new ot.crypto.ECDSA({curve:h}).generateKeyPairHex();return(a=new ot.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),a.setPrivateKeyHex(u.ecprvhex),a.isPrivate=!0,a.isPublic=!1,(i=new ot.crypto.ECDSA({curve:h})).setPublicKeyHex(u.ecpubhex),i.isPrivate=!1,i.isPublic=!0,(o={}).prvKeyObj=a,o.pubKeyObj=i,o}throw new Error("unknown algorithm: "+t)},zt.getPEM=function(t,e,r,i,n,s){var a=ot,o=a.asn1,h=o.DERObjectIdentifier,u=o.DERInteger,c=o.ASN1Util.newObject,l=o.x509.SubjectPublicKeyInfo,f=a.crypto,p=f.DSA,g=f.ECDSA,d=rt;function v(t){return c({seq:[{int:0},{int:{bigint:t.n}},{int:t.e},{int:{bigint:t.d}},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.dmp1}},{int:{bigint:t.dmq1}},{int:{bigint:t.coeff}}]})}function m(t){return c({seq:[{int:1},{octstr:{hex:t.prvKeyHex}},{tag:["a0",!0,{oid:{name:t.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]}]})}function y(t){return c({seq:[{int:0},{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}},{int:{bigint:t.y}},{int:{bigint:t.x}}]})}if((void 0!==d&&t instanceof d||void 0!==p&&t instanceof p||void 0!==g&&t instanceof g)&&1==t.isPublic&&(void 0===e||"PKCS8PUB"==e))return wt(w=new l(t).tohex(),"PUBLIC KEY");if("PKCS1PRV"==e&&void 0!==d&&t instanceof d&&(void 0===r||null==r)&&1==t.isPrivate)return wt(w=v(t).tohex(),"RSA PRIVATE KEY");if("PKCS1PRV"==e&&void 0!==g&&t instanceof g&&(void 0===r||null==r)&&1==t.isPrivate){var x=new h({name:t.curveName}).tohex(),S=m(t).tohex(),E="";return E+=wt(x,"EC PARAMETERS"),E+=wt(S,"EC PRIVATE KEY")}if("PKCS1PRV"==e&&void 0!==p&&t instanceof p&&(void 0===r||null==r)&&1==t.isPrivate)return wt(w=y(t).tohex(),"DSA PRIVATE KEY");if("PKCS5PRV"==e&&void 0!==d&&t instanceof d&&void 0!==r&&null!=r&&1==t.isPrivate){var w=v(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",w,r,i,s)}if("PKCS5PRV"==e&&void 0!==g&&t instanceof g&&void 0!==r&&null!=r&&1==t.isPrivate){w=m(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",w,r,i,s)}if("PKCS5PRV"==e&&void 0!==p&&t instanceof p&&void 0!==r&&null!=r&&1==t.isPrivate){w=y(t).tohex();return void 0===i&&(i="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",w,r,i,s)}var F=function(t,e){if("string"==typeof e)return zt.getEncryptedPKCS8PEM(t,e);if("object"==typeof e&&null!=_t(e,"passcode")){var r=JSON.parse(JSON.stringify(e)),i=r.passcode;return delete r.passcode,zt.getEncryptedPKCS8PEM(t,i,r)}};if("PKCS8PRV"==e&&null!=d&&t instanceof d&&1==t.isPrivate){var b=v(t).tohex();w=c({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:b}}]}).tohex();return void 0===r||null==r?wt(w,"PRIVATE KEY"):F(w,r)}if("PKCS8PRV"==e&&void 0!==g&&t instanceof g&&1==t.isPrivate){var A={seq:[{int:1},{octstr:{hex:t.prvKeyHex}}]};"string"==typeof t.pubKeyHex&&A.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+t.pubKeyHex}}]});b=new c(A).tohex(),w=c({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:t.curveName}}]},{octstr:{hex:b}}]}).tohex();return void 0===r||null==r?wt(w,"PRIVATE KEY"):F(w,r)}if("PKCS8PRV"==e&&void 0!==p&&t instanceof p&&1==t.isPrivate){b=new u({bigint:t.x}).tohex(),w=c({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:t.p}},{int:{bigint:t.q}},{int:{bigint:t.g}}]}]},{octstr:{hex:b}}]}).tohex();return void 0===r||null==r?wt(w,"PRIVATE KEY"):F(w,r)}throw new Error("unsupported object nor format")},zt.getKeyFromCSRPEM=function(t){var e=Ft(t,"CERTIFICATE REQUEST");return zt.getKeyFromCSRHex(e)},zt.getKeyFromCSRHex=function(t){var e=zt.parseCSRHex(t);return zt.getKey(e.p8pubkeyhex,null,"pkcs8pub")},zt.parseCSRHex=function(t){var e=ct,r=e.getChildIdx,i=e.getTLV,n={},s=t;if("30"!=s.substr(0,2))throw new Error("malformed CSR(code:001)");var a=r(s,0);if(a.length<1)throw new Error("malformed CSR(code:002)");if("30"!=s.substr(a[0],2))throw new Error("malformed CSR(code:003)");var o=r(s,a[0]);if(o.length<3)throw new Error("malformed CSR(code:004)");return n.p8pubkeyhex=i(s,o[2]),n},zt.getKeyID=function(t){var e=zt,r=ct;"string"==typeof t&&-1!=t.indexOf("BEGIN ")&&(t=e.getKey(t));var i=Ft(e.getPEM(t)),n=r.getIdxbyList(i,0,[1]),s=r.getV(i,n).substring(2);return ot.crypto.Util.hashHex(s,"sha1")},zt.getJWK=function(t,e,r,i,n){var s,a,o={},h=ot.crypto.Util.hashHex;if("string"==typeof t)s=zt.getKey(t),-1!=t.indexOf("CERTIFICATE")&&(a=Ft(t));else{if("object"!=typeof t)throw new Error("unsupported keyinfo type");t instanceof $t?(s=t.getPublicKey(),a=t.hex):s=t}if(s instanceof rt&&s.isPrivate)o.kty="RSA",o.n=dt(s.n.toString(16)),o.e=dt(s.e.toString(16)),o.d=dt(s.d.toString(16)),o.p=dt(s.p.toString(16)),o.q=dt(s.q.toString(16)),o.dp=dt(s.dmp1.toString(16)),o.dq=dt(s.dmq1.toString(16)),o.qi=dt(s.coeff.toString(16));else if(s instanceof rt&&s.isPublic)o.kty="RSA",o.n=dt(s.n.toString(16)),o.e=dt(s.e.toString(16));else if(s instanceof ot.crypto.ECDSA&&s.isPrivate){if("P-256"!==(c=s.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);var u=s.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=dt(u.x),o.y=dt(u.y),o.d=dt(s.prvKeyHex)}else if(s instanceof ot.crypto.ECDSA&&s.isPublic){var c;if("P-256"!==(c=s.getShortNISTPCurveName())&&"P-384"!==c&&"P-521"!==c)throw new Error("unsupported curve name for JWT: "+c);u=s.getPublicKeyXYHex();o.kty="EC",o.crv=c,o.x=dt(u.x),o.y=dt(u.y)}if(null==o.kty)throw new Error("unsupported keyinfo");return s.isPrivate||1==e||(o.kid=ot.jws.JWS.getJWKthumbprint(o)),null!=a&&1!=r&&(o.x5c=[m(a)]),null!=a&&1!=i&&(o.x5t=pt(m(h(a,"sha1")))),null!=a&&1!=n&&(o["x5t#S256"]=pt(m(h(a,"sha256")))),o},zt.getJWKFromKey=function(t){return zt.getJWK(t,!0,!0,!0,!0)},rt.getPosArrayOfChildrenFromHex=function(t){return ct.getChildIdx(t,0)},rt.getHexValueArrayOfChildrenFromHex=function(t){var e,r=ct.getV,i=r(t,(e=rt.getPosArrayOfChildrenFromHex(t))[0]),n=r(t,e[1]),s=r(t,e[2]),a=r(t,e[3]),o=r(t,e[4]),h=r(t,e[5]),u=r(t,e[6]),c=r(t,e[7]),l=r(t,e[8]);return(e=new Array).push(i,n,s,a,o,h,u,c,l),e},rt.prototype.readPrivateKeyFromPEMString=function(t){var e=Ft(t),r=rt.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])},rt.prototype.readPKCS5PrvKeyHex=function(t){var e=rt.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8])},rt.prototype.readPKCS8PrvKeyHex=function(t){var e,r,i,n,s,a,o,h,u=ct,c=u.getVbyListEx;if(!1===u.isASN1HEX(t))throw new Error("not ASN.1 hex string");try{e=c(t,0,[2,0,1],"02"),r=c(t,0,[2,0,2],"02"),i=c(t,0,[2,0,3],"02"),n=c(t,0,[2,0,4],"02"),s=c(t,0,[2,0,5],"02"),a=c(t,0,[2,0,6],"02"),o=c(t,0,[2,0,7],"02"),h=c(t,0,[2,0,8],"02")}catch(t){throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(e,r,i,n,s,a,o,h)},rt.prototype.readPKCS5PubKeyHex=function(t){var e=ct,r=e.getV;if(!1===e.isASN1HEX(t))throw new Error("keyHex is not ASN.1 hex string");var i=e.getChildIdx(t,0);if(2!==i.length||"02"!==t.substr(i[0],2)||"02"!==t.substr(i[1],2))throw new Error("wrong hex for PKCS#5 public key");var n=r(t,i[0]),s=r(t,i[1]);this.setPublic(n,s)},rt.prototype.readPKCS8PubKeyHex=function(t){var e=ct;if(!1===e.isASN1HEX(t))throw new Error("not ASN.1 hex string");if("06092a864886f70d010101"!==e.getTLVbyListEx(t,0,[0,0]))throw new Error("not PKCS8 RSA public key");var r=e.getTLVbyListEx(t,0,[1,0]);this.readPKCS5PubKeyHex(r)},rt.prototype.readCertPubKeyHex=function(t,e){var r,i;(r=new $t).readCertHex(t),i=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(i)},rt.prototype.sign=function(t,e){var r=function(t){return ot.crypto.Util.hashString(t,e)}(t);return this.signWithMessageHash(r,e)},rt.prototype.signWithMessageHash=function(t,e){var r=et(ot.crypto.Util.getPaddedDigestInfoHex(t,e,this.n.bitLength()),16);return Wt(this.doPrivate(r).toString(16),this.n.bitLength())},rt.prototype.signPSS=function(t,e,r){var i=function(t){return ot.crypto.Util.hashHex(t,e)}(Et(t));return void 0===r&&(r=-1),this.signWithMessageHashPSS(i,e,r)},rt.prototype.signWithMessageHashPSS=function(t,e,r){var i,n=St(t),s=n.length,a=this.n.bitLength()-1,o=Math.ceil(a/8),h=function(t){return ot.crypto.Util.hashHex(t,e)};if(-1===r||void 0===r)r=s;else if(-2===r)r=o-s-2;else if(r<-2)throw new Error("invalid salt length");if(o<s+r+2)throw new Error("data too long");var u="";r>0&&(u=new Array(r),(new tt).nextBytes(u),u=String.fromCharCode.apply(String,u));var c=St(h(Et("\0\0\0\0\0\0\0\0"+n+u))),l=[];for(i=0;i<o-r-s-2;i+=1)l[i]=0;var f=String.fromCharCode.apply(String,l)+""+u,p=Jt(c,f.length,h),g=[];for(i=0;i<f.length;i+=1)g[i]=f.charCodeAt(i)^p.charCodeAt(i);var d=65280>>8*o-a&255;for(g[0]&=~d,i=0;i<s;i++)g.push(c.charCodeAt(i));return g.push(188),Wt(this.doPrivate(new x(g)).toString(16),this.n.bitLength())},rt.prototype.verify=function(t,e){if(null==(e=e.toLowerCase()).match(/^[0-9a-f]+$/))return!1;var r=et(e,16),i=this.n.bitLength();if(r.bitLength()>i)return!1;var n=this.doPublic(r).toString(16);if(n.length+3!=i/4)return!1;var s=Yt(n.replace(/^1f+00/,""));if(0==s.length)return!1;var a=s[0],o=s[1],h=function(t){return ot.crypto.Util.hashString(t,a)}(t);return o==h},rt.prototype.verifyWithMessageHash=function(t,e){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=et(e,16);if(r.bitLength()>this.n.bitLength())return 0;var i=Yt(this.doPublic(r).toString(16).replace(/^1f+00/,""));return 0!=i.length&&i[1]==t},rt.prototype.verifyPSS=function(t,e,r,i){var n,s=(n=Et(t),ot.crypto.Util.hashHex(n,r));return void 0===i&&(i=-1),this.verifyWithMessageHashPSS(s,e,r,i)},rt.prototype.verifyWithMessageHashPSS=function(t,e,r,i){if(e.length!=Math.ceil(this.n.bitLength()/4))return!1;var n,s=new x(e,16),a=function(t){return ot.crypto.Util.hashHex(t,r)},o=St(t),h=o.length,u=this.n.bitLength()-1,c=Math.ceil(u/8);if(-1===i||void 0===i)i=h;else if(-2===i)i=c-h-2;else if(i<-2)throw new Error("invalid salt length");if(c<h+i+2)throw new Error("data too long");var l=this.doPublic(s).toByteArray();for(n=0;n<l.length;n+=1)l[n]&=255;for(;l.length<c;)l.unshift(0);if(188!==l[c-1])throw new Error("encoded message does not end in 0xbc");var f=(l=String.fromCharCode.apply(String,l)).substr(0,c-h-1),p=l.substr(f.length,h),g=65280>>8*c-u&255;if(0!==(f.charCodeAt(0)&g))throw new Error("bits beyond keysize not zero");var d=Jt(p,f.length,a),v=[];for(n=0;n<f.length;n+=1)v[n]=f.charCodeAt(n)^d.charCodeAt(n);v[0]&=~g;var m=c-h-i-2;for(n=0;n<m;n+=1)if(0!==v[n])throw new Error("leftmost octets not zero");if(1!==v[m])throw new Error("0x01 marker not found");return p===St(a(Et("\0\0\0\0\0\0\0\0"+o+String.fromCharCode.apply(String,v.slice(-i)))))},rt.SALT_LEN_HLEN=-1,rt.SALT_LEN_MAX=-2,rt.SALT_LEN_RECOVER=-2,$t.EXT_PARSER={},$t.registExtParser=function(t,e){$t.EXT_PARSER[t]=e},$t.hex2dn=function(t,e){void 0===e&&(e=0);var r=new $t;return ct.getTLV(t,e),r.getX500Name(t).str},$t.hex2rdn=function(t,e){if(void 0===e&&(e=0),"31"!==t.substr(e,2))throw new Error("malformed RDN");for(var r=new Array,i=ct.getChildIdx(t,e),n=0;n<i.length;n++)r.push($t.hex2attrTypeValue(t,i[n]));return r=r.map(function(t){return t.replace("+","\\+")}),r.join("+")},$t.hex2attrTypeValue=function(t,e){var r=ct,i=r.getV;if(void 0===e&&(e=0),"30"!==t.substr(e,2))throw new Error("malformed attribute type and value");var n=r.getChildIdx(t,e);2!==n.length||t.substr(n[0],2);var s=i(t,n[0]),a=ot.asn1.ASN1Util.oidHexToInt(s);return ot.asn1.x509.OID.oid2atype(a)+"="+St(i(t,n[1]))},$t.getPublicKeyFromCertHex=function(t){var e=new $t;return e.readCertHex(t),e.getPublicKey()},$t.getPublicKeyFromCertPEM=function(t){var e=new $t;return e.readCertPEM(t),e.getPublicKey()},$t.getPublicKeyInfoPropOfCertPEM=function(t){var e,r,i=ct.getVbyList,n={};return n.algparam=null,(e=new $t).readCertPEM(t),r=e.getPublicKeyHex(),n.keyhex=i(r,0,[1],"03").substr(2),n.algoid=i(r,0,[0,0],"06"),"2a8648ce3d0201"===n.algoid&&(n.algparam=i(r,0,[0,1],"06")),n},$t.KEYUSAGE_NAME=["digitalSignature","nonRepudiation","keyEncipherment","dataEncipherment","keyAgreement","keyCertSign","cRLSign","encipherOnly","decipherOnly"],void 0!==ot&&ot||(ot={}),void 0!==ot.jws&&ot.jws||(ot.jws={}),ot.jws.JWS=function(){var t=ot.jws.JWS.isSafeJSONString;this.parseJWS=function(e,r){if(void 0===this.parsedJWS||!r&&void 0===this.parsedJWS.sigvalH){var i=e.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(null==i)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var n=i[1],s=i[2],a=i[3],o=n+"."+s;if(this.parsedJWS={},this.parsedJWS.headB64U=n,this.parsedJWS.payloadB64U=s,this.parsedJWS.sigvalB64U=a,this.parsedJWS.si=o,!r){var h=vt(a),u=et(h,16);this.parsedJWS.sigvalH=h,this.parsedJWS.sigvalBI=u}var c=ut(n),l=ut(s);if(this.parsedJWS.headS=c,this.parsedJWS.payloadS=l,!t(c,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+c}}},ot.jws.JWS.sign=function(t,e,r,i,n){var s,a,o,h=ot,u=h.jws.JWS,c=u.readSafeJSONString,l=u.isSafeJSONString,f=h.crypto,p=f.Mac,g=f.Signature,d=JSON;if("string"!=typeof e&&"object"!=typeof e)throw"spHeader must be JSON string or object: "+e;if("object"==typeof e&&(a=e,s=d.stringify(a)),"string"==typeof e){if(!l(s=e))throw"JWS Head is not safe JSON string: "+s;a=c(s)}if(o=r,"object"==typeof r&&(o=d.stringify(r)),""!=t&&null!=t||void 0===a.alg||(t=a.alg),""!=t&&null!=t&&void 0===a.alg&&(a.alg=t,s=d.stringify(a)),t!==a.alg)throw"alg and sHeader.alg doesn't match: "+t+"!="+a.alg;var v=null;if(void 0===u.jwsalg2sigalg[t])throw"unsupported alg name: "+t;v=u.jwsalg2sigalg[t];var m=ht(s)+"."+ht(o),y="";if("Hmac"==v.substr(0,4)){if(void 0===i)throw"mac key shall be specified for HS* alg";var x=new p({alg:v,prov:"cryptojs",pass:i});x.updateString(m),y=x.doFinal()}else if(-1!=v.indexOf("withECDSA")){(E=new g({alg:v})).init(i,n),E.updateString(m);var S=E.sign();y=ot.crypto.ECDSA.asn1SigToConcatSig(S)}else{var E;if("none"!=v)(E=new g({alg:v})).init(i,n),E.updateString(m),y=E.sign()}return m+"."+dt(y)},ot.jws.JWS.verify=function(t,e,r){var i,n=ot,s=n.jws.JWS,a=s.readSafeJSONString,o=n.crypto,h=o.ECDSA,u=o.Mac,c=o.Signature;if(i=rt,!jt(t))return!1;var l=t.split(".");if(3!==l.length)return!1;var f=l[0]+"."+l[1],p=vt(l[2]),g=a(ut(l[0])),d=null,v=null;if(void 0===g.alg)throw"algorithm not specified in header";if((v=(d=g.alg).substr(0,2),null!=r&&"[object Array]"===Object.prototype.toString.call(r)&&r.length>0)&&-1==(":"+r.join(":")+":").indexOf(":"+d+":"))throw"algorithm '"+d+"' not accepted in the list";if("none"!=d&&null===e)throw"key shall be specified to verify.";if("string"==typeof e&&-1!=e.indexOf("-----BEGIN ")&&(e=zt.getKey(e)),!("RS"!=v&&"PS"!=v||e instanceof i))throw"key shall be a RSAKey obj for RS* and PS* algs";if("ES"==v&&!(e instanceof h))throw"key shall be a ECDSA obj for ES* algs";var m=null;if(void 0===s.jwsalg2sigalg[g.alg])throw new Error("unsupported alg name: "+d);if(m=s.jwsalg2sigalg[d],void 0!==g.crit){if(!Array.isArray(g.crit)||0===g.crit.length)throw new Error("wrong critical header");for(var y=0;y<g.crit.length;y++){var x=g.crit[y];if("string"!=typeof x||0===x.length)throw new Error("wrong critical header");if(void 0===g[x])throw new Error("critical header '"+x+"' missing")}}if("none"==m)throw new Error("not supported");if("Hmac"==m.substr(0,4)){if(void 0===e)throw new Error("hexadecimal key shall be specified for HMAC");var S=new u({alg:m,pass:e});return S.updateString(f),Kt(p,S.doFinal())}if(-1!=m.indexOf("withECDSA")){var E,w=null;try{w=h.concatSigToASN1Sig(p)}catch(t){return!1}return(E=new c({alg:m})).init(e),E.updateString(f),E.verify(w)}return(E=new c({alg:m})).init(e),E.updateString(f),E.verify(p)},ot.jws.JWS.parse=function(t){var e,r,i,n=t.split("."),s={};if(2!=n.length&&3!=n.length)throw"malformed sJWS: wrong number of '.' splitted elements";return e=n[0],r=n[1],3==n.length&&(i=n[2]),s.headerObj=ot.jws.JWS.readSafeJSONString(ut(e)),s.payloadObj=ot.jws.JWS.readSafeJSONString(ut(r)),s.headerPP=JSON.stringify(s.headerObj,null," "),null==s.payloadObj?s.payloadPP=ut(r):s.payloadPP=JSON.stringify(s.payloadObj,null," "),void 0!==i&&(s.sigHex=vt(i)),s},ot.jws.JWS.verifyJWT=function(t,e,r){var i=ot.jws,n=i.JWS,s=n.readSafeJSONString,a=n.inArray,o=n.includedArray;if(!jt(t))return!1;var h=t.split(".");if(3!=h.length)return!1;var u=h[0],c=h[1];vt(h[2]);var l=s(ut(u)),f=s(ut(c));if(void 0===l.alg)return!1;if(void 0===r.alg)throw"acceptField.alg shall be specified";if(!a(l.alg,r.alg))return!1;if(void 0!==f.iss&&"object"==typeof r.iss&&!a(f.iss,r.iss))return!1;if(void 0!==f.sub&&"object"==typeof r.sub&&!a(f.sub,r.sub))return!1;if(void 0!==f.aud&&"object"==typeof r.aud)if("string"==typeof f.aud){if(!a(f.aud,r.aud))return!1}else if("object"==typeof f.aud&&!o(f.aud,r.aud))return!1;var p=i.IntDate.getNow();return void 0!==r.verifyAt&&"number"==typeof r.verifyAt&&(p=r.verifyAt),void 0!==r.gracePeriod&&"number"==typeof r.gracePeriod||(r.gracePeriod=0),!(void 0!==f.exp&&"number"==typeof f.exp&&f.exp+r.gracePeriod<p)&&(!(void 0!==f.nbf&&"number"==typeof f.nbf&&p<f.nbf-r.gracePeriod)&&(!(void 0!==f.iat&&"number"==typeof f.iat&&p<f.iat-r.gracePeriod)&&((void 0===f.jti||void 0===r.jti||f.jti===r.jti)&&!!n.verify(t,e,r.alg))))},ot.jws.JWS.includedArray=function(t,e){var r=ot.jws.JWS.inArray;if(null===t)return!1;if("object"!=typeof t)return!1;if("number"!=typeof t.length)return!1;for(var i=0;i<t.length;i++)if(!r(t[i],e))return!1;return!0},ot.jws.JWS.inArray=function(t,e){if(null===e)return!1;if("object"!=typeof e)return!1;if("number"!=typeof e.length)return!1;for(var r=0;r<e.length;r++)if(e[r]==t)return!0;return!1},ot.jws.JWS.jwsalg2sigalg={HS256:"HmacSHA256",HS384:"HmacSHA384",HS512:"HmacSHA512",RS256:"SHA256withRSA",RS384:"SHA384withRSA",RS512:"SHA512withRSA",ES256:"SHA256withECDSA",ES384:"SHA384withECDSA",ES512:"SHA512withECDSA",PS256:"SHA256withRSAandMGF1",PS384:"SHA384withRSAandMGF1",PS512:"SHA512withRSAandMGF1",none:"none"},ot.jws.JWS.isSafeJSONString=function(t,e,r){var i=null;try{return"object"!=typeof(i=at(t))||i.constructor===Array?0:(e&&(e[r]=i),1)}catch(t){return 0}},ot.jws.JWS.readSafeJSONString=function(t){var e=null;try{return"object"!=typeof(e=at(t))||e.constructor===Array?null:e}catch(t){return null}},ot.jws.JWS.getEncodedSignatureValueFromJWS=function(t){var e=t.match(/^[^.]+\.[^.]+\.([^.]+)$/);if(null==e)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";return e[1]},ot.jws.JWS.getJWKthumbprint=function(t){if("RSA"!==t.kty&&"EC"!==t.kty&&"oct"!==t.kty)throw new Error("unsupported algorithm for JWK Thumprint");var e="{";if("RSA"===t.kty){if("string"!=typeof t.n||"string"!=typeof t.e)throw new Error("wrong n and e value for RSA key");e+='"e":"'+t.e+'",',e+='"kty":"'+t.kty+'",',e+='"n":"'+t.n+'"}'}else if("EC"===t.kty){if("string"!=typeof t.crv||"string"!=typeof t.x||"string"!=typeof t.y)throw new Error("wrong crv, x and y value for EC key");e+='"crv":"'+t.crv+'",',e+='"kty":"'+t.kty+'",',e+='"x":"'+t.x+'",',e+='"y":"'+t.y+'"}'}else if("oct"===t.kty){if("string"!=typeof t.k)throw new Error("wrong k value for oct(symmetric) key");e+='"k":"'+t.k+'",',e+='"kty":"'+t.kty+'"}'}var r=Et(e);return dt(ot.crypto.Util.hashHex(r,"sha256"))},ot.jws.IntDate={},ot.jws.IntDate.get=function(t){var e=ot.jws.IntDate,r=e.getNow,i=e.getZulu;if("now"==t)return r();if("now + 1hour"==t)return r()+3600;if("now + 1day"==t)return r()+86400;if("now + 1month"==t)return r()+2592e3;if("now + 1year"==t)return r()+31536e3;if(t.match(/Z$/))return i(t);if(t.match(/^[0-9]+$/))return parseInt(t);throw"unsupported format: "+t},ot.jws.IntDate.getZulu=function(t){return bt(t)},ot.jws.IntDate.getNow=function(){return~~(new Date/1e3)},ot.jws.IntDate.intDate2UTCString=function(t){return new Date(1e3*t).toUTCString()},ot.jws.IntDate.intDate2Zulu=function(t){var e=new Date(1e3*t);return("0000"+e.getUTCFullYear()).slice(-4)+("00"+(e.getUTCMonth()+1)).slice(-2)+("00"+e.getUTCDate()).slice(-2)+("00"+e.getUTCHours()).slice(-2)+("00"+e.getUTCMinutes()).slice(-2)+("00"+e.getUTCSeconds()).slice(-2)+"Z"},void 0!==ot&&ot||(ot={}),void 0!==ot.jws&&ot.jws||(ot.jws={}),ot.jws.JWSJS=function(){var t=ot.jws.JWS,e=t.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(t){this.init();var e=t.split(".");if(3!=e.length)throw"malformed input JWS";this.aHeader.push(e[0]),this.sPayload=e[1],this.aSignature.push(e[2])},this.addSignature=function(t,e,r,i){if(void 0===this.sPayload||null===this.sPayload)throw"there's no JSON-JS signature to add.";var n=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var s=ot.jws.JWS.sign(t,e,this.sPayload,r,i).split(".");this.aHeader.push(s[0]),this.aSignature.push(s[2])}catch(t){throw this.aHeader.length>n&&this.aHeader.pop(),this.aSignature.length>n&&this.aSignature.pop(),"addSignature failed: "+t}},this.verifyAll=function(t){if(this.aHeader.length!==t.length||this.aSignature.length!==t.length)return!1;for(var e=0;e<t.length;e++){var r=t[e];if(2!==r.length)return!1;if(!1===this.verifyNth(e,r[0],r[1]))return!1}return!0},this.verifyNth=function(e,r,i){if(this.aHeader.length<=e||this.aSignature.length<=e)return!1;var n=this.aHeader[e],s=this.aSignature[e],a=n+"."+this.sPayload+"."+s,o=!1;try{o=t.verify(a,r,i)}catch(t){return!1}return o},this.readJWSJS=function(t){if("string"==typeof t){var r=e(t);if(null==r)throw"argument is not safe JSON object string";this.aHeader=r.headers,this.sPayload=r.payload,this.aSignature=r.signatures}else try{if(!(t.headers.length>0))throw"malformed header";if(this.aHeader=t.headers,"string"!=typeof t.payload)throw"malformed signatures";if(this.sPayload=t.payload,!(t.signatures.length>0))throw"malformed signatures";this.aSignature=t.signatures}catch(t){throw"malformed JWS-JS JSON object: "+t}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return 0==this.aHeader.length?1:0}};var Xt=ot;const Zt=(t,e=!1)=>t.map(t=>{const r={title:t.name};return t.url&&(r.path=t.url),t.icon&&(r.svgName=t.icon),t.type&&(r.type=t.type),e?t.children&&t.children.length>0&&0===t.type&&(r.children=Zt(t.children)):t.children&&t.children.length>0&&(r.children=Zt(t.children)),r});exports.CacheKey=e,exports.MENU_DATA_KEY="user_menu_data",exports.WHITE_LIST=["/login","/404","/403","/register","/file-views","/iitc","/account"],exports.copyText=e=>{if(!e)return void t.ElMessage.warning("暂无可复制内容");const r=document.createElement("input");r.value=e,document.body.appendChild(r),r.select(),document.execCommand("copy"),document.body.removeChild(r),t.ElMessage.success("复制成功")},exports.debounce=(t,e=300)=>{let r=null;return function(...i){r&&clearTimeout(r),r=setTimeout(()=>{t.apply(this,i)},e)}},exports.downloadFile=(t,e)=>{const r=document.createElement("a");if(r.style.display="none","string"==typeof t)r.href=t;else{if(!(t instanceof Blob))return void console.error("不支持的文件源类型");r.href=URL.createObjectURL(t)}r.setAttribute("download",e),document.body.appendChild(r),r.click(),document.body.removeChild(r),t instanceof Blob&&window.URL.revokeObjectURL(r.href)},exports.exportFile=async(e,i,n)=>{try{const e=await fetch(i,{method:"get",headers:{token:r()},responseType:"blob"});e.ok||t.ElMessage.error("请求失败");const s=await e.blob(),a=e.headers.get("content-disposition");let o=n;if(a){const t=a.match(/filename="?([^"]+)"?/);t&&t[1]&&(o=decodeURIComponent(t[1]))}const h=window.URL.createObjectURL(s),u=document.createElement("a");u.href=h,u.download=o,document.body.appendChild(u),u.click(),t.ElMessage.success("下载成功"),window.URL.revokeObjectURL(h),document.body.removeChild(u)}catch(e){console.error("下载Excel失败:",e),t.ElMessage.error("下载失败")}},exports.extractPropValues=(t=[],e="",{keepEmpty:r=!1}={})=>{if(!Array.isArray(t))return[];const i=e.split(".").filter(t=>t.trim());return t.map(t=>{let e=t;for(const t of i)if(e=e?.[t],null==e)break;return e}).filter(t=>r||null!=t)},exports.formatAmount=t=>null==t||isNaN(t)?"":Number(t).toLocaleString("zh-CN",{minimumFractionDigits:2,maximumFractionDigits:2}),exports.formatAmountToUnits=function(t){const e=["","","","","","","","","","",""];if("number"!=typeof t||isNaN(t)||!isFinite(t))return e;if(t>999999999.99)return console.warn("金额过大,最大支持999999999.99元"),e;if(t<0)return console.warn("金额不能为负数"),e;if(0===t)return e;const r=Math.abs(t).toFixed(2),[i,n]=r.split("."),s=i.length;for(let t=0;t<s;t++){const r=i[s-1-t],n=8-t;n>=0&&(e[n]=r)}return(parseInt(i)>0||parseInt(n)>0)&&(e[9]=n[0],e[10]=n[1]),e},exports.formatMenuData=Zt,exports.formatMenuTree=function t(e){return Array.isArray(e)?e.filter(t=>1===t.type||void 0===t.type).map(e=>{const r={title:e.title,...e.path&&{path:e.path},...e.svgName&&{svgName:e.svgName}};if(e.children&&e.children.length){const i=t(e.children);i.length&&(r.children=i)}return r}):[]},exports.formatMoney=(t,e,r,i=!0)=>{if(null==t||isNaN(Number(t)))return i?"0":"";let n=Number(t);if(0===n&&!i)return"";void 0!==r&&"number"==typeof r&&r>=0?n=n.toFixed(r):void 0!==e&&"number"==typeof e&&e>=0&&(n=n.toFixed(e));const s=n.toString().split("."),a=s[0],o=s[1]||"",h=a.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${h}.${o}`:h},exports.formatToFirstDay=function(t){if(!t)return"";const[e,r]=t.split("-");return`${e}-${r}-01`},exports.generate32BitRandomString=function(){const t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let e="";for(let r=0;r<32;r++)if("undefined"!=typeof crypto&&crypto.getRandomValues){const r=new Uint8Array(1);crypto.getRandomValues(r);const i=r[0]%62;e+=t.charAt(i)}else{const r=Math.floor(62*Math.random());e+=t.charAt(r)}return e},exports.generateTimestamp=function(t=13){if(10===t)return Math.floor(Date.now()/1e3);if(13===t)return Date.now();throw new Error("只支持10位或13位时间戳")},exports.getCompanyAccountPeriod=function(){return localStorage.getItem(e.COMPANYACCOUNTPERIOD)},exports.getCompanyAccountPeriodNow=function(){return localStorage.getItem(e.COMPANYACCOUNTPERIODNOW)},exports.getCompanyAuditStatusMsg=function(){return localStorage.getItem(e.COMPANYAUDITSTATUSMSG)},exports.getCompanyAuditStatusMsgNow=function(){return localStorage.getItem(e.COMPANYAUDITSTATUSMSGNOW)},exports.getCompanyCode=function(){return localStorage.getItem(e.COMPANYCODE)},exports.getCompanyName=function(){return localStorage.getItem(e.COMPANYNAME)},exports.getCompanyType=function(){return localStorage.getItem(e.COMPANYTYPE)},exports.getCurrentMonth=()=>{const t=new Date;return`${t.getFullYear()}-${(t.getMonth()+1).toString().padStart(2,"0")}`},exports.getFileTypeFromUrlRegex=t=>{if(!t||"string"!=typeof t)return"unknown";const e=t.split("?")[0].match(/\.([a-zA-Z0-9]+)$/);if(!e)return"unknown";const r=e[1].toLowerCase();return/^pdf$/i.test(r)?"pdf":/^(jpg|jpeg|png|gif|bmp|webp|svg|ico|tiff|tif|heic|heif)$/i.test(r)?"image":"unknown"},exports.getFinancialStandardDictType=function(){return localStorage.getItem(e.FINANCIALSTANDARDDICTTYPE)},exports.getFormattedDateTime=function(){const t=new Date;return`${t.getFullYear()}${String(t.getMonth()+1).padStart(2,"0")}${String(t.getDate()).padStart(2,"0")}${String(t.getHours()).padStart(2,"0")}${String(t.getMinutes()).padStart(2,"0")}${String(t.getSeconds()).padStart(2,"0")}`},exports.getToken=r,exports.getUserInfo=function(){return localStorage.getItem(e.USER_INFO)},exports.handleViewFile=function(t){if("string"!=typeof t){const e="文件地址必须是字符串,当前传入类型:"+typeof t;return console.error("[handleViewFile] 错误:",e),{success:!1,error:e}}if(!t.trim()){const t="文件地址不能为空或仅空格";return console.error("[handleViewFile] 错误:",t),{success:!1,error:t}}let e;try{e=new URL(t)}catch(e){const r=`无效的URL格式:${t}(请检查是否包含特殊字符或缺失协议)`;return console.error("[handleViewFile] URL解析错误:",e,"| 地址:",t),{success:!1,error:r}}if(!["http:","https:"].includes(e.protocol)){const t=`仅支持HTTP/HTTPS协议,当前协议:${e.protocol}`;return console.error("[handleViewFile] 协议错误:",t),{success:!1,error:t}}const r=e.pathname,i=r.lastIndexOf(".");if(-1===i){const e=`文件地址不含后缀名:${t}(需是jpg/png/pdf)`;return console.error("[handleViewFile] 格式错误:",e),{success:!1,error:e}}const n=r.slice(i+1).toLowerCase(),s=["jpg","jpeg","png","pdf"];if(!s.includes(n)){const t=`不支持的文件格式:.${n},仅支持${s.join("、")}`;return console.error("[handleViewFile] 格式错误:",t),{success:!1,error:t}}try{if(!window.open(t,"_blank","noopener,noreferrer,width=1000,height=800")){const t="文件窗口被浏览器拦截,请允许弹窗后重试(地址栏右侧查看拦截提示)";return console.warn("[handleViewFile] 弹窗被拦截:",t),{success:!1,error:t}}return console.log("[handleViewFile] 成功:文件已在新窗口打开,地址:",t),{success:!0,message:"文件已在新窗口打开"}}catch(e){const r=`打开文件失败:${e.message}(可能是浏览器安全设置或网络问题)`;return console.error("[handleViewFile] 打开失败:",e,"| 地址:",t),{success:!1,error:r}}},exports.percentToNumber=function(t){const e=String(t).replace(/%/g,""),r=Number(e);return isNaN(r)?0:r},exports.periodDisabledDate=t=>{const e=new Date,r=e.getFullYear(),i=e.getMonth(),n=t.getFullYear(),s=t.getMonth();if(0===i){return!(n===r-1&&11===s||n===r)}return n!==r},exports.periodDisabledDateAllAfter=t=>{const e=new Date,r=e.getFullYear(),i=e.getMonth(),n=t.getFullYear(),s=t.getMonth();return n>r||n===r&&s>=i},exports.phoneRegex=/^1[3-9]\d{9}$/,exports.postExportFile=async(e,i,n,s)=>{try{const e=await fetch(i,{method:"post",headers:{token:r(),"Content-Type":"application/json"},responseType:"blob",body:JSON.stringify(s)});e.ok||t.ElMessage.error("请求失败");const a=await e.blob(),o=e.headers.get("content-disposition");let h=n;if(o){const t=o.match(/filename="?([^"]+)"?/);t&&t[1]&&(h=decodeURIComponent(t[1]))}const u=window.URL.createObjectURL(a),c=document.createElement("a");c.href=u,c.download=h,document.body.appendChild(c),c.click(),t.ElMessage.success("下载成功"),window.URL.revokeObjectURL(u),document.body.removeChild(c)}catch(e){console.error("下载Excel失败:",e),t.ElMessage.error("下载失败")}},exports.processVoucherArrayEnhanced=function(t,e={}){const{emptyObject:r={},preserveOriginal:i=!1}=e;if(!Array.isArray(t))throw new Error("参数必须是数组");const n=[];return t.forEach((t,e)=>{if(!t||"object"!=typeof t)return;const s=t.voucherList;if(!Array.isArray(s)){const s=i?{...t}:{...t,_metadata:{originalIndex:e,isPadded:!0,originalLength:0}};return s.voucherList=[{...r},{...r},{...r},{...r},{...r}],s.page=1,s.pageCount=1,void n.push(s)}const a=Math.ceil(s.length/5);if(s.length>5)for(let o=0;o<s.length;o+=5){const h=s.slice(o,o+5),u=Math.floor(o/5)+1,c=[...h];for(;c.length<5;)c.push({...r});const l=i?{...t}:{...t,_metadata:{originalIndex:e,isSplit:o>0,chunkIndex:Math.floor(o/5),totalChunks:a}};l.voucherList=c,l.page=u,l.pageCount=a,n.push(l)}else if(s.length<5){const a=s.map(t=>({...t}));for(;a.length<5;)a.push({...r});const o=i?{...t}:{...t,_metadata:{originalIndex:e,isPadded:!0,originalLength:s.length}};o.voucherList=a,o.page=1,o.pageCount=1,n.push(o)}else{const r=i?{...t}:{...t,_metadata:{originalIndex:e,isOriginal:!0}};r.page=1,r.pageCount=1,n.push(r)}}),n},exports.publicKey="MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAL/EwnX/3BaH5gJXJiv7qKhuKKol5JSgayGyYMWDdRO8KKAtOFrniXp/iAGGoV6Y0GF9Z8iY3xHOiU3rHeSJ3G6wFDY87Qr4k2m48/6YRX+s/iMGJ5j5obdCFiDkFUzoR/EHTqC6PM3h6bhDNNIXQpqVbQrg28tW5Y57+yxqRrUjAgMBAAECgYAHlgB9S3xI1eJm6Eylw8RFuWnZZTtYF8p1IEnMtmkMuU5AG9nVWsBo/J+EM++xPslLefr/h/CXEz0CPJFHp551HucLlRA7EOXSPfwLGODlz5rMnXyM8jD3ZMACXsRLvLEiNt+0nP+G7M+Dxuf6SLkmvqYa/NdJACb5/16E2P+pNQJBAO0hgUcKYfvJSXVolonVQNpR8Hu/4LH+5bBVLef+D6JNP6x0hr9U/ce+nI7I5wIPbBgFknvCWfVbgz16tPZhmC0CQQDPBzLArfdUfMs2h/3cxQAeZnX0ybt3F6CR3K9dliDJRn1p3ovdK0OmyggpKfx94KH+VRcJSaWTHLeFvub8KgSPAkEAhUWcY7HZKeqSB5OVb7fT8B+3OcW4YjFxI+5rk4Q9gylJTQJcrPH2g6mEUddlxcmnJcUT88xiRLx/ATGSvRpSrQJAJSfTkgUm6IDlL8pEY4TvuoUFEoPKI1uYM9V5m8A/7h+6jm+khnMnVx3XTRv99tGEAVNgKQiQsNBsl5JlfkhEPQJBAJ2nPXpGolp/R5usP+LP314snwj93G54+HaZnuOoIB0ApusErnpWCSHXbQtvXKo1n6SE3ccp010CPJBnOm/LRaA=",exports.recalculateCashFlowData=t=>{if(!t||!t.length)return;t.forEach(t=>{1==t.draftCalType&&(t.currentAmount=0)});let e=null;t.forEach(t=>{if(1==t.draftCalType)e=t;else if((2==t.draftCalType||3==t.draftCalType)&&e){const r=Number(t.currentAmount)||0,i=-1===t.calDirection?-1:1;e.currentAmount=(e.currentAmount||0)+r*i}})},exports.removeCompanyAccountPeriod=function(){localStorage.removeItem(e.COMPANYACCOUNTPERIOD)},exports.removeCompanyAccountPeriodNow=function(){localStorage.removeItem(e.COMPANYACCOUNTPERIODNOW)},exports.removeCompanyAuditStatusMsg=function(){localStorage.removeItem(e.COMPANYAUDITSTATUSMSG)},exports.removeCompanyAuditStatusMsgNow=function(){localStorage.removeItem(e.COMPANYAUDITSTATUSMSGNOW)},exports.removeCompanyCode=function(){localStorage.removeItem(e.COMPANYCODE)},exports.removeCompanyName=function(){localStorage.removeItem(e.COMPANYNAME)},exports.removeCompanyType=function(){localStorage.removeItem(e.COMPANYTYPE)},exports.removeFinancialStandardDictType=function(){localStorage.removeItem(e.FINANCIALSTANDARDDICTTYPE)},exports.removeOperation=(t,e)=>{const r=t.operations.indexOf(e);r>-1&&t.operations.splice(r,1)},exports.removeToken=function(){localStorage.removeItem(e.TOKEN)},exports.removeUserInfo=function(){localStorage.removeItem(e.USER_INFO)},exports.scrollToId=function(t,e=0,r=500){if("string"!=typeof t||!t.trim())return console.error("[scrollToId] 错误:id必须是非空字符串"),!1;const i=document.getElementById(t);if(!i)return console.error(`[scrollToId] 错误:未找到ID为"${t}"的元素`),!1;const n=i.getBoundingClientRect().top+window.pageYOffset,s=window.pageYOffset,a=n-s-e;let o=null;return requestAnimationFrame(function t(e){null===o&&(o=e);const i=e-o,n=function(t,e,r,i){return t/=i/2,t<1?r/2*t*t+e:(t--,-r/2*(t*(t-2)-1)+e)}(i,s,a,r);window.scrollTo(0,n),i<r&&requestAnimationFrame(t)}),!0},exports.setCompanyAccountPeriod=function(t){localStorage.setItem(e.COMPANYACCOUNTPERIOD,t)},exports.setCompanyAccountPeriodNow=function(t){localStorage.setItem(e.COMPANYACCOUNTPERIODNOW,t)},exports.setCompanyAuditStatusMsg=function(t){localStorage.setItem(e.COMPANYAUDITSTATUSMSG,t)},exports.setCompanyAuditStatusMsgNow=function(t){localStorage.setItem(e.COMPANYAUDITSTATUSMSGNOW,t)},exports.setCompanyCode=function(t){localStorage.setItem(e.COMPANYCODE,t)},exports.setCompanyName=function(t){localStorage.setItem(e.COMPANYNAME,t)},exports.setCompanyType=function(t){localStorage.setItem(e.COMPANYTYPE,t)},exports.setFinancialStandardDictType=function(t){localStorage.setItem(e.FINANCIALSTANDARDDICTTYPE,t)},exports.setToken=function(t){localStorage.setItem(e.TOKEN,t)},exports.setUserInfo=function(t){localStorage.setItem(e.USER_INFO,t)},exports.signWithSHA256RSA=function(t,e){console.log(t,e);const r=new Xt.crypto.Signature({alg:"SHA256withRSA",prov:"cryptojs/jsrsa"});return r.init(e),r.updateString(t),r.sign()},exports.svgConst={viewBox:"0 0 1536 1024",version:"1.1",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em"},exports.svgSjPath={d:"M73.75498878 312.79929781L689.59344939 960.31767875A98.63975344 98.63975344 0 0 0 762.55326659 991.9976a98.63975344 98.63975344 0 0 0 72.71981813-31.67992125L1451.3515444 312.79929781a106.55973375 106.55973375 0 0 0 23.99994-114.23971406 113.75971594 113.75971594 0 0 0-96.95975719-70.55982375l-1231.19692219 0a113.27971688 113.27971688 0 0 0-97.19975718 70.31982375 106.55973375 106.55973375 0 0 0 23.75994094 114.47971406z",fill:"#001533"},exports.truncateToTwoDecimals=function(t,e){if(!isFinite(t)||0===t)return t.toFixed(2);const r=Math.trunc(100*t)/100;return Object.is(r,-0)?"-0.00":r.toFixed(e)},exports.unclosablePaths=["/accounting/accounting-voucher-detail","/accounting/accounting-voucher-add","/accounting/accounting-voucher-red"],exports.version="0.0.4";
|
|
2
27
|
//# sourceMappingURL=jiezhangxin-utils.cjs.js.map
|