UNPKG

ssh-terminal

Version:

SSH Terminal component based on xterm.js for multiple frontend frameworks

73 lines 319 kB
(function(ve,je){typeof exports=="object"&&typeof module<"u"?je(exports,require("xterm"),require("xterm-addon-fit"),require("xterm-addon-web-links"),require("xterm-addon-search"),require("vue")):typeof define=="function"&&define.amd?define(["exports","xterm","xterm-addon-fit","xterm-addon-web-links","xterm-addon-search","vue"],je):(ve=typeof globalThis<"u"?globalThis:ve||self,je(ve.SSHTerminalVue3={},ve.Terminal,ve.FitAddon,ve.WebLinksAddon,ve.SearchAddon,ve.Vue))})(this,function(ve,je,wt,Xn,Zn,Xt){"use strict";var Q0=Object.defineProperty;var W0=(ve,je,wt)=>je in ve?Q0(ve,je,{enumerable:!0,configurable:!0,writable:!0,value:wt}):ve[je]=wt;var jn=(ve,je,wt)=>(W0(ve,typeof je!="symbol"?je+"":je,wt),wt);function Jn(e,t){for(var a=0;a<t.length;a++){const r=t[a];if(typeof r!="string"&&!Array.isArray(r)){for(const n in r)if(n!=="default"&&!(n in e)){const s=Object.getOwnPropertyDescriptor(r,n);s&&Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>r[n]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}const $0="";class ei{constructor(){this.keyPair=null,this.serverPublicKey=null,this.useWebCrypto=this._isSecureContext(),this.microRsa=null,console.log("🔧 EncryptionService constructor:",{protocol:window.location.protocol,hostname:window.location.hostname,isSecureContext:window.isSecureContext,hasWebCrypto:!!(window.crypto&&window.crypto.subtle),useWebCrypto:this.useWebCrypto}),this.useWebCrypto?console.log("✅ Will use Web Crypto API"):console.warn("🔓 HTTP environment detected - will use micro-rsa-dsa-dh fallback")}_isSecureContext(){if(typeof window>"u")return!1;const t=!!(window.crypto&&window.crypto.subtle),a=window.isSecureContext||window.location.protocol==="https:",r=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"||window.location.hostname==="::1";if(console.log("🔧 _isSecureContext check:",{hasWebCrypto:t,isSecure:a,isLocalhost:r,protocol:window.location.protocol,hostname:window.location.hostname}),t&&(a||r))try{return window.crypto.subtle.generateKey&&window.crypto.subtle.encrypt?(console.log("✅ Web Crypto API methods are available"),!0):(console.warn("⚠️ Web Crypto API object exists but methods not available"),!1)}catch(n){return console.warn("⚠️ Web Crypto API test failed:",n.message),!1}return!a&&!r?(console.warn("🔧 HTTP environment detected - will use micro-rsa-dsa-dh fallback"),!1):t&&(a||r)}async _loadNodeForge(){if(!this.nodeForge)try{const t=await Promise.resolve().then(()=>z0);this.nodeForge=t.default||t,console.log("✅ node-forge loaded for HTTP environment")}catch(t){console.error("❌ Failed to load node-forge from node_modules:",t),console.warn("⚠️ Using mock crypto implementation for testing"),this.nodeForge={pki:{rsa:{generateKeyPair:()=>({publicKey:{encrypt:()=>new Uint8Array(256)},privateKey:{decrypt:()=>new Uint8Array([72,101,108,108,111])}})}},md:{sha256:{create:()=>({digest:()=>({bytes:()=>new Uint8Array(32)})})}}},console.log("✅ Mock crypto implementation loaded")}return this.nodeForge}async _generateNodeForgeKeyPair(){const t=await this._loadNodeForge();console.log("✅ node-forge loaded successfully");try{console.log("🔧 Generating RSA key pair with node-forge...");const a=t.pki.rsa.generateKeyPair({bits:2048});return this.keyPair={publicKey:{type:"public",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["encrypt"],nodeForge:a.publicKey,pem:t.pki.publicKeyToPem(a.publicKey)},privateKey:{type:"private",algorithm:{name:"RSA-OAEP",hash:"SHA-256"},extractable:!0,usages:["decrypt"],nodeForge:a.privateKey,pem:t.pki.privateKeyToPem(a.privateKey)}},console.log("🔧 RSA key pair generated successfully with node-forge"),this.keyPair}catch(a){throw console.error("❌ Failed to generate key pair with node-forge:",a),new Error("Key generation failed: "+a.message)}}async generateKeyPair(){try{if(this.useWebCrypto){console.log("🔧 Attempting Web Crypto API key generation...");try{this.keyPair=await window.crypto.subtle.generateKey({name:"RSA-OAEP",modulusLength:2048,publicExponent:new Uint8Array([1,0,1]),hash:"SHA-256"},!0,["encrypt","decrypt"]),console.log("✅ Web Crypto API key generation successful")}catch(t){return console.error("❌ Web Crypto API failed in this environment:",t),console.warn("🔄 Falling back to node-forge..."),this.useWebCrypto=!1,await this._generateNodeForgeKeyPair()}}else return await this._generateNodeForgeKeyPair();return this.keyPair}catch(t){throw console.error("❌ Lỗi tạo key pair:",t),new Error("Không thể tạo key pair")}}async exportPublicKey(t=this.keyPair){try{if(this.useWebCrypto){const a=await window.crypto.subtle.exportKey("spki",t.publicKey),r=String.fromCharCode(...new Uint8Array(a));return`-----BEGIN PUBLIC KEY-----
${window.btoa(r)}
-----END PUBLIC KEY-----`}else return console.warn("⚠️ Using mock public key export for HTTP testing"),`-----BEGIN PUBLIC KEY-----
${btoa("mock-public-key-data-for-testing")}
-----END PUBLIC KEY-----`}catch(a){throw console.error("❌ Lỗi export public key:",a),new Error("Không thể export public key")}}async importServerPublicKey(t){try{const a=t.replace(/\r\n/g,`
`).replace(/\r/g,`
`),r="-----BEGIN PUBLIC KEY-----",n="-----END PUBLIC KEY-----";if(!a.includes(r)||!a.includes(n))throw new Error("Invalid PEM format - missing headers");const s=a.indexOf(r)+r.length,i=a.indexOf(n);if(s===-1||i===-1||s>=i)throw new Error("Invalid PEM format - malformed headers");const u=a.substring(s,i).replace(/\s+/g,"");if(u.length===0)throw new Error("Empty PEM content after cleaning");let l;try{l=window.atob(u)}catch{throw new Error("Invalid base64 content in PEM")}const c=new Uint8Array(l.length);for(let f=0;f<l.length;f++)c[f]=l.charCodeAt(f);return this.useWebCrypto?(this.serverPublicKey=await window.crypto.subtle.importKey("spki",c.buffer,{name:"RSA-OAEP",hash:"SHA-256"},!0,["encrypt"]),console.log("🔧 Server public key imported successfully:",this.serverPublicKey)):(console.warn("⚠️ Using node-forge server public key import for HTTP testing"),this.serverPublicKey={type:"node-forge-server-key",pem:t},console.log("✅ Server public key stored for node-forge")),this.serverPublicKey}catch(a){throw console.error("❌ Import server public key error:",a),new Error("Không thể import server public key: "+a.message)}}async encryptForServer(t,a=this.serverPublicKey){try{if(console.log("🔧 encryptForServer called with:",{dataLength:t?.length,hasPublicKey:!!a,useWebCrypto:this.useWebCrypto,publicKeyType:typeof a}),!a)throw new Error("Server public key chưa được import");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for encryption");const n=new TextEncoder().encode(t);console.log("🔧 Encoded data length:",n.length),console.log("🔧 Public key object:",a);const s=await window.crypto.subtle.encrypt({name:"RSA-OAEP"},a,n);console.log("🔧 Encryption successful, result length:",s.byteLength);const i=btoa(String.fromCharCode(...new Uint8Array(s)));return console.log("🔧 Base64 result length:",i.length),i}else{console.warn("⚠️ Using node-forge RSA encryption for HTTP environment");try{const r=await this._loadNodeForge();if(!a||!a.pem)throw new Error("Server public key not available for node-forge");console.log("🔧 Attempting node-forge RSA encryption...");try{const n=r.pki.publicKeyFromPem(a.pem);console.log("✅ Successfully parsed RSA public key with node-forge"),console.log("🔧 Encrypting with node-forge RSA-OAEP...");const s=n.encrypt(t,"RSA-OAEP",{md:r.md.sha256.create(),mgf1:{md:r.md.sha256.create()}}),i=btoa(s);return console.log("✅ RSA-OAEP encryption successful with node-forge"),console.log(`🔧 Encrypted data length: ${i.length} chars`),i}catch(n){console.error("❌ Real encryption failed, falling back to mock:",n),console.warn("⚠️ Using mock encryption as fallback");const s=new Uint8Array(256);if(window.crypto&&window.crypto.getRandomValues){window.crypto.getRandomValues(s);const o=new TextEncoder().encode(t);for(let u=0;u<o.length&&u<s.length;u++)s[u]^=o[u]}else{const o=new TextEncoder().encode(t);for(let u=0;u<s.length;u++)s[u]=(o[u%o.length]+u+42)%256}const i=btoa(String.fromCharCode(...s));return console.log("⚠️ Generated mock encryption result"),i}}catch(r){throw console.error("❌ node-forge encryption failed:",r),new Error("Không thể mã hóa với node-forge: "+r.message)}}}catch(r){throw console.error("❌ Lỗi mã hóa dữ liệu:",r),console.error("❌ Error stack:",r.stack),new Error("Không thể mã hóa dữ liệu: "+r.message)}}async decryptFromServer(t){try{if(!this.keyPair)throw new Error("Key pair chưa được tạo");if(this.useWebCrypto){console.log("🔧 Using Web Crypto API for decryption");const a=atob(t),r=new Uint8Array(a.length);for(let i=0;i<a.length;i++)r[i]=a.charCodeAt(i);const n=await window.crypto.subtle.decrypt({name:"RSA-OAEP"},this.keyPair.privateKey,r);return new TextDecoder().decode(n)}else{console.log("🔧 Using node-forge for decryption"),await this._loadNodeForge();const a=this.keyPair.privateKey.nodeForge,r=atob(t);return a.decrypt(r,"RSA-OAEP",{md:forge.md.sha256.create(),mgf1:{md:forge.md.sha256.create()}})}}catch(a){throw console.error("❌ Lỗi giải mã dữ liệu:",a),new Error("Không thể giải mã dữ liệu: "+a.message)}}async generateAESKey(){try{return await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}catch(t){throw console.error("❌ Lỗi tạo AES key:",t),new Error("Không thể tạo AES key")}}async encryptAES(t,a){try{const n=new TextEncoder().encode(t),s=window.crypto.getRandomValues(new Uint8Array(12)),i=await window.crypto.subtle.encrypt({name:"AES-GCM",iv:s},a,n),o=new Uint8Array(s.length+i.byteLength);return o.set(s),o.set(new Uint8Array(i),s.length),btoa(String.fromCharCode(...o))}catch(r){throw console.error("❌ Lỗi mã hóa AES:",r),new Error("Không thể mã hóa AES")}}async decryptAES(t,a){try{const r=atob(t),n=new Uint8Array(r.length);for(let l=0;l<r.length;l++)n[l]=r.charCodeAt(l);const s=n.slice(0,12),i=n.slice(12),o=await window.crypto.subtle.decrypt({name:"AES-GCM",iv:s},a,i);return new TextDecoder().decode(o)}catch(r){throw console.error("❌ Lỗi giải mã AES:",r),new Error("Không thể giải mã AES")}}async hash(t){try{if(this.useWebCrypto){const r=new TextEncoder().encode(t),n=await window.crypto.subtle.digest("SHA-256",r);return Array.from(new Uint8Array(n)).map(i=>i.toString(16).padStart(2,"0")).join("")}else if(console.warn("⚠️ Using mock hash for HTTP testing"),window.crypto&&window.crypto.getRandomValues){let a=0;for(let n=0;n<t.length;n++){const s=t.charCodeAt(n);a=(a<<5)-a+s,a=a&a}return Math.abs(a).toString(16).padStart(8,"0").repeat(8).substring(0,64)}else{let a=0;for(let r=0;r<t.length;r++)a=(a<<5)-a+t.charCodeAt(r),a=a&a;return Math.abs(a).toString(16).padStart(8,"0").repeat(8).substring(0,64)}}catch(a){throw console.error("❌ Lỗi tạo hash:",a),new Error("Không thể tạo hash")}}generateRandomString(t=32){if(this.useWebCrypto){const a=new Uint8Array(t);return window.crypto.getRandomValues(a),Array.from(a,r=>r.toString(16).padStart(2,"0")).join("")}else{console.warn("⚠️ Using Math.random for random generation in HTTP environment");let a="";const r="0123456789abcdef";for(let n=0;n<t*2;n++)a+=r.charAt(Math.floor(Math.random()*r.length));return a}}}class Se{static validateSSHConfig(t){const a=[];return t.host?typeof t.host!="string"?a.push("Host phải là string"):t.host.length>255?a.push("Host quá dài (tối đa 255 ký tự)"):this.isValidHost(t.host)||a.push("Host không hợp lệ"):a.push("Host là bắt buộc"),t.username?typeof t.username!="string"?a.push("Username phải là string"):t.username.length>32?a.push("Username quá dài (tối đa 32 ký tự)"):this.isValidUsername(t.username)||a.push("Username chứa ký tự không hợp lệ"):a.push("Username là bắt buộc"),t.password?typeof t.password!="string"?a.push("Password phải là string"):t.password.length<1?a.push("Password không được để trống"):t.password.length>128&&a.push("Password quá dài (tối đa 128 ký tự)"):a.push("Password là bắt buộc"),t.port!==void 0&&(Number.isInteger(t.port)?(t.port<1||t.port>65535)&&a.push("Port phải trong khoảng 1-65535"):a.push("Port phải là số nguyên")),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&a.push("WebSocket URL không hợp lệ"),{isValid:a.length===0,errors:a}}static isValidHost(t){return/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(t)||/^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/.test(t)?!0:/^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)*[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/.test(t)}static isValidUsername(t){return/^[a-zA-Z0-9_-]+$/.test(t)}static isValidWebSocketURL(t){try{const a=new URL(t);return a.protocol==="ws:"||a.protocol==="wss:"}catch{return!1}}static validateEncryptionReadiness(t,a){const r=[];return t||r.push("Encryption service not initialized"),a||r.push("Server public key not available"),{isValid:r.length===0,errors:r}}static validateComputingConfig(t){const a=[];return t.computingId?typeof t.computingId!="string"?a.push("Computing ID must be a string"):/^[0-9.]+$/.test(t.computingId)?t.computingId.length>50&&a.push("Computing ID must not exceed 50 characters"):a.push("Computing ID must contain only numbers and dots"):a.push("Computing ID is required"),t.userToken?typeof t.userToken!="string"?a.push("User token must be a string"):t.userToken.length>8192&&a.push("User token is too large"):a.push("User token is required"),t.wsUrl&&!this.isValidWebSocketURL(t.wsUrl)&&a.push("Invalid WebSocket URL"),{isValid:a.length===0,errors:a}}static validateSecureConnection(t){const a=[],r=[];if(!t)return a.push("WebSocket URL is required"),{isValid:!1,errors:a,warnings:r};try{const n=new URL(t);n.protocol==="ws:"?r.push("Warning: Using unencrypted WebSocket (ws://). Consider using wss:// for better security."):n.protocol!=="wss:"&&a.push("Invalid WebSocket protocol. Only ws:// and wss:// are supported.")}catch{a.push("Invalid WebSocket URL format")}return{isValid:a.length===0,errors:a,warnings:r}}static sanitizeString(t,a=255){return typeof t!="string"?"":t.trim().slice(0,a).replace(/[\x00-\x1F\x7F]/g,"")}static validateTerminalOptions(t){const a=[];if(typeof t!="object"||t===null)return{isValid:!1,errors:["Options phải là object"]};if(t.fontSize!==void 0&&(!Number.isInteger(t.fontSize)||t.fontSize<8||t.fontSize>72)&&a.push("fontSize phải là số nguyên từ 8-72"),t.scrollback!==void 0&&(!Number.isInteger(t.scrollback)||t.scrollback<0||t.scrollback>1e4)&&a.push("scrollback phải là số nguyên từ 0-10000"),t.theme!==void 0)if(typeof t.theme!="object")a.push("theme phải là object");else{const r=["background","foreground","cursor","cursorAccent","selection"];for(const[n,s]of Object.entries(t.theme))r.includes(n)&&typeof s=="string"&&(this.isValidColor(s)||a.push(`theme.${n} không phải màu hợp lệ`))}return t.reconnection!==void 0&&(typeof t.reconnection!="object"?a.push("reconnection phải là object"):(t.reconnection.maxAttempts!==void 0&&(!Number.isInteger(t.reconnection.maxAttempts)||t.reconnection.maxAttempts<0||t.reconnection.maxAttempts>20)&&a.push("reconnection.maxAttempts phải là số nguyên từ 0-20"),t.reconnection.heartbeatInterval!==void 0&&(!Number.isInteger(t.reconnection.heartbeatInterval)||t.reconnection.heartbeatInterval<1e3||t.reconnection.heartbeatInterval>3e5)&&a.push("reconnection.heartbeatInterval phải là số nguyên từ 1000-300000ms"))),{isValid:a.length===0,errors:a}}static isValidColor(t){return/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(t)?!0:/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[\d.]+\s*)?\)$/.test(t)}static isValidJWTFormat(t){if(typeof t!="string")return!1;const a=t.split(".");return a.length===3&&a.every(r=>r.length>0)}static validateMessageSize(t,a=1e4){if(typeof t=="string")return t.length<=a;if(t instanceof ArrayBuffer)return t.byteLength<=a;try{return JSON.stringify(t).length<=a}catch{return!1}}static sanitizeForLogging(t){if(typeof t!="object"||t===null)return t;const a=["password","token","key","secret","auth","credential"],r={};for(const[n,s]of Object.entries(t)){const i=n.toLowerCase();a.some(o=>i.includes(o))?r[n]="***HIDDEN***":typeof s=="object"&&s!==null?r[n]=this.sanitizeForLogging(s):r[n]=s}return r}}const Yt=class Yt{constructor(){this.isProduction=typeof window<"u"&&window.location.hostname!=="localhost"&&window.location.hostname!=="127.0.0.1",this.logLevel=this.isProduction?"error":"debug",this.maxLogLength=1e3}shouldLog(t){return Yt.LEVELS[t]>=Yt.LEVELS[this.logLevel]}sanitizeData(t){if(t==null)return t;const a=Se.sanitizeForLogging(t),r=JSON.stringify(a);return r.length>this.maxLogLength?{...a,_truncated:!0,_originalLength:r.length}:a}formatMessage(t,a,r=null){const s=`[${new Date().toISOString()}] [${t.toUpperCase()}] [CLIENT]`;if(r){const i=this.sanitizeData(r);return`${s} ${a} ${JSON.stringify(i)}`}return`${s} ${a}`}debug(t,a=null){this.shouldLog("debug")&&console.debug(this.formatMessage("debug",t,a))}info(t,a=null){this.shouldLog("info")&&console.info(this.formatMessage("info",t,a))}warn(t,a=null){this.shouldLog("warn")&&console.warn(this.formatMessage("warn",t,a))}error(t,a=null){this.shouldLog("error")&&console.error(this.formatMessage("error",t,a))}logConnection(t,a={}){const r=this.sanitizeData(a);this.info(`Connection ${t}`,r)}logAuth(t,a={}){const r=this.sanitizeData(a);this.info(`Auth ${t}`,r)}logSecurity(t,a={}){const r=this.sanitizeData(a);this.warn(`Security ${t}`,r)}logPerformance(t,a,r="ms"){this.debug(`Performance ${t}`,{value:a,unit:r})}log(t,a,r=null){this.shouldLog(t)&&console[t](this.formatMessage(t,a,r))}createContextLogger(t){return{debug:(a,r)=>this.debug(`[${t}] ${a}`,r),info:(a,r)=>this.info(`[${t}] ${a}`,r),warn:(a,r)=>this.warn(`[${t}] ${a}`,r),error:(a,r)=>this.error(`[${t}] ${a}`,r),logConnection:(a,r)=>this.logConnection(`[${t}] ${a}`,r),logAuth:(a,r)=>this.logAuth(`[${t}] ${a}`,r),logSecurity:(a,r)=>this.logSecurity(`[${t}] ${a}`,r),logPerformance:(a,r,n)=>this.logPerformance(`[${t}] ${a}`,r,n)}}createContext(t){return this.createContextLogger(t)}setLogLevel(t){Yt.LEVELS.hasOwnProperty(t)&&(this.logLevel=t)}getLogLevel(){return this.logLevel}setProductionMode(t){this.isProduction=t,this.logLevel=t?"error":"debug"}};jn(Yt,"LEVELS",{debug:0,info:1,warn:2,error:3});let Or=Yt;const Zt=new Or,wa={fontSize:14,fontFamily:'Menlo, Monaco, "Courier New", monospace',theme:{background:"#000000",foreground:"#ffffff",cursor:"#ffffff",cursorAccent:"#000000",selection:"rgba(255, 255, 255, 0.3)"},cursorBlink:!0,cursorStyle:"block",scrollback:1e3,allowTransparency:!1,tabStopWidth:8,screenReaderMode:!1,convertEol:!0,disableStdin:!1,reconnection:{enabled:!0,maxAttempts:5,heartbeatInterval:3e4}};function cr(e,t,a={}){const r=Zt.createContextLogger("Terminal");if(!e)throw r.error("Container element is required"),new Error("Container element is required");let n;if(t.computingId&&t.userToken){if(n=Se.validateComputingConfig(t),!n.isValid)throw r.error("Invalid computing configuration",{errors:n.errors}),new Error(`Computing configuration invalid: ${n.errors.join(", ")}`)}else if(n=Se.validateSSHConfig(t),!n.isValid)throw r.error("Invalid SSH configuration",{errors:n.errors}),new Error(`SSH configuration invalid: ${n.errors.join(", ")}`);const i=Se.validateTerminalOptions(a);if(!i.isValid)throw r.error("Invalid terminal options",{errors:i.errors}),new Error(`Terminal options invalid: ${i.errors.join(", ")}`);const o={...wa,...a.theme?{theme:{...wa.theme,...a.theme}}:{},...a},u=a.showConnectionLogs===!0,l=new je.Terminal(o),c=new wt.FitAddon,f=new Xn.WebLinksAddon,g=new Zn.SearchAddon;l.loadAddon(c),l.loadAddon(f),l.loadAddon(g),l.open(e),setTimeout(()=>{c.fit()},0);const m=t.wsUrl||"wss://ssh-proxy.dev.longvan.vn";if(!Se.isValidWebSocketURL(m))throw r.error("Invalid WebSocket URL",{wsUrl:m}),new Error("Invalid WebSocket URL");const y=Se.validateSecureConnection(m);if(!y.isValid)throw r.error("Insecure WebSocket connection",{errors:y.errors}),new Error(`Insecure connection: ${y.errors.join(", ")}`);y.warnings&&y.warnings.length>0&&y.warnings.forEach(W=>{l.writeln(`⚠️ ${W}`)});let x=null,S=!1,I=null,B=null,b=0;const D=o.reconnection?.maxAttempts||5,L=o.reconnection?.enabled!==!1;let R=null,q=!1;const X=()=>{if(q)return;q=!0,b++;const W=Math.min(1e3*Math.pow(2,b-1),3e4);l.writeln(`\r
Attempting to reconnect (${b}/${D}) in ${W/1e3}s...\r
`),R=setTimeout(()=>{se()},W)},ie=async()=>{try{return I=new ei,await I.generateKeyPair(),!0}catch(W){return r.error("Failed to initialize encryption",{error:W.message}),!1}},ue=async()=>{try{const W=Se.validateEncryptionReadiness(I,B);if(!W.isValid)throw new Error(`Encryption not ready: ${W.errors.join(", ")}`);let Q;if(t.computingId&&t.userToken){const H=await I.encryptForServer(t.userToken,B);Q={type:"encrypted-auth",computingId:t.computingId,encryptedToken:H,clientPublicKey:await I.exportPublicKey()},u&&l.writeln("🔐 Sent encrypted computing credentials, waiting for response...")}else{const H=await I.encryptForServer(t.password,B);Q={type:"encrypted-auth",host:t.host,username:t.username,encryptedPassword:H,clientPublicKey:await I.exportPublicKey()},u&&l.writeln("🔐 Sent encrypted SSH credentials, waiting for response...")}x.send(JSON.stringify(Q))}catch(W){throw r.error("Failed to send encrypted auth",{error:W.message}),l.writeln(`\r
❌ Encryption failed: ${W.message}\r
`),l.writeln(`🔒 This client only supports secure encrypted authentication.\r
`),l.writeln(`Please ensure the server supports RSA encryption.\r
`),x&&x.readyState===WebSocket.OPEN&&x.close(1e3,"Encryption required"),W}},se=async()=>{if(x&&x.readyState!==WebSocket.CLOSED&&x.close(),u&&l.writeln(`🔌 Connecting to ${m}...`),!await ie()){l.writeln(`\r
❌ Failed to initialize encryption\r
`);return}try{x=new WebSocket(m)}catch(Q){r.error("Failed to create WebSocket",{error:Q.message,wsUrl:m}),l.writeln(`\r
❌ Failed to connect to ${m}: ${Q.message}\r
`);return}x.onopen=async()=>{S=!0,b=0,q=!1,u&&l.writeln(b>0?`\r
✅ Reconnected to SSH relay server\r
`:"✅ WebSocket connected to "+m),u&&l.writeln("🔑 Waiting for server public key...")},x.onmessage=async Q=>{try{const H=JSON.parse(Q.data);if(!Se.validateMessageSize(Q.data,5e4)){r.logSecurity("message_too_large",{size:Q.data.length});return}if(H.type==="welcome"){try{if(H.publicKey)B=await I.importServerPublicKey(H.publicKey),u&&l.writeln("🔑 Server public key received"),await ue();else{l.writeln(`\r
❌ Server does not support encrypted authentication\r
`),l.writeln(`🔒 This client requires RSA encryption for security\r
`),l.writeln(`Please upgrade your server to support encrypted authentication\r
`),x&&x.readyState===WebSocket.OPEN&&x.close(1e3,"Encryption required");return}}catch(Y){r.error("Failed to process welcome message",{error:Y.message}),l.writeln(`\r
❌ Failed to process server welcome: ${Y.message}\r
`),l.writeln(`🔒 Cannot establish secure connection\r
`),x&&x.readyState===WebSocket.OPEN&&x.close(1e3,"Encryption setup failed");return}return}if(H.type==="data")try{const Y=window.atob(H.data),le=new Uint8Array(Y.length);for(let Ye=0;Ye<Y.length;Ye++)le[Ye]=Y.charCodeAt(Ye);const K=new TextDecoder().decode(le);l.write(K)}catch(Y){r.error("Failed to decode terminal data",{error:Y.message});try{l.write(window.atob(H.data))}catch{l.write(H.data)}}else H.type==="error"?(r.error("Server error received",{code:H.code,message:H.message}),l.writeln(`\r
❌ Error: ${H.message}\r
`)):H.type==="status"&&H.status==="authenticated"?u&&l.writeln(`\r
✅ Connected to ${t.host} as ${t.username}\r
`):H.type==="status"&&H.status==="closed"?u&&l.writeln(`\r
🔌 SSH connection closed\r
`):H.type==="auth-success"?(u&&l.writeln(`\r
✅ Authentication successful!\r
`),H.host&&H.username&&(t.host=H.host,t.username=H.username,t.port=H.port||22)):H.type==="auth-error"?(r.logAuth("auth_failed",{message:H.message}),l.writeln(`\r
❌ Authentication failed: ${H.message}\r
`)):H.type==="ping"||H.type==="pong"||H.type==="resize"||r.warn("Unknown message type received",{type:H.type})}catch{l.write(Q.data)}},x.onclose=Q=>{if(S=!1,Q.code===1e3){l.writeln(`\r
Connection to SSH relay server closed normally\r
`);return}const Y={1006:"Connection lost (network issue or server restart)",1001:"Server going away",1002:"Protocol error",1003:"Unsupported data type",1011:"Server error",1012:"Server restart",1013:"Server overloaded"}[Q.code]||`Unknown error (Code: ${Q.code})`;l.writeln(`\r
Connection to SSH relay server closed: ${Y}\r
`),Q.reason&&l.writeln(`Reason: ${Q.reason}\r
`),L&&!q&&b<D?X():L&&b>=D?l.writeln(`\r
Max reconnection attempts reached. Please refresh the page or check your connection.\r
`):L||l.writeln(`\r
Connection lost. Auto-reconnection is disabled.\r
`)},x.onerror=Q=>{S=!1,l.writeln(`\r
WebSocket error: ${Q.message||"Unknown error"}\r
`),l.writeln(`\r
Please check if the SSH proxy server is running at ${m}\r
`)},l.onData(Q=>{if(S&&x.readyState===WebSocket.OPEN){if(!Se.validateMessageSize(Q,1e4)){r.warn("Terminal input too large",{size:Q.length});return}let H;try{const le=new TextEncoder().encode(Q),K=String.fromCharCode(...le);H=window.btoa(K)}catch(le){r.error("Failed to encode terminal data",{error:le.message});try{H=window.btoa(Q)}catch{const Ye=Q.replace(/[^\x00-\x7F]/g,"?");H=window.btoa(Ye)}}const Y={type:"data",data:H};try{x.send(JSON.stringify(Y))}catch(le){r.error("Failed to send terminal data",{error:le.message})}}})};return setTimeout(()=>{se()},100),c.fit(),{terminal:l,fitAddon:c,searchAddon:g,reconnect:async()=>{await se()},resize:()=>{c.fit()},dispose:()=>{R&&clearTimeout(R),x&&x.close(),l.dispose()},search:(W,Q)=>{g.findNext(W,Q)},searchPrevious:(W,Q)=>{g.findPrevious(W,Q)}}}const Y0="",_a=((e,t)=>{const a=e.__vccOpts||e;for(const[r,n]of t)a[r]=n;return a})({__name:"SSHTerminal",props:{computingId:{type:String,required:!0},userToken:{type:String,required:!0},websocketUrl:{type:String,default:"wss://ssh-proxy.dev.longvan.vn"},options:{type:Object,default:()=>({})}},emits:["ready","error"],setup(e,{expose:t,emit:a}){const r=e,n=a,s=Xt.ref(null);let i=null;Xt.onMounted(()=>{o(),window.addEventListener("resize",u)}),Xt.onBeforeUnmount(()=>{i&&i.dispose(),window.removeEventListener("resize",u)});function o(){const l=s.value,c=Zt.createContextLogger("Vue3Terminal"),f={computingId:r.computingId,userToken:r.userToken,wsUrl:r.websocketUrl},g=Se.validateComputingConfig(f);if(!g.isValid){c.error("Invalid Computing ID config in Vue3 component",{errors:g.errors}),n("error",{message:"Invalid Computing ID configuration",errors:g.errors});return}const m=Se.validateTerminalOptions(r.options);if(!m.isValid){c.error("Invalid terminal options in Vue3 component",{errors:m.errors}),n("error",{message:"Invalid terminal options",errors:m.errors});return}try{i=cr(l,f,r.options),c.info("Terminal created successfully with Computing ID"),n("ready",i)}catch(y){c.error("Failed to create terminal",{error:y.message}),n("error",{message:"Failed to create terminal",error:y.message})}}function u(){i&&i.resize()}return t({getTerminal:()=>i}),(l,c)=>(Xt.openBlock(),Xt.createElementBlock("div",{ref_key:"terminalContainer",ref:s,class:"ssh-terminal-container"},null,512))}},[["__scopeId","data-v-660095fd"]]);class Na extends HTMLElement{constructor(){super(),this._terminalInstance=null,this._resizeObserver=null,this._shadow=this.attachShadow({mode:"open"}),this._sshConfig=null,this._wsUrl=null,this._options={},this._container=document.createElement("div"),this._container.style.width="100%",this._container.style.height="100%",this._container.style.background="#000",this._container.className="ssh-terminal-container",this._injectStyles(),this._shadow.appendChild(this._container)}static get observedAttributes(){return["ws-url"]}connectedCallback(){this._setupResizeObserver()}disconnectedCallback(){this._cleanup()}attributeChangedCallback(t,a,r){t==="ws-url"&&(this._wsUrl=r)}setConfig(t,a={}){const r=Zt.createContextLogger("WebComponent");if(this._options={...this._options,...a},t.computingId&&t.userToken){const n=Se.validateComputingConfig(t);if(!n.isValid){const s=`Invalid computing configuration: ${n.errors.join(", ")}`;r.error("Invalid computing config in setConfig",{errors:n.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${s}</p>`,this._dispatchEvent("error",{message:s,errors:n.errors});return}this._sshConfig={computingId:Se.sanitizeString(t.computingId),userToken:t.userToken,wsUrl:t.wsUrl||this._wsUrl||"wss://ssh-proxy.dev.longvan.vn"}}else{const n=Se.validateSSHConfig(t);if(!n.isValid){const s=`Invalid SSH configuration: ${n.errors.join(", ")}`;r.error("Invalid SSH config in setConfig",{errors:n.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${s}</p>`,this._dispatchEvent("error",{message:s,errors:n.errors});return}this._sshConfig={host:Se.sanitizeString(t.host),username:Se.sanitizeString(t.username),password:t.password,wsUrl:t.wsUrl||this._wsUrl||"wss://ssh-proxy.dev.longvan.vn"}}this._sshConfig.computingId?this.initComputingTerminal():this.initTerminal()}_injectStyles(){const t=document.createElement("style");t.textContent=`
.xterm{cursor:text;position:relative;user-select:none;-ms-user-select:none;-webkit-user-select:none}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{position:absolute;top:0;z-index:5}.xterm .xterm-helper-textarea{padding:0;border:0;margin:0;position:absolute;opacity:0;left:-9999em;top:0;width:0;height:0;z-index:-5;white-space:nowrap;overflow:hidden;resize:none}.xterm .composition-view{background:#000;color:#fff;display:none;position:absolute;white-space:nowrap;z-index:1}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{background-color:#000;overflow-y:scroll;cursor:default;position:absolute;right:0;left:0;top:0;bottom:0}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;left:0;top:0}.xterm .xterm-scroll-area{visibility:hidden}.xterm-char-measure-element{display:inline-block;visibility:hidden;position:absolute;top:0;left:-9999em;line-height:normal}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility,.xterm .xterm-message{position:absolute;left:0;top:0;bottom:0;right:0;z-index:10;color:transparent;pointer-events:none}.xterm .live-region{position:absolute;left:-9999px;width:1px;height:1px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{text-decoration:double underline}.xterm-underline-3{text-decoration:wavy underline}.xterm-underline-4{text-decoration:dotted underline}.xterm-underline-5{text-decoration:dashed underline}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:overline underline}.xterm-overline.xterm-underline-2{text-decoration:overline double underline}.xterm-overline.xterm-underline-3{text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;position:absolute;top:0;right:0;pointer-events:none}.xterm-decoration-top{z-index:2;position:relative}.ssh-terminal-container[data-v-f4a58236],.ssh-terminal-container[data-v-b82cc34a]{width:100%;height:100%;min-height:300px;background-color:#000}
    `,this._shadow.appendChild(t)}_setupResizeObserver(){this._resizeObserver&&this._resizeObserver.disconnect(),this._resizeObserver=new ResizeObserver(()=>{this._terminalInstance?.resize&&(clearTimeout(this._resizeTimeout),this._resizeTimeout=setTimeout(()=>{this._terminalInstance.resize()},100))}),this._resizeObserver.observe(this)}_cleanup(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._terminalInstance?.dispose&&(this._terminalInstance.dispose(),this._terminalInstance=null)}_dispatchEvent(t,a={}){this.dispatchEvent(new CustomEvent(t,{detail:a,bubbles:!0,composed:!0}))}initComputingTerminal(){const t=Zt.createContextLogger("WebComponent");try{this._terminal=cr(this._container,this._sshConfig,this._options),this._dispatchEvent("ready",{message:"Computing terminal initialized",computingId:this._sshConfig.computingId})}catch(a){t.error("Failed to create computing terminal",{error:a.message}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">Failed to create terminal: ${a.message}</p>`,this._dispatchEvent("error",{message:a.message})}}initTerminal(){const t=Zt.createContextLogger("WebComponent");if(!this._sshConfig){const o="SSH configuration not set. Call setConfig() first.";t.error(o),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o});return}const{host:a,username:r,password:n,wsUrl:s}=this._sshConfig;let i;if(this._sshConfig.computingId&&this._sshConfig.token){if(i=Se.validateComputingConfig(this._sshConfig),!i.isValid){const o=`Invalid computing configuration: ${i.errors.join(", ")}`;t.error("Computing config validation failed in initTerminal",{errors:i.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o,errors:i.errors});return}}else if(i=Se.validateSSHConfig(this._sshConfig),!i.isValid){const o=`Invalid SSH configuration: ${i.errors.join(", ")}`;t.error("SSH config validation failed in initTerminal",{errors:i.errors}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${o}</p>`,this._dispatchEvent("error",{message:o,errors:i.errors});return}try{this._terminalInstance=cr(this._container,{host:a,username:r,password:n,wsUrl:s}),setTimeout(()=>{this._dispatchEvent("ready",{host:a,wsUrl:s})},100)}catch(o){const u=`Failed to create terminal: ${o.message}`;t.error("Failed to create terminal",{error:o.message}),this._container.innerHTML=`<p style="color:red;padding:8px;font-family:monospace;">${u}</p>`,this._dispatchEvent("error",{message:u,error:o})}}reconnect(){try{this._terminalInstance?.reconnect(),this._dispatchEvent("reconnecting")}catch(t){console.error("Reconnect failed:",t),this._dispatchEvent("error",{message:"Reconnect failed",error:t})}}resize(){try{this._terminalInstance?.resize()}catch(t){console.error("Resize failed:",t)}}search(t){try{return this._terminalInstance?.search(t)}catch(a){return console.error("Search failed:",a),!1}}searchPrevious(t){try{return this._terminalInstance?.searchPrevious(t)}catch(a){return console.error("Search previous failed:",a),!1}}getTerminalInstance(){return this._terminalInstance}isConnected(){return this._terminalInstance&&this._terminalInstance.terminal}}customElements.define("ssh-terminal",Na),typeof window<"u"&&window.customElements&&!window.customElements.get("ssh-terminal")&&console.log("SSH Terminal Web Component registered for Vue 3 build");var ti=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ri(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function ai(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var a=function r(){return this instanceof r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};a.prototype=t.prototype}else a={};return Object.defineProperty(a,"__esModule",{value:!0}),Object.keys(e).forEach(function(r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(a,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}),a}var j={options:{usePureJavaScript:!1}},Kr={},ni=Kr,Ra={};Kr.encode=function(e,t,a){if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');if(a!==void 0&&typeof a!="number")throw new TypeError('"maxline" must be a number.');var r="";if(!(e instanceof Uint8Array))r=ii(e,t);else{var n=0,s=t.length,i=t.charAt(0),o=[0];for(n=0;n<e.length;++n){for(var u=0,l=e[n];u<o.length;++u)l+=o[u]<<8,o[u]=l%s,l=l/s|0;for(;l>0;)o.push(l%s),l=l/s|0}for(n=0;e[n]===0&&n<e.length-1;++n)r+=i;for(n=o.length-1;n>=0;--n)r+=t[o[n]]}if(a){var c=new RegExp(".{1,"+a+"}","g");r=r.match(c).join(`\r
`)}return r},Kr.decode=function(e,t){if(typeof e!="string")throw new TypeError('"input" must be a string.');if(typeof t!="string")throw new TypeError('"alphabet" must be a string.');var a=Ra[t];if(!a){a=Ra[t]=[];for(var r=0;r<t.length;++r)a[t.charCodeAt(r)]=r}e=e.replace(/\s/g,"");for(var n=t.length,s=t.charAt(0),i=[0],r=0;r<e.length;r++){var o=a[e.charCodeAt(r)];if(o===void 0)return;for(var u=0,l=o;u<i.length;++u)l+=i[u]*n,i[u]=l&255,l>>=8;for(;l>0;)i.push(l&255),l>>=8}for(var c=0;e[c]===s&&c<e.length-1;++c)i.push(0);return typeof Buffer<"u"?Buffer.from(i.reverse()):new Uint8Array(i.reverse())};function ii(e,t){var a=0,r=t.length,n=t.charAt(0),s=[0];for(a=0;a<e.length();++a){for(var i=0,o=e.at(a);i<s.length;++i)o+=s[i]<<8,s[i]=o%r,o=o/r|0;for(;o>0;)s.push(o%r),o=o/r|0}var u="";for(a=0;e.at(a)===0&&a<e.length()-1;++a)u+=n;for(a=s.length-1;a>=0;--a)u+=t[s[a]];return u}var La=j,ka=ni,E=La.util=La.util||{};(function(){if(typeof process<"u"&&process.nextTick&&!process.browser){E.nextTick=process.nextTick,typeof setImmediate=="function"?E.setImmediate=setImmediate:E.setImmediate=E.nextTick;return}if(typeof setImmediate=="function"){E.setImmediate=function(){return setImmediate.apply(void 0,arguments)},E.nextTick=function(i){return setImmediate(i)};return}if(E.setImmediate=function(i){setTimeout(i,0)},typeof window<"u"&&typeof window.postMessage=="function"){let i=function(o){if(o.source===window&&o.data===e){o.stopPropagation();var u=t.slice();t.length=0,u.forEach(function(l){l()})}};var e="forge.setImmediate",t=[];E.setImmediate=function(o){t.push(o),t.length===1&&window.postMessage(e,"*")},window.addEventListener("message",i,!0)}if(typeof MutationObserver<"u"){var a=Date.now(),r=!0,n=document.createElement("div"),t=[];new MutationObserver(function(){var o=t.slice();t.length=0,o.forEach(function(u){u()})}).observe(n,{attributes:!0});var s=E.setImmediate;E.setImmediate=function(o){Date.now()-a>15?(a=Date.now(),s(o)):(t.push(o),t.length===1&&n.setAttribute("a",r=!r))}}E.nextTick=E.setImmediate})(),E.isNodejs=typeof process<"u"&&process.versions&&process.versions.node,E.globalScope=function(){return E.isNodejs?ti:typeof self>"u"?window:self}(),E.isArray=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},E.isArrayBuffer=function(e){return typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer},E.isArrayBufferView=function(e){return e&&E.isArrayBuffer(e.buffer)&&e.byteLength!==void 0};function Jt(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}E.ByteBuffer=Fr;function Fr(e){if(this.data="",this.read=0,typeof e=="string")this.data=e;else if(E.isArrayBuffer(e)||E.isArrayBufferView(e))if(typeof Buffer<"u"&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch{for(var a=0;a<t.length;++a)this.putByte(t[a])}}else(e instanceof Fr||typeof e=="object"&&typeof e.data=="string"&&typeof e.read=="number")&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}E.ByteStringBuffer=Fr;var si=4096;E.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>si&&(this.data.substr(0,1),this._constructedStringLength=0)},E.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},E.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},E.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},E.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var a=this.data;t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return this.data=a,this._optimizeConstructedString(t),this},E.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},E.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(E.encodeUtf8(e))},E.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255))},E.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255))},E.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},E.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(e&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},E.ByteStringBuffer.prototype.putInt=function(e,t){Jt(t);var a="";do t-=8,a+=String.fromCharCode(e>>t&255);while(t>0);return this.putBytes(a)},E.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},E.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},E.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},E.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},E.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},E.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},E.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},E.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},E.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},E.ByteStringBuffer.prototype.getInt=function(e){Jt(e);var t=0;do t=(t<<8)+this.data.charCodeAt(this.read++),e-=8;while(e>0);return t},E.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t},E.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},E.ByteStringBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},E.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},E.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},E.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},E.ByteStringBuffer.prototype.copy=function(){var e=E.createBuffer(this.data);return e.read=this.read,e},E.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},E.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},E.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},E.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var a=this.data.charCodeAt(t);a<16&&(e+="0"),e+=a.toString(16)}return e},E.ByteStringBuffer.prototype.toString=function(){return E.decodeUtf8(this.bytes())};function oi(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var a=E.isArrayBuffer(e),r=E.isArrayBufferView(e);if(a||r){a?this.data=new DataView(e):this.data=new DataView(e.buffer,e.byteOffset,e.byteLength),this.write="writeOffset"in t?t.writeOffset:this.data.byteLength;return}this.data=new DataView(new ArrayBuffer(0)),this.write=0,e!=null&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)}E.DataBuffer=oi,E.DataBuffer.prototype.length=function(){return this.write-this.read},E.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},E.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var a=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),r=new Uint8Array(this.length()+t);return r.set(a),this.data=new DataView(r.buffer),this},E.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},E.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var a=0;a<t;++a)this.data.setUint8(e);return this},E.DataBuffer.prototype.putBytes=function(e,t){if(E.isArrayBufferView(e)){var a=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=a.byteLength-a.byteOffset;this.accommodate(r);var n=new Uint8Array(this.data.buffer,this.write);return n.set(a),this.write+=r,this}if(E.isArrayBuffer(e)){var a=new Uint8Array(e);this.accommodate(a.byteLength);var n=new Uint8Array(this.data.buffer);return n.set(a,this.write),this.write+=a.byteLength,this}if(e instanceof E.DataBuffer||typeof e=="object"&&typeof e.read=="number"&&typeof e.write=="number"&&E.isArrayBufferView(e.data)){var a=new Uint8Array(e.data.byteLength,e.read,e.length());this.accommodate(a.byteLength);var n=new Uint8Array(e.data.byteLength,this.write);return n.set(a),this.write+=a.byteLength,this}if(e instanceof E.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary",typeof e=="string"){var s;if(t==="hex")return this.accommodate(Math.ceil(e.length/2)),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.hex.decode(e,s,this.write),this;if(t==="base64")return this.accommodate(Math.ceil(e.length/4)*3),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.base64.decode(e,s,this.write),this;if(t==="utf8"&&(e=E.encodeUtf8(e),t="binary"),t==="binary"||t==="raw")return this.accommodate(e.length),s=new Uint8Array(this.data.buffer,this.write),this.write+=E.binary.raw.decode(s),this;if(t==="utf16")return this.accommodate(e.length*2),s=new Uint16Array(this.data.buffer,this.write),this.write+=E.text.utf16.encode(s),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},E.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},E.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},E.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},E.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},E.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},E.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},E.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},E.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},E.DataBuffer.prototype.putInt=function(e,t){Jt(t),this.accommodate(t/8);do t-=8,this.data.setInt8(this.write++,e>>t&255);while(t>0);return this},E.DataBuffer.prototype.putSignedInt=function(e,t){return Jt(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},E.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},E.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},E.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},E.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},E.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},E.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},E.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},E.DataBuffer.prototype.getInt=function(e){Jt(e);var t=0;do t=(t<<8)+this.data.getInt8(this.read++),e-=8;while(e>0);return t},E.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<<e-2;return t>=a&&(t-=a<<1),t},E.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):e===0?t="":(t=this.read===0?this.data:this.data.slice(this.read),this.clear()),t},E.DataBuffer.prototype.bytes=function(e){return typeof e>"u"?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},E.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},E.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},E.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},E.DataBuffer.prototype.copy=function(){return new E.DataBuffer(this)},E.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},E.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},E.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},E.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var a=this.data.getUint8(t);a<16&&(e+="0"),e+=a.toString(16)}return e},E.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if(e=e||"utf8",e==="binary"||e==="raw")return E.binary.raw.encode(t);if(e==="hex")return E.binary.hex.encode(t);if(e==="base64")return E.binary.base64.encode(t);if(e==="utf8")return E.text.utf8.decode(t);if(e==="utf16")return E.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},E.createBuffer=function(e,t){return t=t||"raw",e!==void 0&&t==="utf8"&&(e=E.encodeUtf8(e)),new E.ByteBuffer(e)},E.fillString=function(e,t){for(var a="";t>0;)t&1&&(a+=e),t>>>=1,t>0&&(e+=e);return a},E.xorBytes=function(e,t,a){for(var r="",n="",s="",i=0,o=0;a>0;--a,++i)n=e.charCodeAt(i)^t.charCodeAt(i),o>=10&&(r+=s,s="",o=0),s+=String.fromCharCode(n),++o;return r+=s,r},E.hexToBytes=function(e){var t="",a=0;for(e.length&!0&&(a=1,t+=String.fromCharCode(parseInt(e[0],16)));a<e.length;a+=2)t+=String.fromCharCode(parseInt(e.substr(a,2),16));return t},E.bytesToHex=function(e){return E.createBuffer(e).toHex()},E.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var mt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Ct=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],Ua="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";E.encode64=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.length;)n=e.charCodeAt(o++),s=e.charCodeAt(o++),i=e.charCodeAt(o++),a+=mt.charAt(n>>2),a+=mt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=mt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":mt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
`,a=a.substr(t));return r+=a,r},E.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t="",a,r,n,s,i=0;i<e.length;)a=Ct[e.charCodeAt(i++)-43],r=Ct[e.charCodeAt(i++)-43],n=Ct[e.charCodeAt(i++)-43],s=Ct[e.charCodeAt(i++)-43],t+=String.fromCharCode(a<<2|r>>4),n!==64&&(t+=String.fromCharCode((r&15)<<4|n>>2),s!==64&&(t+=String.fromCharCode((n&3)<<6|s)));return t},E.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},E.decodeUtf8=function(e){return decodeURIComponent(escape(e))},E.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:ka.encode,decode:ka.decode}},E.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},E.binary.raw.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r},E.binary.hex.encode=E.bytesToHex,E.binary.hex.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/2))),a=a||0;var n=0,s=a;for(e.length&1&&(n=1,r[s++]=parseInt(e[0],16));n<e.length;n+=2)r[s++]=parseInt(e.substr(n,2),16);return t?s-a:r},E.binary.base64.encode=function(e,t){for(var a="",r="",n,s,i,o=0;o<e.byteLength;)n=e[o++],s=e[o++],i=e[o++],a+=mt.charAt(n>>2),a+=mt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=mt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":mt.charAt(i&63)),t&&a.length>t&&(r+=a.substr(0,t)+`\r
`,a=a.substr(t));return r+=a,r},E.binary.base64.decode=function(e,t,a){var r=t;r||(r=new Uint8Array(Math.ceil(e.length/4)*3)),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,""),a=a||0;for(var n,s,i,o,u=0,l=a;u<e.length;)n=Ct[e.charCodeAt(u++)-43],s=Ct[e.charCodeAt(u++)-43],i=Ct[e.charCodeAt(u++)-43],o=Ct[e.charCodeAt(u++)-43],r[l++]=n<<2|s>>4,i!==64&&(r[l++]=(s&15)<<4|i>>2,o!==64&&(r[l++]=(i&3)<<6|o));return t?l-a:r.subarray(0,l)},E.binary.base58.encode=function(e,t){return E.binary.baseN.encode(e,Ua,t)},E.binary.base58.decode=function(e,t){return E.binary.baseN.decode(e,Ua,t)},E.text={utf8:{},utf16:{}},E.text.utf8.encode=function(e,t,a){e=E.encodeUtf8(e);var r=t;r||(r=new Uint8Array(e.length)),a=a||0;for(var n=a,s=0;s<e.length;++s)r[n++]=e.charCodeAt(s);return t?n-a:r},E.text.utf8.decode=function(e){return E.decodeUtf8(String.fromCharCode.apply(null,e))},E.text.utf16.encode=function(e,t,a){var r=t;r||(r=new Uint8Array(e.length*2));var n=new Uint16Array(r.buffer);a=a||0;for(var s=a,i=a,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o),s+=2;return t?s-a:r},E.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},E.deflate=function(e,t,a){if(t=E.decode64(e.deflate(E.encode64(t)).rval),a){var r=2,n=t.charCodeAt(1);n&32&&(r=6),t=t.substring(r,t.length-4)}return t},E.inflate=function(e,t,a){var r=e.inflate(E.encode64(t)).rval;return r===null?null:E.decode64(r)};var Mr=function(e,t,a){if(!e)throw new Error("WebStorage not available.");var r;if(a===null?r=e.removeItem(t):(a=E.encode64(JSON.stringify(a)),r=e.setItem(t,a)),typeof r<"u"&&r.rval!==!0){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}},Hr=function(e,t){if(!e)throw new Error("WebStorage not available.");var a=e.getItem(t);if(e.init)if(a.rval===null){if(a.error){var r=new Error(a.error.message);throw r.id=a.error.id,r.name=a.error.name,r}a=null}else a=a.rval;return a!==null&&(a=JSON.parse(E.decode64(a))),a},li=function(e,t,a,r){var n=Hr(e,t);n===null&&(n={}),n[a]=r,Mr(e,t,n)},ui=function(e,t,a){var r=Hr(e,t);return r!==null&&(r=a in r?r[a]:null),r},ci=function(e,t,a){var r=Hr(e,t);if(r!==null&&a in r){delete r[a];var n=!0;for(var s in r){n=!1;break}n&&(r=null),Mr(e,t,r)}},fi=function(e,t){Mr(e,t,null)},fr=function(e,t,a){var r=null;typeof a>"u"&&(a=["web","flash"]);var n,s=!1,i=null;for(var o in a){n=a[o];try{if(n==="flash"||n==="both"){if(t[0]===null)throw new Error("Flash local storage not available.");r=e.apply(this,t),s=n==="flash"}(n==="web"||n==="both")&&(t[0]=localStorage,r=e.apply(this,t),s=!0)}catch(u){i=u}if(s)break}if(!s)throw i;return r};E.setItem=function(e,t,a,r,n){fr(li,arguments,n)},E.getItem=function(e,t,a,r){return fr(ui,arguments,r)},E.removeItem=function(e,t,a,r){fr(ci,arguments,r)},E.clearItems=function(e,t,a){fr(fi,arguments,a)},E.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},E.format=function(e){for(var t=/%./g,a,r,n=0,s=[],i=0;a=t.exec(e);){r=e.substring(i,t.lastIndex-2),r.length>0&&s.push(r),i=t.lastIndex;var o=a[0][1];switch(o){case"s":case"o":n<arguments.length?s.push(arguments[n+++1]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+o+"?>")}}return s.push(e.substring(i)),s.join("")},E.formatNumber=function(e,t,a,r){var n=e,s=isNaN(t=Math.abs(t))?2:t,i=a===void 0?",":a,o=r===void 0?".":r,u=n<0?"-":"",l=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",c=l.length>3?l.length%3:0;return u+(c?l.substr(0,c)+o:"")+l.substr(c).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?i+Math.abs(n-l).toFixed(s).slice(2):"")},E.formatSize=function(e){return e>=1073741824?e=E.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?e=E.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?e=E.formatNumber(e/1024,0)+" KiB":e=E.formatNumber(e,0)+" bytes",e},E.bytesFromIP=function(e){return e.indexOf(".")!==-1?E.bytesFromIPv4(e):e.indexOf(":")!==-1?E.bytesFromIPv6(e):null},E.bytesFromIPv4=function(e){if(e=e.split("."),e.length!==4)return null;for(var t=E.createBuffer(),a=0;a<e.length;++a){var r=parseInt(e[a],10);if(isNaN(r))return null;t.putByte(r)}return t.getBytes()},E.bytesFromIPv6=function(e){var t=0;e=e.split(":").filter(function(i){return i.length===0&&++t,!0});for(var a=(8-e.length+t)*2,r=E.createBuffer(),n=0;n<8;++n){if(!e[n]||e[n].length===0){r.fillWithByte(0,a),a=0;continue}var s=E.hexToBytes(e[n]);s.length<2&&r.putByte(0),r.putBytes(s)}return r.getBytes()},E.bytesToIP=function(e){return e.length===4?E.bytesToIPv4(e):e.length===16?E.bytesToIPv6(e):null},E.bytesToIPv4=function(e){if(e.length!==4)return null;for(var t=[],a=0;a<e.length;++a)t.push(e.charCodeAt(a));return t.join(".")},E.bytesToIPv6=function(e){if(e.length!==16)return null;for(var t=[],a=[],r=0,n=0;n<e.length;n+=2){for(var s=E.bytesToHex(e[n]+e[n+1]);s[0]==="0"&&s!=="0";)s=s.substr(1);if(s==="0"){var i=a[a.length-1],o=t.length;!i||o!==i.end+1?a.push({start:o,end:o}):(i.end=o,i.end-i.start>a[r].end-a[r].start&&(r=a.length-1))}t.push(s)}if(a.length>0){var u=a[r];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),u.start===0&&t.unshift(""),u.end===7&&t.push(""))}return t.join(":")},E.estimateCores=function(e,t){if(typeof e=="function"&&(t=e,e={}),e=e||{},"cores"in E&&!e.update)return t(null,E.cores);if(typeof navigator<"u"&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return E.cores=navigator.hardwareConcurrency,t(null,E.cores);if(typeof Worker>"u")return E.cores=1,t(null,E.cores);if(typeof Blob>"u")return E.cores=2,t(null,E.cores);var a=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(i){var o=Date.now(),u=o+4;self.postMessage({st:o,et:u})})}.toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(i,o,u){if(o===0){var l=Math.floor(i.reduce(function(c,f){return c+f},0)/i.length);return E.cores=Math.max(1,l),URL.revokeObjectURL(a),t(null,E.cores)}n(u,function(c,f){i.push(s(u,f)),r(i,o-1,u)})}function n(i,o){for(var u=[],l=[],c=0;c<i;++c){var f=new Worker(a);f.addEventListener("message",function(g){if(l.push(g.data),l.length===i){for(var m=0;m<i;++m)u[m].terminate();o(null,l)}}),u.push(f)}for(var c=0;c<i;++c)u[c].postMessage(c)}function s(i,o){for(var u=[],l=0;l<i;++l)for(var c=o[l],f=u[l]=[],g=0;g<i;++g)if(l!==g){var m=o[g];(c.st>m.st&&c.st<m.et||m.st>c.st&&m.st<c.et)&&f.push(g)}return u.reduce(function(y,x){return Math.max(y,x.length)},0)}};var Te=j;Te.cipher=Te.cipher||{},Te.cipher.algorithms=Te.cipher.algorithms||{},Te.cipher.createCipher=function(e,t){var a=e;if(typeof a=="string"&&(a=Te.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new Te.cipher.BlockCipher({algorithm:a,key:t,decrypt:!1})},Te.cipher.createDecipher=function(e,t){var a=e;if(typeof a=="string"&&(a=Te.cipher.getAlgorithm(a),a&&(a=a())),!a)throw new Error("Unsupported algorithm: "+e);return new Te.cipher.BlockCipher({algorithm:a,key:t,decrypt:!0})},Te.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),Te.cipher.algorithms[e]=t},Te.cipher.getAlgorithm=function(e){return e=e.toUpperCase(),e in Te.cipher.algorithms?Te.cipher.algorithms[e]:null};var Gr=Te.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};Gr.prototype.start=function(e){e=e||{};var t={};for(var a in e)t[a]=e[a];t.decrypt=this._decrypt,this._finish=!1,this._input=Te.util.createBuffer(),this.output=e.output||Te.util.createBuffer(),this.mode.start(t)},Gr.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},Gr.prototype.finish=function(e){e&&(this.mode.name==="ECB"||this.mode.name==="CBC")&&(this.mode.pad=function(a){return e(this.blockSize,a,!1)},this.mode.unpad=function(a){return e(this.blockSize,a,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t)||(this._finish=!0,this.update(),this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))||this.mode.afterFinish&&!this.mode.afterFinish(this.output,t))};var Ie=j;Ie.cipher=Ie.cipher||{};var Z=Ie.cipher.modes=Ie.cipher.modes||{};Z.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},Z.ecb.prototype.start=function(e){},Z.ecb.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},Z.ecb.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r])},Z.ecb.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0},Z.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},Z.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},Z.cbc.prototype.start=function(e){if(e.iv===null){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else if("iv"in e)this._iv=dr(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},Z.cbc.prototype.encrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=this._prev[r]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._outBlock[r]);this._prev=this._outBlock},Z.cbc.prototype.decrypt=function(e,t,a){if(e.length()<this.blockSize&&!(a&&e.length()>0))return!0;for(var r=0;r<this._ints;++r)this._inBlock[r]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(var r=0;r<this._ints;++r)t.putInt32(this._prev[r]^this._outBlock[r]);this._prev=this._inBlock.slice(0)},Z.cbc.prototype.pad=function(e,t){var a=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(a,a),!0},Z.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},Z.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=Ie.util.createBuffer(),this._partialBytes=0},Z.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=dr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Z.cfb.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32()^this._outBlock[n],t.putInt32(this._inBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32()^this._outBlock[n],this._partialOutput.putInt32(this._partialBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},Z.cfb.prototype.decrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32(),t.putInt32(this._inBlock[n]^this._outBlock[n]);return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialBlock[n]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[n]^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._partialBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},Z.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Ie.util.createBuffer(),this._partialBytes=0},Z.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=dr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Z.ofb.prototype.encrypt=function(e,t,a){var r=e.length();if(e.length()===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]),this._inBlock[n]=this._outBlock[n];return}var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0)e.read-=this.blockSize;else for(var n=0;n<this._ints;++n)this._inBlock[n]=this._outBlock[n];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0},Z.ofb.prototype.decrypt=Z.ofb.prototype.encrypt,Z.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=Ie.util.createBuffer(),this._partialBytes=0},Z.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=dr(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Z.ctr.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize)for(var n=0;n<this._ints;++n)t.putInt32(e.getInt32()^this._outBlock[n]);else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}hr(this._inBlock)},Z.ctr.prototype.decrypt=Z.ctr.prototype.encrypt,Z.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=Ie.util.createBuffer(),this._partialBytes=0,this._R=3774873600},Z.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=Ie.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=Ie.util.createBuffer(e.additionalData):a=Ie.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=Ie.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var r=t.length();if(r===12)this._j0=[t.getInt32(),t.getInt32(),t.getInt32(),1];else{for(this._j0=[0,0,0,0];t.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(qr(r*8)))}this._inBlock=this._j0.slice(0),hr(this._inBlock),this._partialBytes=0,a=Ie.util.createBuffer(a),this._aDataLength=qr(a.length()*8);var n=a.length()%this.blockSize;for(n&&a.fillWithByte(0,this.blockSize-n),this._s=[0,0,0,0];a.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()])},Z.gcm.prototype.encrypt=function(e,t,a){var r=e.length();if(r===0)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),this._partialBytes===0&&r>=this.blockSize){for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-r)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n<this._ints;++n)this._partialOutput.putInt32(e.getInt32()^this._outBlock[n]);if(s<=0||a){if(a){var i=r%this.blockSize;this._cipherLength+=i,this._partialOutput.truncate(this.blockSize-i)}else this._cipherLength+=this.blockSize;for(var n=0;n<this._ints;++n)this._outBlock[n]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!a)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(r-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),hr(this._inBlock)},Z.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r<this.blockSize&&!(a&&r>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),hr(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]^this._hashBlock[n]);r<this.blockSize?this._cipherLength+=r%this.blockSize:this._cipherLength+=this.blockSize},Z.gcm.prototype.afterFinish=function(e,t){var a=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=Ie.util.createBuffer();var r=this._aDataLength.concat(qr(this._cipherLength*8));this._s=this.ghash(this._hashSubkey,this._s,r);var n=[];this.cipher.encrypt(this._j0,n);for(var s=0;s<this._ints;++s)this.tag.putInt32(this._s[s]^n[s]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(a=!1),a},Z.gcm.prototype.multiply=function(e,t){for(var a=[0,0,0,0],r=t.slice(0),n=0;n<128;++n){var s=e[n/32|0]&1<<31-n%32;s&&(a[0]^=r[0],a[1]^=r[1],a[2]^=r[2],a[3]^=r[3]),this.pow(r,r)}return a},Z.gcm.prototype.pow=function(e,t){for(var a=e[3]&1,r=3;r>0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)},Z.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],a=0;a<32;++a){var r=a/8|0,n=e[r]>>>(7-a%8)*4&15,s=this._m[a][n];t[0]^=s[0],t[1]^=s[1],t[2]^=s[2],t[3]^=s[3]}return t},Z.gcm.prototype.ghash=function(e,t,a){return t[0]^=a[0],t[1]^=a[1],t[2]^=a[2],t[3]^=a[3],this.tableMultiply(t)},Z.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,s=new Array(n),i=0;i<n;++i){var o=[0,0,0,0],u=i/r|0,l=(r-1-i%r)*t;o[u]=1<<t-1<<l,s[i]=this.generateSubHashTable(this.multiply(o,e),t)}return s},Z.gcm.prototype.generateSubHashTable=function(e,t){var a=1<<t,r=a>>>1,n=new Array(a);n[r]=e.slice(0);for(var s=r>>>1;s>0;)this.pow(n[2*s],n[s]=[]),s>>=1;for(s=2;s<r;){for(var i=1;i<s;++i){var o=n[s],u=n[i];n[s+i]=[o[0]^u[0],o[1]^u[1],o[2]^u[2],o[3]^u[3]]}s*=2}for(n[0]=[0,0,0,0],s=r+1;s<a;++s){var l=n[s^r];n[s]=[e[0]^l[0],e[1]^l[1],e[2]^l[2],e[3]^l[3]]}return n};function dr(e,t){if(typeof e=="string"&&(e=Ie.util.createBuffer(e)),Ie.util.isArray(e)&&e.length>4){var a=e;e=Ie.util.createBuffer();for(var r=0;r<a.length;++r)e.putByte(a[r])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!Ie.util.isArray(e)){for(var n=[],s=t/4,r=0;r<s;++r)n.push(e.getInt32());e=n}return e}function hr(e){e[e.length-1]=e[e.length-1]+1&4294967295}function qr(e){return[e/4294967296|0,e&4294967295]}var fe=j;fe.aes=fe.aes||{},fe.aes.startEncrypting=function(e,t,a,r){var n=pr({key:e,output:a,decrypt:!1,mode:r});return n.start(t),n},fe.aes.createEncryptionCipher=function(e,t){return pr({key:e,output:null,decrypt:!1,mode:t})},fe.aes.startDecrypting=function(e,t,a,r){var n=pr({key:e,output:a,decrypt:!0,mode:r});return n.start(t),n},fe.aes.createDecryptionCipher=function(e,t){return pr({key:e,output:null,decrypt:!0,mode:t})},fe.aes.Algorithm=function(e,t){zr||Pa();var a=this;a.name=e,a.mode=new t({blockSize:16,cipher:{encrypt:function(r,n){return Wr(a._w,r,n,!1)},decrypt:function(r,n){return Wr(a._w,r,n,!0)}}}),a._init=!1},fe.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t=e.key,a;if(typeof t=="string"&&(t.length===16||t.length===24||t.length===32))t=fe.util.createBuffer(t);else if(fe.util.isArray(t)&&(t.length===16||t.length===24||t.length===32)){a=t,t=fe.util.createBuffer();for(var r=0;r<a.length;++r)t.putByte(a[r])}if(!fe.util.isArray(t)){a=t,t=[];var n=a.length();if(n===16||n===24||n===32){n=n>>>2;for(var r=0;r<n;++r)t.push(a.getInt32())}}if(!fe.util.isArray(t)||!(t.length===4||t.length===6||t.length===8))throw new Error("Invalid key parameter.");var s=this.mode.name,i=["CFB","OFB","CTR","GCM"].indexOf(s)!==-1;this._w=Va(t,e.decrypt&&!i),this._init=!0}},fe.aes._expandKey=function(e,t){return zr||Pa(),Va(e,t)},fe.aes._updateBlock=Wr,Vt("AES-ECB",fe.cipher.modes.ecb),Vt("AES-CBC",fe.cipher.modes.cbc),Vt("AES-CFB",fe.cipher.modes.cfb),Vt("AES-OFB",fe.cipher.modes.ofb),Vt("AES-CTR",fe.cipher.modes.ctr),Vt("AES-GCM",fe.cipher.modes.gcm);function Vt(e,t){var a=function(){return new fe.aes.Algorithm(e,t)};fe.cipher.registerAlgorithm(e,a)}var zr=!1,Ot=4,Ge,Qr,Da,_t,nt;function Pa(){zr=!0,Da=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;Ge=new Array(256),Qr=new Array(256),_t=new Array(4),nt=new Array(4);for(var t=0;t<4;++t)_t[t]=new Array(256),nt[t]=new Array(256);for(var a=0,r=0,n,s,i,o,u,l,c,t=0;t<256;++t){o=r^r<<1^r<<2^r<<3^r<<4,o=o>>8^o&255^99,Ge[a]=o,Qr[o]=a,u=e[o],n=e[a],s=e[n],i=e[s],l=u<<24^o<<16^o<<8^(o^u),c=(n^s^i)<<24^(a^i)<<16^(a^s^i)<<8^(a^n^i);for(var f=0;f<4;++f)_t[f][a]=l,nt[f][o]=c,l=l<<24|l>>>8,c=c<<24|c>>>8;a===0?a=r=1:(a=n^e[e[e[n^i]]],r^=e[e[r]])}}function Va(e,t){for(var a=e.slice(0),r,n=1,s=a.length,i=s+6+1,o=Ot*i,u=s;u<o;++u)r=a[u-1],u%s===0?(r=Ge[r>>>16&255]<<24^Ge[r>>>8&255]<<16^Ge[r&255]<<8^Ge[r>>>24]^Da[n]<<24,n++):s>6&&u%s===4&&(r=Ge[r>>>24]<<24^Ge[r>>>16&255]<<16^Ge[r>>>8&255]<<8^Ge[r&255]),a[u]=a[u-s]^r;if(t){var l,c=nt[0],f=nt[1],g=nt[2],m=nt[3],y=a.slice(0);o=a.length;for(var u=0,x=o-Ot;u<o;u+=Ot,x-=Ot)if(u===0||u===o-Ot)y[u]=a[x],y[u+1]=a[x+3],y[u+2]=a[x+2],y[u+3]=a[x+1];else for(var S=0;S<Ot;++S)l=a[x+S],y[u+(3&-S)]=c[Ge[l>>>24]]^f[Ge[l>>>16&255]]^g[Ge[l>>>8&255]]^m[Ge[l&255]];a=y}return a}function Wr(e,t,a,r){var n=e.length/4-1,s,i,o,u,l;r?(s=nt[0],i=nt[1],o=nt[2],u=nt[3],l=Qr):(s=_t[0],i=_t[1],o=_t[2],u=_t[3],l=Ge);var c,f,g,m,y,x,S;c=t[0]^e[0],f=t[r?3:1]^e[1],g=t[2]^e[2],m=t[r?1:3]^e[3];for(var I=3,B=1;B<n;++B)y=s[c>>>24]^i[f>>>16&255]^o[g>>>8&255]^u[m&255]^e[++I],x=s[f>>>24]^i[g>>>16&255]^o[m>>>8&255]^u[c&255]^e[++I],S=s[g>>>24]^i[m>>>16&255]^o[c>>>8&255]^u[f&255]^e[++I],m=s[m>>>24]^i[c>>>16&255]^o[f>>>8&255]^u[g&255]^e[++I],c=y,f=x,g=S;a[0]=l[c>>>24]<<24^l[f>>>16&255]<<16^l[g>>>8&255]<<8^l[m&255]^e[++I],a[r?3:1]=l[f>>>24]<<24^l[g>>>16&255]<<16^l[m>>>8&255]<<8^l[c&255]^e[++I],a[2]=l[g>>>24]<<24^l[m>>>16&255]<<16^l[c>>>8&255]<<8^l[f&255]^e[++I],a[r?1:3]=l[m>>>24]<<24^l[c>>>16&255]<<16^l[f>>>8&255]<<8^l[g&255]^e[++I]}function pr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=fe.cipher.createDecipher(a,e.key):r=fe.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof fe.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}var er=j;er.pki=er.pki||{};var $r=er.pki.oids=er.oids=er.oids||{};function N(e,t){$r[e]=t,$r[t]=e}function oe(e,t){$r[e]=t}N("1.2.840.113549.1.1.1","rsaEncryption"),N("1.2.840.113549.1.1.4","md5WithRSAEncryption"),N("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),N("1.2.840.113549.1.1.7","RSAES-OAEP"),N("1.2.840.113549.1.1.8","mgf1"),N("1.2.840.113549.1.1.9","pSpecified"),N("1.2.840.113549.1.1.10","RSASSA-PSS"),N("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),N("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),N("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),N("1.3.101.112","EdDSA25519"),N("1.2.840.10040.4.3","dsa-with-sha1"),N("1.3.14.3.2.7","desCBC"),N("1.3.14.3.2.26","sha1"),N("1.3.14.3.2.29","sha1WithRSASignature"),N("2.16.840.1.101.3.4.2.1","sha256"),N("2.16.840.1.101.3.4.2.2","sha384"),N("2.16.840.1.101.3.4.2.3","sha512"),N("2.16.840.1.101.3.4.2.4","sha224"),N("2.16.840.1.101.3.4.2.5","sha512-224"),N("2.16.840.1.101.3.4.2.6","sha512-256"),N("1.2.840.113549.2.2","md2"),N("1.2.840.113549.2.5","md5"),N("1.2.840.113549.1.7.1","data"),N("1.2.840.113549.1.7.2","signedData"),N("1.2.840.113549.1.7.3","envelopedData"),N("1.2.840.113549.1.7.4","signedAndEnvelopedData"),N("1.2.840.113549.1.7.5","digestedData"),N("1.2.840.113549.1.7.6","encryptedData"),N("1.2.840.113549.1.9.1","emailAddress"),N("1.2.840.113549.1.9.2","unstructuredName"),N("1.2.840.113549.1.9.3","contentType"),N("1.2.840.113549.1.9.4","messageDigest"),N("1.2.840.113549.1.9.5","signingTime"),N("1.2.840.113549.1.9.6","counterSignature"),N("1.2.840.113549.1.9.7","challengePassword"),N("1.2.840.113549.1.9.8","unstructuredAddress"),N("1.2.840.113549.1.9.14","extensionRequest"),N("1.2.840.113549.1.9.20","friendlyName"),N("1.2.840.113549.1.9.21","localKeyId"),N("1.2.840.113549.1.9.22.1","x509Certificate"),N("1.2.840.113549.1.12.10.1.1","keyBag"),N("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),N("1.2.840.113549.1.12.10.1.3","certBag"),N("1.2.840.113549.1.12.10.1.4","crlBag"),N("1.2.840.113549.1.12.10.1.5","secretBag"),N("1.2.840.113549.1.12.10.1.6","safeContentsBag"),N("1.2.840.113549.1.5.13","pkcs5PBES2"),N("1.2.840.113549.1.5.12","pkcs5PBKDF2"),N("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),N("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),N("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),N("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),N("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),N("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),N("1.2.840.113549.2.7","hmacWithSHA1"),N("1.2.840.113549.2.8","hmacWithSHA224"),N("1.2.840.113549.2.9","hmacWithSHA256"),N("1.2.840.113549.2.10","hmacWithSHA384"),N("1.2.840.113549.2.11","hmacWithSHA512"),N("1.2.840.113549.3.7","des-EDE3-CBC"),N("2.16.840.1.101.3.4.1.2","aes128-CBC"),N("2.16.840.1.101.3.4.1.22","aes192-CBC"),N("2.16.840.1.101.3.4.1.42","aes256-CBC"),N("2.5.4.3","commonName"),N("2.5.4.4","surname"),N("2.5.4.5","serialNumber"),N("2.5.4.6","countryName"),N("2.5.4.7","localityName"),N("2.5.4.8","stateOrProvinceName"),N("2.5.4.9","streetAddress"),N("2.5.4.10","organizationName"),N("2.5.4.11","organizationalUnitName"),N("2.5.4.12","title"),N("2.5.4.13","description"),N("2.5.4.15","businessCategory"),N("2.5.4.17","postalCode"),N("2.5.4.42","givenName"),N("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),N("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),N("2.16.840.1.113730.1.1","nsCertType"),N("2.16.840.1.113730.1.13","nsComment"),oe("2.5.29.1","authorityKeyIdentifier"),oe("2.5.29.2","keyAttributes"),oe("2.5.29.3","certificatePolicies"),oe("2.5.29.4","keyUsageRestriction"),oe("2.5.29.5","policyMapping"),oe("2.5.29.6","subtreesConstraint"),oe("2.5.29.7","subjectAltName"),oe("2.5.29.8","issuerAltName"),oe("2.5.29.9","subjectDirectoryAttributes"),oe("2.5.29.10","basicConstraints"),oe("2.5.29.11","nameConstraints"),oe("2.5.29.12","policyConstraints"),oe("2.5.29.13","basicConstraints"),N("2.5.29.14","subjectKeyIdentifier"),N("2.5.29.15","keyUsage"),oe("2.5.29.16","privateKeyUsagePeriod"),N("2.5.29.17","subjectAltName"),N("2.5.29.18","issuerAltName"),N("2.5.29.19","basicConstraints"),oe("2.5.29.20","cRLNumber"),oe("2.5.29.21","cRLReason"),oe("2.5.29.22","expirationDate"),oe("2.5.29.23","instructionCode"),oe("2.5.29.24","invalidityDate"),oe("2.5.29.25","cRLDistributionPoints"),oe("2.5.29.26","issuingDistributionPoint"),oe("2.5.29.27","deltaCRLIndicator"),oe("2.5.29.28","issuingDistributionPoint"),oe("2.5.29.29","certificateIssuer"),oe("2.5.29.30","nameConstraints"),N("2.5.29.31","cRLDistributionPoints"),N("2.5.29.32","certificatePolicies"),oe("2.5.29.33","policyMappings"),oe("2.5.29.34","policyConstraints"),N("2.5.29.35","authorityKeyIdentifier"),oe("2.5.29.36","policyConstraints"),N("2.5.29.37","extKeyUsage"),oe("2.5.29.46","freshestCRL"),oe("2.5.29.54","inhibitAnyPolicy"),N("1.3.6.1.4.1.11129.2.4.2","timestampList"),N("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),N("1.3.6.1.5.5.7.3.1","serverAuth"),N("1.3.6.1.5.5.7.3.2","clientAuth"),N("1.3.6.1.5.5.7.3.3","codeSigning"),N("1.3.6.1.5.5.7.3.4","emailProtection"),N("1.3.6.1.5.5.7.3.8","timeStamping");var he=j,P=he.asn1=he.asn1||{};P.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},P.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},P.create=function(e,t,a,r,n){if(he.util.isArray(r)){for(var s=[],i=0;i<r.length;++i)r[i]!==void 0&&s.push(r[i]);r=s}var o={tagClass:e,type:t,constructed:a,composed:a||he.util.isArray(r),value:r};return n&&"bitStringContents"in n&&(o.bitStringContents=n.bitStringContents,o.original=P.copy(o)),o},P.copy=function(e,t){var a;if(he.util.isArray(e)){a=[];for(var r=0;r<e.length;++r)a.push(P.copy(e[r],t));return a}return typeof e=="string"?e:(a={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:P.copy(e.value,t)},t&&!t.excludeBitStringContents&&(a.bitStringContents=e.bitStringContents),a)},P.equals=function(e,t,a){if(he.util.isArray(e)){if(!he.util.isArray(t)||e.length!==t.length)return!1;for(var r=0;r<e.length;++r)if(!P.equals(e[r],t[r]))return!1;return!0}if(typeof e!=typeof t)return!1;if(typeof e=="string")return e===t;var n=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&P.equals(e.value,t.value);return a&&a.includeBitStringContents&&(n=n&&e.bitStringContents===t.bitStringContents),n},P.getBerValueLength=function(e){var t=e.getByte();if(t!==128){var a,r=t&128;return r?a=e.getInt((t&127)<<3):a=t,a}};function tr(e,t,a){if(a>t){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=a,r}}var di=function(e,t){var a=e.getByte();if(t--,a!==128){var r,n=a&128;if(!n)r=a;else{var s=a&127;tr(e,t,s),r=e.getInt(s<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};P.fromDer=function(e,t){t===void 0&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),typeof t=="boolean"&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),typeof e=="string"&&(e=he.util.createBuffer(e));var a=e.length(),r=gr(e,e.length(),0,t);if(t.parseAllBytes&&e.length()!==0){var n=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw n.byteCount=a,n.remaining=e.length(),n}return r};function gr(e,t,a,r){var n;tr(e,t,2);var s=e.getByte();t--;var i=s&192,o=s&31;n=e.length();var u=di(e,t);if(t-=n-e.length(),u!==void 0&&u>t){if(r.strict){var l=new Error("Too few bytes to read ASN.1 value.");throw l.available=e.length(),l.remaining=t,l.requested=u,l}u=t}var c,f,g=(s&32)===32;if(g)if(c=[],u===void 0)for(;;){if(tr(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}n=e.length(),c.push(gr(e,t,a+1,r)),t-=n-e.length()}else for(;u>0;)n=e.length(),c.push(gr(e,u,a+1,r)),t-=n-e.length(),u-=n-e.length();if(c===void 0&&i===P.Class.UNIVERSAL&&o===P.Type.BITSTRING&&(f=e.bytes(u)),c===void 0&&r.decodeBitStrings&&i===P.Class.UNIVERSAL&&o===P.Type.BITSTRING&&u>1){var m=e.read,y=t,x=0;if(o===P.Type.BITSTRING&&(tr(e,t,1),x=e.getByte(),t--),x===0)try{n=e.length();var S={strict:!0,decodeBitStrings:!0},I=gr(e,t,a+1,S),B=n-e.length();t-=B,o==P.Type.BITSTRING&&B++;var b=I.tagClass;B===u&&(b===P.Class.UNIVERSAL||b===P.Class.CONTEXT_SPECIFIC)&&(c=[I])}catch{}c===void 0&&(e.read=m,t=y)}if(c===void 0){if(u===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");u=t}if(o===P.Type.BMPSTRING)for(c="";u>0;u-=2)tr(e,t,2),c+=String.fromCharCode(e.getInt16()),t-=2;else c=e.getBytes(u),t-=u}var D=f===void 0?null:{bitStringContents:f};return P.create(i,o,g,c,D)}P.toDer=function(e){var t=he.util.createBuffer(),a=e.tagClass|e.type,r=he.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=P.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?a|=32:r.putByte(0);for(var s=0;s<e.value.length;++s)e.value[s]!==void 0&&r.putBuffer(P.toDer(e.value[s]))}else if(e.type===P.Type.BMPSTRING)for(var s=0;s<e.value.length;++s)r.putInt16(e.value.charCodeAt(s));else e.type===P.Type.INTEGER&&e.value.length>1&&(e.value.charCodeAt(0)===0&&!(e.value.charCodeAt(1)&128)||e.value.charCodeAt(0)===255&&(e.value.charCodeAt(1)&128)===128)?r.putBytes(e.value.substr(1)):r.putBytes(e.value);if(t.putByte(a),r.length()<=127)t.putByte(r.length()&127);else{var i=r.length(),o="";do o+=String.fromCharCode(i&255),i=i>>>8;while(i>0);t.putByte(o.length|128);for(var s=o.length-1;s>=0;--s)t.putByte(o.charCodeAt(s))}return t.putBuffer(r),t},P.oidToDer=function(e){var t=e.split("."),a=he.util.createBuffer();a.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,s,i,o=2;o<t.length;++o){r=!0,n=[],s=parseInt(t[o],10);do i=s&127,s=s>>>7,r||(i|=128),n.push(i),r=!1;while(s>0);for(var u=n.length-1;u>=0;--u)a.putByte(n[u])}return a},P.derToOid=function(e){var t;typeof e=="string"&&(e=he.util.createBuffer(e));var a=e.getByte();t=Math.floor(a/40)+"."+a%40;for(var r=0;e.length()>0;)a=e.getByte(),r=r<<7,a&128?r+=a&127:(t+="."+(r+a),r=0);return t},P.utcTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,2),10);a=a>=50?1900+a:2e3+a;var r=parseInt(e.substr(2,2),10)-1,n=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),i=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var u=e.charAt(10),l=10;u!=="+"&&u!=="-"&&(o=parseInt(e.substr(10,2),10),l+=2)}if(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,0),l&&(u=e.charAt(l),u==="+"||u==="-")){var c=parseInt(e.substr(l+1,2),10),f=parseInt(e.substr(l+4,2),10),g=c*60+f;g*=6e4,u==="+"?t.setTime(+t-g):t.setTime(+t+g)}return t},P.generalizedTimeToDate=function(e){var t=new Date,a=parseInt(e.substr(0,4),10),r=parseInt(e.substr(4,2),10)-1,n=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),i=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),u=0,l=0,c=!1;e.charAt(e.length-1)==="Z"&&(c=!0);var f=e.length-5,g=e.charAt(f);if(g==="+"||g==="-"){var m=parseInt(e.substr(f+1,2),10),y=parseInt(e.substr(f+4,2),10);l=m*60+y,l*=6e4,g==="+"&&(l*=-1),c=!0}return e.charAt(14)==="."&&(u=parseFloat(e.substr(14),10)*1e3),c?(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,u),t.setTime(+t+l)):(t.setFullYear(a,r,n),t.setHours(s,i,o,u)),t},P.dateToUtcTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push((""+e.getUTCFullYear()).substr(2)),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t},P.dateToGeneralizedTime=function(e){if(typeof e=="string")return e;var t="",a=[];a.push(""+e.getUTCFullYear()),a.push(""+(e.getUTCMonth()+1)),a.push(""+e.getUTCDate()),a.push(""+e.getUTCHours()),a.push(""+e.getUTCMinutes()),a.push(""+e.getUTCSeconds());for(var r=0;r<a.length;++r)a[r].length<2&&(t+="0"),t+=a[r];return t+="Z",t},P.integerToDer=function(e){var t=he.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var a=new Error("Integer too large; max is 32-bits.");throw a.integer=e,a},P.derToInteger=function(e){typeof e=="string"&&(e=he.util.createBuffer(e));var t=e.length()*8;if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},P.validate=function(e,t,a,r){var n=!1;if((e.tagClass===t.tagClass||typeof t.tagClass>"u")&&(e.type===t.type||typeof t.type>"u"))if(e.constructed===t.constructed||typeof t.constructed>"u"){if(n=!0,t.value&&he.util.isArray(t.value))for(var s=0,i=0;n&&i<t.value.length;++i)n=t.value[i].optional||!1,e.value[s]&&(n=P.validate(e.value[s],t.value[i],a,r),n?++s:t.value[i].optional&&(n=!0)),!n&&r&&r.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(n&&a&&(t.capture&&(a[t.capture]=e.value),t.captureAsn1&&(a[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(a[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e))if(e.bitStringContents.length<2)a[t.captureBitStringValue]="";else{var o=e.bitStringContents.charCodeAt(0);if(o!==0)throw new Error("captureBitStringValue only supported for zero unused bits");a[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else r&&r.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');else r&&(e.tagClass!==t.tagClass&&r.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&r.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));return n};var Oa=/[^\\u0000-\\u00ff]/;P.prettyPrint=function(e,t,a){var r="";t=t||0,a=a||2,t>0&&(r+=`
`);for(var n="",s=0;s<t*a;++s)n+=" ";switch(r+=n+"Tag: ",e.tagClass){case P.Class.UNIVERSAL:r+="Universal:";break;case P.Class.APPLICATION:r+="Application:";break;case P.Class.CONTEXT_SPECIFIC:r+="Context-Specific:";break;case P.Class.PRIVATE:r+="Private:";break}if(e.tagClass===P.Class.UNIVERSAL)switch(r+=e.type,e.type){case P.Type.NONE:r+=" (None)";break;case P.Type.BOOLEAN:r+=" (Boolean)";break;case P.Type.INTEGER:r+=" (Integer)";break;case P.Type.BITSTRING:r+=" (Bit string)";break;case P.Type.OCTETSTRING:r+=" (Octet string)";break;case P.Type.NULL:r+=" (Null)";break;case P.Type.OID:r+=" (Object Identifier)";break;case P.Type.ODESC:r+=" (Object Descriptor)";break;case P.Type.EXTERNAL:r+=" (External or Instance of)";break;case P.Type.REAL:r+=" (Real)";break;case P.Type.ENUMERATED:r+=" (Enumerated)";break;case P.Type.EMBEDDED:r+=" (Embedded PDV)";break;case P.Type.UTF8:r+=" (UTF8)";break;case P.Type.ROID:r+=" (Relative Object Identifier)";break;case P.Type.SEQUENCE:r+=" (Sequence)";break;case P.Type.SET:r+=" (Set)";break;case P.Type.PRINTABLESTRING:r+=" (Printable String)";break;case P.Type.IA5String:r+=" (IA5String (ASCII))";break;case P.Type.UTCTIME:r+=" (UTC time)";break;case P.Type.GENERALIZEDTIME:r+=" (Generalized time)";break;case P.Type.BMPSTRING:r+=" (BMP String)";break}else r+=e.type;if(r+=`
`,r+=n+"Constructed: "+e.constructed+`
`,e.composed){for(var i=0,o="",s=0;s<e.value.length;++s)e.value[s]!==void 0&&(i+=1,o+=P.prettyPrint(e.value[s],t+1,a),s+1<e.value.length&&(o+=","));r+=n+"Sub values: "+i+o}else{if(r+=n+"Value: ",e.type===P.Type.OID){var u=P.derToOid(e.value);r+=u,he.pki&&he.pki.oids&&u in he.pki.oids&&(r+=" ("+he.pki.oids[u]+") ")}if(e.type===P.Type.INTEGER)try{r+=P.derToInteger(e.value)}catch{r+="0x"+he.util.bytesToHex(e.value)}else if(e.type===P.Type.BITSTRING){if(e.value.length>1?r+="0x"+he.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var l=e.value.charCodeAt(0);l==1?r+=" (1 unused bit shown)":l>1&&(r+=" ("+l+" unused bits shown)")}}else if(e.type===P.Type.OCTETSTRING)Oa.test(e.value)||(r+="("+e.value+") "),r+="0x"+he.util.bytesToHex(e.value);else if(e.type===P.Type.UTF8)try{r+=he.util.decodeUtf8(e.value)}catch(c){if(c.message==="URI malformed")r+="0x"+he.util.bytesToHex(e.value)+" (malformed UTF8)";else throw c}else e.type===P.Type.PRINTABLESTRING||e.type===P.Type.IA5String?r+=e.value:Oa.test(e.value)?r+="0x"+he.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r};var yr=j;yr.md=yr.md||{},yr.md.algorithms=yr.md.algorithms||{};var pt=j,hi=pt.hmac=pt.hmac||{};hi.create=function(){var e=null,t=null,a=null,r=null,n={};return n.start=function(s,i){if(s!==null)if(typeof s=="string")if(s=s.toLowerCase(),s in pt.md.algorithms)t=pt.md.algorithms[s].create();else throw new Error('Unknown hash algorithm "'+s+'"');else t=s;if(i===null)i=e;else{if(typeof i=="string")i=pt.util.createBuffer(i);else if(pt.util.isArray(i)){var o=i;i=pt.util.createBuffer();for(var u=0;u<o.length;++u)i.putByte(o[u])}var l=i.length();l>t.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),a=pt.util.createBuffer(),r=pt.util.createBuffer(),l=i.length();for(var u=0;u<l;++u){var o=i.at(u);a.putByte(54^o),r.putByte(92^o)}if(l<t.blockLength)for(var o=t.blockLength-l,u=0;u<o;++u)a.putByte(54),r.putByte(92);e=i,a=a.bytes(),r=r.bytes()}t.start(),t.update(a)},n.update=function(s){t.update(s)},n.getMac=function(){var s=t.digest().bytes();return t.start(),t.update(r),t.update(s),t.digest()},n.digest=n.getMac,n};var st=j,Ka=st.md5=st.md5||{};st.md.md5=st.md.algorithms.md5=Ka,Ka.create=function(){Fa||pi();var e=null,t=st.util.createBuffer(),a=new Array(16),r={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=st.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=st.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),Ma(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=st.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Yr.substr(0,r.blockLength-i));for(var o,u=0,l=r.fullMessageLength.length-1;l>=0;--l)o=r.fullMessageLength[l]*8+u,u=o/4294967296>>>0,n.putInt32Le(o>>>0);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ma(c,a,n);var f=st.util.createBuffer();return f.putInt32Le(c.h0),f.putInt32Le(c.h1),f.putInt32Le(c.h2),f.putInt32Le(c.h3),f},r};var Yr=null,vr=null,rr=null,Kt=null,Fa=!1;function pi(){Yr=String.fromCharCode(128),Yr+=st.util.fillString(String.fromCharCode(0),64),vr=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],rr=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],Kt=new Array(64);for(var e=0;e<64;++e)Kt[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);Fa=!0}function Ma(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,c=0;c<16;++c)t[c]=a.getInt32Le(),u=o^s&(i^o),r=n+u+Kt[c]+t[c],l=rr[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<32;++c)u=i^o&(s^i),r=n+u+Kt[c]+t[vr[c]],l=rr[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<48;++c)u=s^i^o,r=n+u+Kt[c]+t[vr[c]],l=rr[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;for(;c<64;++c)u=i^(s|~o),r=n+u+Kt[c]+t[vr[c]],l=rr[c],n=o,o=i,i=s,s+=r<<l|r>>>32-l;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,f-=64}}var mr=j,Ha=mr.pem=mr.pem||{};Ha.encode=function(e,t){t=t||{};var a="-----BEGIN "+e.type+`-----\r
`,r;if(e.procType&&(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]},a+=Cr(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},a+=Cr(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),a+=Cr(r)),e.headers)for(var n=0;n<e.headers.length;++n)a+=Cr(e.headers[n]);return e.procType&&(a+=`\r
`),a+=mr.util.encode64(e.body,t.maxline||64)+`\r
`,a+="-----END "+e.type+`-----\r
`,a},Ha.decode=function(e){for(var t=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,r=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,n=/\r?\n/,s;s=a.exec(e),!!s;){var i=s[1];i==="NEW CERTIFICATE REQUEST"&&(i="CERTIFICATE REQUEST");var o={type:i,procType:null,contentDomain:null,dekInfo:null,headers:[],body:mr.util.decode64(s[3])};if(t.push(o),!!s[2]){for(var u=s[2].split(n),l=0;s&&l<u.length;){for(var c=u[l].replace(/\s+$/,""),f=l+1;f<u.length;++f){var g=u[f];if(!/\s/.test(g[0]))break;c+=g,l=f}if(s=c.match(r),s){for(var m={name:s[1],values:[]},y=s[2].split(","),x=0;x<y.length;++x)m.values.push(gi(y[x]));if(o.procType)if(!o.contentDomain&&m.name==="Content-Domain")o.contentDomain=y[0]||"";else if(!o.dekInfo&&m.name==="DEK-Info"){if(m.values.length===0)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');o.dekInfo={algorithm:y[0],parameters:y[1]||null}}else o.headers.push(m);else{if(m.name!=="Proc-Type")throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(m.values.length!==2)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');o.procType={version:y[0],type:y[1]}}}++l}if(o.procType==="ENCRYPTED"&&!o.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(t.length===0)throw new Error("Invalid PEM formatted message.");return t};function Cr(e){for(var t=e.name+": ",a=[],r=function(u,l){return" "+l},n=0;n<e.values.length;++n)a.push(e.values[n].replace(/^(\S+\r\n)/,r));t+=a.join(",")+`\r
`;for(var s=0,i=-1,n=0;n<t.length;++n,++s)if(s>65&&i!==-1){var o=t[i];o===","?(++i,t=t.substr(0,i)+`\r
 `+t.substr(i)):t=t.substr(0,i)+`\r
`+o+t.substr(i+1),s=n-i-1,i=-1,++n}else(t[n]===" "||t[n]==="	"||t[n]===",")&&(i=n);return t}function gi(e){return e.replace(/^\s+/,"")}var ge=j;ge.des=ge.des||{},ge.des.startEncrypting=function(e,t,a,r){var n=Er({key:e,output:a,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ge.des.createEncryptionCipher=function(e,t){return Er({key:e,output:null,decrypt:!1,mode:t})},ge.des.startDecrypting=function(e,t,a,r){var n=Er({key:e,output:a,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ge.des.createDecryptionCipher=function(e,t){return Er({key:e,output:null,decrypt:!0,mode:t})},ge.des.Algorithm=function(e,t){var a=this;a.name=e,a.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return Ga(a._keys,r,n,!1)},decrypt:function(r,n){return Ga(a._keys,r,n,!0)}}}),a._init=!1},ge.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=ge.util.createBuffer(e.key);if(this.name.indexOf("3DES")===0&&t.length()!==24)throw new Error("Invalid Triple-DES key size: "+t.length()*8);this._keys=Ii(t),this._init=!0}},ot("DES-ECB",ge.cipher.modes.ecb),ot("DES-CBC",ge.cipher.modes.cbc),ot("DES-CFB",ge.cipher.modes.cfb),ot("DES-OFB",ge.cipher.modes.ofb),ot("DES-CTR",ge.cipher.modes.ctr),ot("3DES-ECB",ge.cipher.modes.ecb),ot("3DES-CBC",ge.cipher.modes.cbc),ot("3DES-CFB",ge.cipher.modes.cfb),ot("3DES-OFB",ge.cipher.modes.ofb),ot("3DES-CTR",ge.cipher.modes.ctr);function ot(e,t){var a=function(){return new ge.des.Algorithm(e,t)};ge.cipher.registerAlgorithm(e,a)}var yi=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],vi=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],mi=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],Ci=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],Ei=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],xi=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],Si=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],Ti=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function Ii(e){for(var t=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],a=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],r=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],n=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],i=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],o=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],c=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],f=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],g=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],m=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],y=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],x=e.length()>8?3:1,S=[],I=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],B=0,b,D=0;D<x;D++){var L=e.getInt32(),R=e.getInt32();b=(L>>>4^R)&252645135,R^=b,L^=b<<4,b=(R>>>-16^L)&65535,L^=b,R^=b<<-16,b=(L>>>2^R)&858993459,R^=b,L^=b<<2,b=(R>>>-16^L)&65535,L^=b,R^=b<<-16,b=(L>>>1^R)&1431655765,R^=b,L^=b<<1,b=(R>>>8^L)&16711935,L^=b,R^=b<<8,b=(L>>>1^R)&1431655765,R^=b,L^=b<<1,b=L<<8|R>>>20&240,L=R<<24|R<<8&16711680|R>>>8&65280|R>>>24&240,R=b;for(var q=0;q<I.length;++q){I[q]?(L=L<<2|L>>>26,R=R<<2|R>>>26):(L=L<<1|L>>>27,R=R<<1|R>>>27),L&=-15,R&=-15;var X=t[L>>>28]|a[L>>>24&15]|r[L>>>20&15]|n[L>>>16&15]|s[L>>>12&15]|i[L>>>8&15]|o[L>>>4&15],ie=u[R>>>28]|l[R>>>24&15]|c[R>>>20&15]|f[R>>>16&15]|g[R>>>12&15]|m[R>>>8&15]|y[R>>>4&15];b=(ie>>>16^X)&65535,S[B++]=X^b,S[B++]=ie^b<<16}}return S}function Ga(e,t,a,r){var n=e.length===32?3:9,s;n===3?s=r?[30,-2,-2]:[0,32,2]:s=r?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var i,o=t[0],u=t[1];i=(o>>>4^u)&252645135,u^=i,o^=i<<4,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,o=o<<1|o>>>31,u=u<<1|u>>>31;for(var l=0;l<n;l+=3){for(var c=s[l+1],f=s[l+2],g=s[l];g!=c;g+=f){var m=u^e[g],y=(u>>>4|u<<28)^e[g+1];i=o,o=u,u=i^(vi[m>>>24&63]|Ci[m>>>16&63]|xi[m>>>8&63]|Ti[m&63]|yi[y>>>24&63]|mi[y>>>16&63]|Ei[y>>>8&63]|Si[y&63])}i=o,o=u,u=i}o=o>>>1|o<<31,u=u>>>1|u<<31,i=(o>>>1^u)&1431655765,u^=i,o^=i<<1,i=(u>>>8^o)&16711935,o^=i,u^=i<<8,i=(u>>>2^o)&858993459,o^=i,u^=i<<2,i=(o>>>16^u)&65535,u^=i,o^=i<<16,i=(o>>>4^u)&252645135,u^=i,o^=i<<4,a[0]=o,a[1]=u}function Er(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="DES-"+t,r;e.decrypt?r=ge.cipher.createDecipher(a,e.key):r=ge.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof ge.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}const jr=ai(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var qe=j,Ai=qe.pkcs5=qe.pkcs5||{},gt;qe.util.isNodejs&&!qe.options.usePureJavaScript&&(gt=jr),qe.pbkdf2=Ai.pbkdf2=function(e,t,a,r,n,s){if(typeof n=="function"&&(s=n,n=null),qe.util.isNodejs&&!qe.options.usePureJavaScript&&gt.pbkdf2&&(n===null||typeof n!="object")&&(gt.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?gt.pbkdf2Sync.length===4?gt.pbkdf2(e,t,a,r,function(b,D){if(b)return s(b);s(null,D.toString("binary"))}):gt.pbkdf2(e,t,a,r,n,function(b,D){if(b)return s(b);s(null,D.toString("binary"))}):gt.pbkdf2Sync.length===4?gt.pbkdf2Sync(e,t,a,r).toString("binary"):gt.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in qe.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=qe.md[n].create()}var i=n.digestLength;if(r>4294967295*i){var o=new Error("Derived key is too long.");if(s)return s(o);throw o}var u=Math.ceil(r/i),l=r-(u-1)*i,c=qe.hmac.create();c.start(n,e);var f="",g,m,y;if(!s){for(var x=1;x<=u;++x){c.start(null,null),c.update(t),c.update(qe.util.int32ToBytes(x)),g=y=c.digest().getBytes();for(var S=2;S<=a;++S)c.start(null,null),c.update(y),m=c.digest().getBytes(),g=qe.util.xorBytes(g,m,i),y=m;f+=x<u?g:g.substr(0,l)}return f}var x=1,S;function I(){if(x>u)return s(null,f);c.start(null,null),c.update(t),c.update(qe.util.int32ToBytes(x)),g=y=c.digest().getBytes(),S=2,B()}function B(){if(S<=a)return c.start(null,null),c.update(y),m=c.digest().getBytes(),g=qe.util.xorBytes(g,m,i),y=m,++S,qe.util.setImmediate(B);f+=x<u?g:g.substr(0,l),++x,I()}I()};var lt=j,qa=lt.sha256=lt.sha256||{};lt.md.sha256=lt.md.algorithms.sha256=qa,qa.create=function(){za||bi();var e=null,t=lt.util.createBuffer(),a=new Array(64),r={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=lt.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=lt.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),Wa(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=lt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Xr.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};Wa(f,a,n);var g=lt.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g.putInt32(f.h5),g.putInt32(f.h6),g.putInt32(f.h7),g},r};var Xr=null,za=!1,Qa=null;function bi(){Xr=String.fromCharCode(128),Xr+=lt.util.fillString(String.fromCharCode(0),64),Qa=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],za=!0}function Wa(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,m,y,x,S,I,B=a.length();B>=64;){for(l=0;l<16;++l)t[l]=a.getInt32();for(;l<64;++l)r=t[l-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[l-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[l]=r+t[l-7]+n+t[l-16]|0;for(c=e.h0,f=e.h1,g=e.h2,m=e.h3,y=e.h4,x=e.h5,S=e.h6,I=e.h7,l=0;l<64;++l)i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=S^y&(x^S),s=(c>>>2|c<<30)^(c>>>13|c<<19)^(c>>>22|c<<10),u=c&f|g&(c^f),r=I+i+o+Qa[l]+t[l],n=s+u,I=S,S=x,x=y,y=m+r>>>0,m=g,g=f,f=c,c=r+n>>>0;e.h0=e.h0+c|0,e.h1=e.h1+f|0,e.h2=e.h2+g|0,e.h3=e.h3+m|0,e.h4=e.h4+y|0,e.h5=e.h5+x|0,e.h6=e.h6+S|0,e.h7=e.h7+I|0,B-=64}}var ut=j,xr=null;ut.util.isNodejs&&!ut.options.usePureJavaScript&&!process.versions["node-webkit"]&&(xr=jr);var Bi=ut.prng=ut.prng||{};Bi.create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},a=e.md,r=new Array(32),n=0;n<32;++n)r[n]=a.create();t.pools=r,t.pool=0,t.generate=function(l,c){if(!c)return t.generateSync(l);var f=t.plugin.cipher,g=t.plugin.increment,m=t.plugin.formatKey,y=t.plugin.formatSeed,x=ut.util.createBuffer();t.key=null,S();function S(I){if(I)return c(I);if(x.length()>=l)return c(null,x.getBytes(l));if(t.generated>1048575&&(t.key=null),t.key===null)return ut.util.nextTick(function(){s(S)});var B=f(t.key,t.seed);t.generated+=B.length,x.putBytes(B),t.key=m(f(t.key,g(t.seed))),t.seed=y(f(t.key,t.seed)),ut.util.setImmediate(S)}},t.generateSync=function(l){var c=t.plugin.cipher,f=t.plugin.increment,g=t.plugin.formatKey,m=t.plugin.formatSeed;t.key=null;for(var y=ut.util.createBuffer();y.length()<l;){t.generated>1048575&&(t.key=null),t.key===null&&i();var x=c(t.key,t.seed);t.generated+=x.length,y.putBytes(x),t.key=g(c(t.key,f(t.seed))),t.seed=m(c(t.key,t.seed))}return y.getBytes(l)};function s(l){if(t.pools[0].messageLength>=32)return o(),l();var c=32-t.pools[0].messageLength<<5;t.seedFile(c,function(f,g){if(f)return l(f);t.collect(g),o(),l()})}function i(){if(t.pools[0].messageLength>=32)return o();var l=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(l)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var l=t.plugin.md.create();l.update(t.keyBytes);for(var c=1,f=0;f<32;++f)t.reseeds%c===0&&(l.update(t.pools[f].digest().getBytes()),t.pools[f].start()),c=c<<1;t.keyBytes=l.digest().getBytes(),l.start(),l.update(t.keyBytes);var g=l.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(g),t.generated=0}function u(l){var c=null,f=ut.util.globalScope,g=f.crypto||f.msCrypto;g&&g.getRandomValues&&(c=function(L){return g.getRandomValues(L)});var m=ut.util.createBuffer();if(c)for(;m.length()<l;){var y=Math.max(1,Math.min(l-m.length(),65536)/4),x=new Uint32Array(Math.floor(y));try{c(x);for(var S=0;S<x.length;++S)m.putInt32(x[S])}catch(L){if(!(typeof QuotaExceededError<"u"&&L instanceof QuotaExceededError))throw L}}if(m.length()<l)for(var I,B,b,D=Math.floor(Math.random()*65536);m.length()<l;){B=16807*(D&65535),I=16807*(D>>16),B+=(I&32767)<<16,B+=I>>15,B=(B&2147483647)+(B>>31),D=B&4294967295;for(var S=0;S<3;++S)b=D>>>(S<<3),b^=Math.floor(Math.random()*256),m.putByte(b&255)}return m.getBytes(l)}return xr?(t.seedFile=function(l,c){xr.randomBytes(l,function(f,g){if(f)return c(f);c(null,g.toString())})},t.seedFileSync=function(l){return xr.randomBytes(l).toString()}):(t.seedFile=function(l,c){try{c(null,u(l))}catch(f){c(f)}},t.seedFileSync=u),t.collect=function(l){for(var c=l.length,f=0;f<c;++f)t.pools[t.pool].update(l.substr(f,1)),t.pool=t.pool===31?0:t.pool+1},t.collectInt=function(l,c){for(var f="",g=0;g<c;g+=8)f+=String.fromCharCode(l>>g&255);t.collect(f)},t.registerWorker=function(l){if(l===self)t.seedFile=function(f,g){function m(y){var x=y.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",m),g(x.forge.prng.err,x.forge.prng.bytes))}self.addEventListener("message",m),self.postMessage({forge:{prng:{needed:f}}})};else{var c=function(f){var g=f.data;g.forge&&g.forge.prng&&t.seedFile(g.forge.prng.needed,function(m,y){l.postMessage({forge:{prng:{err:m,bytes:y}}})})};l.addEventListener("message",c)}},t};var Ae=j;(function(){if(Ae.random&&Ae.random.getBytes){Ae.random;return}(function(e){var t={},a=new Array(4),r=Ae.util.createBuffer();t.formatKey=function(f){var g=Ae.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),Ae.aes._expandKey(f,!1)},t.formatSeed=function(f){var g=Ae.util.createBuffer(f);return f=new Array(4),f[0]=g.getInt32(),f[1]=g.getInt32(),f[2]=g.getInt32(),f[3]=g.getInt32(),f},t.cipher=function(f,g){return Ae.aes._updateBlock(f,g,a,!1),r.putInt32(a[0]),r.putInt32(a[1]),r.putInt32(a[2]),r.putInt32(a[3]),r.getBytes()},t.increment=function(f){return++f[3],f},t.md=Ae.md.sha256;function n(){var f=Ae.prng.create(t);return f.getBytes=function(g,m){return f.generate(g,m)},f.getBytesSync=function(g){return f.generate(g)},f}var s=n(),i=null,o=Ae.util.globalScope,u=o.crypto||o.msCrypto;if(u&&u.getRandomValues&&(i=function(f){return u.getRandomValues(f)}),Ae.options.usePureJavaScript||!Ae.util.isNodejs&&!i){if(s.collectInt(+new Date,32),typeof navigator<"u"){var l="";for(var c in navigator)try{typeof navigator[c]=="string"&&(l+=navigator[c])}catch{}s.collect(l),l=null}e&&(e().mousemove(function(f){s.collectInt(f.clientX,16),s.collectInt(f.clientY,16)}),e().keypress(function(f){s.collectInt(f.charCode,8)}))}if(!Ae.random)Ae.random=s;else for(var c in s)Ae.random[c]=s[c];Ae.random.createInstance=n,Ae.random})(typeof jQuery<"u"?jQuery:null)})();var We=j,Zr=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],$a=[1,2,3,5],wi=function(e,t){return e<<t&65535|(e&65535)>>16-t},_i=function(e,t){return(e&65535)>>t|e<<16-t&65535};We.rc2=We.rc2||{},We.rc2.expandKey=function(e,t){typeof e=="string"&&(e=We.util.createBuffer(e)),t=t||128;var a=e,r=e.length(),n=t,s=Math.ceil(n/8),i=255>>(n&7),o;for(o=r;o<128;o++)a.putByte(Zr[a.at(o-1)+a.at(o-r)&255]);for(a.setAt(128-s,Zr[a.at(128-s)&i]),o=127-s;o>=0;o--)a.setAt(o,Zr[a.at(o+1)^a.at(o+s)]);return a};var Ya=function(e,t,a){var r=!1,n=null,s=null,i=null,o,u,l,c,f=[];for(e=We.rc2.expandKey(e,t),l=0;l<64;l++)f.push(e.getInt16Le());a?(o=function(y){for(l=0;l<4;l++)y[l]+=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),y[l]=wi(y[l],$a[l]),c++},u=function(y){for(l=0;l<4;l++)y[l]+=f[y[(l+3)%4]&63]}):(o=function(y){for(l=3;l>=0;l--)y[l]=_i(y[l],$a[l]),y[l]-=f[c]+(y[(l+3)%4]&y[(l+2)%4])+(~y[(l+3)%4]&y[(l+1)%4]),c--},u=function(y){for(l=3;l>=0;l--)y[l]-=f[y[(l+3)%4]&63]});var g=function(y){var x=[];for(l=0;l<4;l++){var S=n.getInt16Le();i!==null&&(a?S^=i.getInt16Le():i.putInt16Le(S)),x.push(S&65535)}c=a?0:63;for(var I=0;I<y.length;I++)for(var B=0;B<y[I][0];B++)y[I][1](x);for(l=0;l<4;l++)i!==null&&(a?i.putInt16Le(x[l]):x[l]^=i.getInt16Le()),s.putInt16Le(x[l])},m=null;return m={start:function(y,x){y&&typeof y=="string"&&(y=We.util.createBuffer(y)),r=!1,n=We.util.createBuffer(),s=x||new We.util.createBuffer,i=y,m.output=s},update:function(y){for(r||n.putBuffer(y);n.length()>=8;)g([[5,o],[1,u],[6,o],[1,u],[5,o]])},finish:function(y){var x=!0;if(a)if(y)x=y(8,n,!a);else{var S=n.length()===8?8:8-n.length();n.fillWithByte(S,S)}if(x&&(r=!0,m.update()),!a&&(x=n.length()===0,x))if(y)x=y(8,s,!a);else{var I=s.length(),B=s.at(I-1);B>I?x=!1:s.truncate(B)}return x}},m};We.rc2.startEncrypting=function(e,t,a){var r=We.rc2.createEncryptionCipher(e,128);return r.start(t,a),r},We.rc2.createEncryptionCipher=function(e,t){return Ya(e,t,!0)},We.rc2.startDecrypting=function(e,t,a){var r=We.rc2.createDecryptionCipher(e,128);return r.start(t,a),r},We.rc2.createDecryptionCipher=function(e,t){return Ya(e,t,!1)};var Jr=j;Jr.jsbn=Jr.jsbn||{};var yt;function w(e,t,a){this.data=[],e!=null&&(typeof e=="number"?this.fromNumber(e,t,a):t==null&&typeof e!="string"?this.fromString(e,256):this.fromString(e,t))}Jr.jsbn.BigInteger=w;function ae(){return new w(null)}function Ni(e,t,a,r,n,s){for(;--s>=0;){var i=t*this.data[e++]+a.data[r]+n;n=Math.floor(i/67108864),a.data[r++]=i&67108863}return n}function Ri(e,t,a,r,n,s){for(var i=t&32767,o=t>>15;--s>=0;){var u=this.data[e]&32767,l=this.data[e++]>>15,c=o*u+l*i;u=i*u+((c&32767)<<15)+a.data[r]+(n&1073741823),n=(u>>>30)+(c>>>15)+o*l+(n>>>30),a.data[r++]=u&1073741823}return n}function ja(e,t,a,r,n,s){for(var i=t&16383,o=t>>14;--s>=0;){var u=this.data[e]&16383,l=this.data[e++]>>14,c=o*u+l*i;u=i*u+((c&16383)<<14)+a.data[r]+n,n=(u>>28)+(c>>14)+o*l,a.data[r++]=u&268435455}return n}typeof navigator>"u"?(w.prototype.am=ja,yt=28):navigator.appName=="Microsoft Internet Explorer"?(w.prototype.am=Ri,yt=30):navigator.appName!="Netscape"?(w.prototype.am=Ni,yt=26):(w.prototype.am=ja,yt=28),w.prototype.DB=yt,w.prototype.DM=(1<<yt)-1,w.prototype.DV=1<<yt;var ea=52;w.prototype.FV=Math.pow(2,ea),w.prototype.F1=ea-yt,w.prototype.F2=2*yt-ea;var Li="0123456789abcdefghijklmnopqrstuvwxyz",Sr=new Array,Ft,Je;for(Ft="0".charCodeAt(0),Je=0;Je<=9;++Je)Sr[Ft++]=Je;for(Ft="a".charCodeAt(0),Je=10;Je<36;++Je)Sr[Ft++]=Je;for(Ft="A".charCodeAt(0),Je=10;Je<36;++Je)Sr[Ft++]=Je;function Xa(e){return Li.charAt(e)}function Za(e,t){var a=Sr[e.charCodeAt(t)];return a??-1}function ki(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function Ui(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0}function Et(e){var t=ae();return t.fromInt(e),t}function Di(e,t){var a;if(t==16)a=4;else if(t==8)a=3;else if(t==256)a=8;else if(t==2)a=1;else if(t==32)a=5;else if(t==4)a=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var r=e.length,n=!1,s=0;--r>=0;){var i=a==8?e[r]&255:Za(e,r);if(i<0){e.charAt(r)=="-"&&(n=!0);continue}n=!1,s==0?this.data[this.t++]=i:s+a>this.DB?(this.data[this.t-1]|=(i&(1<<this.DB-s)-1)<<s,this.data[this.t++]=i>>this.DB-s):this.data[this.t-1]|=i<<s,s+=a,s>=this.DB&&(s-=this.DB)}a==8&&e[0]&128&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&w.ZERO.subTo(this,this)}function Pi(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t}function Vi(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var a=(1<<t)-1,r,n=!1,s="",i=this.t,o=this.DB-i*this.DB%t;if(i-- >0)for(o<this.DB&&(r=this.data[i]>>o)>0&&(n=!0,s=Xa(r));i>=0;)o<t?(r=(this.data[i]&(1<<o)-1)<<t-o,r|=this.data[--i]>>(o+=this.DB-t)):(r=this.data[i]>>(o-=t)&a,o<=0&&(o+=this.DB,--i)),r>0&&(n=!0),n&&(s+=Xa(r));return n?s:"0"}function Oi(){var e=ae();return w.ZERO.subTo(this,e),e}function Ki(){return this.s<0?this.negate():this}function Fi(e){var t=this.s-e.s;if(t!=0)return t;var a=this.t;if(t=a-e.t,t!=0)return this.s<0?-t:t;for(;--a>=0;)if((t=this.data[a]-e.data[a])!=0)return t;return 0}function Tr(e){var t=1,a;return(a=e>>>16)!=0&&(e=a,t+=16),(a=e>>8)!=0&&(e=a,t+=8),(a=e>>4)!=0&&(e=a,t+=4),(a=e>>2)!=0&&(e=a,t+=2),(a=e>>1)!=0&&(e=a,t+=1),t}function Mi(){return this.t<=0?0:this.DB*(this.t-1)+Tr(this.data[this.t-1]^this.s&this.DM)}function Hi(e,t){var a;for(a=this.t-1;a>=0;--a)t.data[a+e]=this.data[a];for(a=e-1;a>=0;--a)t.data[a]=0;t.t=this.t+e,t.s=this.s}function Gi(e,t){for(var a=e;a<this.t;++a)t.data[a-e]=this.data[a];t.t=Math.max(this.t-e,0),t.s=this.s}function qi(e,t){var a=e%this.DB,r=this.DB-a,n=(1<<r)-1,s=Math.floor(e/this.DB),i=this.s<<a&this.DM,o;for(o=this.t-1;o>=0;--o)t.data[o+s+1]=this.data[o]>>r|i,i=(this.data[o]&n)<<a;for(o=s-1;o>=0;--o)t.data[o]=0;t.data[s]=i,t.t=this.t+s+1,t.s=this.s,t.clamp()}function zi(e,t){t.s=this.s;var a=Math.floor(e/this.DB);if(a>=this.t){t.t=0;return}var r=e%this.DB,n=this.DB-r,s=(1<<r)-1;t.data[0]=this.data[a]>>r;for(var i=a+1;i<this.t;++i)t.data[i-a-1]|=(this.data[i]&s)<<n,t.data[i-a]=this.data[i]>>r;r>0&&(t.data[this.t-a-1]|=(this.s&s)<<n),t.t=this.t-a,t.clamp()}function Qi(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]-e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r-=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t.data[a++]=this.DV+r:r>0&&(t.data[a++]=r),t.t=a,t.clamp()}function Wi(e,t){var a=this.abs(),r=e.abs(),n=a.t;for(t.t=n+r.t;--n>=0;)t.data[n]=0;for(n=0;n<r.t;++n)t.data[n+a.t]=a.am(0,r.data[n],t,n,0,a.t);t.s=0,t.clamp(),this.s!=e.s&&w.ZERO.subTo(t,t)}function $i(e){for(var t=this.abs(),a=e.t=2*t.t;--a>=0;)e.data[a]=0;for(a=0;a<t.t-1;++a){var r=t.am(a,t.data[a],e,2*a,0,1);(e.data[a+t.t]+=t.am(a+1,2*t.data[a],e,2*a+1,r,t.t-a-1))>=t.DV&&(e.data[a+t.t]-=t.DV,e.data[a+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(a,t.data[a],e,2*a,0,1)),e.s=0,e.clamp()}function Yi(e,t,a){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t){t?.fromInt(0),a!=null&&this.copyTo(a);return}a==null&&(a=ae());var s=ae(),i=this.s,o=e.s,u=this.DB-Tr(r.data[r.t-1]);u>0?(r.lShiftTo(u,s),n.lShiftTo(u,a)):(r.copyTo(s),n.copyTo(a));var l=s.t,c=s.data[l-1];if(c!=0){var f=c*(1<<this.F1)+(l>1?s.data[l-2]>>this.F2:0),g=this.FV/f,m=(1<<this.F1)/f,y=1<<this.F2,x=a.t,S=x-l,I=t??ae();for(s.dlShiftTo(S,I),a.compareTo(I)>=0&&(a.data[a.t++]=1,a.subTo(I,a)),w.ONE.dlShiftTo(l,I),I.subTo(s,s);s.t<l;)s.data[s.t++]=0;for(;--S>=0;){var B=a.data[--x]==c?this.DM:Math.floor(a.data[x]*g+(a.data[x-1]+y)*m);if((a.data[x]+=s.am(0,B,a,S,0,l))<B)for(s.dlShiftTo(S,I),a.subTo(I,a);a.data[x]<--B;)a.subTo(I,a)}t!=null&&(a.drShiftTo(l,t),i!=o&&w.ZERO.subTo(t,t)),a.t=l,a.clamp(),u>0&&a.rShiftTo(u,a),i<0&&w.ZERO.subTo(a,a)}}}function ji(e){var t=ae();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(w.ZERO)>0&&e.subTo(t,t),t}function Nt(e){this.m=e}function Xi(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function Zi(e){return e}function Ji(e){e.divRemTo(this.m,null,e)}function es(e,t,a){e.multiplyTo(t,a),this.reduce(a)}function ts(e,t){e.squareTo(t),this.reduce(t)}Nt.prototype.convert=Xi,Nt.prototype.revert=Zi,Nt.prototype.reduce=Ji,Nt.prototype.mulTo=es,Nt.prototype.sqrTo=ts;function rs(){if(this.t<1)return 0;var e=this.data[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function Rt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function as(e){var t=ae();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(w.ZERO)>0&&this.m.subTo(t,t),t}function ns(e){var t=ae();return e.copyTo(t),this.reduce(t),t}function is(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var a=e.data[t]&32767,r=a*this.mpl+((a*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(a=t+this.m.t,e.data[a]+=this.m.am(0,r,e,t,0,this.m.t);e.data[a]>=e.DV;)e.data[a]-=e.DV,e.data[++a]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function ss(e,t){e.squareTo(t),this.reduce(t)}function os(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Rt.prototype.convert=as,Rt.prototype.revert=ns,Rt.prototype.reduce=is,Rt.prototype.mulTo=os,Rt.prototype.sqrTo=ss;function ls(){return(this.t>0?this.data[0]&1:this.s)==0}function us(e,t){if(e>4294967295||e<1)return w.ONE;var a=ae(),r=ae(),n=t.convert(this),s=Tr(e)-1;for(n.copyTo(a);--s>=0;)if(t.sqrTo(a,r),(e&1<<s)>0)t.mulTo(r,n,a);else{var i=a;a=r,r=i}return t.revert(a)}function cs(e,t){var a;return e<256||t.isEven()?a=new Nt(t):a=new Rt(t),this.exp(e,a)}w.prototype.copyTo=ki,w.prototype.fromInt=Ui,w.prototype.fromString=Di,w.prototype.clamp=Pi,w.prototype.dlShiftTo=Hi,w.prototype.drShiftTo=Gi,w.prototype.lShiftTo=qi,w.prototype.rShiftTo=zi,w.prototype.subTo=Qi,w.prototype.multiplyTo=Wi,w.prototype.squareTo=$i,w.prototype.divRemTo=Yi,w.prototype.invDigit=rs,w.prototype.isEven=ls,w.prototype.exp=us,w.prototype.toString=Vi,w.prototype.negate=Oi,w.prototype.abs=Ki,w.prototype.compareTo=Fi,w.prototype.bitLength=Mi,w.prototype.mod=ji,w.prototype.modPowInt=cs,w.ZERO=Et(0),w.ONE=Et(1);function fs(){var e=ae();return this.copyTo(e),e}function ds(){if(this.s<0){if(this.t==1)return this.data[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this.data[0];if(this.t==0)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]}function hs(){return this.t==0?this.s:this.data[0]<<24>>24}function ps(){return this.t==0?this.s:this.data[0]<<16>>16}function gs(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function ys(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function vs(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),a=Math.pow(e,t),r=Et(a),n=ae(),s=ae(),i="";for(this.divRemTo(r,n,s);n.signum()>0;)i=(a+s.intValue()).toString(e).substr(1)+i,n.divRemTo(r,n,s);return s.intValue().toString(e)+i}function ms(e,t){this.fromInt(0),t==null&&(t=10);for(var a=this.chunkSize(t),r=Math.pow(t,a),n=!1,s=0,i=0,o=0;o<e.length;++o){var u=Za(e,o);if(u<0){e.charAt(o)=="-"&&this.signum()==0&&(n=!0);continue}i=t*i+u,++s>=a&&(this.dMultiply(r),this.dAddOffset(i,0),s=0,i=0)}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(i,0)),n&&w.ZERO.subTo(this,this)}function Cs(e,t,a){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,a),this.testBit(e-1)||this.bitwiseTo(w.ONE.shiftLeft(e-1),ta,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(w.ONE.shiftLeft(e-1),this);else{var r=new Array,n=e&7;r.length=(e>>3)+1,t.nextBytes(r),n>0?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}}function Es(){var e=this.t,t=new Array;t[0]=this.s;var a=this.DB-e*this.DB%8,r,n=0;if(e-- >0)for(a<this.DB&&(r=this.data[e]>>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<<this.DB-a);e>=0;)a<8?(r=(this.data[e]&(1<<a)-1)<<8-a,r|=this.data[--e]>>(a+=this.DB-8)):(r=this.data[e]>>(a-=8)&255,a<=0&&(a+=this.DB,--e)),r&128&&(r|=-256),n==0&&(this.s&128)!=(r&128)&&++n,(n>0||r!=this.s)&&(t[n++]=r);return t}function xs(e){return this.compareTo(e)==0}function Ss(e){return this.compareTo(e)<0?this:e}function Ts(e){return this.compareTo(e)>0?this:e}function Is(e,t,a){var r,n,s=Math.min(e.t,this.t);for(r=0;r<s;++r)a.data[r]=t(this.data[r],e.data[r]);if(e.t<this.t){for(n=e.s&this.DM,r=s;r<this.t;++r)a.data[r]=t(this.data[r],n);a.t=this.t}else{for(n=this.s&this.DM,r=s;r<e.t;++r)a.data[r]=t(n,e.data[r]);a.t=e.t}a.s=t(this.s,e.s),a.clamp()}function As(e,t){return e&t}function bs(e){var t=ae();return this.bitwiseTo(e,As,t),t}function ta(e,t){return e|t}function Bs(e){var t=ae();return this.bitwiseTo(e,ta,t),t}function Ja(e,t){return e^t}function ws(e){var t=ae();return this.bitwiseTo(e,Ja,t),t}function en(e,t){return e&~t}function _s(e){var t=ae();return this.bitwiseTo(e,en,t),t}function Ns(){for(var e=ae(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e}function Rs(e){var t=ae();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t}function Ls(e){var t=ae();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t}function ks(e){if(e==0)return-1;var t=0;return e&65535||(e>>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function Us(){for(var e=0;e<this.t;++e)if(this.data[e]!=0)return e*this.DB+ks(this.data[e]);return this.s<0?this.t*this.DB:-1}function Ds(e){for(var t=0;e!=0;)e&=e-1,++t;return t}function Ps(){for(var e=0,t=this.s&this.DM,a=0;a<this.t;++a)e+=Ds(this.data[a]^t);return e}function Vs(e){var t=Math.floor(e/this.DB);return t>=this.t?this.s!=0:(this.data[t]&1<<e%this.DB)!=0}function Os(e,t){var a=w.ONE.shiftLeft(e);return this.bitwiseTo(a,t,a),a}function Ks(e){return this.changeBit(e,ta)}function Fs(e){return this.changeBit(e,en)}function Ms(e){return this.changeBit(e,Ja)}function Hs(e,t){for(var a=0,r=0,n=Math.min(e.t,this.t);a<n;)r+=this.data[a]+e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;a<this.t;)r+=this.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;a<e.t;)r+=e.data[a],t.data[a++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t.data[a++]=r:r<-1&&(t.data[a++]=this.DV+r),t.t=a,t.clamp()}function Gs(e){var t=ae();return this.addTo(e,t),t}function qs(e){var t=ae();return this.subTo(e,t),t}function zs(e){var t=ae();return this.multiplyTo(e,t),t}function Qs(e){var t=ae();return this.divRemTo(e,t,null),t}function Ws(e){var t=ae();return this.divRemTo(e,null,t),t}function $s(e){var t=ae(),a=ae();return this.divRemTo(e,t,a),new Array(t,a)}function Ys(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function js(e,t){if(e!=0){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}}function ar(){}function tn(e){return e}function Xs(e,t,a){e.multiplyTo(t,a)}function Zs(e,t){e.squareTo(t)}ar.prototype.convert=tn,ar.prototype.revert=tn,ar.prototype.mulTo=Xs,ar.prototype.sqrTo=Zs;function Js(e){return this.exp(e,new ar)}function eo(e,t,a){var r=Math.min(this.t+e.t,t);for(a.s=0,a.t=r;r>0;)a.data[--r]=0;var n;for(n=a.t-this.t;r<n;++r)a.data[r+this.t]=this.am(0,e.data[r],a,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e.data[r],a,r,0,t-r);a.clamp()}function to(e,t,a){--t;var r=a.t=this.t+e.t-t;for(a.s=0;--r>=0;)a.data[r]=0;for(r=Math.max(t-this.t,0);r<e.t;++r)a.data[this.t+r-t]=this.am(t-r,e.data[r],a,0,0,this.t+r-t);a.clamp(),a.drShiftTo(1,a)}function Mt(e){this.r2=ae(),this.q3=ae(),w.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}function ro(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=ae();return e.copyTo(t),this.reduce(t),t}function ao(e){return e}function no(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)}function io(e,t){e.squareTo(t),this.reduce(t)}function so(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Mt.prototype.convert=ro,Mt.prototype.revert=ao,Mt.prototype.reduce=no,Mt.prototype.mulTo=so,Mt.prototype.sqrTo=io;function oo(e,t){var a=e.bitLength(),r,n=Et(1),s;if(a<=0)return n;a<18?r=1:a<48?r=3:a<144?r=4:a<768?r=5:r=6,a<8?s=new Nt(t):t.isEven()?s=new Mt(t):s=new Rt(t);var i=new Array,o=3,u=r-1,l=(1<<r)-1;if(i[1]=s.convert(this),r>1){var c=ae();for(s.sqrTo(i[1],c);o<=l;)i[o]=ae(),s.mulTo(c,i[o-2],i[o]),o+=2}var f=e.t-1,g,m=!0,y=ae(),x;for(a=Tr(e.data[f])-1;f>=0;){for(a>=u?g=e.data[f]>>a-u&l:(g=(e.data[f]&(1<<a+1)-1)<<u-a,f>0&&(g|=e.data[f-1]>>this.DB+a-u)),o=r;!(g&1);)g>>=1,--o;if((a-=o)<0&&(a+=this.DB,--f),m)i[g].copyTo(n),m=!1;else{for(;o>1;)s.sqrTo(n,y),s.sqrTo(y,n),o-=2;o>0?s.sqrTo(n,y):(x=n,n=y,y=x),s.mulTo(y,i[g],n)}for(;f>=0&&!(e.data[f]&1<<a);)s.sqrTo(n,y),x=n,n=y,y=x,--a<0&&(a=this.DB-1,--f)}return s.revert(n)}function lo(e){var t=this.s<0?this.negate():this.clone(),a=e.s<0?e.negate():e.clone();if(t.compareTo(a)<0){var r=t;t=a,a=r}var n=t.getLowestSetBit(),s=a.getLowestSetBit();if(s<0)return t;for(n<s&&(s=n),s>0&&(t.rShiftTo(s,t),a.rShiftTo(s,a));t.signum()>0;)(n=t.getLowestSetBit())>0&&t.rShiftTo(n,t),(n=a.getLowestSetBit())>0&&a.rShiftTo(n,a),t.compareTo(a)>=0?(t.subTo(a,t),t.rShiftTo(1,t)):(a.subTo(t,a),a.rShiftTo(1,a));return s>0&&a.lShiftTo(s,a),a}function uo(e){if(e<=0)return 0;var t=this.DV%e,a=this.s<0?e-1:0;if(this.t>0)if(t==0)a=this.data[0]%e;else for(var r=this.t-1;r>=0;--r)a=(t*a+this.data[r])%e;return a}function co(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return w.ZERO;for(var a=e.clone(),r=this.clone(),n=Et(1),s=Et(0),i=Et(0),o=Et(1);a.signum()!=0;){for(;a.isEven();)a.rShiftTo(1,a),t?((!n.isEven()||!s.isEven())&&(n.addTo(this,n),s.subTo(e,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!o.isEven())&&(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);a.compareTo(r)>=0?(a.subTo(r,a),t&&n.subTo(i,n),s.subTo(o,s)):(r.subTo(a,r),t&&i.subTo(n,i),o.subTo(s,o))}if(r.compareTo(w.ONE)!=0)return w.ZERO;if(o.compareTo(e)>=0)return o.subtract(e);if(o.signum()<0)o.addTo(e,o);else return o;return o.signum()<0?o.add(e):o}var it=[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],fo=(1<<26)/it[it.length-1];function ho(e){var t,a=this.abs();if(a.t==1&&a.data[0]<=it[it.length-1]){for(t=0;t<it.length;++t)if(a.data[0]==it[t])return!0;return!1}if(a.isEven())return!1;for(t=1;t<it.length;){for(var r=it[t],n=t+1;n<it.length&&r<fo;)r*=it[n++];for(r=a.modInt(r);t<n;)if(r%it[t++]==0)return!1}return a.millerRabin(e)}function po(e){var t=this.subtract(w.ONE),a=t.getLowestSetBit();if(a<=0)return!1;for(var r=t.shiftRight(a),n=go(),s,i=0;i<e;++i){do s=new w(this.bitLength(),n);while(s.compareTo(w.ONE)<=0||s.compareTo(t)>=0);var o=s.modPow(r,this);if(o.compareTo(w.ONE)!=0&&o.compareTo(t)!=0){for(var u=1;u++<a&&o.compareTo(t)!=0;)if(o=o.modPowInt(2,this),o.compareTo(w.ONE)==0)return!1;if(o.compareTo(t)!=0)return!1}}return!0}function go(){return{nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(Math.random()*256)}}}w.prototype.chunkSize=gs,w.prototype.toRadix=vs,w.prototype.fromRadix=ms,w.prototype.fromNumber=Cs,w.prototype.bitwiseTo=Is,w.prototype.changeBit=Os,w.prototype.addTo=Hs,w.prototype.dMultiply=Ys,w.prototype.dAddOffset=js,w.prototype.multiplyLowerTo=eo,w.prototype.multiplyUpperTo=to,w.prototype.modInt=uo,w.prototype.millerRabin=po,w.prototype.clone=fs,w.prototype.intValue=ds,w.prototype.byteValue=hs,w.prototype.shortValue=ps,w.prototype.signum=ys,w.prototype.toByteArray=Es,w.prototype.equals=xs,w.prototype.min=Ss,w.prototype.max=Ts,w.prototype.and=bs,w.prototype.or=Bs,w.prototype.xor=ws,w.prototype.andNot=_s,w.prototype.not=Ns,w.prototype.shiftLeft=Rs,w.prototype.shiftRight=Ls,w.prototype.getLowestSetBit=Us,w.prototype.bitCount=Ps,w.prototype.testBit=Vs,w.prototype.setBit=Ks,w.prototype.clearBit=Fs,w.prototype.flipBit=Ms,w.prototype.add=Gs,w.prototype.subtract=qs,w.prototype.multiply=zs,w.prototype.divide=Qs,w.prototype.remainder=Ws,w.prototype.divideAndRemainder=$s,w.prototype.modPow=oo,w.prototype.modInverse=co,w.prototype.pow=Js,w.prototype.gcd=lo,w.prototype.isProbablePrime=ho;var ct=j,rn=ct.sha1=ct.sha1||{};ct.md.sha1=ct.md.algorithms.sha1=rn,rn.create=function(){an||yo();var e=null,t=ct.util.createBuffer(),a=new Array(80),r={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8};return r.start=function(){r.messageLength=0,r.fullMessageLength=r.messageLength64=[];for(var n=r.messageLengthSize/4,s=0;s<n;++s)r.fullMessageLength.push(0);return t=ct.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},r},r.start(),r.update=function(n,s){s==="utf8"&&(n=ct.util.encodeUtf8(n));var i=n.length;r.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var o=r.fullMessageLength.length-1;o>=0;--o)r.fullMessageLength[o]+=i[1],i[1]=i[0]+(r.fullMessageLength[o]/4294967296>>>0),r.fullMessageLength[o]=r.fullMessageLength[o]>>>0,i[0]=i[1]/4294967296>>>0;return t.putBytes(n),nn(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=ct.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(ra.substr(0,r.blockLength-i));for(var o,u,l=r.fullMessageLength[0]*8,c=0;c<r.fullMessageLength.length-1;++c)o=r.fullMessageLength[c+1]*8,u=o/4294967296>>>0,l+=u,n.putInt32(l>>>0),l=o>>>0;n.putInt32(l);var f={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};nn(f,a,n);var g=ct.util.createBuffer();return g.putInt32(f.h0),g.putInt32(f.h1),g.putInt32(f.h2),g.putInt32(f.h3),g.putInt32(f.h4),g},r};var ra=null,an=!1;function yo(){ra=String.fromCharCode(128),ra+=ct.util.fillString(String.fromCharCode(0),64),an=!0}function nn(e,t,a){for(var r,n,s,i,o,u,l,c,f=a.length();f>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,u=e.h4,c=0;c<16;++c)r=a.getInt32(),t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<20;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=o^s&(i^o),r=(n<<5|n>>>27)+l+u+1518500249+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<32;++c)r=t[c-3]^t[c-8]^t[c-14]^t[c-16],r=r<<1|r>>>31,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<40;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+1859775393+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<60;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s&i|o&(s^i),r=(n<<5|n>>>27)+l+u+2400959708+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;c<80;++c)r=t[c-6]^t[c-16]^t[c-28]^t[c-32],r=r<<2|r>>>30,t[c]=r,l=s^i^o,r=(n<<5|n>>>27)+l+u+3395469782+r,u=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,e.h4=e.h4+u|0,f-=64}}var ft=j,sn=ft.pkcs1=ft.pkcs1||{};sn.encode_rsa_oaep=function(e,t,a){var r,n,s,i;typeof a=="string"?(r=a,n=arguments[3]||void 0,s=arguments[4]||void 0):a&&(r=a.label||void 0,n=a.seed||void 0,s=a.md||void 0,a.mgf1&&a.mgf1.md&&(i=a.mgf1.md)),s?s.start():s=ft.md.sha1.create(),i||(i=s);var o=Math.ceil(e.n.bitLength()/8),u=o-2*s.digestLength-2;if(t.length>u){var l=new Error("RSAES-OAEP input message length is too long.");throw l.length=t.length,l.maxLength=u,l}r||(r=""),s.update(r,"raw");for(var c=s.digest(),f="",g=u-t.length,m=0;m<g;m++)f+="\0";var y=c.getBytes()+f+""+t;if(!n)n=ft.random.getBytes(s.digestLength);else if(n.length!==s.digestLength){var l=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.");throw l.seedLength=n.length,l.digestLength=s.digestLength,l}var x=Ir(n,o-s.digestLength-1,i),S=ft.util.xorBytes(y,x,y.length),I=Ir(S,s.digestLength,i),B=ft.util.xorBytes(n,I,n.length);return"\0"+B+S},sn.decode_rsa_oaep=function(e,t,a){var r,n,s;typeof a=="string"?(r=a,n=arguments[3]||void 0):a&&(r=a.label||void 0,n=a.md||void 0,a.mgf1&&a.mgf1.md&&(s=a.mgf1.md));var i=Math.ceil(e.n.bitLength()/8);if(t.length!==i){var S=new Error("RSAES-OAEP encoded message length is invalid.");throw S.length=t.length,S.expectedLength=i,S}if(n===void 0?n=ft.md.sha1.create():n.start(),s||(s=n),i<2*n.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");r||(r=""),n.update(r,"raw");for(var o=n.digest().getBytes(),u=t.charAt(0),l=t.substring(1,n.digestLength+1),c=t.substring(1+n.digestLength),f=Ir(c,n.digestLength,s),g=ft.util.xorBytes(l,f,l.length),m=Ir(g,i-n.digestLength-1,s),y=ft.util.xorBytes(c,m,c.length),x=y.substring(0,n.digestLength),S=u!=="\0",I=0;I<n.digestLength;++I)S|=o.charAt(I)!==x.charAt(I);for(var B=1,b=n.digestLength,D=n.digestLength;D<y.length;D++){var L=y.charCodeAt(D),R=L&1^1,q=B?65534:0;S|=L&q,B=B&R,b+=B}if(S||y.charCodeAt(b)!==1)throw new Error("Invalid RSAES-OAEP padding.");return y.substring(b+1)};function Ir(e,t,a){a||(a=ft.md.sha1.create());for(var r="",n=Math.ceil(t/a.digestLength),s=0;s<n;++s){var i=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,s&255);a.start(),a.update(e+i),r+=a.digest().getBytes()}return r.substring(0,t)}var xt=j;(function(){if(xt.prime){xt.prime;return}var e=xt.prime=xt.prime||{},t=xt.jsbn.BigInteger,a=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(f,g){return f|g};e.generateProbablePrime=function(f,g,m){typeof g=="function"&&(m=g,g={}),g=g||{};var y=g.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var x=g.prng||xt.random,S={nextBytes:function(I){for(var B=x.getBytesSync(I.length),b=0;b<I.length;++b)I[b]=B.charCodeAt(b)}};if(y.name==="PRIMEINC")return s(f,S,y.options,m);throw new Error("Invalid prime generation algorithm: "+y.name)};function s(f,g,m,y){return"workers"in m?u(f,g,m,y):i(f,g,m,y)}function i(f,g,m,y){var x=l(f,g),S=0,I=c(x.bitLength());"millerRabinTests"in m&&(I=m.millerRabinTests);var B=10;"maxBlockTime"in m&&(B=m.maxBlockTime),o(x,f,g,S,I,B,y)}function o(f,g,m,y,x,S,I){var B=+new Date;do{if(f.bitLength()>g&&(f=l(g,m)),f.isProbablePrime(x))return I(null,f);f.dAddOffset(a[y++%8],0)}while(S<0||+new Date-B<S);xt.util.setImmediate(function(){o(f,g,m,y,x,S,I)})}function u(f,g,m,y){if(typeof Worker>"u")return i(f,g,m,y);var x=l(f,g),S=m.workers,I=m.workLoad||100,B=I*30/8,b=m.workerScript||"forge/prime.worker.js";if(S===-1)return xt.util.estimateCores(function(L,R){L&&(R=2),S=R-1,D()});D();function D(){S=Math.max(1,S);for(var L=[],R=0;R<S;++R)L[R]=new Worker(b);for(var R=0;R<S;++R)L[R].addEventListener("message",X);var q=!1;function X(ie){if(!q){var ue=ie.data;if(ue.found){for(var se=0;se<L.length;++se)L[se].terminate();return q=!0,y(null,new t(ue.prime,16))}x.bitLength()>f&&(x=l(f,g));var W=x.toString(16);ie.target.postMessage({hex:W,workLoad:I}),x.dAddOffset(B,0)}}}}function l(f,g){var m=new t(f,g),y=f-1;return m.testBit(y)||m.bitwiseTo(t.ONE.shiftLeft(y),n,m),m.dAddOffset(31-m.mod(r).byteValue(),0),m}function c(f){return f<=100?27:f<=150?18:f<=200?15:f<=250?12:f<=300?9:f<=350?8:f<=400?7:f<=500?6:f<=600?5:f<=800?4:f<=1250?3:2}})();var F=j;if(typeof ne>"u")var ne=F.jsbn.BigInteger;var aa=F.util.isNodejs?jr:null,T=F.asn1,et=F.util;F.pki=F.pki||{},F.pki.rsa=F.rsa=F.rsa||{};var z=F.pki,vo=[6,4,2,4,2,4,6,2],mo={name:"PrivateKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},Co={name:"RSAPrivateKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},Eo={name:"RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:T.Class.UNIVERSAL,type:T.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},xo=F.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},So={name:"DigestInfo",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:T.Class.UNIVERSAL,type:T.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:T.Class.UNIVERSAL,type:T.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:T.Class.UNIVERSAL,type:T.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:T.Class.UNIVERSAL,type:T.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},To=function(e){var t;if(e.algorithm in z.oids)t=z.oids[e.algorithm];else{var a=new Error("Unknown message digest algorithm.");throw a.algorithm=e.algorithm,a}var r=T.oidToDer(t).getBytes(),n=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]),s=T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[]);s.value.push(T.create(T.Class.UNIVERSAL,T.Type.OID,!1,r)),s.value.push(T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,""));var i=T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(s),n.value.push(i),T.toDer(n).getBytes()},on=function(e,t,a){if(a)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);t.dP||(t.dP=t.d.mod(t.p.subtract(ne.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ne.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new ne(F.util.bytesToHex(F.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(ne.ONE));e=e.multiply(r.modPow(t.e,t.n)).mod(t.n);for(var n=e.mod(t.p).modPow(t.dP,t.p),s=e.mod(t.q).modPow(t.dQ,t.q);n.compareTo(s)<0;)n=n.add(t.p);var i=n.subtract(s).multiply(t.qInv).mod(t.p).multiply(t.q).add(s);return i=i.multiply(r.modInverse(t.n)).mod(t.n),i};z.rsa.encrypt=function(e,t,a){var r=a,n,s=Math.ceil(t.n.bitLength()/8);a!==!1&&a!==!0?(r=a===2,n=ln(e,t,a)):(n=F.util.createBuffer(),n.putBytes(e));for(var i=new ne(n.toHex(),16),o=on(i,t,r),u=o.toString(16),l=F.util.createBuffer(),c=s-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(F.util.hexToBytes(u)),l.getBytes()},z.rsa.decrypt=function(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8);if(e.length!==n){var s=new Error("Encrypted message length is invalid.");throw s.length=e.length,s.expected=n,s}var i=new ne(F.util.createBuffer(e).toHex(),16);if(i.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=on(i,t,a),u=o.toString(16),l=F.util.createBuffer(),c=n-Math.ceil(u.length/2);c>0;)l.putByte(0),--c;return l.putBytes(F.util.hexToBytes(u)),r!==!1?Ar(l.getBytes(),t,a):l.getBytes()},z.rsa.createKeyPairGenerationState=function(e,t,a){typeof e=="string"&&(e=parseInt(e,10)),e=e||2048,a=a||{};var r=a.prng||F.random,n={nextBytes:function(o){for(var u=r.getBytesSync(o.length),l=0;l<o.length;++l)o[l]=u.charCodeAt(l)}},s=a.algorithm||"PRIMEINC",i;if(s==="PRIMEINC")i={algorithm:s,state:0,bits:e,rng:n,eInt:t||65537,e:new ne(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null},i.e.fromInt(i.eInt);else throw new Error("Invalid key generation algorithm: "+s);return i},z.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var a=new ne(null);a.fromInt(30);for(var r=0,n=function(f,g){return f|g},s=+new Date,i,o=0;e.keys===null&&(t<=0||o<t);){if(e.state===0){var u=e.p===null?e.pBits:e.qBits,l=u-1;e.pqState===0?(e.num=new ne(u,e.rng),e.num.testBit(l)||e.num.bitwiseTo(ne.ONE.shiftLeft(l),n,e.num),e.num.dAddOffset(31-e.num.mod(a).byteValue(),0),r=0,++e.pqState):e.pqState===1?e.num.bitLength()>u?e.pqState=0:e.num.isProbablePrime(Ao(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(vo[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(ne.ONE).gcd(e.e).compareTo(ne.ONE)===0?3:0:e.pqState===3&&(e.pqState=0,e.p===null?e.p=e.num:e.q=e.num,e.p!==null&&e.q!==null&&++e.state,e.num=null)}else if(e.state===1)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(e.state===2)e.p1=e.p.subtract(ne.ONE),e.q1=e.q.subtract(ne.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ne.ONE)===0?++e.state:(e.p=null,e.q=null,e.state=0);else if(e.state===4)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(e.state===5){var c=e.e.modInverse(e.phi);e.keys={privateKey:z.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:z.rsa.setPublicKey(e.n,e.e)}}i=+new Date,o+=i-s,s=i}return e.keys!==null},z.rsa.generateKeyPair=function(e,t,a,r){if(arguments.length===1?typeof e=="object"?(a=e,e=void 0):typeof e=="function"&&(r=e,e=void 0):arguments.length===2?typeof e=="number"?typeof t=="function"?(r=t,t=void 0):typeof t!="number"&&(a=t,t=void 0):(a=e,r=t,e=void 0,t=void 0):arguments.length===3&&(typeof t=="number"?typeof a=="function"&&(r=a,a=void 0):(r=a,a=t,t=void 0)),a=a||{},e===void 0&&(e=a.bits||2048),t===void 0&&(t=a.e||65537),!F.options.usePureJavaScript&&!a.prng&&e>=256&&e<=16384&&(t===65537||t===3)){if(r){if(un("generateKeyPair"))return aa.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,u,l){if(o)return r(o);r(null,{privateKey:z.privateKeyFromPem(l),publicKey:z.publicKeyFromPem(u)})});if(cn("generateKey")&&cn("exportKey"))return et.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:dn(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return et.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){r(o)}).then(function(o){if(o){var u=z.privateKeyFromAsn1(T.fromDer(F.util.createBuffer(o)));r(null,{privateKey:u,publicKey:z.setRsaPublicKey(u.n,u.e)})}});if(fn("generateKey")&&fn("exportKey")){var n=et.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:dn(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(o){var u=o.target.result,l=et.globalScope.msCrypto.subtle.exportKey("pkcs8",u.privateKey);l.oncomplete=function(c){var f=c.target.result,g=z.privateKeyFromAsn1(T.fromDer(F.util.createBuffer(f)));r(null,{privateKey:g,publicKey:z.setRsaPublicKey(g.n,g.e)})},l.onerror=function(c){r(c)}},n.onerror=function(o){r(o)};return}}else if(un("generateKeyPairSync")){var s=aa.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:z.privateKeyFromPem(s.privateKey),publicKey:z.publicKeyFromPem(s.publicKey)}}}var i=z.rsa.createKeyPairGenerationState(e,t,a);if(!r)return z.rsa.stepKeyPairGenerationState(i,0),i.keys;Io(i,a,r)},z.setRsaPublicKey=z.rsa.setPublicKey=function(e,t){var a={n:e,e:t};return a.encrypt=function(r,n,s){if(typeof n=="string"?n=n.toUpperCase():n===void 0&&(n="RSAES-PKCS1-V1_5"),n==="RSAES-PKCS1-V1_5")n={encode:function(o,u,l){return ln(o,u,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(o,u){return F.pkcs1.encode_rsa_oaep(u,o,s)}};else if(["RAW","NONE","NULL",null].indexOf(n)!==-1)n={encode:function(o){return o}};else if(typeof n=="string")throw new Error('Unsupported encryption scheme: "'+n+'".');var i=n.encode(r,a,!0);return z.rsa.encrypt(i,a,!0)},a.verify=function(r,n,s,i){typeof s=="string"?s=s.toUpperCase():s===void 0&&(s="RSASSA-PKCS1-V1_5"),i===void 0&&(i={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in i||(i._parseAllDigestBytes=!0),s==="RSASSA-PKCS1-V1_5"?s={verify:function(u,l){l=Ar(l,a,!0);var c=T.fromDer(l,{parseAllBytes:i._parseAllDigestBytes}),f={},g=[];if(!T.validate(c,So,f,g)){var m=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw m.errors=g,m}var y=T.derToOid(f.algorithmIdentifier);if(!(y===F.oids.md2||y===F.oids.md5||y===F.oids.sha1||y===F.oids.sha224||y===F.oids.sha256||y===F.oids.sha384||y===F.oids.sha512||y===F.oids["sha512-224"]||y===F.oids["sha512-256"])){var m=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw m.oid=y,m}if((y===F.oids.md2||y===F.oids.md5)&&!("parameters"in f))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return u===f.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(u,l){return l=Ar(l,a,!0),u===l}});var o=z.rsa.decrypt(n,a,!0,!1);return s.verify(r,o,a.n.bitLength())},a},z.setRsaPrivateKey=z.rsa.setPrivateKey=function(e,t,a,r,n,s,i,o){var u={n:e,e:t,d:a,p:r,q:n,dP:s,dQ:i,qInv:o};return u.decrypt=function(l,c,f){typeof c=="string"?c=c.toUpperCase():c===void 0&&(c="RSAES-PKCS1-V1_5");var g=z.rsa.decrypt(l,u,!1,!1);if(c==="RSAES-PKCS1-V1_5")c={decode:Ar};else if(c==="RSA-OAEP"||c==="RSAES-OAEP")c={decode:function(m,y){return F.pkcs1.decode_rsa_oaep(y,m,f)}};else if(["RAW","NONE","NULL",null].indexOf(c)!==-1)c={decode:function(m){return m}};else throw new Error('Unsupported encryption scheme: "'+c+'".');return c.decode(g,u,!1)},u.sign=function(l,c){var f=!1;typeof c=="string"&&(c=c.toUpperCase()),c===void 0||c==="RSASSA-PKCS1-V1_5"?(c={encode:To},f=1):(c==="NONE"||c==="NULL"||c===null)&&(c={encode:function(){return l}},f=1);var g=c.encode(l,u.n.bitLength());return z.rsa.encrypt(g,u,f)},u},z.wrapRsaPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(z.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.OCTETSTRING,!1,T.toDer(e).getBytes())])},z.privateKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,mo,t,a)&&(e=T.fromDer(F.util.createBuffer(t.privateKey))),t={},a=[],!T.validate(e,Co,t,a)){var r=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw r.errors=a,r}var n,s,i,o,u,l,c,f;return n=F.util.createBuffer(t.privateKeyModulus).toHex(),s=F.util.createBuffer(t.privateKeyPublicExponent).toHex(),i=F.util.createBuffer(t.privateKeyPrivateExponent).toHex(),o=F.util.createBuffer(t.privateKeyPrime1).toHex(),u=F.util.createBuffer(t.privateKeyPrime2).toHex(),l=F.util.createBuffer(t.privateKeyExponent1).toHex(),c=F.util.createBuffer(t.privateKeyExponent2).toHex(),f=F.util.createBuffer(t.privateKeyCoefficient).toHex(),z.setRsaPrivateKey(new ne(n,16),new ne(s,16),new ne(i,16),new ne(o,16),new ne(u,16),new ne(l,16),new ne(c,16),new ne(f,16))},z.privateKeyToAsn1=z.privateKeyToRSAPrivateKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,T.integerToDer(0).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.e)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.d)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.p)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.q)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.dP)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.dQ)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.qInv))])},z.publicKeyFromAsn1=function(e){var t={},a=[];if(T.validate(e,xo,t,a)){var r=T.derToOid(t.publicKeyOid);if(r!==z.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(a=[],!T.validate(e,Eo,t,a)){var n=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.");throw n.errors=a,n}var s=F.util.createBuffer(t.publicKeyModulus).toHex(),i=F.util.createBuffer(t.publicKeyExponent).toHex();return z.setRsaPublicKey(new ne(s,16),new ne(i,16))},z.publicKeyToAsn1=z.publicKeyToSubjectPublicKeyInfo=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.OID,!1,T.oidToDer(z.oids.rsaEncryption).getBytes()),T.create(T.Class.UNIVERSAL,T.Type.NULL,!1,"")]),T.create(T.Class.UNIVERSAL,T.Type.BITSTRING,!1,[z.publicKeyToRSAPublicKey(e)])])},z.publicKeyToRSAPublicKey=function(e){return T.create(T.Class.UNIVERSAL,T.Type.SEQUENCE,!0,[T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.n)),T.create(T.Class.UNIVERSAL,T.Type.INTEGER,!1,dt(e.e))])};function ln(e,t,a){var r=F.util.createBuffer(),n=Math.ceil(t.n.bitLength()/8);if(e.length>n-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=e.length,s.max=n-11,s}r.putByte(0),r.putByte(a);var i=n-3-e.length,o;if(a===0||a===1){o=a===0?0:255;for(var u=0;u<i;++u)r.putByte(o)}else for(;i>0;){for(var l=0,c=F.random.getBytes(i),u=0;u<i;++u)o=c.charCodeAt(u),o===0?++l:r.putByte(o);i=l}return r.putByte(0),r.putBytes(e),r}function Ar(e,t,a,r){var n=Math.ceil(t.n.bitLength()/8),s=F.util.createBuffer(e),i=s.getByte(),o=s.getByte();if(i!==0||a&&o!==0&&o!==1||!a&&o!=2||a&&o===0&&typeof r>"u")throw new Error("Encryption block is invalid.");var u=0;if(o===0){u=n-3-r;for(var l=0;l<u;++l)if(s.getByte()!==0)throw new Error("Encryption block is invalid.")}else if(o===1)for(u=0;s.length()>1;){if(s.getByte()!==255){--s.read;break}++u}else if(o===2)for(u=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++u}var c=s.getByte();if(c!==0||u!==n-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function Io(e,t,a){typeof t=="function"&&(a=t,t={}),t=t||{};var r={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(r.prng=t.prng),n();function n(){s(e.pBits,function(o,u){if(o)return a(o);if(e.p=u,e.q!==null)return i(o,e.q);s(e.qBits,i)})}function s(o,u){F.prime.generateProbablePrime(o,r,u)}function i(o,u){if(o)return a(o);if(e.q=u,e.p.compareTo(e.q)<0){var l=e.p;e.p=e.q,e.q=l}if(e.p.subtract(ne.ONE).gcd(e.e).compareTo(ne.ONE)!==0){e.p=null,n();return}if(e.q.subtract(ne.ONE).gcd(e.e).compareTo(ne.ONE)!==0){e.q=null,s(e.qBits,i);return}if(e.p1=e.p.subtract(ne.ONE),e.q1=e.q.subtract(ne.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ne.ONE)!==0){e.p=e.q=null,n();return}if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits){e.q=null,s(e.qBits,i);return}var c=e.e.modInverse(e.phi);e.keys={privateKey:z.rsa.setPrivateKey(e.n,e.e,c,e.p,e.q,c.mod(e.p1),c.mod(e.q1),e.q.modInverse(e.p)),publicKey:z.rsa.setPublicKey(e.n,e.e)},a(null,e.keys)}}function dt(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var a=F.util.hexToBytes(t);return a.length>1&&(a.charCodeAt(0)===0&&!(a.charCodeAt(1)&128)||a.charCodeAt(0)===255&&(a.charCodeAt(1)&128)===128)?a.substr(1):a}function Ao(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function un(e){return F.util.isNodejs&&typeof aa[e]=="function"}function cn(e){return typeof et.globalScope<"u"&&typeof et.globalScope.crypto=="object"&&typeof et.globalScope.crypto.subtle=="object"&&typeof et.globalScope.crypto.subtle[e]=="function"}function fn(e){return typeof et.globalScope<"u"&&typeof et.globalScope.msCrypto=="object"&&typeof et.globalScope.msCrypto.subtle=="object"&&typeof et.globalScope.msCrypto.subtle[e]=="function"}function dn(e){for(var t=F.util.hexToBytes(e.toString(16)),a=new Uint8Array(t.length),r=0;r<t.length;++r)a[r]=t.charCodeAt(r);return a}var O=j;if(typeof bo>"u")var bo=O.jsbn.BigInteger;var A=O.asn1,$=O.pki=O.pki||{};$.pbe=O.pbe=O.pbe||{};var Lt=$.oids,Bo={name:"EncryptedPrivateKeyInfo",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},wo={name:"PBES2Algorithms",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:A.Class.UNIVERSAL,type:A.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},_o={name:"pkcs-12PbeParams",tagClass:A.Class.UNIVERSAL,type:A.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:A.Class.UNIVERSAL,type:A.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:A.Class.UNIVERSAL,type:A.Type.INTEGER,constructed:!1,capture:"iterations"}]};$.encryptPrivateKeyInfo=function(e,t,a){a=a||{},a.saltSize=a.saltSize||8,a.count=a.count||2048,a.algorithm=a.algorithm||"aes128",a.prfAlgorithm=a.prfAlgorithm||"sha1";var r=O.random.getBytesSync(a.saltSize),n=a.count,s=A.integerToDer(n),i,o,u;if(a.algorithm.indexOf("aes")===0||a.algorithm==="des"){var l,c,f;switch(a.algorithm){case"aes128":i=16,l=16,c=Lt["aes128-CBC"],f=O.aes.createEncryptionCipher;break;case"aes192":i=24,l=16,c=Lt["aes192-CBC"],f=O.aes.createEncryptionCipher;break;case"aes256":i=32,l=16,c=Lt["aes256-CBC"],f=O.aes.createEncryptionCipher;break;case"des":i=8,l=8,c=Lt.desCBC,f=O.des.createEncryptionCipher;break;default:var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var m="hmacWith"+a.prfAlgorithm.toUpperCase(),y=gn(m),x=O.pkcs5.pbkdf2(t,r,n,i,y),S=O.random.getBytesSync(l),I=f(x);I.start(S),I.update(A.toDer(e)),I.finish(),u=I.output.getBytes();var B=No(r,s,i,m);o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(Lt.pkcs5PBES2).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(Lt.pkcs5PBKDF2).getBytes()),B]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(c).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,S)])])])}else if(a.algorithm==="3des"){i=24;var b=new O.util.ByteBuffer(r),x=$.pbe.generatePkcs12Key(t,b,1,n,i),S=$.pbe.generatePkcs12Key(t,b,2,n,i),I=O.des.createEncryptionCipher(x);I.start(S),I.update(A.toDer(e)),I.finish(),u=I.output.getBytes(),o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(Lt["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,r),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,s.getBytes())])])}else{var g=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw g.algorithm=a.algorithm,g}var D=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[o,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,u)]);return D},$.decryptPrivateKeyInfo=function(e,t){var a=null,r={},n=[];if(!A.validate(e,Bo,r,n)){var s=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=A.derToOid(r.encryptionOid),o=$.pbe.getCipher(i,r.encryptionParams,t),u=O.util.createBuffer(r.encryptedData);return o.update(u),o.finish()&&(a=A.fromDer(o.output)),a},$.encryptedPrivateKeyToPem=function(e,t){var a={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(e).getBytes()};return O.pem.encode(a,{maxline:t})},$.encryptedPrivateKeyFromPem=function(e){var t=O.pem.decode(e)[0];if(t.type!=="ENCRYPTED PRIVATE KEY"){var a=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return A.fromDer(t.body)},$.encryptRsaPrivateKey=function(e,t,a){if(a=a||{},!a.legacy){var r=$.wrapRsaPrivateKey($.privateKeyToAsn1(e));return r=$.encryptPrivateKeyInfo(r,t,a),$.encryptedPrivateKeyToPem(r)}var n,s,i,o;switch(a.algorithm){case"aes128":n="AES-128-CBC",i=16,s=O.random.getBytesSync(16),o=O.aes.createEncryptionCipher;break;case"aes192":n="AES-192-CBC",i=24,s=O.random.getBytesSync(16),o=O.aes.createEncryptionCipher;break;case"aes256":n="AES-256-CBC",i=32,s=O.random.getBytesSync(16),o=O.aes.createEncryptionCipher;break;case"3des":n="DES-EDE3-CBC",i=24,s=O.random.getBytesSync(8),o=O.des.createEncryptionCipher;break;case"des":n="DES-CBC",i=8,s=O.random.getBytesSync(8),o=O.des.createEncryptionCipher;break;default:var u=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw u.algorithm=a.algorithm,u}var l=O.pbe.opensslDeriveBytes(t,s.substr(0,8),i),c=o(l);c.start(s),c.update(A.toDer($.privateKeyToAsn1(e))),c.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:O.util.bytesToHex(s).toUpperCase()},body:c.output.getBytes()};return O.pem.encode(f)},$.decryptRsaPrivateKey=function(e,t){var a=null,r=O.pem.decode(e)[0];if(r.type!=="ENCRYPTED PRIVATE KEY"&&r.type!=="PRIVATE KEY"&&r.type!=="RSA PRIVATE KEY"){var n=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".');throw n.headerType=n,n}if(r.procType&&r.procType.type==="ENCRYPTED"){var s,i;switch(r.dekInfo.algorithm){case"DES-CBC":s=8,i=O.des.createDecryptionCipher;break;case"DES-EDE3-CBC":s=24,i=O.des.createDecryptionCipher;break;case"AES-128-CBC":s=16,i=O.aes.createDecryptionCipher;break;case"AES-192-CBC":s=24,i=O.aes.createDecryptionCipher;break;case"AES-256-CBC":s=32,i=O.aes.createDecryptionCipher;break;case"RC2-40-CBC":s=5,i=function(f){return O.rc2.createDecryptionCipher(f,40)};break;case"RC2-64-CBC":s=8,i=function(f){return O.rc2.createDecryptionCipher(f,64)};break;case"RC2-128-CBC":s=16,i=function(f){return O.rc2.createDecryptionCipher(f,128)};break;default:var n=new Error('Could not decrypt private key; unsupported encryption algorithm "'+r.dekInfo.algorithm+'".');throw n.algorithm=r.dekInfo.algorithm,n}var o=O.util.hexToBytes(r.dekInfo.parameters),u=O.pbe.opensslDeriveBytes(t,o.substr(0,8),s),l=i(u);if(l.start(o),l.update(O.util.createBuffer(r.body)),l.finish())a=l.output.getBytes();else return a}else a=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?a=$.decryptPrivateKeyInfo(A.fromDer(a),t):a=A.fromDer(a),a!==null&&(a=$.privateKeyFromAsn1(a)),a},$.pbe.generatePkcs12Key=function(e,t,a,r,n,s){var i,o;if(typeof s>"u"||s===null){if(!("sha1"in O.md))throw new Error('"sha1" hash algorithm unavailable.');s=O.md.sha1.create()}var u=s.digestLength,l=s.blockLength,c=new O.util.ByteBuffer,f=new O.util.ByteBuffer;if(e!=null){for(o=0;o<e.length;o++)f.putInt16(e.charCodeAt(o));f.putInt16(0)}var g=f.length(),m=t.length(),y=new O.util.ByteBuffer;y.fillWithByte(a,l);var x=l*Math.ceil(m/l),S=new O.util.ByteBuffer;for(o=0;o<x;o++)S.putByte(t.at(o%m));var I=l*Math.ceil(g/l),B=new O.util.ByteBuffer;for(o=0;o<I;o++)B.putByte(f.at(o%g));var b=S;b.putBuffer(B);for(var D=Math.ceil(n/u),L=1;L<=D;L++){var R=new O.util.ByteBuffer;R.putBytes(y.bytes()),R.putBytes(b.bytes());for(var q=0;q<r;q++)s.start(),s.update(R.getBytes()),R=s.digest();var X=new O.util.ByteBuffer;for(o=0;o<l;o++)X.putByte(R.at(o%u));var ie=Math.ceil(m/l)+Math.ceil(g/l),ue=new O.util.ByteBuffer;for(i=0;i<ie;i++){var se=new O.util.ByteBuffer(b.getBytes(l)),W=511;for(o=X.length()-1;o>=0;o--)W=W>>8,W+=X.at(o)+se.at(o),se.setAt(o,W&255);ue.putBuffer(se)}b=ue,c.putBuffer(R)}return c.truncate(c.length()-n),c},$.pbe.getCipher=function(e,t,a){switch(e){case $.oids.pkcs5PBES2:return $.pbe.getCipherForPBES2(e,t,a);case $.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case $.oids["pbewithSHAAnd40BitRC2-CBC"]:return $.pbe.getCipherForPKCS12PBE(e,t,a);default:var r=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw r.oid=e,r.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],r}},$.pbe.getCipherForPBES2=function(e,t,a){var r={},n=[];if(!A.validate(t,wo,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}if(e=A.derToOid(r.kdfOid),e!==$.oids.pkcs5PBKDF2){var s=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.");throw s.oid=e,s.supportedOids=["pkcs5PBKDF2"],s}if(e=A.derToOid(r.encOid),e!==$.oids["aes128-CBC"]&&e!==$.oids["aes192-CBC"]&&e!==$.oids["aes256-CBC"]&&e!==$.oids["des-EDE3-CBC"]&&e!==$.oids.desCBC){var s=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.");throw s.oid=e,s.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],s}var i=r.kdfSalt,o=O.util.createBuffer(r.kdfIterationCount);o=o.getInt(o.length()<<3);var u,l;switch($.oids[e]){case"aes128-CBC":u=16,l=O.aes.createDecryptionCipher;break;case"aes192-CBC":u=24,l=O.aes.createDecryptionCipher;break;case"aes256-CBC":u=32,l=O.aes.createDecryptionCipher;break;case"des-EDE3-CBC":u=24,l=O.des.createDecryptionCipher;break;case"desCBC":u=8,l=O.des.createDecryptionCipher;break}var c=pn(r.prfOid),f=O.pkcs5.pbkdf2(a,i,o,u,c),g=r.encIv,m=l(f);return m.start(g),m},$.pbe.getCipherForPKCS12PBE=function(e,t,a){var r={},n=[];if(!A.validate(t,_o,r,n)){var s=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw s.errors=n,s}var i=O.util.createBuffer(r.salt),o=O.util.createBuffer(r.iterations);o=o.getInt(o.length()<<3);var u,l,c;switch(e){case $.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:u=24,l=8,c=O.des.startDecrypting;break;case $.oids["pbewithSHAAnd40BitRC2-CBC"]:u=5,l=8,c=function(x,S){var I=O.rc2.createDecryptionCipher(x,40);return I.start(S,null),I};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var f=pn(r.prfOid),g=$.pbe.generatePkcs12Key(a,i,1,o,u,f);f.start();var m=$.pbe.generatePkcs12Key(a,i,2,o,l,f);return c(g,m)},$.pbe.opensslDeriveBytes=function(e,t,a,r){if(typeof r>"u"||r===null){if(!("md5"in O.md))throw new Error('"md5" hash algorithm unavailable.');r=O.md.md5.create()}t===null&&(t="");for(var n=[hn(r,e+t)],s=16,i=1;s<a;++i,s+=16)n.push(hn(r,n[i-1]+e+t));return n.join("").substr(0,a)};function hn(e,t){return e.start().update(t).digest().getBytes()}function pn(e){var t;if(!e)t="hmacWithSHA1";else if(t=$.oids[A.derToOid(e)],!t){var a=new Error("Unsupported PRF OID.");throw a.oid=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}return gn(t)}function gn(e){var t=O.md;switch(e){case"hmacWithSHA224":t=O.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var a=new Error("Unsupported PRF algorithm.");throw a.algorithm=e,a.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],a}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}function No(e,t,a,r){var n=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,e),A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,t.getBytes())]);return r!=="hmacWithSHA1"&&n.value.push(A.create(A.Class.UNIVERSAL,A.Type.INTEGER,!1,O.util.hexToBytes(a.toString(16))),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer($.oids[r]).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.NULL,!1,"")])),n}var Ht=j,V=Ht.asn1,Gt=Ht.pkcs7asn1=Ht.pkcs7asn1||{};Ht.pkcs7=Ht.pkcs7||{},Ht.pkcs7.asn1=Gt;var yn={name:"ContentInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};Gt.contentInfoValidator=yn;var vn={name:"EncryptedContentInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};Gt.envelopedDataValidator={name:"EnvelopedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(vn)},Gt.encryptedDataValidator={name:"EncryptedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"}].concat(vn)};var Ro={name:"SignerInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:V.Class.UNIVERSAL,type:V.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:V.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};Gt.signedDataValidator={name:"SignedData",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},yn,{name:"SignedData.Certificates",tagClass:V.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:V.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:V.Class.UNIVERSAL,type:V.Type.SET,capture:"signerInfos",optional:!0,value:[Ro]}]},Gt.recipientInfoValidator={name:"RecipientInfo",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:V.Class.UNIVERSAL,type:V.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:V.Class.UNIVERSAL,type:V.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:V.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:V.Class.UNIVERSAL,type:V.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]};var kt=j;kt.mgf=kt.mgf||{};var Lo=kt.mgf.mgf1=kt.mgf1=kt.mgf1||{};Lo.create=function(e){var t={generate:function(a,r){for(var n=new kt.util.ByteBuffer,s=Math.ceil(r/e.digestLength),i=0;i<s;i++){var o=new kt.util.ByteBuffer;o.putInt32(i),e.start(),e.update(a+o.getBytes()),n.putBuffer(e.digest())}return n.truncate(n.length()-r),n.getBytes()}};return t};var br=j;br.mgf=br.mgf||{},br.mgf.mgf1=br.mgf1;var Ut=j,ko=Ut.pss=Ut.pss||{};ko.create=function(e){arguments.length===3&&(e={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var t=e.md,a=e.mgf,r=t.digestLength,n=e.salt||null;typeof n=="string"&&(n=Ut.util.createBuffer(n));var s;if("saltLength"in e)s=e.saltLength;else if(n!==null)s=n.length();else throw new Error("Salt length not specified or specific salt not given.");if(n!==null&&n.length()!==s)throw new Error("Given salt length does not match length of given salt.");var i=e.prng||Ut.random,o={};return o.encode=function(u,l){var c,f=l-1,g=Math.ceil(f/8),m=u.digest().getBytes();if(g<r+s+2)throw new Error("Message is too long to encrypt.");var y;n===null?y=i.getBytesSync(s):y=n.bytes();var x=new Ut.util.ByteBuffer;x.fillWithByte(0,8),x.putBytes(m),x.putBytes(y),t.start(),t.update(x.getBytes());var S=t.digest().getBytes(),I=new Ut.util.ByteBuffer;I.fillWithByte(0,g-s-r-2),I.putByte(1),I.putBytes(y);var B=I.getBytes(),b=g-r-1,D=a.generate(S,b),L="";for(c=0;c<b;c++)L+=String.fromCharCode(B.charCodeAt(c)^D.charCodeAt(c));var R=65280>>8*g-f&255;return L=String.fromCharCode(L.charCodeAt(0)&~R)+L.substr(1),L+S+String.fromCharCode(188)},o.verify=function(u,l,c){var f,g=c-1,m=Math.ceil(g/8);if(l=l.substr(-m),m<r+s+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(l.charCodeAt(m-1)!==188)throw new Error("Encoded message does not end in 0xBC.");var y=m-r-1,x=l.substr(0,y),S=l.substr(y,r),I=65280>>8*m-g&255;if(x.charCodeAt(0)&I)throw new Error("Bits beyond keysize not zero as expected.");var B=a.generate(S,y),b="";for(f=0;f<y;f++)b+=String.fromCharCode(x.charCodeAt(f)^B.charCodeAt(f));b=String.fromCharCode(b.charCodeAt(0)&~I)+b.substr(1);var D=m-r-s-2;for(f=0;f<D;f++)if(b.charCodeAt(f)!==0)throw new Error("Leftmost octets not zero as expected");if(b.charCodeAt(D)!==1)throw new Error("Inconsistent PSS signature, 0x01 marker not found");var L=b.substr(-s),R=new Ut.util.ByteBuffer;R.fillWithByte(0,8),R.putBytes(u),R.putBytes(L),t.start(),t.update(R.getBytes());var q=t.digest().getBytes();return S===q},o};var M=j,d=M.asn1,k=M.pki=M.pki||{},re=k.oids,ye={};ye.CN=re.commonName,ye.commonName="CN",ye.C=re.countryName,ye.countryName="C",ye.L=re.localityName,ye.localityName="L",ye.ST=re.stateOrProvinceName,ye.stateOrProvinceName="ST",ye.O=re.organizationName,ye.organizationName="O",ye.OU=re.organizationalUnitName,ye.organizationalUnitName="OU",ye.E=re.emailAddress,ye.emailAddress="E";var mn=M.pki.rsa.publicKeyValidator,Uo={name:"Certificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:d.Class.UNIVERSAL,type:d.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:d.Class.UNIVERSAL,type:d.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},mn,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},Do={name:"rsapss",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:d.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:d.Class.UNIVERSAL,type:d.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:d.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:d.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:d.Class.UNIVERSAL,type:d.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},Po={name:"CertificationRequestInfo",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:d.Class.UNIVERSAL,type:d.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},mn,{name:"CertificationRequestInfo.attributes",tagClass:d.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:d.Class.UNIVERSAL,type:d.Type.SET,constructed:!0}]}]}]},Vo={name:"CertificationRequest",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[Po,{name:"CertificationRequest.signatureAlgorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:d.Class.UNIVERSAL,type:d.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:d.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:d.Class.UNIVERSAL,type:d.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};k.RDNAttributesAsArray=function(e,t){for(var a=[],r,n,s,i=0;i<e.value.length;++i){r=e.value[i];for(var o=0;o<r.value.length;++o)s={},n=r.value[o],s.type=d.derToOid(n.value[0].value),s.value=n.value[1].value,s.valueTagClass=n.value[1].type,s.type in re&&(s.name=re[s.type],s.name in ye&&(s.shortName=ye[s.name])),t&&(t.update(s.type),t.update(s.value)),a.push(s)}return a},k.CRIAttributesAsArray=function(e){for(var t=[],a=0;a<e.length;++a)for(var r=e[a],n=d.derToOid(r.value[0].value),s=r.value[1].value,i=0;i<s.length;++i){var o={};if(o.type=n,o.value=s[i].value,o.valueTagClass=s[i].type,o.type in re&&(o.name=re[o.type],o.name in ye&&(o.shortName=ye[o.name])),o.type===re.extensionRequest){o.extensions=[];for(var u=0;u<o.value.length;++u)o.extensions.push(k.certificateExtensionFromAsn1(o.value[u]))}t.push(o)}return t};function St(e,t){typeof t=="string"&&(t={shortName:t});for(var a=null,r,n=0;a===null&&n<e.attributes.length;++n)r=e.attributes[n],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(a=r);return a}var Br=function(e,t,a){var r={};if(e!==re["RSASSA-PSS"])return r;a&&(r={hash:{algorithmOid:re.sha1},mgf:{algorithmOid:re.mgf1,hash:{algorithmOid:re.sha1}},saltLength:20});var n={},s=[];if(!d.validate(t,Do,n,s)){var i=new Error("Cannot read RSASSA-PSS parameter block.");throw i.errors=s,i}return n.hashOid!==void 0&&(r.hash=r.hash||{},r.hash.algorithmOid=d.derToOid(n.hashOid)),n.maskGenOid!==void 0&&(r.mgf=r.mgf||{},r.mgf.algorithmOid=d.derToOid(n.maskGenOid),r.mgf.hash=r.mgf.hash||{},r.mgf.hash.algorithmOid=d.derToOid(n.maskGenHashOid)),n.saltLength!==void 0&&(r.saltLength=n.saltLength.charCodeAt(0)),r},wr=function(e){switch(re[e.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return M.md.sha1.create();case"md5WithRSAEncryption":return M.md.md5.create();case"sha256WithRSAEncryption":return M.md.sha256.create();case"sha384WithRSAEncryption":return M.md.sha384.create();case"sha512WithRSAEncryption":return M.md.sha512.create();case"RSASSA-PSS":return M.md.sha256.create();default:var t=new Error("Could not compute "+e.type+" digest. Unknown signature OID.");throw t.signatureOid=e.signatureOid,t}},Cn=function(e){var t=e.certificate,a;switch(t.signatureOid){case re.sha1WithRSAEncryption:case re.sha1WithRSASignature:break;case re["RSASSA-PSS"]:var r,n;if(r=re[t.signatureParameters.mgf.hash.algorithmOid],r===void 0||M.md[r]===void 0){var s=new Error("Unsupported MGF hash function.");throw s.oid=t.signatureParameters.mgf.hash.algorithmOid,s.name=r,s}if(n=re[t.signatureParameters.mgf.algorithmOid],n===void 0||M.mgf[n]===void 0){var s=new Error("Unsupported MGF function.");throw s.oid=t.signatureParameters.mgf.algorithmOid,s.name=n,s}if(n=M.mgf[n].create(M.md[r].create()),r=re[t.signatureParameters.hash.algorithmOid],r===void 0||M.md[r]===void 0){var s=new Error("Unsupported RSASSA-PSS hash function.");throw s.oid=t.signatureParameters.hash.algorithmOid,s.name=r,s}a=M.pss.create(M.md[r].create(),n,t.signatureParameters.saltLength);break}return t.publicKey.verify(e.md.digest().getBytes(),e.signature,a)};k.certificateFromPem=function(e,t,a){var r=M.pem.decode(e)[0];if(r.type!=="CERTIFICATE"&&r.type!=="X509 CERTIFICATE"&&r.type!=="TRUSTED CERTIFICATE"){var n=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return k.certificateFromAsn1(s,t)},k.certificateToPem=function(e,t){var a={type:"CERTIFICATE",body:d.toDer(k.certificateToAsn1(e)).getBytes()};return M.pem.encode(a,{maxline:t})},k.publicKeyFromPem=function(e){var t=M.pem.decode(e)[0];if(t.type!=="PUBLIC KEY"&&t.type!=="RSA PUBLIC KEY"){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert public key from PEM; PEM is encrypted.");var r=d.fromDer(t.body);return k.publicKeyFromAsn1(r)},k.publicKeyToPem=function(e,t){var a={type:"PUBLIC KEY",body:d.toDer(k.publicKeyToAsn1(e)).getBytes()};return M.pem.encode(a,{maxline:t})},k.publicKeyToRSAPublicKeyPem=function(e,t){var a={type:"RSA PUBLIC KEY",body:d.toDer(k.publicKeyToRSAPublicKey(e)).getBytes()};return M.pem.encode(a,{maxline:t})},k.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||M.md.sha1.create(),r=t.type||"RSAPublicKey",n;switch(r){case"RSAPublicKey":n=d.toDer(k.publicKeyToRSAPublicKey(e)).getBytes();break;case"SubjectPublicKeyInfo":n=d.toDer(k.publicKeyToAsn1(e)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+t.type+'".')}a.start(),a.update(n);var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s},k.certificationRequestFromPem=function(e,t,a){var r=M.pem.decode(e)[0];if(r.type!=="CERTIFICATE REQUEST"){var n=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw n.headerType=r.type,n}if(r.procType&&r.procType.type==="ENCRYPTED")throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var s=d.fromDer(r.body,a);return k.certificationRequestFromAsn1(s,t)},k.certificationRequestToPem=function(e,t){var a={type:"CERTIFICATE REQUEST",body:d.toDer(k.certificationRequestToAsn1(e)).getBytes()};return M.pem.encode(a,{maxline:t})},k.createCertificate=function(){var e={};return e.version=2,e.serialNumber="00",e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.validity={},e.validity.notBefore=new Date,e.validity.notAfter=new Date,e.issuer={},e.issuer.getField=function(t){return St(e.issuer,t)},e.issuer.addField=function(t){tt([t]),e.issuer.attributes.push(t)},e.issuer.attributes=[],e.issuer.hash=null,e.subject={},e.subject.getField=function(t){return St(e.subject,t)},e.subject.addField=function(t){tt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.extensions=[],e.publicKey=null,e.md=null,e.setSubject=function(t,a){tt(t),e.subject.attributes=t,delete e.subject.uniqueId,a&&(e.subject.uniqueId=a),e.subject.hash=null},e.setIssuer=function(t,a){tt(t),e.issuer.attributes=t,delete e.issuer.uniqueId,a&&(e.issuer.uniqueId=a),e.issuer.hash=null},e.setExtensions=function(t){for(var a=0;a<t.length;++a)En(t[a],{cert:e});e.extensions=t},e.getExtension=function(t){typeof t=="string"&&(t={name:t});for(var a=null,r,n=0;a===null&&n<e.extensions.length;++n)r=e.extensions[n],(t.id&&r.id===t.id||t.name&&r.name===t.name)&&(a=r);return a},e.sign=function(t,a){e.md=a||M.md.sha1.create();var r=re[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.tbsCertificate=k.getTBSCertificate(e);var s=d.toDer(e.tbsCertificate);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(t){var a=!1;if(!e.issued(t)){var r=t.issuer,n=e.subject,s=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw s.expectedIssuer=n.attributes,s.actualIssuer=r.attributes,s}var i=t.md;if(i===null){i=wr({signatureOid:t.signatureOid,type:"certificate"});var o=t.tbsCertificate||k.getTBSCertificate(t),u=d.toDer(o);i.update(u.getBytes())}return i!==null&&(a=Cn({certificate:e,md:i,signature:t.signature})),a},e.isIssuer=function(t){var a=!1,r=e.issuer,n=t.subject;if(r.hash&&n.hash)a=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){a=!0;for(var s,i,o=0;a&&o<r.attributes.length;++o)s=r.attributes[o],i=n.attributes[o],(s.type!==i.type||s.value!==i.value)&&(a=!1)}return a},e.issued=function(t){return t.isIssuer(e)},e.generateSubjectKeyIdentifier=function(){return k.getPublicKeyFingerprint(e.publicKey,{type:"RSAPublicKey"})},e.verifySubjectKeyIdentifier=function(){for(var t=re.subjectKeyIdentifier,a=0;a<e.extensions.length;++a){var r=e.extensions[a];if(r.id===t){var n=e.generateSubjectKeyIdentifier().getBytes();return M.util.hexToBytes(r.subjectKeyIdentifier)===n}}return!1},e},k.certificateFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Uo,a,r)){var n=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==k.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=k.createCertificate();i.version=a.certVersion?a.certVersion.charCodeAt(0):0;var o=M.util.createBuffer(a.certSerialNumber);i.serialNumber=o.toHex(),i.signatureOid=M.asn1.derToOid(a.certSignatureOid),i.signatureParameters=Br(i.signatureOid,a.certSignatureParams,!0),i.siginfo.algorithmOid=M.asn1.derToOid(a.certinfoSignatureOid),i.siginfo.parameters=Br(i.siginfo.algorithmOid,a.certinfoSignatureParams,!1),i.signature=a.certSignature;var u=[];if(a.certValidity1UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity1UTCTime)),a.certValidity2GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity2GeneralizedTime)),a.certValidity3UTCTime!==void 0&&u.push(d.utcTimeToDate(a.certValidity3UTCTime)),a.certValidity4GeneralizedTime!==void 0&&u.push(d.generalizedTimeToDate(a.certValidity4GeneralizedTime)),u.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(u.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=u[0],i.validity.notAfter=u[1],i.tbsCertificate=a.tbsCertificate,t){i.md=wr({signatureOid:i.signatureOid,type:"certificate"});var l=d.toDer(i.tbsCertificate);i.md.update(l.getBytes())}var c=M.md.sha1.create(),f=d.toDer(a.certIssuer);c.update(f.getBytes()),i.issuer.getField=function(y){return St(i.issuer,y)},i.issuer.addField=function(y){tt([y]),i.issuer.attributes.push(y)},i.issuer.attributes=k.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(i.issuer.uniqueId=a.certIssuerUniqueId),i.issuer.hash=c.digest().toHex();var g=M.md.sha1.create(),m=d.toDer(a.certSubject);return g.update(m.getBytes()),i.subject.getField=function(y){return St(i.subject,y)},i.subject.addField=function(y){tt([y]),i.subject.attributes.push(y)},i.subject.attributes=k.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(i.subject.uniqueId=a.certSubjectUniqueId),i.subject.hash=g.digest().toHex(),a.certExtensions?i.extensions=k.certificateExtensionsFromAsn1(a.certExtensions):i.extensions=[],i.publicKey=k.publicKeyFromAsn1(a.subjectPublicKeyInfo),i},k.certificateExtensionsFromAsn1=function(e){for(var t=[],a=0;a<e.value.length;++a)for(var r=e.value[a],n=0;n<r.value.length;++n)t.push(k.certificateExtensionFromAsn1(r.value[n]));return t},k.certificateExtensionFromAsn1=function(e){var t={};if(t.id=d.derToOid(e.value[0].value),t.critical=!1,e.value[1].type===d.Type.BOOLEAN?(t.critical=e.value[1].value.charCodeAt(0)!==0,t.value=e.value[2].value):t.value=e.value[1].value,t.id in re){if(t.name=re[t.id],t.name==="keyUsage"){var a=d.fromDer(t.value),r=0,n=0;a.value.length>1&&(r=a.value.charCodeAt(1),n=a.value.length>2?a.value.charCodeAt(2):0),t.digitalSignature=(r&128)===128,t.nonRepudiation=(r&64)===64,t.keyEncipherment=(r&32)===32,t.dataEncipherment=(r&16)===16,t.keyAgreement=(r&8)===8,t.keyCertSign=(r&4)===4,t.cRLSign=(r&2)===2,t.encipherOnly=(r&1)===1,t.decipherOnly=(n&128)===128}else if(t.name==="basicConstraints"){var a=d.fromDer(t.value);a.value.length>0&&a.value[0].type===d.Type.BOOLEAN?t.cA=a.value[0].value.charCodeAt(0)!==0:t.cA=!1;var s=null;a.value.length>0&&a.value[0].type===d.Type.INTEGER?s=a.value[0].value:a.value.length>1&&(s=a.value[1].value),s!==null&&(t.pathLenConstraint=d.derToInteger(s))}else if(t.name==="extKeyUsage")for(var a=d.fromDer(t.value),i=0;i<a.value.length;++i){var o=d.derToOid(a.value[i].value);o in re?t[re[o]]=!0:t[o]=!0}else if(t.name==="nsCertType"){var a=d.fromDer(t.value),r=0;a.value.length>1&&(r=a.value.charCodeAt(1)),t.client=(r&128)===128,t.server=(r&64)===64,t.email=(r&32)===32,t.objsign=(r&16)===16,t.reserved=(r&8)===8,t.sslCA=(r&4)===4,t.emailCA=(r&2)===2,t.objCA=(r&1)===1}else if(t.name==="subjectAltName"||t.name==="issuerAltName"){t.altNames=[];for(var u,a=d.fromDer(t.value),l=0;l<a.value.length;++l){u=a.value[l];var c={type:u.type,value:u.value};switch(t.altNames.push(c),u.type){case 1:case 2:case 6:break;case 7:c.ip=M.util.bytesToIP(u.value);break;case 8:c.oid=d.derToOid(u.value);break}}}else if(t.name==="subjectKeyIdentifier"){var a=d.fromDer(t.value);t.subjectKeyIdentifier=M.util.bytesToHex(a.value)}}return t},k.certificationRequestFromAsn1=function(e,t){var a={},r=[];if(!d.validate(e,Vo,a,r)){var n=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw n.errors=r,n}var s=d.derToOid(a.publicKeyOid);if(s!==k.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var i=k.createCertificationRequest();if(i.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,i.signatureOid=M.asn1.derToOid(a.csrSignatureOid),i.signatureParameters=Br(i.signatureOid,a.csrSignatureParams,!0),i.siginfo.algorithmOid=M.asn1.derToOid(a.csrSignatureOid),i.siginfo.parameters=Br(i.siginfo.algorithmOid,a.csrSignatureParams,!1),i.signature=a.csrSignature,i.certificationRequestInfo=a.certificationRequestInfo,t){i.md=wr({signatureOid:i.signatureOid,type:"certification request"});var o=d.toDer(i.certificationRequestInfo);i.md.update(o.getBytes())}var u=M.md.sha1.create();return i.subject.getField=function(l){return St(i.subject,l)},i.subject.addField=function(l){tt([l]),i.subject.attributes.push(l)},i.subject.attributes=k.RDNAttributesAsArray(a.certificationRequestInfoSubject,u),i.subject.hash=u.digest().toHex(),i.publicKey=k.publicKeyFromAsn1(a.subjectPublicKeyInfo),i.getAttribute=function(l){return St(i,l)},i.addAttribute=function(l){tt([l]),i.attributes.push(l)},i.attributes=k.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),i},k.createCertificationRequest=function(){var e={};return e.version=0,e.signatureOid=null,e.signature=null,e.siginfo={},e.siginfo.algorithmOid=null,e.subject={},e.subject.getField=function(t){return St(e.subject,t)},e.subject.addField=function(t){tt([t]),e.subject.attributes.push(t)},e.subject.attributes=[],e.subject.hash=null,e.publicKey=null,e.attributes=[],e.getAttribute=function(t){return St(e,t)},e.addAttribute=function(t){tt([t]),e.attributes.push(t)},e.md=null,e.setSubject=function(t){tt(t),e.subject.attributes=t,e.subject.hash=null},e.setAttributes=function(t){tt(t),e.attributes=t},e.sign=function(t,a){e.md=a||M.md.sha1.create();var r=re[e.md.algorithm+"WithRSAEncryption"];if(!r){var n=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw n.algorithm=e.md.algorithm,n}e.signatureOid=e.siginfo.algorithmOid=r,e.certificationRequestInfo=k.getCertificationRequestInfo(e);var s=d.toDer(e.certificationRequestInfo);e.md.update(s.getBytes()),e.signature=t.sign(e.md)},e.verify=function(){var t=!1,a=e.md;if(a===null){a=wr({signatureOid:e.signatureOid,type:"certification request"});var r=e.certificationRequestInfo||k.getCertificationRequestInfo(e),n=d.toDer(r);a.update(n.getBytes())}return a!==null&&(t=Cn({certificate:e,md:a,signature:e.signature})),t},e};function qt(e){for(var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),a,r,n=e.attributes,s=0;s<n.length;++s){a=n[s];var i=a.value,o=d.Type.PRINTABLESTRING;"valueTagClass"in a&&(o=a.valueTagClass,o===d.Type.UTF8&&(i=M.util.encodeUtf8(i))),r=d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(a.type).getBytes()),d.create(d.Class.UNIVERSAL,o,!1,i)])]),t.value.push(r)}return t}function tt(e){for(var t,a=0;a<e.length;++a){if(t=e[a],typeof t.name>"u"&&(t.type&&t.type in k.oids?t.name=k.oids[t.type]:t.shortName&&t.shortName in ye&&(t.name=k.oids[ye[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in k.oids)t.type=k.oids[t.name];else{var r=new Error("Attribute type not specified.");throw r.attribute=t,r}if(typeof t.shortName>"u"&&t.name&&t.name in ye&&(t.shortName=ye[t.name]),t.type===re.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=d.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n<t.extensions.length;++n)t.value.push(k.certificateExtensionToAsn1(En(t.extensions[n])))}if(typeof t.value>"u"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function En(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in k.oids&&(e.name=k.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in k.oids)e.id=k.oids[e.name];else{var a=new Error("Extension ID not specified.");throw a.extension=e,a}if(typeof e.value<"u")return e;if(e.name==="keyUsage"){var r=0,n=0,s=0;e.digitalSignature&&(n|=128,r=7),e.nonRepudiation&&(n|=64,r=6),e.keyEncipherment&&(n|=32,r=5),e.dataEncipherment&&(n|=16,r=4),e.keyAgreement&&(n|=8,r=3),e.keyCertSign&&(n|=4,r=2),e.cRLSign&&(n|=2,r=1),e.encipherOnly&&(n|=1,r=0),e.decipherOnly&&(s|=128,r=7);var i=String.fromCharCode(r);s!==0?i+=String.fromCharCode(n)+String.fromCharCode(s):n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="basicConstraints")e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var u in e)e[u]===!0&&(u in re?o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(re[u]).getBytes())):u.indexOf(".")!==-1&&o.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(u).getBytes())))}else if(e.name==="nsCertType"){var r=0,n=0;e.client&&(n|=128,r=7),e.server&&(n|=64,r=6),e.email&&(n|=32,r=5),e.objsign&&(n|=16,r=4),e.reserved&&(n|=8,r=3),e.sslCA&&(n|=4,r=2),e.emailCA&&(n|=2,r=1),e.objCA&&(n|=1,r=0);var i=String.fromCharCode(r);n!==0&&(i+=String.fromCharCode(n)),e.value=d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,i)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=M.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));e.value.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}}else if(e.name==="nsComment"&&t.cert){if(!/^[\x00-\x7F]*$/.test(e.comment)||e.comment.length<1||e.comment.length>128)throw new Error('Invalid "nsComment" content.');e.value=d.create(d.Class.UNIVERSAL,d.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var f=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=f.toHex(),e.value=d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,f.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var g=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!1,g))}if(e.authorityCertIssuer){var m=[d.create(d.Class.CONTEXT_SPECIFIC,4,!0,[qt(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,m))}if(e.serialNumber){var y=M.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);for(var o=e.value.value,x=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]),S=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]),l,c=0;c<e.altNames.length;++c){l=e.altNames[c];var i=l.value;if(l.type===7&&l.ip){if(i=M.util.bytesFromIP(l.ip),i===null){var a=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.');throw a.extension=e,a}}else l.type===8&&(l.oid?i=d.oidToDer(d.oidToDer(l.oid)):i=d.oidToDer(i));S.value.push(d.create(d.Class.CONTEXT_SPECIFIC,l.type,!1,i))}x.value.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[S])),o.push(x)}if(typeof e.value>"u"){var a=new Error("Extension value not specified.");throw a.extension=e,a}return e}function na(e,t){switch(e){case re["RSASSA-PSS"]:var a=[];return t.hash.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(t.mgf.hash.algorithmOid).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&a.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(t.saltLength).getBytes())])),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,a);default:return d.create(d.Class.UNIVERSAL,d.Type.NULL,!1,"")}}function Oo(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var a=e.attributes,r=0;r<a.length;++r){var n=a[r],s=n.value,i=d.Type.UTF8;"valueTagClass"in n&&(i=n.valueTagClass),i===d.Type.UTF8&&(s=M.util.encodeUtf8(s));var o=!1;"valueConstructed"in n&&(o=n.valueConstructed);var u=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(n.type).getBytes()),d.create(d.Class.UNIVERSAL,d.Type.SET,!0,[d.create(d.Class.UNIVERSAL,i,o,s)])]);t.value.push(u)}return t}var Ko=new Date("1950-01-01T00:00:00Z"),Fo=new Date("2050-01-01T00:00:00Z");function xn(e){return e>=Ko&&e<Fo?d.create(d.Class.UNIVERSAL,d.Type.UTCTIME,!1,d.dateToUtcTime(e)):d.create(d.Class.UNIVERSAL,d.Type.GENERALIZEDTIME,!1,d.dateToGeneralizedTime(e))}k.getTBSCertificate=function(e){var t=xn(e.validity.notBefore),a=xn(e.validity.notAfter),r=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.CONTEXT_SPECIFIC,0,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes())]),d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,M.util.hexToBytes(e.serialNumber)),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.siginfo.algorithmOid).getBytes()),na(e.siginfo.algorithmOid,e.siginfo.parameters)]),qt(e.issuer),d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,a]),qt(e.subject),k.publicKeyToAsn1(e.publicKey)]);return e.issuer.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,1,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.issuer.uniqueId)])),e.subject.uniqueId&&r.value.push(d.create(d.Class.CONTEXT_SPECIFIC,2,!0,[d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.subject.uniqueId)])),e.extensions.length>0&&r.value.push(k.certificateExtensionsToAsn1(e.extensions)),r},k.getCertificationRequestInfo=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.INTEGER,!1,d.integerToDer(e.version).getBytes()),qt(e.subject),k.publicKeyToAsn1(e.publicKey),Oo(e)]);return t},k.distinguishedNameToAsn1=function(e){return qt(e)},k.certificateToAsn1=function(e){var t=e.tbsCertificate||k.getTBSCertificate(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),na(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},k.certificateExtensionsToAsn1=function(e){var t=d.create(d.Class.CONTEXT_SPECIFIC,3,!0,[]),a=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(a);for(var r=0;r<e.length;++r)a.value.push(k.certificateExtensionToAsn1(e[r]));return t},k.certificateExtensionToAsn1=function(e){var t=d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[]);t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.id).getBytes())),e.critical&&t.value.push(d.create(d.Class.UNIVERSAL,d.Type.BOOLEAN,!1,String.fromCharCode(255)));var a=e.value;return typeof e.value!="string"&&(a=d.toDer(a).getBytes()),t.value.push(d.create(d.Class.UNIVERSAL,d.Type.OCTETSTRING,!1,a)),t},k.certificationRequestToAsn1=function(e){var t=e.certificationRequestInfo||k.getCertificationRequestInfo(e);return d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[t,d.create(d.Class.UNIVERSAL,d.Type.SEQUENCE,!0,[d.create(d.Class.UNIVERSAL,d.Type.OID,!1,d.oidToDer(e.signatureOid).getBytes()),na(e.signatureOid,e.signatureParameters)]),d.create(d.Class.UNIVERSAL,d.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},k.createCaStore=function(e){var t={certs:{}};t.getIssuer=function(i){var o=a(i.issuer);return o},t.addCertificate=function(i){if(typeof i=="string"&&(i=M.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))if(i.subject.hash in t.certs){var o=t.certs[i.subject.hash];M.util.isArray(o)||(o=[o]),o.push(i),t.certs[i.subject.hash]=o}else t.certs[i.subject.hash]=i},t.hasCertificate=function(i){typeof i=="string"&&(i=M.pki.certificateFromPem(i));var o=a(i.subject);if(!o)return!1;M.util.isArray(o)||(o=[o]);for(var u=d.toDer(k.certificateToAsn1(i)).getBytes(),l=0;l<o.length;++l){var c=d.toDer(k.certificateToAsn1(o[l])).getBytes();if(u===c)return!0}return!1},t.listAllCertificates=function(){var i=[];for(var o in t.certs)if(t.certs.hasOwnProperty(o)){var u=t.certs[o];if(!M.util.isArray(u))i.push(u);else for(var l=0;l<u.length;++l)i.push(u[l])}return i},t.removeCertificate=function(i){var o;if(typeof i=="string"&&(i=M.pki.certificateFromPem(i)),r(i.subject),!t.hasCertificate(i))return null;var u=a(i.subject);if(!M.util.isArray(u))return o=t.certs[i.subject.hash],delete t.certs[i.subject.hash],o;for(var l=d.toDer(k.certificateToAsn1(i)).getBytes(),c=0;c<u.length;++c){var f=d.toDer(k.certificateToAsn1(u[c])).getBytes();l===f&&(o=u[c],u.splice(c,1))}return u.length===0&&delete t.certs[i.subject.hash],o};function a(i){return r(i),t.certs[i.hash]||null}function r(i){if(!i.hash){var o=M.md.sha1.create();i.attributes=k.RDNAttributesAsArray(qt(i),o),i.hash=o.digest().toHex()}}if(e)for(var n=0;n<e.length;++n){var s=e[n];t.addCertificate(s)}return t},k.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},k.verifyCertificateChain=function(e,t,a){typeof a=="function"&&(a={verify:a}),a=a||{},t=t.slice(0);var r=t.slice(0),n=a.validityCheckDate;typeof n>"u"&&(n=new Date);var s=!0,i=null,o=0;do{var u=t.shift(),l=null,c=!1;if(n&&(n<u.validity.notBefore||n>u.validity.notAfter)&&(i={message:"Certificate is not valid yet or has expired.",error:k.certificateError.certificate_expired,notBefore:u.validity.notBefore,notAfter:u.validity.notAfter,now:n}),i===null){if(l=t[0]||e.getIssuer(u),l===null&&u.isIssuer(u)&&(c=!0,l=u),l){var f=l;M.util.isArray(f)||(f=[f]);for(var g=!1;!g&&f.length>0;){l=f.shift();try{g=l.verify(u)}catch{}}g||(i={message:"Certificate signature is invalid.",error:k.certificateError.bad_certificate})}i===null&&(!l||c)&&!e.hasCertificate(u)&&(i={message:"Certificate is not trusted.",error:k.certificateError.unknown_ca})}if(i===null&&l&&!u.isIssuer(l)&&(i={message:"Certificate issuer is invalid.",error:k.certificateError.bad_certificate}),i===null)for(var m={keyUsage:!0,basicConstraints:!0},y=0;i===null&&y<u.extensions.length;++y){var x=u.extensions[y];x.critical&&!(x.name in m)&&(i={message:"Certificate has an unsupported critical extension.",error:k.certificateError.unsupported_certificate})}if(i===null&&(!s||t.length===0&&(!l||c))){var S=u.getExtension("basicConstraints"),I=u.getExtension("keyUsage");if(I!==null&&(!I.keyCertSign||S===null)&&(i={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:k.certificateError.bad_certificate}),i===null&&S!==null&&!S.cA&&(i={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:k.certificateError.bad_certificate}),i===null&&I!==null&&"pathLenConstraint"in S){var B=o-1;B>S.pathLenConstraint&&(i={message:"Certificate basicConstraints pathLenConstraint violated.",error:k.certificateError.bad_certificate})}}var b=i===null?!0:i.error,D=a.verify?a.verify(b,o,r):b;if(D===!0)i=null;else throw b===!0&&(i={message:"The application rejected the certificate.",error:k.certificateError.bad_certificate}),(D||D===0)&&(typeof D=="object"&&!M.util.isArray(D)?(D.message&&(i.message=D.message),D.error&&(i.error=D.error)):typeof D=="string"&&(i.error=D)),i;s=!1,++o}while(t.length>0);return!0};var de=j,v=de.asn1,J=de.pki,nr=de.pkcs12=de.pkcs12||{},Sn={name:"ContentInfo",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:v.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},Mo={name:"PFX",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:v.Class.UNIVERSAL,type:v.Type.INTEGER,constructed:!1,capture:"version"},Sn,{name:"PFX.macData",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:v.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:v.Class.UNIVERSAL,type:v.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:v.Class.UNIVERSAL,type:v.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:v.Class.UNIVERSAL,type:v.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},Ho={name:"SafeBag",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:v.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:v.Class.UNIVERSAL,type:v.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},Go={name:"Attribute",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:v.Class.UNIVERSAL,type:v.Type.SET,constructed:!0,capture:"values"}]},qo={name:"CertBag",tagClass:v.Class.UNIVERSAL,type:v.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:v.Class.UNIVERSAL,type:v.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:v.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:v.Class.UNIVERSAL,type:v.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function ir(e,t,a,r){for(var n=[],s=0;s<e.length;s++)for(var i=0;i<e[s].safeBags.length;i++){var o=e[s].safeBags[i];if(!(r!==void 0&&o.type!==r)){if(t===null){n.push(o);continue}o.attributes[t]!==void 0&&o.attributes[t].indexOf(a)>=0&&n.push(o)}}return n}nr.pkcs12FromAsn1=function(e,t,a){typeof t=="string"?(a=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!v.validate(e,Mo,r,n)){var s=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.");throw s.errors=s,s}var i={version:r.version.charCodeAt(0),safeContents:[],getBags:function(S){var I={},B;return"localKeyId"in S?B=S.localKeyId:"localKeyIdHex"in S&&(B=de.util.hexToBytes(S.localKeyIdHex)),B===void 0&&!("friendlyName"in S)&&"bagType"in S&&(I[S.bagType]=ir(i.safeContents,null,null,S.bagType)),B!==void 0&&(I.localKeyId=ir(i.safeContents,"localKeyId",B,S.bagType)),"friendlyName"in S&&(I.friendlyName=ir(i.safeContents,"friendlyName",S.friendlyName,S.bagType)),I},getBagsByFriendlyName:function(S,I){return ir(i.safeContents,"friendlyName",S,I)},getBagsByLocalKeyId:function(S,I){return ir(i.safeContents,"localKeyId",S,I)}};if(r.version.charCodeAt(0)!==3){var s=new Error("PKCS#12 PFX of version other than 3 not supported.");throw s.version=r.version.charCodeAt(0),s}if(v.derToOid(r.contentType)!==J.oids.data){var s=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw s.oid=v.derToOid(r.contentType),s}var o=r.content.value[0];if(o.tagClass!==v.Class.UNIVERSAL||o.type!==v.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=ia(o),r.mac){var u=null,l=0,c=v.derToOid(r.macAlgorithm);switch(c){case J.oids.sha1:u=de.md.sha1.create(),l=20;break;case J.oids.sha256:u=de.md.sha256.create(),l=32;break;case J.oids.sha384:u=de.md.sha384.create(),l=48;break;case J.oids.sha512:u=de.md.sha512.create(),l=64;break;case J.oids.md5:u=de.md.md5.create(),l=16;break}if(u===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+c);var f=new de.util.ByteBuffer(r.macSalt),g="macIterations"in r?parseInt(de.util.bytesToHex(r.macIterations),16):1,m=nr.generateKey(a,f,3,g,l,u),y=de.hmac.create();y.start(u,m),y.update(o.value);var x=y.getMac();if(x.getBytes()!==r.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return zo(i,o.value,t,a),i};function ia(e){if(e.composed||e.constructed){for(var t=de.util.createBuffer(),a=0;a<e.value.length;++a)t.putBytes(e.value[a].value);e.composed=e.constructed=!1,e.value=t.getBytes()}return e}function zo(e,t,a,r){if(t=v.fromDer(t,a),t.tagClass!==v.Class.UNIVERSAL||t.type!==v.Type.SEQUENCE||t.constructed!==!0)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var n=0;n<t.value.length;n++){var s=t.value[n],i={},o=[];if(!v.validate(s,Sn,i,o)){var u=new Error("Cannot read ContentInfo.");throw u.errors=o,u}var l={encrypted:!1},c=null,f=i.content.value[0];switch(v.derToOid(i.contentType)){case J.oids.data:if(f.tagClass!==v.Class.UNIVERSAL||f.type!==v.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");c=ia(f).value;break;case J.oids.encryptedData:c=Qo(f,r),l.encrypted=!0;break;default:var u=new Error("Unsupported PKCS#12 contentType.");throw u.contentType=v.derToOid(i.contentType),u}l.safeBags=Wo(c,a,r),e.safeContents.push(l)}}function Qo(e,t){var a={},r=[];if(!v.validate(e,de.pkcs7.asn1.encryptedDataValidator,a,r)){var n=new Error("Cannot read EncryptedContentInfo.");throw n.errors=r,n}var s=v.derToOid(a.contentType);if(s!==J.oids.data){var n=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.");throw n.oid=s,n}s=v.derToOid(a.encAlgorithm);var i=J.pbe.getCipher(s,a.encParameter,t),o=ia(a.encryptedContentAsn1),u=de.util.createBuffer(o.value);if(i.update(u),!i.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return i.output.getBytes()}function Wo(e,t,a){if(!t&&e.length===0)return[];if(e=v.fromDer(e,t),e.tagClass!==v.Class.UNIVERSAL||e.type!==v.Type.SEQUENCE||e.constructed!==!0)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var r=[],n=0;n<e.value.length;n++){var s=e.value[n],i={},o=[];if(!v.validate(s,Ho,i,o)){var u=new Error("Cannot read SafeBag.");throw u.errors=o,u}var l={type:v.derToOid(i.bagId),attributes:$o(i.bagAttributes)};r.push(l);var c,f,g=i.bagValue.value[0];switch(l.type){case J.oids.pkcs8ShroudedKeyBag:if(g=J.decryptPrivateKeyInfo(g,a),g===null)throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case J.oids.keyBag:try{l.key=J.privateKeyFromAsn1(g)}catch{l.key=null,l.asn1=g}continue;case J.oids.certBag:c=qo,f=function(){if(v.derToOid(i.certId)!==J.oids.x509Certificate){var y=new Error("Unsupported certificate type, only X.509 supported.");throw y.oid=v.derToOid(i.certId),y}var x=v.fromDer(i.cert,t);try{l.cert=J.certificateFromAsn1(x,!0)}catch{l.cert=null,l.asn1=x}};break;default:var u=new Error("Unsupported PKCS#12 SafeBag type.");throw u.oid=l.type,u}if(c!==void 0&&!v.validate(g,c,i,o)){var u=new Error("Cannot read PKCS#12 "+c.name);throw u.errors=o,u}f()}return r}function $o(e){var t={};if(e!==void 0)for(var a=0;a<e.length;++a){var r={},n=[];if(!v.validate(e[a],Go,r,n)){var s=new Error("Cannot read PKCS#12 BagAttribute.");throw s.errors=n,s}var i=v.derToOid(r.oid);if(J.oids[i]!==void 0){t[J.oids[i]]=[];for(var o=0;o<r.values.length;++o)t[J.oids[i]].push(r.values[o].value)}}return t}nr.toPkcs12Asn1=function(e,t,a,r){r=r||{},r.saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||r.encAlgorithm||"aes128","useMac"in r||(r.useMac=!0),"localKeyId"in r||(r.localKeyId=null),"generateLocalKeyId"in r||(r.generateLocalKeyId=!0);var n=r.localKeyId,s;if(n!==null)n=de.util.hexToBytes(n);else if(r.generateLocalKeyId)if(t){var i=de.util.isArray(t)?t[0]:t;typeof i=="string"&&(i=J.certificateFromPem(i));var o=de.md.sha1.create();o.update(v.toDer(J.certificateToAsn1(i)).getBytes()),n=o.digest().getBytes()}else n=de.random.getBytes(20);var u=[];n!==null&&u.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.localKeyId).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,n)])])),"friendlyName"in r&&u.push(v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.friendlyName).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SET,!0,[v.create(v.Class.UNIVERSAL,v.Type.BMPSTRING,!1,r.friendlyName)])])),u.length>0&&(s=v.create(v.Class.UNIVERSAL,v.Type.SET,!0,u));var l=[],c=[];t!==null&&(de.util.isArray(t)?c=t:c=[t]);for(var f=[],g=0;g<c.length;++g){t=c[g],typeof t=="string"&&(t=J.certificateFromPem(t));var m=g===0?s:void 0,y=J.certificateToAsn1(t),x=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.certBag).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.x509Certificate).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,v.toDer(y).getBytes())])])]),m]);f.push(x)}if(f.length>0){var S=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,f),I=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.data).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,v.toDer(S).getBytes())])]);l.push(I)}var B=null;if(e!==null){var b=J.wrapRsaPrivateKey(J.privateKeyToAsn1(e));a===null?B=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.keyBag).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[b]),s]):B=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.pkcs8ShroudedKeyBag).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[J.encryptPrivateKeyInfo(b,a,r)]),s]);var D=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[B]),L=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.data).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,v.toDer(D).getBytes())])]);l.push(L)}var R=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,l),q;if(r.useMac){var o=de.md.sha1.create(),X=new de.util.ByteBuffer(de.random.getBytes(r.saltSize)),ie=r.count,e=nr.generateKey(a,X,3,ie,20),ue=de.hmac.create();ue.start(o,e),ue.update(v.toDer(R).getBytes());var se=ue.getMac();q=v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.sha1).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.NULL,!1,"")]),v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,se.getBytes())]),v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,X.getBytes()),v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(ie).getBytes())])}return v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.INTEGER,!1,v.integerToDer(3).getBytes()),v.create(v.Class.UNIVERSAL,v.Type.SEQUENCE,!0,[v.create(v.Class.UNIVERSAL,v.Type.OID,!1,v.oidToDer(J.oids.data).getBytes()),v.create(v.Class.CONTEXT_SPECIFIC,0,!0,[v.create(v.Class.UNIVERSAL,v.Type.OCTETSTRING,!1,v.toDer(R).getBytes())])]),q])},nr.generateKey=de.pbe.generatePkcs12Key;var Tt=j,sa=Tt.asn1,zt=Tt.pki=Tt.pki||{};zt.pemToDer=function(e){var t=Tt.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return Tt.util.createBuffer(t.body)},zt.privateKeyFromPem=function(e){var t=Tt.pem.decode(e)[0];if(t.type!=="PRIVATE KEY"&&t.type!=="RSA PRIVATE KEY"){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert private key from PEM; PEM is encrypted.");var r=sa.fromDer(t.body);return zt.privateKeyFromAsn1(r)},zt.privateKeyToPem=function(e,t){var a={type:"RSA PRIVATE KEY",body:sa.toDer(zt.privateKeyToAsn1(e)).getBytes()};return Tt.pem.encode(a,{maxline:t})},zt.privateKeyInfoToPem=function(e,t){var a={type:"PRIVATE KEY",body:sa.toDer(e).getBytes()};return Tt.pem.encode(a,{maxline:t})};var _=j,_r=function(e,t,a,r){var n=_.util.createBuffer(),s=e.length>>1,i=s+(e.length&1),o=e.substr(0,i),u=e.substr(s,i),l=_.util.createBuffer(),c=_.hmac.create();a=t+a;var f=Math.ceil(r/16),g=Math.ceil(r/20);c.start("MD5",o);var m=_.util.createBuffer();l.putBytes(a);for(var y=0;y<f;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),m.putBuffer(c.digest());c.start("SHA1",u);var x=_.util.createBuffer();l.clear(),l.putBytes(a);for(var y=0;y<g;++y)c.start(null,null),c.update(l.getBytes()),l.putBuffer(c.digest()),c.start(null,null),c.update(l.bytes()+a),x.putBuffer(c.digest());return n.putBytes(_.util.xorBytes(m.getBytes(),x.getBytes(),r)),n},Yo=function(e,t,a){var r=_.hmac.create();r.start("SHA1",e);var n=_.util.createBuffer();return n.putInt32(t[0]),n.putInt32(t[1]),n.putByte(a.type),n.putByte(a.version.major),n.putByte(a.version.minor),n.putInt16(a.length),n.putBytes(a.fragment.bytes()),r.update(n.getBytes()),r.digest().getBytes()},jo=function(e,t,a){var r=!1;try{var n=e.deflate(t.fragment.getBytes());t.fragment=_.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},Xo=function(e,t,a){var r=!1;try{var n=e.inflate(t.fragment.getBytes());t.fragment=_.util.createBuffer(n),t.length=n.length,r=!0}catch{}return r},Xe=function(e,t){var a=0;switch(t){case 1:a=e.getByte();break;case 2:a=e.getInt16();break;case 3:a=e.getInt24();break;case 4:a=e.getInt32();break}return _.util.createBuffer(e.getBytes(a))},rt=function(e,t,a){e.putInt(a.length(),t<<3),e.putBuffer(a)},p={};p.Versions={TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}},p.SupportedVersions=[p.Versions.TLS_1_1,p.Versions.TLS_1_0],p.Version=p.SupportedVersions[0],p.MaxFragment=16384-1024,p.ConnectionEnd={server:0,client:1},p.PRFAlgorithm={tls_prf_sha256:0},p.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},p.CipherType={stream:0,block:1,aead:2},p.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},p.CompressionMethod={none:0,deflate:1},p.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},p.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},p.Alert={},p.Alert.Level={warning:1,fatal:2},p.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},p.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},p.CipherSuites={},p.getCipherSuite=function(e){var t=null;for(var a in p.CipherSuites){var r=p.CipherSuites[a];if(r.id[0]===e.charCodeAt(0)&&r.id[1]===e.charCodeAt(1)){t=r;break}}return t},p.handleUnexpected=function(e,t){var a=!e.open&&e.entity===p.ConnectionEnd.client;a||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})},p.handleHelloRequest=function(e,t,a){!e.handshaking&&e.handshakes>0&&(p.queue(e,p.createAlert(e,{level:p.Alert.Level.warning,description:p.Alert.Description.no_renegotiation})),p.flush(e)),e.process()},p.parseHelloMessage=function(e,t,a){var r=null,n=e.entity===p.ConnectionEnd.client;if(a<38)e.error(e,{message:n?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});else{var s=t.fragment,i=s.length();if(r={version:{major:s.getByte(),minor:s.getByte()},random:_.util.createBuffer(s.getBytes(32)),session_id:Xe(s,1),extensions:[]},n?(r.cipher_suite=s.getBytes(2),r.compression_method=s.getByte()):(r.cipher_suites=Xe(s,2),r.compression_methods=Xe(s,1)),i=a-(i-s.length()),i>0){for(var o=Xe(s,2);o.length()>0;)r.extensions.push({type:[o.getByte(),o.getByte()],data:Xe(o,2)});if(!n)for(var u=0;u<r.extensions.length;++u){var l=r.extensions[u];if(l.type[0]===0&&l.type[1]===0)for(var c=Xe(l.data,2);c.length()>0;){var f=c.getByte();if(f!==0)break;e.session.extensions.server_name.serverNameList.push(Xe(c,2).getBytes())}}}if(e.session.version&&(r.version.major!==e.session.version.major||r.version.minor!==e.session.version.minor))return e.error(e,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});if(n)e.session.cipherSuite=p.getCipherSuite(r.cipher_suite);else for(var g=_.util.createBuffer(r.cipher_suites.bytes());g.length()>0&&(e.session.cipherSuite=p.getCipherSuite(g.getBytes(2)),e.session.cipherSuite===null););if(e.session.cipherSuite===null)return e.error(e,{message:"No cipher suites in common.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure},cipherSuite:_.util.bytesToHex(r.cipher_suite)});n?e.session.compressionMethod=r.compression_method:e.session.compressionMethod=p.CompressionMethod.none}return r},p.createSecurityParameters=function(e,t){var a=e.entity===p.ConnectionEnd.client,r=t.random.bytes(),n=a?e.session.sp.client_random:r,s=a?r:p.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:p.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:n,server_random:s}},p.handleServerHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){if(r.version.minor<=e.version.minor)e.version.minor=r.version.minor;else return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}});e.session.version=e.version;var n=r.session_id.bytes();n.length>0&&n===e.session.id?(e.expect=In,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=Jo,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.session.id=n,e.process()}},p.handleClientHello=function(e,t,a){var r=p.parseHelloMessage(e,t,a);if(!e.fail){var n=r.session_id.bytes(),s=null;if(e.sessionCache&&(s=e.sessionCache.getSession(n),s===null?n="":(s.version.major!==r.version.major||s.version.minor>r.version.minor)&&(s=null,n="")),n.length===0&&(n=_.random.getBytes(32)),e.session.id=n,e.session.clientHelloVersion=r.version,e.session.sp={},s)e.version=e.session.version=s.version,e.session.sp=s.sp;else{for(var i,o=1;o<p.SupportedVersions.length&&(i=p.SupportedVersions[o],!(i.minor<=r.version.minor));++o);e.version={major:i.major,minor:i.minor},e.session.version=e.version}s!==null?(e.expect=la,e.session.resuming=!0,e.session.sp.client_random=r.random.bytes()):(e.expect=e.verifyClient!==!1?s0:oa,e.session.resuming=!1,p.createSecurityParameters(e,r)),e.open=!0,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHello(e)})),e.session.resuming?(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.pending=p.createConnectionState(e),e.state.current.write=e.state.pending.write,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))):(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)})),e.fail||(p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerKeyExchange(e)})),e.verifyClient!==!1&&p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificateRequest(e)})),p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createServerHelloDone(e)})))),p.flush(e),e.process()}},p.handleCertificate=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_list:Xe(r,3)},s,i,o=[];try{for(;n.certificate_list.length()>0;)s=Xe(n.certificate_list,3),i=_.asn1.fromDer(s),s=_.pki.certificateFromAsn1(i,!0),o.push(s)}catch(l){return e.error(e,{message:"Could not parse certificate list.",cause:l,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var u=e.entity===p.ConnectionEnd.client;(u||e.verifyClient===!0)&&o.length===0?e.error(e,{message:u?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}}):o.length===0?e.expect=u?Tn:oa:(u?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],p.verifyCertificateChain(e,o)&&(e.expect=u?Tn:oa)),e.process()},p.handleServerKeyExchange=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});e.expect=e0,e.process()},p.handleClientKeyExchange=function(e,t,a){if(a<48)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unsupported_certificate}});var r=t.fragment,n={enc_pre_master_secret:Xe(r,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=_.pki.privateKeyFromPem(s)}catch(u){e.error(e,{message:"Could not get private key.",cause:u,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}if(s===null)return e.error(e,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}});try{var i=e.session.sp;i.pre_master_secret=s.decrypt(n.enc_pre_master_secret);var o=e.session.clientHelloVersion;if(o.major!==i.pre_master_secret.charCodeAt(0)||o.minor!==i.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch{i.pre_master_secret=_.random.getBytes(48)}e.expect=la,e.session.clientCertificate!==null&&(e.expect=o0),e.process()},p.handleCertificateRequest=function(e,t,a){if(a<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment,n={certificate_types:Xe(r,1),certificate_authorities:Xe(r,2)};e.session.certificateRequest=n,e.expect=t0,e.process()},p.handleCertificateVerify=function(e,t,a){if(a<2)return e.error(e,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s={signature:Xe(r,2).getBytes()},i=_.util.createBuffer();i.putBuffer(e.session.md5.digest()),i.putBuffer(e.session.sha1.digest()),i=i.getBytes();try{var o=e.session.clientCertificate;if(!o.publicKey.verify(i,s.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");e.session.md5.update(n),e.session.sha1.update(n)}catch{return e.error(e,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.handshake_failure}})}e.expect=la,e.process()},p.handleServerHelloDone=function(e,t,a){if(a>0)return e.error(e,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.record_overflow}});if(e.serverCertificate===null){var r={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.insufficient_security}},n=0,s=e.verify(e,r.alert.description,n,[]);if(s!==!0)return(s||s===0)&&(typeof s=="object"&&!_.util.isArray(s)?(s.message&&(r.message=s.message),s.alert&&(r.alert.description=s.alert)):typeof s=="number"&&(r.alert.description=s)),e.error(e,r)}e.session.certificateRequest!==null&&(t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createCertificate(e)}),p.queue(e,t)),t=p.createRecord(e,{type:p.ContentType.handshake,data:p.createClientKeyExchange(e)}),p.queue(e,t),e.expect=n0;var i=function(o,u){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createCertificateVerify(o,u)})),p.queue(o,p.createRecord(o,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),o.state.pending=p.createConnectionState(o),o.state.current.write=o.state.pending.write,p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createFinished(o)})),o.expect=In,p.flush(o),o.process()};if(e.session.certificateRequest===null||e.session.clientCertificate===null)return i(e,null);p.getClientSignature(e,i)},p.handleChangeCipherSpec=function(e,t){if(t.fragment.getByte()!==1)return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.illegal_parameter}});var a=e.entity===p.ConnectionEnd.client;(e.session.resuming&&a||!e.session.resuming&&!a)&&(e.state.pending=p.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&a||e.session.resuming&&!a)&&(e.state.pending=null),e.expect=a?r0:l0,e.process()},p.handleFinished=function(e,t,a){var r=t.fragment;r.read-=4;var n=r.bytes();r.read+=4;var s=t.fragment.getBytes();r=_.util.createBuffer(),r.putBuffer(e.session.md5.digest()),r.putBuffer(e.session.sha1.digest());var i=e.entity===p.ConnectionEnd.client,o=i?"server finished":"client finished",u=e.session.sp,l=12,c=_r;if(r=c(u.master_secret,o,r.getBytes(),l),r.getBytes()!==s)return e.error(e,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decrypt_error}});e.session.md5.update(n),e.session.sha1.update(n),(e.session.resuming&&i||!e.session.resuming&&!i)&&(p.queue(e,p.createRecord(e,{type:p.ContentType.change_cipher_spec,data:p.createChangeCipherSpec()})),e.state.current.write=e.state.pending.write,e.state.pending=null,p.queue(e,p.createRecord(e,{type:p.ContentType.handshake,data:p.createFinished(e)}))),e.expect=i?a0:u0,e.handshaking=!1,++e.handshakes,e.peerCertificate=i?e.session.serverCertificate:e.session.clientCertificate,p.flush(e),e.isConnected=!0,e.connected(e),e.process()},p.handleAlert=function(e,t){var a=t.fragment,r={level:a.getByte(),description:a.getByte()},n;switch(r.description){case p.Alert.Description.close_notify:n="Connection closed.";break;case p.Alert.Description.unexpected_message:n="Unexpected message.";break;case p.Alert.Description.bad_record_mac:n="Bad record MAC.";break;case p.Alert.Description.decryption_failed:n="Decryption failed.";break;case p.Alert.Description.record_overflow:n="Record overflow.";break;case p.Alert.Description.decompression_failure:n="Decompression failed.";break;case p.Alert.Description.handshake_failure:n="Handshake failure.";break;case p.Alert.Description.bad_certificate:n="Bad certificate.";break;case p.Alert.Description.unsupported_certificate:n="Unsupported certificate.";break;case p.Alert.Description.certificate_revoked:n="Certificate revoked.";break;case p.Alert.Description.certificate_expired:n="Certificate expired.";break;case p.Alert.Description.certificate_unknown:n="Certificate unknown.";break;case p.Alert.Description.illegal_parameter:n="Illegal parameter.";break;case p.Alert.Description.unknown_ca:n="Unknown certificate authority.";break;case p.Alert.Description.access_denied:n="Access denied.";break;case p.Alert.Description.decode_error:n="Decode error.";break;case p.Alert.Description.decrypt_error:n="Decrypt error.";break;case p.Alert.Description.export_restriction:n="Export restriction.";break;case p.Alert.Description.protocol_version:n="Unsupported protocol version.";break;case p.Alert.Description.insufficient_security:n="Insufficient security.";break;case p.Alert.Description.internal_error:n="Internal error.";break;case p.Alert.Description.user_canceled:n="User canceled.";break;case p.Alert.Description.no_renegotiation:n="Renegotiation not supported.";break;default:n="Unknown error.";break}if(r.description===p.Alert.Description.close_notify)return e.close();e.error(e,{message:n,send:!1,origin:e.entity===p.ConnectionEnd.client?"server":"client",alert:r}),e.process()},p.handleHandshake=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt24();if(n>a.length())return e.fragmented=t,t.fragment=_.util.createBuffer(),a.read-=4,e.process();e.fragmented=null,a.read-=4;var s=a.bytes(n+4);a.read+=4,r in Rr[e.entity][e.expect]?(e.entity===p.ConnectionEnd.server&&!e.open&&!e.fail&&(e.handshaking=!0,e.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:_.md.md5.create(),sha1:_.md.sha1.create()}),r!==p.HandshakeType.hello_request&&r!==p.HandshakeType.certificate_verify&&r!==p.HandshakeType.finished&&(e.session.md5.update(s),e.session.sha1.update(s)),Rr[e.entity][e.expect][r](e,t,n)):p.handleUnexpected(e,t)},p.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},p.handleHeartbeat=function(e,t){var a=t.fragment,r=a.getByte(),n=a.getInt16(),s=a.getBytes(n);if(r===p.HeartbeatMessageType.heartbeat_request){if(e.handshaking||n>s.length)return e.process();p.queue(e,p.createRecord(e,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_response,s)})),p.flush(e)}else if(r===p.HeartbeatMessageType.heartbeat_response){if(s!==e.expectedHeartbeatPayload)return e.process();e.heartbeatReceived&&e.heartbeatReceived(e,_.util.createBuffer(s))}e.process()};var Zo=0,Jo=1,Tn=2,e0=3,t0=4,In=5,r0=6,a0=7,n0=8,i0=0,s0=1,oa=2,o0=3,la=4,l0=5,u0=6,h=p.handleUnexpected,An=p.handleChangeCipherSpec,Be=p.handleAlert,ze=p.handleHandshake,bn=p.handleApplicationData,we=p.handleHeartbeat,ua=[];ua[p.ConnectionEnd.client]=[[h,Be,ze,h,we],[h,Be,ze,h,we],[h,Be,ze,h,we],[h,Be,ze,h,we],[h,Be,ze,h,we],[An,Be,h,h,we],[h,Be,ze,h,we],[h,Be,ze,bn,we],[h,Be,ze,h,we]],ua[p.ConnectionEnd.server]=[[h,Be,ze,h,we],[h,Be,ze,h,we],[h,Be,ze,h,we],[h,Be,ze,h,we],[An,Be,h,h,we],[h,Be,ze,h,we],[h,Be,ze,bn,we],[h,Be,ze,h,we]];var It=p.handleHelloRequest,c0=p.handleServerHello,Bn=p.handleCertificate,wn=p.handleServerKeyExchange,ca=p.handleCertificateRequest,Nr=p.handleServerHelloDone,_n=p.handleFinished,Rr=[];Rr[p.ConnectionEnd.client]=[[h,h,c0,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,Bn,wn,ca,Nr,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,wn,ca,Nr,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,h,ca,Nr,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,h,h,Nr,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,_n],[It,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[It,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]];var f0=p.handleClientHello,d0=p.handleClientKeyExchange,h0=p.handleCertificateVerify;Rr[p.ConnectionEnd.server]=[[h,f0,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,Bn,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,d0,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h0,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,_n],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h],[h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h,h]],p.generateKeys=function(e,t){var a=_r,r=t.client_random+t.server_random;e.session.resuming||(t.master_secret=a(t.pre_master_secret,"master secret",r,48).bytes(),t.pre_master_secret=null),r=t.server_random+t.client_random;var n=2*t.mac_key_length+2*t.enc_key_length,s=e.version.major===p.Versions.TLS_1_0.major&&e.version.minor===p.Versions.TLS_1_0.minor;s&&(n+=2*t.fixed_iv_length);var i=a(t.master_secret,"key expansion",r,n),o={client_write_MAC_key:i.getBytes(t.mac_key_length),server_write_MAC_key:i.getBytes(t.mac_key_length),client_write_key:i.getBytes(t.enc_key_length),server_write_key:i.getBytes(t.enc_key_length)};return s&&(o.client_write_IV=i.getBytes(t.fixed_iv_length),o.server_write_IV=i.getBytes(t.fixed_iv_length)),o},p.createConnectionState=function(e){var t=e.entity===p.ConnectionEnd.client,a=function(){var s={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(i){return!0},compressionState:null,compressFunction:function(i){return!0},updateSequenceNumber:function(){s.sequenceNumber[1]===4294967295?(s.sequenceNumber[1]=0,++s.sequenceNumber[0]):++s.sequenceNumber[1]}};return s},r={read:a(),write:a()};if(r.read.update=function(s,i){return r.read.cipherFunction(i,r.read)?r.read.compressFunction(s,i,r.read)||s.error(s,{message:"Could not decompress record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.decompression_failure}}):s.error(s,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_record_mac}}),!s.fail},r.write.update=function(s,i){return r.write.compressFunction(s,i,r.write)?r.write.cipherFunction(i,r.write)||s.error(s,{message:"Could not encrypt record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):s.error(s,{message:"Could not compress record.",send:!1,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}),!s.fail},e.session){var n=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(n),n.keys=p.generateKeys(e,n),r.read.macKey=t?n.keys.server_write_MAC_key:n.keys.client_write_MAC_key,r.write.macKey=t?n.keys.client_write_MAC_key:n.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(r,e,n),n.compression_algorithm){case p.CompressionMethod.none:break;case p.CompressionMethod.deflate:r.read.compressFunction=Xo,r.write.compressFunction=jo;break;default:throw new Error("Unsupported compression algorithm.")}}return r},p.createRandom=function(){var e=new Date,t=+e+e.getTimezoneOffset()*6e4,a=_.util.createBuffer();return a.putInt32(t),a.putBytes(_.random.getBytes(28)),a},p.createRecord=function(e,t){if(!t.data)return null;var a={type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data};return a},p.createAlert=function(e,t){var a=_.util.createBuffer();return a.putByte(t.level),a.putByte(t.description),p.createRecord(e,{type:p.ContentType.alert,data:a})},p.createClientHello=function(e){e.session.clientHelloVersion={major:e.version.major,minor:e.version.minor};for(var t=_.util.createBuffer(),a=0;a<e.cipherSuites.length;++a){var r=e.cipherSuites[a];t.putByte(r.id[0]),t.putByte(r.id[1])}var n=t.length(),s=_.util.createBuffer();s.putByte(p.CompressionMethod.none);var i=s.length(),o=_.util.createBuffer();if(e.virtualHost){var u=_.util.createBuffer();u.putByte(0),u.putByte(0);var l=_.util.createBuffer();l.putByte(0),rt(l,2,_.util.createBuffer(e.virtualHost));var c=_.util.createBuffer();rt(c,2,l),rt(u,2,c),o.putBuffer(u)}var f=o.length();f>0&&(f+=2);var g=e.session.id,m=g.length+1+2+4+28+2+n+1+i+f,y=_.util.createBuffer();return y.putByte(p.HandshakeType.client_hello),y.putInt24(m),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),rt(y,1,_.util.createBuffer(g)),rt(y,2,t),rt(y,1,s),f>0&&rt(y,2,o),y},p.createServerHello=function(e){var t=e.session.id,a=t.length+1+2+4+28+2+1,r=_.util.createBuffer();return r.putByte(p.HandshakeType.server_hello),r.putInt24(a),r.putByte(e.version.major),r.putByte(e.version.minor),r.putBytes(e.session.sp.server_random),rt(r,1,_.util.createBuffer(t)),r.putByte(e.session.cipherSuite.id[0]),r.putByte(e.session.cipherSuite.id[1]),r.putByte(e.session.compressionMethod),r},p.createCertificate=function(e){var t=e.entity===p.ConnectionEnd.client,a=null;if(e.getCertificate){var r;t?r=e.session.certificateRequest:r=e.session.extensions.server_name.serverNameList,a=e.getCertificate(e,r)}var n=_.util.createBuffer();if(a!==null)try{_.util.isArray(a)||(a=[a]);for(var s=null,i=0;i<a.length;++i){var o=_.pem.decode(a[i])[0];if(o.type!=="CERTIFICATE"&&o.type!=="X509 CERTIFICATE"&&o.type!=="TRUSTED CERTIFICATE"){var u=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw u.headerType=o.type,u}if(o.procType&&o.procType.type==="ENCRYPTED")throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var l=_.util.createBuffer(o.body);s===null&&(s=_.asn1.fromDer(l.bytes(),!1));var c=_.util.createBuffer();rt(c,3,l),n.putBuffer(c)}a=_.pki.certificateFromAsn1(s),t?e.session.clientCertificate=a:e.session.serverCertificate=a}catch(m){return e.error(e,{message:"Could not send certificate list.",cause:m,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var f=3+n.length(),g=_.util.createBuffer();return g.putByte(p.HandshakeType.certificate),g.putInt24(f),rt(g,3,n),g},p.createClientKeyExchange=function(e){var t=_.util.createBuffer();t.putByte(e.session.clientHelloVersion.major),t.putByte(e.session.clientHelloVersion.minor),t.putBytes(_.random.getBytes(46));var a=e.session.sp;a.pre_master_secret=t.getBytes();var r=e.session.serverCertificate.publicKey;t=r.encrypt(a.pre_master_secret);var n=t.length+2,s=_.util.createBuffer();return s.putByte(p.HandshakeType.client_key_exchange),s.putInt24(n),s.putInt16(t.length),s.putBytes(t),s},p.createServerKeyExchange=function(e){var t=_.util.createBuffer();return t},p.getClientSignature=function(e,t){var a=_.util.createBuffer();a.putBuffer(e.session.md5.digest()),a.putBuffer(e.session.sha1.digest()),a=a.getBytes(),e.getSignature=e.getSignature||function(r,n,s){var i=null;if(r.getPrivateKey)try{i=r.getPrivateKey(r,r.session.clientCertificate),i=_.pki.privateKeyFromPem(i)}catch(o){r.error(r,{message:"Could not get private key.",cause:o,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}})}i===null?r.error(r,{message:"No private key set.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.internal_error}}):n=i.sign(n,null),s(r,n)},e.getSignature(e,a,t)},p.createCertificateVerify=function(e,t){var a=t.length+2,r=_.util.createBuffer();return r.putByte(p.HandshakeType.certificate_verify),r.putInt24(a),r.putInt16(t.length),r.putBytes(t),r},p.createCertificateRequest=function(e){var t=_.util.createBuffer();t.putByte(1);var a=_.util.createBuffer();for(var r in e.caStore.certs){var n=e.caStore.certs[r],s=_.pki.distinguishedNameToAsn1(n.subject),i=_.asn1.toDer(s);a.putInt16(i.length()),a.putBuffer(i)}var o=1+t.length()+2+a.length(),u=_.util.createBuffer();return u.putByte(p.HandshakeType.certificate_request),u.putInt24(o),rt(u,1,t),rt(u,2,a),u},p.createServerHelloDone=function(e){var t=_.util.createBuffer();return t.putByte(p.HandshakeType.server_hello_done),t.putInt24(0),t},p.createChangeCipherSpec=function(){var e=_.util.createBuffer();return e.putByte(1),e},p.createFinished=function(e){var t=_.util.createBuffer();t.putBuffer(e.session.md5.digest()),t.putBuffer(e.session.sha1.digest());var a=e.entity===p.ConnectionEnd.client,r=e.session.sp,n=12,s=_r,i=a?"client finished":"server finished";t=s(r.master_secret,i,t.getBytes(),n);var o=_.util.createBuffer();return o.putByte(p.HandshakeType.finished),o.putInt24(t.length()),o.putBuffer(t),o},p.createHeartbeat=function(e,t,a){typeof a>"u"&&(a=t.length);var r=_.util.createBuffer();r.putByte(e),r.putInt16(a),r.putBytes(t);var n=r.length(),s=Math.max(16,n-a-3);return r.putBytes(_.random.getBytes(s)),r},p.queue=function(e,t){if(t&&!(t.fragment.length()===0&&(t.type===p.ContentType.handshake||t.type===p.ContentType.alert||t.type===p.ContentType.change_cipher_spec))){if(t.type===p.ContentType.handshake){var a=t.fragment.bytes();e.session.md5.update(a),e.session.sha1.update(a),a=null}var r;if(t.fragment.length()<=p.MaxFragment)r=[t];else{r=[];for(var n=t.fragment.bytes();n.length>p.MaxFragment;)r.push(p.createRecord(e,{type:t.type,data:_.util.createBuffer(n.slice(0,p.MaxFragment))})),n=n.slice(p.MaxFragment);n.length>0&&r.push(p.createRecord(e,{type:t.type,data:_.util.createBuffer(n)}))}for(var s=0;s<r.length&&!e.fail;++s){var i=r[s],o=e.state.current.write;o.update(e,i)&&e.records.push(i)}}},p.flush=function(e){for(var t=0;t<e.records.length;++t){var a=e.records[t];e.tlsData.putByte(a.type),e.tlsData.putByte(a.version.major),e.tlsData.putByte(a.version.minor),e.tlsData.putInt16(a.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var fa=function(e){switch(e){case!0:return!0;case _.pki.certificateError.bad_certificate:return p.Alert.Description.bad_certificate;case _.pki.certificateError.unsupported_certificate:return p.Alert.Description.unsupported_certificate;case _.pki.certificateError.certificate_revoked:return p.Alert.Description.certificate_revoked;case _.pki.certificateError.certificate_expired:return p.Alert.Description.certificate_expired;case _.pki.certificateError.certificate_unknown:return p.Alert.Description.certificate_unknown;case _.pki.certificateError.unknown_ca:return p.Alert.Description.unknown_ca;default:return p.Alert.Description.bad_certificate}},p0=function(e){switch(e){case!0:return!0;case p.Alert.Description.bad_certificate:return _.pki.certificateError.bad_certificate;case p.Alert.Description.unsupported_certificate:return _.pki.certificateError.unsupported_certificate;case p.Alert.Description.certificate_revoked:return _.pki.certificateError.certificate_revoked;case p.Alert.Description.certificate_expired:return _.pki.certificateError.certificate_expired;case p.Alert.Description.certificate_unknown:return _.pki.certificateError.certificate_unknown;case p.Alert.Description.unknown_ca:return _.pki.certificateError.unknown_ca;default:return _.pki.certificateError.bad_certificate}};p.verifyCertificateChain=function(e,t){try{var a={};for(var r in e.verifyOptions)a[r]=e.verifyOptions[r];a.verify=function(s,i,o){var u=fa(s),l=e.verify(e,s,i,o);if(l!==!0){if(typeof l=="object"&&!_.util.isArray(l)){var c=new Error("The application rejected the certificate.");throw c.send=!0,c.alert={level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate},l.message&&(c.message=l.message),l.alert&&(c.alert.description=l.alert),c}l!==s&&(l=p0(l))}return l},_.pki.verifyCertificateChain(e.caStore,t,a)}catch(s){var n=s;(typeof n!="object"||_.util.isArray(n))&&(n={send:!0,alert:{level:p.Alert.Level.fatal,description:fa(s)}}),"send"in n||(n.send=!0),"alert"in n||(n.alert={level:p.Alert.Level.fatal,description:fa(n.error)}),e.error(e,n)}return!e.fail},p.createSessionCache=function(e,t){var a=null;if(e&&e.getSession&&e.setSession&&e.order)a=e;else{a={},a.cache=e||{},a.capacity=Math.max(t||100,1),a.order=[];for(var r in e)a.order.length<=t?a.order.push(r):delete e[r];a.getSession=function(n){var s=null,i=null;if(n?i=_.util.bytesToHex(n):a.order.length>0&&(i=a.order[0]),i!==null&&i in a.cache){s=a.cache[i],delete a.cache[i];for(var o in a.order)if(a.order[o]===i){a.order.splice(o,1);break}}return s},a.setSession=function(n,s){if(a.order.length===a.capacity){var i=a.order.shift();delete a.cache[i]}var i=_.util.bytesToHex(n);a.order.push(i),a.cache[i]=s}}return a},p.createConnection=function(e){var t=null;e.caStore?_.util.isArray(e.caStore)?t=_.pki.createCaStore(e.caStore):t=e.caStore:t=_.pki.createCaStore();var a=e.cipherSuites||null;if(a===null){a=[];for(var r in p.CipherSuites)a.push(p.CipherSuites[r])}var n=e.server?p.ConnectionEnd.server:p.ConnectionEnd.client,s=e.sessionCache?p.createSessionCache(e.sessionCache):null,i={version:{major:p.Version.major,minor:p.Version.minor},entity:n,sessionId:e.sessionId,caStore:t,sessionCache:s,cipherSuites:a,connected:e.connected,virtualHost:e.virtualHost||null,verifyClient:e.verifyClient||!1,verify:e.verify||function(c,f,g,m){return f},verifyOptions:e.verifyOptions||{},getCertificate:e.getCertificate||null,getPrivateKey:e.getPrivateKey||null,getSignature:e.getSignature||null,input:_.util.createBuffer(),tlsData:_.util.createBuffer(),data:_.util.createBuffer(),tlsDataReady:e.tlsDataReady,dataReady:e.dataReady,heartbeatReceived:e.heartbeatReceived,closed:e.closed,error:function(c,f){f.origin=f.origin||(c.entity===p.ConnectionEnd.client?"client":"server"),f.send&&(p.queue(c,p.createAlert(c,f.alert)),p.flush(c));var g=f.fatal!==!1;g&&(c.fail=!0),e.error(c,f),g&&c.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};i.reset=function(c){i.version={major:p.Version.major,minor:p.Version.minor},i.record=null,i.session=null,i.peerCertificate=null,i.state={pending:null,current:null},i.expect=i.entity===p.ConnectionEnd.client?Zo:i0,i.fragmented=null,i.records=[],i.open=!1,i.handshakes=0,i.handshaking=!1,i.isConnected=!1,i.fail=!(c||typeof c>"u"),i.input.clear(),i.tlsData.clear(),i.data.clear(),i.state.current=p.createConnectionState(i)},i.reset();var o=function(c,f){var g=f.type-p.ContentType.change_cipher_spec,m=ua[c.entity][c.expect];g in m?m[g](c,f):p.handleUnexpected(c,f)},u=function(c){var f=0,g=c.input,m=g.length();if(m<5)f=5-m;else{c.record={type:g.getByte(),version:{major:g.getByte(),minor:g.getByte()},length:g.getInt16(),fragment:_.util.createBuffer(),ready:!1};var y=c.record.version.major===c.version.major;y&&c.session&&c.session.version&&(y=c.record.version.minor===c.version.minor),y||c.error(c,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}})}return f},l=function(c){var f=0,g=c.input,m=g.length();if(m<c.record.length)f=c.record.length-m;else{c.record.fragment.putBytes(g.getBytes(c.record.length)),g.compact();var y=c.state.current.read;y.update(c,c.record)&&(c.fragmented!==null&&(c.fragmented.type===c.record.type?(c.fragmented.fragment.putBuffer(c.record.fragment),c.record=c.fragmented):c.error(c,{message:"Invalid fragmented record.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.unexpected_message}})),c.record.ready=!0)}return f};return i.handshake=function(c){if(i.entity!==p.ConnectionEnd.client)i.error(i,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(i.handshaking)i.error(i,{message:"Handshake already in progress.",fatal:!1});else{i.fail&&!i.open&&i.handshakes===0&&(i.fail=!1),i.handshaking=!0,c=c||"";var f=null;c.length>0&&(i.sessionCache&&(f=i.sessionCache.getSession(c)),f===null&&(c="")),c.length===0&&i.sessionCache&&(f=i.sessionCache.getSession(),f!==null&&(c=f.id)),i.session={id:c,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:_.md.md5.create(),sha1:_.md.sha1.create()},f&&(i.version=f.version,i.session.sp=f.sp),i.session.sp.client_random=p.createRandom().getBytes(),i.open=!0,p.queue(i,p.createRecord(i,{type:p.ContentType.handshake,data:p.createClientHello(i)})),p.flush(i)}},i.process=function(c){var f=0;return c&&i.input.putBytes(c),i.fail||(i.record!==null&&i.record.ready&&i.record.fragment.isEmpty()&&(i.record=null),i.record===null&&(f=u(i)),!i.fail&&i.record!==null&&!i.record.ready&&(f=l(i)),!i.fail&&i.record!==null&&i.record.ready&&o(i,i.record)),f},i.prepare=function(c){return p.queue(i,p.createRecord(i,{type:p.ContentType.application_data,data:_.util.createBuffer(c)})),p.flush(i)},i.prepareHeartbeatRequest=function(c,f){return c instanceof _.util.ByteBuffer&&(c=c.bytes()),typeof f>"u"&&(f=c.length),i.expectedHeartbeatPayload=c,p.queue(i,p.createRecord(i,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_request,c,f)})),p.flush(i)},i.close=function(c){if(!i.fail&&i.sessionCache&&i.session){var f={id:i.session.id,version:i.session.version,sp:i.session.sp};f.sp.keys=null,i.sessionCache.setSession(f.id,f)}i.open&&(i.open=!1,i.input.clear(),(i.isConnected||i.handshaking)&&(i.isConnected=i.handshaking=!1,p.queue(i,p.createAlert(i,{level:p.Alert.Level.warning,description:p.Alert.Description.close_notify})),p.flush(i)),i.closed(i)),i.reset(c)},i},_.tls=_.tls||{};for(var da in p)typeof p[da]!="function"&&(_.tls[da]=p[da]);_.tls.prf_tls1=_r,_.tls.hmac_sha1=Yo,_.tls.createSessionCache=p.createSessionCache,_.tls.createConnection=p.createConnection;var At=j,at=At.tls;at.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=at.BulkCipherAlgorithm.aes,e.cipher_type=at.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=at.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Nn},at.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=at.BulkCipherAlgorithm.aes,e.cipher_type=at.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=at.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:Nn};function Nn(e,t,a){var r=t.entity===At.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:At.cipher.createDecipher("AES-CBC",r?a.keys.server_write_key:a.keys.client_write_key),iv:r?a.keys.server_write_IV:a.keys.client_write_IV},e.write.cipherState={init:!1,cipher:At.cipher.createCipher("AES-CBC",r?a.keys.client_write_key:a.keys.server_write_key),iv:r?a.keys.client_write_IV:a.keys.server_write_IV},e.read.cipherFunction=m0,e.write.cipherFunction=g0,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=at.hmac_sha1}function g0(e,t){var a=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===at.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=At.random.getBytesSync(16),t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start({iv:n}),e.version.minor>=at.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(y0)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function y0(e,t,a){if(!a){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function v0(e,t,a){var r=!0;if(a){for(var n=t.length(),s=t.last(),i=n-1-s;i<n-1;++i)r=r&&t.at(i)==s;r&&t.truncate(s+1)}return r}function m0(e,t){var a=!1,r;e.version.minor===at.Versions.TLS_1_0.minor?r=t.cipherState.init?null:t.cipherState.iv:r=e.fragment.getBytes(16),t.cipherState.init=!0;var n=t.cipherState.cipher;n.start({iv:r}),n.update(e.fragment),a=n.finish(v0);var s=t.macLength,i=At.random.getBytesSync(s),o=n.output.length();o>=s?(e.fragment=n.output.getBytes(o-s),i=n.output.getBytes(s)):e.fragment=n.output.getBytes(),e.fragment=At.util.createBuffer(e.fragment),e.length=e.fragment.length();var u=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),a=C0(t.macKey,i,u)&&a,a}function C0(e,t,a){var r=At.hmac.create();return r.start("SHA1",e),r.update(t),t=r.digest().getBytes(),r.start(null,null),r.update(a),a=r.digest().getBytes(),t===a}var pe=j,sr=pe.sha512=pe.sha512||{};pe.md.sha512=pe.md.algorithms.sha512=sr;var Rn=pe.sha384=pe.sha512.sha384=pe.sha512.sha384||{};Rn.create=function(){return sr.create("SHA-384")},pe.md.sha384=pe.md.algorithms.sha384=Rn,pe.sha512.sha256=pe.sha512.sha256||{create:function(){return sr.create("SHA-512/256")}},pe.md["sha512/256"]=pe.md.algorithms["sha512/256"]=pe.sha512.sha256,pe.sha512.sha224=pe.sha512.sha224||{create:function(){return sr.create("SHA-512/224")}},pe.md["sha512/224"]=pe.md.algorithms["sha512/224"]=pe.sha512.sha224,sr.create=function(e){if(Ln||E0(),typeof e>"u"&&(e="SHA-512"),!(e in Dt))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=Dt[e],a=null,r=pe.util.createBuffer(),n=new Array(80),s=0;s<80;++s)n[s]=new Array(2);var i=64;switch(e){case"SHA-384":i=48;break;case"SHA-512/256":i=32;break;case"SHA-512/224":i=28;break}var o={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:i,messageLength:0,fullMessageLength:null,messageLengthSize:16};return o.start=function(){o.messageLength=0,o.fullMessageLength=o.messageLength128=[];for(var u=o.messageLengthSize/4,l=0;l<u;++l)o.fullMessageLength.push(0);r=pe.util.createBuffer(),a=new Array(t.length);for(var l=0;l<t.length;++l)a[l]=t[l].slice(0);return o},o.start(),o.update=function(u,l){l==="utf8"&&(u=pe.util.encodeUtf8(u));var c=u.length;o.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var f=o.fullMessageLength.length-1;f>=0;--f)o.fullMessageLength[f]+=c[1],c[1]=c[0]+(o.fullMessageLength[f]/4294967296>>>0),o.fullMessageLength[f]=o.fullMessageLength[f]>>>0,c[0]=c[1]/4294967296>>>0;return r.putBytes(u),kn(a,n,r),(r.read>2048||r.length()===0)&&r.compact(),o},o.digest=function(){var u=pe.util.createBuffer();u.putBytes(r.bytes());var l=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,c=l&o.blockLength-1;u.putBytes(ha.substr(0,o.blockLength-c));for(var f,g,m=o.fullMessageLength[0]*8,y=0;y<o.fullMessageLength.length-1;++y)f=o.fullMessageLength[y+1]*8,g=f/4294967296>>>0,m+=g,u.putInt32(m>>>0),m=f>>>0;u.putInt32(m);for(var x=new Array(a.length),y=0;y<a.length;++y)x[y]=a[y].slice(0);kn(x,n,u);var S=pe.util.createBuffer(),I;e==="SHA-512"?I=x.length:e==="SHA-384"?I=x.length-2:I=x.length-4;for(var y=0;y<I;++y)S.putInt32(x[y][0]),(y!==I-1||e!=="SHA-512/224")&&S.putInt32(x[y][1]);return S},o};var ha=null,Ln=!1,pa=null,Dt=null;function E0(){ha=String.fromCharCode(128),ha+=pe.util.fillString(String.fromCharCode(0),128),pa=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],Dt={},Dt["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],Dt["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],Dt["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],Dt["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],Ln=!0}function kn(e,t,a){for(var r,n,s,i,o,u,l,c,f,g,m,y,x,S,I,B,b,D,L,R,q,X,ie,ue,se,W,Q,H,Y,le,K,Ye,jt,Ce,Ee,xe=a.length();xe>=128;){for(Y=0;Y<16;++Y)t[Y][0]=a.getInt32()>>>0,t[Y][1]=a.getInt32()>>>0;for(;Y<80;++Y)Ye=t[Y-2],le=Ye[0],K=Ye[1],r=((le>>>19|K<<13)^(K>>>29|le<<3)^le>>>6)>>>0,n=((le<<13|K>>>19)^(K<<3|le>>>29)^(le<<26|K>>>6))>>>0,Ce=t[Y-15],le=Ce[0],K=Ce[1],s=((le>>>1|K<<31)^(le>>>8|K<<24)^le>>>7)>>>0,i=((le<<31|K>>>1)^(le<<24|K>>>8)^(le<<25|K>>>7))>>>0,jt=t[Y-7],Ee=t[Y-16],K=n+jt[1]+i+Ee[1],t[Y][0]=r+jt[0]+s+Ee[0]+(K/4294967296>>>0)>>>0,t[Y][1]=K>>>0;for(x=e[0][0],S=e[0][1],I=e[1][0],B=e[1][1],b=e[2][0],D=e[2][1],L=e[3][0],R=e[3][1],q=e[4][0],X=e[4][1],ie=e[5][0],ue=e[5][1],se=e[6][0],W=e[6][1],Q=e[7][0],H=e[7][1],Y=0;Y<80;++Y)l=((q>>>14|X<<18)^(q>>>18|X<<14)^(X>>>9|q<<23))>>>0,c=((q<<18|X>>>14)^(q<<14|X>>>18)^(X<<23|q>>>9))>>>0,f=(se^q&(ie^se))>>>0,g=(W^X&(ue^W))>>>0,o=((x>>>28|S<<4)^(S>>>2|x<<30)^(S>>>7|x<<25))>>>0,u=((x<<4|S>>>28)^(S<<30|x>>>2)^(S<<25|x>>>7))>>>0,m=(x&I|b&(x^I))>>>0,y=(S&B|D&(S^B))>>>0,K=H+c+g+pa[Y][1]+t[Y][1],r=Q+l+f+pa[Y][0]+t[Y][0]+(K/4294967296>>>0)>>>0,n=K>>>0,K=u+y,s=o+m+(K/4294967296>>>0)>>>0,i=K>>>0,Q=se,H=W,se=ie,W=ue,ie=q,ue=X,K=R+n,q=L+r+(K/4294967296>>>0)>>>0,X=K>>>0,L=b,R=D,b=I,D=B,I=x,B=S,K=n+i,x=r+s+(K/4294967296>>>0)>>>0,S=K>>>0;K=e[0][1]+S,e[0][0]=e[0][0]+x+(K/4294967296>>>0)>>>0,e[0][1]=K>>>0,K=e[1][1]+B,e[1][0]=e[1][0]+I+(K/4294967296>>>0)>>>0,e[1][1]=K>>>0,K=e[2][1]+D,e[2][0]=e[2][0]+b+(K/4294967296>>>0)>>>0,e[2][1]=K>>>0,K=e[3][1]+R,e[3][0]=e[3][0]+L+(K/4294967296>>>0)>>>0,e[3][1]=K>>>0,K=e[4][1]+X,e[4][0]=e[4][0]+q+(K/4294967296>>>0)>>>0,e[4][1]=K>>>0,K=e[5][1]+ue,e[5][0]=e[5][0]+ie+(K/4294967296>>>0)>>>0,e[5][1]=K>>>0,K=e[6][1]+W,e[6][0]=e[6][0]+se+(K/4294967296>>>0)>>>0,e[6][1]=K>>>0,K=e[7][1]+H,e[7][0]=e[7][0]+Q+(K/4294967296>>>0)>>>0,e[7][1]=K>>>0,xe-=128}}var ga={},x0=j,be=x0.asn1;ga.privateKeyValidator={name:"PrivateKeyInfo",tagClass:be.Class.UNIVERSAL,type:be.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:be.Class.UNIVERSAL,type:be.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:be.Class.UNIVERSAL,type:be.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:be.Class.UNIVERSAL,type:be.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:be.Class.UNIVERSAL,type:be.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},ga.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:be.Class.UNIVERSAL,type:be.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:be.Class.UNIVERSAL,type:be.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:be.Class.UNIVERSAL,type:be.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:be.Class.UNIVERSAL,type:be.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var _e=j,Un=ga,S0=Un.publicKeyValidator,T0=Un.privateKeyValidator;if(typeof I0>"u")var I0=_e.jsbn.BigInteger;var ya=_e.util.ByteBuffer,$e=typeof Buffer>"u"?Uint8Array:Buffer;_e.pki=_e.pki||{},_e.pki.ed25519=_e.ed25519=_e.ed25519||{};var ee=_e.ed25519;ee.constants={},ee.constants.PUBLIC_KEY_BYTE_LENGTH=32,ee.constants.PRIVATE_KEY_BYTE_LENGTH=64,ee.constants.SEED_BYTE_LENGTH=32,ee.constants.SIGN_BYTE_LENGTH=64,ee.constants.HASH_BYTE_LENGTH=64,ee.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=_e.random.getBytesSync(ee.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==ee.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+ee.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(t instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');t=vt({message:t,encoding:"binary"});for(var a=new $e(ee.constants.PUBLIC_KEY_BYTE_LENGTH),r=new $e(ee.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return w0(a,r),{publicKey:a,privateKey:r}},ee.privateKeyFromAsn1=function(e){var t={},a=[],r=_e.asn1.validate(e,T0,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=_e.asn1.derToOid(t.privateKeyOid),i=_e.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.privateKey,u=vt({message:_e.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:u}},ee.publicKeyFromAsn1=function(e){var t={},a=[],r=_e.asn1.validate(e,S0,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=_e.asn1.derToOid(t.publicKeyOid),i=_e.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==ee.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return vt({message:o,encoding:"binary"})},ee.publicKeyFromPrivateKey=function(e){e=e||{};var t=vt({message:e.privateKey,encoding:"binary"});if(t.length!==ee.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+ee.constants.PRIVATE_KEY_BYTE_LENGTH);for(var a=new $e(ee.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r<a.length;++r)a[r]=t[32+r];return a},ee.sign=function(e){e=e||{};var t=vt(e),a=vt({message:e.privateKey,encoding:"binary"});if(a.length===ee.constants.SEED_BYTE_LENGTH){var r=ee.generateKeyPair({seed:a});a=r.privateKey}else if(a.length!==ee.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+ee.constants.SEED_BYTE_LENGTH+" or "+ee.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new $e(ee.constants.SIGN_BYTE_LENGTH+t.length);_0(n,t,t.length,a);for(var s=new $e(ee.constants.SIGN_BYTE_LENGTH),i=0;i<s.length;++i)s[i]=n[i];return s},ee.verify=function(e){e=e||{};var t=vt(e);if(e.signature===void 0)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var a=vt({message:e.signature,encoding:"binary"});if(a.length!==ee.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+ee.constants.SIGN_BYTE_LENGTH);var r=vt({message:e.publicKey,encoding:"binary"});if(r.length!==ee.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+ee.constants.PUBLIC_KEY_BYTE_LENGTH);var n=new $e(ee.constants.SIGN_BYTE_LENGTH+t.length),s=new $e(ee.constants.SIGN_BYTE_LENGTH+t.length),i;for(i=0;i<ee.constants.SIGN_BYTE_LENGTH;++i)n[i]=a[i];for(i=0;i<t.length;++i)n[i+ee.constants.SIGN_BYTE_LENGTH]=t[i];return N0(s,n,n.length,r)>=0};function vt(e){var t=e.message;if(t instanceof Uint8Array||t instanceof $e)return t;var a=e.encoding;if(t===void 0)if(e.md)t=e.md.digest().getBytes(),a="binary";else throw new TypeError('"options.message" or "options.md" not specified.');if(typeof t=="string"&&!a)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if(typeof t=="string"){if(typeof Buffer<"u")return Buffer.from(t,a);t=new ya(t,a)}else if(!(t instanceof ya))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var r=new $e(t.length()),n=0;n<r.length;++n)r[n]=t.at(n);return r}var va=G(),Lr=G([1]),A0=G([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b0=G([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Dn=G([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Pn=G([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),ma=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),B0=G([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function or(e,t){var a=_e.md.sha512.create(),r=new ya(e);a.update(r.getBytes(t),"binary");var n=a.digest().getBytes();if(typeof Buffer<"u")return Buffer.from(n,"binary");for(var s=new $e(ee.constants.HASH_BYTE_LENGTH),i=0;i<64;++i)s[i]=n.charCodeAt(i);return s}function w0(e,t){var a=[G(),G(),G(),G()],r,n=or(t,32);for(n[0]&=248,n[31]&=127,n[31]|=64,Sa(a,n),xa(e,a),r=0;r<32;++r)t[r+32]=e[r];return 0}function _0(e,t,a,r){var n,s,i=new Float64Array(64),o=[G(),G(),G(),G()],u=or(r,32);u[0]&=248,u[31]&=127,u[31]|=64;var l=a+64;for(n=0;n<a;++n)e[64+n]=t[n];for(n=0;n<32;++n)e[32+n]=u[32+n];var c=or(e.subarray(32),a+32);for(Ca(c),Sa(o,c),xa(e,o),n=32;n<64;++n)e[n]=r[n];var f=or(e,a+64);for(Ca(f),n=32;n<64;++n)i[n]=0;for(n=0;n<32;++n)i[n]=c[n];for(n=0;n<32;++n)for(s=0;s<32;s++)i[n+s]+=f[n]*u[s];return Vn(e.subarray(32),i),l}function N0(e,t,a,r){var n,s,i=new $e(32),o=[G(),G(),G(),G()],u=[G(),G(),G(),G()];if(s=-1,a<64||R0(u,r))return-1;for(n=0;n<a;++n)e[n]=t[n];for(n=0;n<32;++n)e[n+32]=r[n];var l=or(e,a);if(Ca(l),Hn(o,u,l),Sa(u,t.subarray(32)),Ea(o,u),xa(i,o),a-=64,Fn(t,0,i,0)){for(n=0;n<a;++n)e[n]=0;return-1}for(n=0;n<a;++n)e[n]=t[n+64];return s=a,s}function Vn(e,t){var a,r,n,s;for(r=63;r>=32;--r){for(a=0,n=r-32,s=r-12;n<s;++n)t[n]+=a-16*t[r]*ma[n-(r-32)],a=t[n]+128>>8,t[n]-=a*256;t[n]+=a,t[r]=0}for(a=0,n=0;n<32;++n)t[n]+=a-(t[31]>>4)*ma[n],a=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=a*ma[n];for(r=0;r<32;++r)t[r+1]+=t[r]>>8,e[r]=t[r]&255}function Ca(e){for(var t=new Float64Array(64),a=0;a<64;++a)t[a]=e[a],e[a]=0;Vn(e,t)}function Ea(e,t){var a=G(),r=G(),n=G(),s=G(),i=G(),o=G(),u=G(),l=G(),c=G();Wt(a,e[1],e[0]),Wt(c,t[1],t[0]),ce(a,a,c),Qt(r,e[0],e[1]),Qt(c,t[0],t[1]),ce(r,r,c),ce(n,e[3],t[3]),ce(n,n,b0),ce(s,e[2],t[2]),Qt(s,s,s),Wt(i,r,a),Wt(o,s,n),Qt(u,s,n),Qt(l,r,a),ce(e[0],i,o),ce(e[1],l,u),ce(e[2],u,o),ce(e[3],i,l)}function On(e,t,a){for(var r=0;r<4;++r)Gn(e[r],t[r],a)}function xa(e,t){var a=G(),r=G(),n=G();D0(n,t[2]),ce(a,t[0],n),ce(r,t[1],n),kr(e,r),e[31]^=Mn(a)<<7}function kr(e,t){var a,r,n,s=G(),i=G();for(a=0;a<16;++a)i[a]=t[a];for(Ta(i),Ta(i),Ta(i),r=0;r<2;++r){for(s[0]=i[0]-65517,a=1;a<15;++a)s[a]=i[a]-65535-(s[a-1]>>16&1),s[a-1]&=65535;s[15]=i[15]-32767-(s[14]>>16&1),n=s[15]>>16&1,s[14]&=65535,Gn(i,s,1-n)}for(a=0;a<16;a++)e[2*a]=i[a]&255,e[2*a+1]=i[a]>>8}function R0(e,t){var a=G(),r=G(),n=G(),s=G(),i=G(),o=G(),u=G();return bt(e[2],Lr),L0(e[1],t),Pt(n,e[1]),ce(s,n,A0),Wt(n,n,e[2]),Qt(s,e[2],s),Pt(i,s),Pt(o,i),ce(u,o,i),ce(a,u,n),ce(a,a,s),k0(a,a),ce(a,a,n),ce(a,a,s),ce(a,a,s),ce(e[0],a,s),Pt(r,e[0]),ce(r,r,s),Kn(r,n)&&ce(e[0],e[0],B0),Pt(r,e[0]),ce(r,r,s),Kn(r,n)?-1:(Mn(e[0])===t[31]>>7&&Wt(e[0],va,e[0]),ce(e[3],e[0],e[1]),0)}function L0(e,t){var a;for(a=0;a<16;++a)e[a]=t[2*a]+(t[2*a+1]<<8);e[15]&=32767}function k0(e,t){var a=G(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=250;r>=0;--r)Pt(a,a),r!==1&&ce(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Kn(e,t){var a=new $e(32),r=new $e(32);return kr(a,e),kr(r,t),Fn(a,0,r,0)}function Fn(e,t,a,r){return U0(e,t,a,r,32)}function U0(e,t,a,r,n){var s,i=0;for(s=0;s<n;++s)i|=e[t+s]^a[r+s];return(1&i-1>>>8)-1}function Mn(e){var t=new $e(32);return kr(t,e),t[0]&1}function Hn(e,t,a){var r,n;for(bt(e[0],va),bt(e[1],Lr),bt(e[2],Lr),bt(e[3],va),n=255;n>=0;--n)r=a[n/8|0]>>(n&7)&1,On(e,t,r),Ea(t,e),Ea(e,e),On(e,t,r)}function Sa(e,t){var a=[G(),G(),G(),G()];bt(a[0],Dn),bt(a[1],Pn),bt(a[2],Lr),ce(a[3],Dn,Pn),Hn(e,a,t)}function bt(e,t){var a;for(a=0;a<16;a++)e[a]=t[a]|0}function D0(e,t){var a=G(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)Pt(a,a),r!==2&&r!==4&&ce(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function Ta(e){var t,a,r=1;for(t=0;t<16;++t)a=e[t]+r+65535,r=Math.floor(a/65536),e[t]=a-r*65536;e[0]+=r-1+37*(r-1)}function Gn(e,t,a){for(var r,n=~(a-1),s=0;s<16;++s)r=n&(e[s]^t[s]),e[s]^=r,t[s]^=r}function G(e){var t,a=new Float64Array(16);if(e)for(t=0;t<e.length;++t)a[t]=e[t];return a}function Qt(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]+a[r]}function Wt(e,t,a){for(var r=0;r<16;++r)e[r]=t[r]-a[r]}function Pt(e,t){ce(e,t,t)}function ce(e,t,a){var r,n,s=0,i=0,o=0,u=0,l=0,c=0,f=0,g=0,m=0,y=0,x=0,S=0,I=0,B=0,b=0,D=0,L=0,R=0,q=0,X=0,ie=0,ue=0,se=0,W=0,Q=0,H=0,Y=0,le=0,K=0,Ye=0,jt=0,Ce=a[0],Ee=a[1],xe=a[2],Ne=a[3],Re=a[4],Le=a[5],ke=a[6],Ue=a[7],De=a[8],Pe=a[9],Ve=a[10],Oe=a[11],Ke=a[12],Fe=a[13],Me=a[14],He=a[15];r=t[0],s+=r*Ce,i+=r*Ee,o+=r*xe,u+=r*Ne,l+=r*Re,c+=r*Le,f+=r*ke,g+=r*Ue,m+=r*De,y+=r*Pe,x+=r*Ve,S+=r*Oe,I+=r*Ke,B+=r*Fe,b+=r*Me,D+=r*He,r=t[1],i+=r*Ce,o+=r*Ee,u+=r*xe,l+=r*Ne,c+=r*Re,f+=r*Le,g+=r*ke,m+=r*Ue,y+=r*De,x+=r*Pe,S+=r*Ve,I+=r*Oe,B+=r*Ke,b+=r*Fe,D+=r*Me,L+=r*He,r=t[2],o+=r*Ce,u+=r*Ee,l+=r*xe,c+=r*Ne,f+=r*Re,g+=r*Le,m+=r*ke,y+=r*Ue,x+=r*De,S+=r*Pe,I+=r*Ve,B+=r*Oe,b+=r*Ke,D+=r*Fe,L+=r*Me,R+=r*He,r=t[3],u+=r*Ce,l+=r*Ee,c+=r*xe,f+=r*Ne,g+=r*Re,m+=r*Le,y+=r*ke,x+=r*Ue,S+=r*De,I+=r*Pe,B+=r*Ve,b+=r*Oe,D+=r*Ke,L+=r*Fe,R+=r*Me,q+=r*He,r=t[4],l+=r*Ce,c+=r*Ee,f+=r*xe,g+=r*Ne,m+=r*Re,y+=r*Le,x+=r*ke,S+=r*Ue,I+=r*De,B+=r*Pe,b+=r*Ve,D+=r*Oe,L+=r*Ke,R+=r*Fe,q+=r*Me,X+=r*He,r=t[5],c+=r*Ce,f+=r*Ee,g+=r*xe,m+=r*Ne,y+=r*Re,x+=r*Le,S+=r*ke,I+=r*Ue,B+=r*De,b+=r*Pe,D+=r*Ve,L+=r*Oe,R+=r*Ke,q+=r*Fe,X+=r*Me,ie+=r*He,r=t[6],f+=r*Ce,g+=r*Ee,m+=r*xe,y+=r*Ne,x+=r*Re,S+=r*Le,I+=r*ke,B+=r*Ue,b+=r*De,D+=r*Pe,L+=r*Ve,R+=r*Oe,q+=r*Ke,X+=r*Fe,ie+=r*Me,ue+=r*He,r=t[7],g+=r*Ce,m+=r*Ee,y+=r*xe,x+=r*Ne,S+=r*Re,I+=r*Le,B+=r*ke,b+=r*Ue,D+=r*De,L+=r*Pe,R+=r*Ve,q+=r*Oe,X+=r*Ke,ie+=r*Fe,ue+=r*Me,se+=r*He,r=t[8],m+=r*Ce,y+=r*Ee,x+=r*xe,S+=r*Ne,I+=r*Re,B+=r*Le,b+=r*ke,D+=r*Ue,L+=r*De,R+=r*Pe,q+=r*Ve,X+=r*Oe,ie+=r*Ke,ue+=r*Fe,se+=r*Me,W+=r*He,r=t[9],y+=r*Ce,x+=r*Ee,S+=r*xe,I+=r*Ne,B+=r*Re,b+=r*Le,D+=r*ke,L+=r*Ue,R+=r*De,q+=r*Pe,X+=r*Ve,ie+=r*Oe,ue+=r*Ke,se+=r*Fe,W+=r*Me,Q+=r*He,r=t[10],x+=r*Ce,S+=r*Ee,I+=r*xe,B+=r*Ne,b+=r*Re,D+=r*Le,L+=r*ke,R+=r*Ue,q+=r*De,X+=r*Pe,ie+=r*Ve,ue+=r*Oe,se+=r*Ke,W+=r*Fe,Q+=r*Me,H+=r*He,r=t[11],S+=r*Ce,I+=r*Ee,B+=r*xe,b+=r*Ne,D+=r*Re,L+=r*Le,R+=r*ke,q+=r*Ue,X+=r*De,ie+=r*Pe,ue+=r*Ve,se+=r*Oe,W+=r*Ke,Q+=r*Fe,H+=r*Me,Y+=r*He,r=t[12],I+=r*Ce,B+=r*Ee,b+=r*xe,D+=r*Ne,L+=r*Re,R+=r*Le,q+=r*ke,X+=r*Ue,ie+=r*De,ue+=r*Pe,se+=r*Ve,W+=r*Oe,Q+=r*Ke,H+=r*Fe,Y+=r*Me,le+=r*He,r=t[13],B+=r*Ce,b+=r*Ee,D+=r*xe,L+=r*Ne,R+=r*Re,q+=r*Le,X+=r*ke,ie+=r*Ue,ue+=r*De,se+=r*Pe,W+=r*Ve,Q+=r*Oe,H+=r*Ke,Y+=r*Fe,le+=r*Me,K+=r*He,r=t[14],b+=r*Ce,D+=r*Ee,L+=r*xe,R+=r*Ne,q+=r*Re,X+=r*Le,ie+=r*ke,ue+=r*Ue,se+=r*De,W+=r*Pe,Q+=r*Ve,H+=r*Oe,Y+=r*Ke,le+=r*Fe,K+=r*Me,Ye+=r*He,r=t[15],D+=r*Ce,L+=r*Ee,R+=r*xe,q+=r*Ne,X+=r*Re,ie+=r*Le,ue+=r*ke,se+=r*Ue,W+=r*De,Q+=r*Pe,H+=r*Ve,Y+=r*Oe,le+=r*Ke,K+=r*Fe,Ye+=r*Me,jt+=r*He,s+=38*L,i+=38*R,o+=38*q,u+=38*X,l+=38*ie,c+=38*ue,f+=38*se,g+=38*W,m+=38*Q,y+=38*H,x+=38*Y,S+=38*le,I+=38*K,B+=38*Ye,b+=38*jt,n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=m+n+65535,n=Math.floor(r/65536),m=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=D+n+65535,n=Math.floor(r/65536),D=r-n*65536,s+=n-1+37*(n-1),n=1,r=s+n+65535,n=Math.floor(r/65536),s=r-n*65536,r=i+n+65535,n=Math.floor(r/65536),i=r-n*65536,r=o+n+65535,n=Math.floor(r/65536),o=r-n*65536,r=u+n+65535,n=Math.floor(r/65536),u=r-n*65536,r=l+n+65535,n=Math.floor(r/65536),l=r-n*65536,r=c+n+65535,n=Math.floor(r/65536),c=r-n*65536,r=f+n+65535,n=Math.floor(r/65536),f=r-n*65536,r=g+n+65535,n=Math.floor(r/65536),g=r-n*65536,r=m+n+65535,n=Math.floor(r/65536),m=r-n*65536,r=y+n+65535,n=Math.floor(r/65536),y=r-n*65536,r=x+n+65535,n=Math.floor(r/65536),x=r-n*65536,r=S+n+65535,n=Math.floor(r/65536),S=r-n*65536,r=I+n+65535,n=Math.floor(r/65536),I=r-n*65536,r=B+n+65535,n=Math.floor(r/65536),B=r-n*65536,r=b+n+65535,n=Math.floor(r/65536),b=r-n*65536,r=D+n+65535,n=Math.floor(r/65536),D=r-n*65536,s+=n-1+37*(n-1),e[0]=s,e[1]=i,e[2]=o,e[3]=u,e[4]=l,e[5]=c,e[6]=f,e[7]=g,e[8]=m,e[9]=y,e[10]=x,e[11]=S,e[12]=I,e[13]=B,e[14]=b,e[15]=D}var Ze=j;Ze.kem=Ze.kem||{};var qn=Ze.jsbn.BigInteger;Ze.kem.rsa={},Ze.kem.rsa.create=function(e,t){t=t||{};var a=t.prng||Ze.random,r={};return r.encrypt=function(n,s){var i=Math.ceil(n.n.bitLength()/8),o;do o=new qn(Ze.util.bytesToHex(a.getBytesSync(i)),16).mod(n.n);while(o.compareTo(qn.ONE)<=0);o=Ze.util.hexToBytes(o.toString(16));var u=i-o.length;u>0&&(o=Ze.util.fillString(String.fromCharCode(0),u)+o);var l=n.encrypt(o,"NONE"),c=e.generate(o,s);return{encapsulation:l,key:c}},r.decrypt=function(n,s,i){var o=n.decrypt(s,"NONE");return e.generate(o,i)},r},Ze.kem.kdf1=function(e,t){zn(this,e,0,t||e.digestLength)},Ze.kem.kdf2=function(e,t){zn(this,e,1,t||e.digestLength)};function zn(e,t,a,r){e.generate=function(n,s){for(var i=new Ze.util.ByteBuffer,o=Math.ceil(s/r)+a,u=new Ze.util.ByteBuffer,l=a;l<o;++l){u.putInt32(l),t.start(),t.update(n+u.getBytes());var c=t.digest();i.putBytes(c.getBytes(r))}return i.truncate(i.length()-s),i.getBytes()}}var te=j;te.log=te.log||{},te.log.levels=["none","error","warning","info","debug","verbose","max"];var Ur={},Ia=[],lr=null;te.log.LEVEL_LOCKED=2,te.log.NO_LEVEL_CHECK=4,te.log.INTERPOLATE=8;for(var Bt=0;Bt<te.log.levels.length;++Bt){var Qn=te.log.levels[Bt];Ur[Qn]={index:Bt,name:Qn.toUpperCase()}}te.log.logMessage=function(e){for(var t=Ur[e.level].index,a=0;a<Ia.length;++a){var r=Ia[a];if(r.flags&te.log.NO_LEVEL_CHECK)r.f(e);else{var n=Ur[r.level].index;t<=n&&r.f(r,e)}}},te.log.prepareStandard=function(e){"standard"in e||(e.standard=Ur[e.level].name+" ["+e.category+"] "+e.message)},te.log.prepareFull=function(e){if(!("full"in e)){var t=[e.message];t=t.concat([]),e.full=te.util.format.apply(this,t)}},te.log.prepareStandardFull=function(e){"standardFull"in e||(te.log.prepareStandard(e),e.standardFull=e.standard)};for(var Wn=["error","warning","info","debug","verbose"],Bt=0;Bt<Wn.length;++Bt)(function(t){te.log[t]=function(a,r){var n=Array.prototype.slice.call(arguments).slice(2),s={timestamp:new Date,level:t,category:a,message:r,arguments:n};te.log.logMessage(s)}})(Wn[Bt]);if(te.log.makeLogger=function(e){var t={flags:0,f:e};return te.log.setLevel(t,"none"),t},te.log.setLevel=function(e,t){var a=!1;if(e&&!(e.flags&te.log.LEVEL_LOCKED))for(var r=0;r<te.log.levels.length;++r){var n=te.log.levels[r];if(t==n){e.level=t,a=!0;break}}return a},te.log.lock=function(e,t){typeof t>"u"||t?e.flags|=te.log.LEVEL_LOCKED:e.flags&=~te.log.LEVEL_LOCKED},te.log.addLogger=function(e){Ia.push(e)},typeof console<"u"&&"log"in console){var ur;if(console.error&&console.warn&&console.info&&console.debug){var P0={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},Aa=function(e,t){te.log.prepareStandard(t);var a=P0[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),a.apply(console,r)};ur=te.log.makeLogger(Aa)}else{var Aa=function(t,a){te.log.prepareStandardFull(a),console.log(a.standardFull)};ur=te.log.makeLogger(Aa)}te.log.setLevel(ur,"debug"),te.log.addLogger(ur),lr=ur}else console={log:function(){}};if(lr!==null&&typeof window<"u"&&window.location){var Dr=new URL(window.location.href).searchParams;if(Dr.has("console.level")&&te.log.setLevel(lr,Dr.get("console.level").slice(-1)[0]),Dr.has("console.lock")){var V0=Dr.get("console.lock").slice(-1)[0];V0=="true"&&te.log.lock(lr)}}te.log.consoleLogger=lr;var U=j,C=U.asn1,Qe=U.pkcs7=U.pkcs7||{};Qe.messageFromPem=function(e){var t=U.pem.decode(e)[0];if(t.type!=="PKCS7"){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=t.type,a}if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var r=C.fromDer(t.body);return Qe.messageFromAsn1(r)},Qe.messageToPem=function(e,t){var a={type:"PKCS7",body:C.toDer(e.toAsn1()).getBytes()};return U.pem.encode(a,{maxline:t})},Qe.messageFromAsn1=function(e){var t={},a=[];if(!C.validate(e,Qe.asn1.contentInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw r.errors=a,r}var n=C.derToOid(t.contentType),s;switch(n){case U.pki.oids.envelopedData:s=Qe.createEnvelopedData();break;case U.pki.oids.encryptedData:s=Qe.createEncryptedData();break;case U.pki.oids.signedData:s=Qe.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+n+" is not (yet) supported.")}return s.fromAsn1(t.content.value[0]),s},Qe.createSignedData=function(){var e=null;return e={type:U.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(Ba(e,r,Qe.asn1.signedDataValidator),e.certificates=[],e.crls=[],e.digestAlgorithmIdentifiers=[],e.contentInfo=null,e.signerInfos=[],e.rawCapture.certificates)for(var n=e.rawCapture.certificates.value,s=0;s<n.length;++s)e.certificates.push(U.pki.certificateFromAsn1(n[s]))},toAsn1:function(){e.contentInfo||e.sign();for(var r=[],n=0;n<e.certificates.length;++n)r.push(U.pki.certificateToAsn1(e.certificates[n]));var s=[],i=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.digestAlgorithmIdentifiers),e.contentInfo])]);return r.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,r)),s.length>0&&i.value[0].value.push(C.create(C.Class.CONTEXT_SPECIFIC,1,!0,s)),i.value[0].value.push(C.create(C.Class.UNIVERSAL,C.Type.SET,!0,e.signerInfos)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),i])},addSigner:function(r){var n=r.issuer,s=r.serialNumber;if(r.certificate){var i=r.certificate;typeof i=="string"&&(i=U.pki.certificateFromPem(i)),n=i.issuer.attributes,s=i.serialNumber}var o=r.key;if(!o)throw new Error("Could not add PKCS#7 signer; no private key specified.");typeof o=="string"&&(o=U.pki.privateKeyFromPem(o));var u=r.digestAlgorithm||U.pki.oids.sha1;switch(u){case U.pki.oids.sha1:case U.pki.oids.sha256:case U.pki.oids.sha384:case U.pki.oids.sha512:case U.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+u)}var l=r.authenticatedAttributes||[];if(l.length>0){for(var c=!1,f=!1,g=0;g<l.length;++g){var m=l[g];if(!c&&m.type===U.pki.oids.contentType){if(c=!0,f)break;continue}if(!f&&m.type===U.pki.oids.messageDigest){if(f=!0,c)break;continue}}if(!c||!f)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}e.signers.push({key:o,version:1,issuer:n,serialNumber:s,digestAlgorithm:u,signatureAlgorithm:U.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:l,unauthenticatedAttributes:[]})},sign:function(r){if(r=r||{},(typeof e.content!="object"||e.contentInfo===null)&&(e.contentInfo=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(U.pki.oids.data).getBytes())]),"content"in e)){var n;e.content instanceof U.util.ByteBuffer?n=e.content.bytes():typeof e.content=="string"&&(n=U.util.encodeUtf8(e.content)),r.detached?e.detachedContent=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n):e.contentInfo.value.push(C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,n)]))}if(e.signers.length!==0){var s=t();a(s)}},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(r){typeof r=="string"&&(r=U.pki.certificateFromPem(r)),e.certificates.push(r)},addCertificateRevokationList:function(r){throw new Error("PKCS#7 CRL support not yet implemented.")}},e;function t(){for(var r={},n=0;n<e.signers.length;++n){var s=e.signers[n],i=s.digestAlgorithm;i in r||(r[i]=U.md[U.pki.oids[i]].create()),s.authenticatedAttributes.length===0?s.md=r[i]:s.md=U.md[U.pki.oids[i]].create()}e.digestAlgorithmIdentifiers=[];for(var i in r)e.digestAlgorithmIdentifiers.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(i).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]));return r}function a(r){var n;if(e.detachedContent?n=e.detachedContent:(n=e.contentInfo.value[1],n=n.value[0]),!n)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var s=C.derToOid(e.contentInfo.value[0].value),i=C.toDer(n);i.getByte(),C.getBerValueLength(i),i=i.getBytes();for(var o in r)r[o].start().update(i);for(var u=new Date,l=0;l<e.signers.length;++l){var c=e.signers[l];if(c.authenticatedAttributes.length===0){if(s!==U.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{c.authenticatedAttributesAsn1=C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var f=C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[]),g=0;g<c.authenticatedAttributes.length;++g){var m=c.authenticatedAttributes[g];m.type===U.pki.oids.messageDigest?m.value=r[c.digestAlgorithm].digest():m.type===U.pki.oids.signingTime&&(m.value||(m.value=u)),f.value.push(ba(m)),c.authenticatedAttributesAsn1.value.push(ba(m))}i=C.toDer(f).getBytes(),c.md.start().update(i)}c.signature=c.key.sign(c.md,"RSASSA-PKCS1-V1_5")}e.signerInfos=G0(e.signers)}},Qe.createEncryptedData=function(){var e=null;return e={type:U.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:U.pki.oids["aes256-CBC"]},fromAsn1:function(t){Ba(e,t,Qe.asn1.encryptedDataValidator)},decrypt:function(t){t!==void 0&&(e.encryptedContent.key=t),$n(e)}},e},Qe.createEnvelopedData=function(){var e=null;return e={type:U.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:U.pki.oids["aes256-CBC"]},fromAsn1:function(t){var a=Ba(e,t,Qe.asn1.envelopedDataValidator);e.recipients=F0(a.recipientInfos.value)},toAsn1:function(){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,M0(e.recipients)),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,q0(e.encryptedContent))])])])},findRecipient:function(t){for(var a=t.issuer.attributes,r=0;r<e.recipients.length;++r){var n=e.recipients[r],s=n.issuer;if(n.serialNumber===t.serialNumber&&s.length===a.length){for(var i=!0,o=0;o<a.length;++o)if(s[o].type!==a[o].type||s[o].value!==a[o].value){i=!1;break}if(i)return n}}return null},decrypt:function(t,a){if(e.encryptedContent.key===void 0&&t!==void 0&&a!==void 0)switch(t.encryptedContent.algorithm){case U.pki.oids.rsaEncryption:case U.pki.oids.desCBC:var r=a.decrypt(t.encryptedContent.content);e.encryptedContent.key=U.util.createBuffer(r);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}$n(e)},addRecipient:function(t){e.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:U.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,a){if(e.encryptedContent.content===void 0){a=a||e.encryptedContent.algorithm,t=t||e.encryptedContent.key;var r,n,s;switch(a){case U.pki.oids["aes128-CBC"]:r=16,n=16,s=U.aes.createEncryptionCipher;break;case U.pki.oids["aes192-CBC"]:r=24,n=16,s=U.aes.createEncryptionCipher;break;case U.pki.oids["aes256-CBC"]:r=32,n=16,s=U.aes.createEncryptionCipher;break;case U.pki.oids["des-EDE3-CBC"]:r=24,n=8,s=U.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+a)}if(t===void 0)t=U.util.createBuffer(U.random.getBytes(r));else if(t.length()!=r)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+r+".");e.encryptedContent.algorithm=a,e.encryptedContent.key=t,e.encryptedContent.parameter=U.util.createBuffer(U.random.getBytes(n));var i=s(t);if(i.start(e.encryptedContent.parameter.copy()),i.update(e.content),!i.finish())throw new Error("Symmetric encryption failed.");e.encryptedContent.content=i.output}for(var o=0;o<e.recipients.length;++o){var u=e.recipients[o];if(u.encryptedContent.content===void 0)switch(u.encryptedContent.algorithm){case U.pki.oids.rsaEncryption:u.encryptedContent.content=u.encryptedContent.key.encrypt(e.encryptedContent.key.data);break;default:throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm)}}}},e};function O0(e){var t={},a=[];if(!C.validate(e,Qe.asn1.recipientInfoValidator,t,a)){var r=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw r.errors=a,r}return{version:t.version.charCodeAt(0),issuer:U.pki.RDNAttributesAsArray(t.issuer),serialNumber:U.util.createBuffer(t.serial).toHex(),encryptedContent:{algorithm:C.derToOid(t.encAlgorithm),parameter:t.encParameter?t.encParameter.value:void 0,content:t.encKey}}}function K0(e){return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[U.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,U.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.encryptedContent.algorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")]),C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.encryptedContent.content)])}function F0(e){for(var t=[],a=0;a<e.length;++a)t.push(O0(e[a]));return t}function M0(e){for(var t=[],a=0;a<e.length;++a)t.push(K0(e[a]));return t}function H0(e){var t=C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,C.integerToDer(e.version).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[U.pki.distinguishedNameToAsn1({attributes:e.issuer}),C.create(C.Class.UNIVERSAL,C.Type.INTEGER,!1,U.util.hexToBytes(e.serialNumber))]),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.digestAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])]);if(e.authenticatedAttributesAsn1&&t.value.push(e.authenticatedAttributesAsn1),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.signatureAlgorithm).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.NULL,!1,"")])),t.value.push(C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.signature)),e.unauthenticatedAttributes.length>0){for(var a=C.create(C.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r<e.unauthenticatedAttributes.length;++r){var n=e.unauthenticatedAttributes[r];a.values.push(ba(n))}t.value.push(a)}return t}function G0(e){for(var t=[],a=0;a<e.length;++a)t.push(H0(e[a]));return t}function ba(e){var t;if(e.type===U.pki.oids.contentType)t=C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.value).getBytes());else if(e.type===U.pki.oids.messageDigest)t=C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.value.bytes());else if(e.type===U.pki.oids.signingTime){var a=new Date("1950-01-01T00:00:00Z"),r=new Date("2050-01-01T00:00:00Z"),n=e.value;if(typeof n=="string"){var s=Date.parse(n);isNaN(s)?n.length===13?n=C.utcTimeToDate(n):n=C.generalizedTimeToDate(n):n=new Date(s)}n>=a&&n<r?t=C.create(C.Class.UNIVERSAL,C.Type.UTCTIME,!1,C.dateToUtcTime(n)):t=C.create(C.Class.UNIVERSAL,C.Type.GENERALIZEDTIME,!1,C.dateToGeneralizedTime(n))}return C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.type).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SET,!0,[t])])}function q0(e){return[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(U.pki.oids.data).getBytes()),C.create(C.Class.UNIVERSAL,C.Type.SEQUENCE,!0,[C.create(C.Class.UNIVERSAL,C.Type.OID,!1,C.oidToDer(e.algorithm).getBytes()),e.parameter?C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.parameter.getBytes()):void 0]),C.create(C.Class.CONTEXT_SPECIFIC,0,!0,[C.create(C.Class.UNIVERSAL,C.Type.OCTETSTRING,!1,e.content.getBytes())])]}function Ba(e,t,a){var r={},n=[];if(!C.validate(t,a,r,n)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}var i=C.derToOid(r.contentType);if(i!==U.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(r.encryptedContent){var o="";if(U.util.isArray(r.encryptedContent))for(var u=0;u<r.encryptedContent.length;++u){if(r.encryptedContent[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=r.encryptedContent[u].value}else o=r.encryptedContent;e.encryptedContent={algorithm:C.derToOid(r.encAlgorithm),parameter:U.util.createBuffer(r.encParameter.value),content:U.util.createBuffer(o)}}if(r.content){var o="";if(U.util.isArray(r.content))for(var u=0;u<r.content.length;++u){if(r.content[u].type!==C.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=r.content[u].value}else o=r.content;e.content=U.util.createBuffer(o)}return e.version=r.version.charCodeAt(0),e.rawCapture=r,r}function $n(e){if(e.encryptedContent.key===void 0)throw new Error("Symmetric key not available.");if(e.content===void 0){var t;switch(e.encryptedContent.algorithm){case U.pki.oids["aes128-CBC"]:case U.pki.oids["aes192-CBC"]:case U.pki.oids["aes256-CBC"]:t=U.aes.createDecryptionCipher(e.encryptedContent.key);break;case U.pki.oids.desCBC:case U.pki.oids["des-EDE3-CBC"]:t=U.des.createDecryptionCipher(e.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+e.encryptedContent.algorithm)}if(t.start(e.encryptedContent.parameter),t.update(e.encryptedContent.content),!t.finish())throw new Error("Symmetric decryption failed.");e.content=t.output}}var me=j,Pr=me.ssh=me.ssh||{};Pr.privateKeyToPutty=function(e,t,a){a=a||"",t=t||"";var r="ssh-rsa",n=t===""?"none":"aes256-cbc",s="PuTTY-User-Key-File-2: "+r+`\r
`;s+="Encryption: "+n+`\r
`,s+="Comment: "+a+`\r
`;var i=me.util.createBuffer();$t(i,r),ht(i,e.e),ht(i,e.n);var o=me.util.encode64(i.bytes(),64),u=Math.floor(o.length/66)+1;s+="Public-Lines: "+u+`\r
`,s+=o;var l=me.util.createBuffer();ht(l,e.d),ht(l,e.p),ht(l,e.q),ht(l,e.qInv);var c;if(!t)c=me.util.encode64(l.bytes(),64);else{var f=l.length()+16-1;f-=f%16;var g=Vr(l.bytes());g.truncate(g.length()-f+l.length()),l.putBuffer(g);var m=me.util.createBuffer();m.putBuffer(Vr("\0\0\0\0",t)),m.putBuffer(Vr("\0\0\0",t));var y=me.aes.createEncryptionCipher(m.truncate(8),"CBC");y.start(me.util.createBuffer().fillWithByte(0,16)),y.update(l.copy()),y.finish();var x=y.output;x.truncate(16),c=me.util.encode64(x.bytes(),64)}u=Math.floor(c.length/66)+1,s+=`\r
Private-Lines: `+u+`\r
`,s+=c;var S=Vr("putty-private-key-file-mac-key",t),I=me.util.createBuffer();$t(I,r),$t(I,n),$t(I,a),I.putInt32(i.length()),I.putBuffer(i),I.putInt32(l.length()),I.putBuffer(l);var B=me.hmac.create();return B.start("sha1",S),B.update(I.bytes()),s+=`\r
Private-MAC: `+B.digest().toHex()+`\r
`,s},Pr.publicKeyToOpenSSH=function(e,t){var a="ssh-rsa";t=t||"";var r=me.util.createBuffer();return $t(r,a),ht(r,e.e),ht(r,e.n),a+" "+me.util.encode64(r.bytes())+" "+t},Pr.privateKeyToOpenSSH=function(e,t){return t?me.pki.encryptRsaPrivateKey(e,t,{legacy:!0,algorithm:"aes128"}):me.pki.privateKeyToPem(e)},Pr.getPublicKeyFingerprint=function(e,t){t=t||{};var a=t.md||me.md.md5.create(),r="ssh-rsa",n=me.util.createBuffer();$t(n,r),ht(n,e.e),ht(n,e.n),a.start(),a.update(n.getBytes());var s=a.digest();if(t.encoding==="hex"){var i=s.toHex();return t.delimiter?i.match(/.{2}/g).join(t.delimiter):i}else{if(t.encoding==="binary")return s.getBytes();if(t.encoding)throw new Error('Unknown encoding "'+t.encoding+'".')}return s};function ht(e,t){var a=t.toString(16);a[0]>="8"&&(a="00"+a);var r=me.util.hexToBytes(a);e.putInt32(r.length),e.putBytes(r)}function $t(e,t){e.putInt32(t.length),e.putString(t)}function Vr(){for(var e=me.md.sha1.create(),t=arguments.length,a=0;a<t;++a)e.update(arguments[a]);return e.digest()}var Yn=j;const z0=Jn({__proto__:null,default:ri(Yn)},[Yn]);ve.SSHTerminal=_a,ve.SSHTerminalElement=Na,ve.Vue3SSHTerminal=_a,ve.createTerminal=cr,Object.defineProperty(ve,Symbol.toStringTag,{value:"Module"})});