(function(){"use strict";var Kn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Mn(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 z={options:{usePureJavaScript:!1}},wr={},Hn=wr,Ea={};wr.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=Gn(e,t);else{var n=0,s=t.length,i=t.charAt(0),o=[0];for(n=0;n0;)o.push(u%s),u=u/s|0}for(n=0;e[n]===0&&n=0;--n)r+=t[o[n]]}if(a){var l=new RegExp(".{1,"+a+"}","g");r=r.match(l).join(`\r `)}return r},wr.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=Ea[t];if(!a){a=Ea[t]=[];for(var r=0;r>=8;for(;u>0;)i.push(u&255),u>>=8}for(var l=0;e[l]===s&&l0;)s.push(o%r),o=o/r|0}var f="";for(a=0;e.at(a)===0&&a=0;--a)f+=t[s[a]];return f}var xa=z,Sa=Hn,E=xa.util=xa.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 f=t.slice();t.length=0,f.forEach(function(u){u()})}};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(f){f()})}).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?Kn: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 Yt(e){if(!(e===8||e===16||e===24||e===32))throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}E.ByteBuffer=Lr;function Lr(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;aqn&&(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){Yt(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<0);return t},E.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<=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=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>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){Yt(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 Yt(t),this.accommodate(t/8),e<0&&(e+=2<0);return t},E.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),a=2<=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;t0;)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>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(e&255)};var pt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",vt=[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],Ta="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";E.encode64=function(e,t){for(var a="",r="",n,s,i,o=0;o>2),a+=pt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=pt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":pt.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>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:Sa.encode,decode:Sa.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>2),a+=pt.charAt((n&3)<<4|s>>4),isNaN(s)?a+="==":(a+=pt.charAt((s&15)<<2|i>>6),a+=isNaN(i)?"=":pt.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,f=0,u=a;f>4,i!==64&&(r[u++]=(s&15)<<4|i>>2,o!==64&&(r[u++]=(i&3)<<6|o));return t?u-a:r.subarray(0,u)},E.binary.base58.encode=function(e,t){return E.binary.baseN.encode(e,Ta,t)},E.binary.base58.decode=function(e,t){return E.binary.baseN.decode(e,Ta,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"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(f){i=f}if(s)break}if(!s)throw i;return r};E.setItem=function(e,t,a,r,n){nr(zn,arguments,n)},E.getItem=function(e,t,a,r){return nr(Yn,arguments,r)},E.removeItem=function(e,t,a,r){nr(Xn,arguments,r)},E.clearItems=function(e,t,a){nr(Wn,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");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,f=n<0?"-":"",u=parseInt(n=Math.abs(+n||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return f+(l?u.substr(0,l)+o:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(s?i+Math.abs(n-u).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;aa[r].end-a[r].start&&(r=a.length-1))}t.push(s)}if(a.length>0){var f=a[r];f.end-f.start>0&&(t.splice(f.start,f.end-f.start+1,""),f.start===0&&t.unshift(""),f.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(),f=o+4;self.postMessage({st:o,et:f})})}).toString(),")()"],{type:"application/javascript"}));r([],5,16);function r(i,o,f){if(o===0){var u=Math.floor(i.reduce(function(l,c){return l+c},0)/i.length);return E.cores=Math.max(1,u),URL.revokeObjectURL(a),t(null,E.cores)}n(f,function(l,c){i.push(s(f,c)),r(i,o-1,f)})}function n(i,o){for(var f=[],u=[],l=0;lC.st&&l.stl.st&&C.st0))return!0;for(var r=0;r0))return!0;for(var r=0;r0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},Y.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)},Y.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=ir(e.iv,this.blockSize),this._prev=this._iv.slice(0);else throw new Error("Invalid IV parameter.")},Y.cbc.prototype.encrypt=function(e,t,a){if(e.length()0))return!0;for(var r=0;r0))return!0;for(var r=0;r0)return!1;var a=e.length(),r=e.at(a-1);return r>this.blockSize<<2?!1:(e.truncate(r),!0)},Y.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=Ee.util.createBuffer(),this._partialBytes=0},Y.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Y.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;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&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},Y.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;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&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},Y.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=Ee.util.createBuffer(),this._partialBytes=0},Y.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Y.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;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n0)e.read-=this.blockSize;else for(var n=0;n0&&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},Y.ofb.prototype.decrypt=Y.ofb.prototype.encrypt,Y.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=Ee.util.createBuffer(),this._partialBytes=0},Y.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=ir(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},Y.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;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n0&&(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}sr(this._inBlock)},Y.ctr.prototype.decrypt=Y.ctr.prototype.encrypt,Y.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=Ee.util.createBuffer(),this._partialBytes=0,this._R=3774873600},Y.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t=Ee.util.createBuffer(e.iv);this._cipherLength=0;var a;if("additionalData"in e?a=Ee.util.createBuffer(e.additionalData):a=Ee.util.createBuffer(),"tagLength"in e?this._tagLength=e.tagLength:this._tagLength=128,this._tag=null,e.decrypt&&(this._tag=Ee.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(Pr(r*8)))}this._inBlock=this._j0.slice(0),sr(this._inBlock),this._partialBytes=0,a=Ee.util.createBuffer(a),this._aDataLength=Pr(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()])},Y.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;n0&&(s=this.blockSize-s),this._partialOutput.clear();for(var n=0;n0&&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),sr(this._inBlock)},Y.gcm.prototype.decrypt=function(e,t,a){var r=e.length();if(r0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),sr(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;n0;--r)t[r]=e[r]>>>1|(e[r-1]&1)<<31;t[0]=e[0]>>>1,a&&(t[0]^=this._R)},Y.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},Y.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)},Y.gcm.prototype.generateHashTable=function(e,t){for(var a=8/t,r=4*a,n=16*a,s=new Array(n),i=0;i>>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;s4){var a=e;e=Ee.util.createBuffer();for(var r=0;r>>2;for(var r=0;r>8^o&255^99,Ke[a]=o,Or[o]=a,f=e[o],n=e[a],s=e[n],i=e[s],u=f<<24^o<<16^o<<8^(o^f),l=(n^s^i)<<24^(a^i)<<16^(a^s^i)<<8^(a^n^i);for(var c=0;c<4;++c)It[c][a]=u,et[c][o]=l,u=u<<24|u>>>8,l=l<<24|l>>>8;a===0?a=r=1:(a=n^e[e[e[n^i]]],r^=e[e[r]])}}function Ba(e,t){for(var a=e.slice(0),r,n=1,s=a.length,i=s+6+1,o=kt*i,f=s;f>>16&255]<<24^Ke[r>>>8&255]<<16^Ke[r&255]<<8^Ke[r>>>24]^Ia[n]<<24,n++):s>6&&f%s===4&&(r=Ke[r>>>24]<<24^Ke[r>>>16&255]<<16^Ke[r>>>8&255]<<8^Ke[r&255]),a[f]=a[f-s]^r;if(t){var u,l=et[0],c=et[1],v=et[2],C=et[3],y=a.slice(0);o=a.length;for(var f=0,x=o-kt;f>>24]]^c[Ke[u>>>16&255]]^v[Ke[u>>>8&255]]^C[Ke[u&255]];a=y}return a}function Kr(e,t,a,r){var n=e.length/4-1,s,i,o,f,u;r?(s=et[0],i=et[1],o=et[2],f=et[3],u=Or):(s=It[0],i=It[1],o=It[2],f=It[3],u=Ke);var l,c,v,C,y,x,T;l=t[0]^e[0],c=t[r?3:1]^e[1],v=t[2]^e[2],C=t[r?1:3]^e[3];for(var I=3,B=1;B>>24]^i[c>>>16&255]^o[v>>>8&255]^f[C&255]^e[++I],x=s[c>>>24]^i[v>>>16&255]^o[C>>>8&255]^f[l&255]^e[++I],T=s[v>>>24]^i[C>>>16&255]^o[l>>>8&255]^f[c&255]^e[++I],C=s[C>>>24]^i[l>>>16&255]^o[c>>>8&255]^f[v&255]^e[++I],l=y,c=x,v=T;a[0]=u[l>>>24]<<24^u[c>>>16&255]<<16^u[v>>>8&255]<<8^u[C&255]^e[++I],a[r?3:1]=u[c>>>24]<<24^u[v>>>16&255]<<16^u[C>>>8&255]<<8^u[l&255]^e[++I],a[2]=u[v>>>24]<<24^u[C>>>16&255]<<16^u[l>>>8&255]<<8^u[c&255]^e[++I],a[r?1:3]=u[C>>>24]<<24^u[l>>>16&255]<<16^u[c>>>8&255]<<8^u[v&255]^e[++I]}function or(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="AES-"+t,r;e.decrypt?r=oe.cipher.createDecipher(a,e.key):r=oe.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof oe.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}var Xt=z;Xt.pki=Xt.pki||{};var Fr=Xt.pki.oids=Xt.oids=Xt.oids||{};function R(e,t){Fr[e]=t,Fr[t]=e}function te(e,t){Fr[e]=t}R("1.2.840.113549.1.1.1","rsaEncryption"),R("1.2.840.113549.1.1.4","md5WithRSAEncryption"),R("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),R("1.2.840.113549.1.1.7","RSAES-OAEP"),R("1.2.840.113549.1.1.8","mgf1"),R("1.2.840.113549.1.1.9","pSpecified"),R("1.2.840.113549.1.1.10","RSASSA-PSS"),R("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),R("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),R("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),R("1.3.101.112","EdDSA25519"),R("1.2.840.10040.4.3","dsa-with-sha1"),R("1.3.14.3.2.7","desCBC"),R("1.3.14.3.2.26","sha1"),R("1.3.14.3.2.29","sha1WithRSASignature"),R("2.16.840.1.101.3.4.2.1","sha256"),R("2.16.840.1.101.3.4.2.2","sha384"),R("2.16.840.1.101.3.4.2.3","sha512"),R("2.16.840.1.101.3.4.2.4","sha224"),R("2.16.840.1.101.3.4.2.5","sha512-224"),R("2.16.840.1.101.3.4.2.6","sha512-256"),R("1.2.840.113549.2.2","md2"),R("1.2.840.113549.2.5","md5"),R("1.2.840.113549.1.7.1","data"),R("1.2.840.113549.1.7.2","signedData"),R("1.2.840.113549.1.7.3","envelopedData"),R("1.2.840.113549.1.7.4","signedAndEnvelopedData"),R("1.2.840.113549.1.7.5","digestedData"),R("1.2.840.113549.1.7.6","encryptedData"),R("1.2.840.113549.1.9.1","emailAddress"),R("1.2.840.113549.1.9.2","unstructuredName"),R("1.2.840.113549.1.9.3","contentType"),R("1.2.840.113549.1.9.4","messageDigest"),R("1.2.840.113549.1.9.5","signingTime"),R("1.2.840.113549.1.9.6","counterSignature"),R("1.2.840.113549.1.9.7","challengePassword"),R("1.2.840.113549.1.9.8","unstructuredAddress"),R("1.2.840.113549.1.9.14","extensionRequest"),R("1.2.840.113549.1.9.20","friendlyName"),R("1.2.840.113549.1.9.21","localKeyId"),R("1.2.840.113549.1.9.22.1","x509Certificate"),R("1.2.840.113549.1.12.10.1.1","keyBag"),R("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),R("1.2.840.113549.1.12.10.1.3","certBag"),R("1.2.840.113549.1.12.10.1.4","crlBag"),R("1.2.840.113549.1.12.10.1.5","secretBag"),R("1.2.840.113549.1.12.10.1.6","safeContentsBag"),R("1.2.840.113549.1.5.13","pkcs5PBES2"),R("1.2.840.113549.1.5.12","pkcs5PBKDF2"),R("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),R("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),R("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),R("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),R("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),R("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),R("1.2.840.113549.2.7","hmacWithSHA1"),R("1.2.840.113549.2.8","hmacWithSHA224"),R("1.2.840.113549.2.9","hmacWithSHA256"),R("1.2.840.113549.2.10","hmacWithSHA384"),R("1.2.840.113549.2.11","hmacWithSHA512"),R("1.2.840.113549.3.7","des-EDE3-CBC"),R("2.16.840.1.101.3.4.1.2","aes128-CBC"),R("2.16.840.1.101.3.4.1.22","aes192-CBC"),R("2.16.840.1.101.3.4.1.42","aes256-CBC"),R("2.5.4.3","commonName"),R("2.5.4.4","surname"),R("2.5.4.5","serialNumber"),R("2.5.4.6","countryName"),R("2.5.4.7","localityName"),R("2.5.4.8","stateOrProvinceName"),R("2.5.4.9","streetAddress"),R("2.5.4.10","organizationName"),R("2.5.4.11","organizationalUnitName"),R("2.5.4.12","title"),R("2.5.4.13","description"),R("2.5.4.15","businessCategory"),R("2.5.4.17","postalCode"),R("2.5.4.42","givenName"),R("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),R("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),R("2.16.840.1.113730.1.1","nsCertType"),R("2.16.840.1.113730.1.13","nsComment"),te("2.5.29.1","authorityKeyIdentifier"),te("2.5.29.2","keyAttributes"),te("2.5.29.3","certificatePolicies"),te("2.5.29.4","keyUsageRestriction"),te("2.5.29.5","policyMapping"),te("2.5.29.6","subtreesConstraint"),te("2.5.29.7","subjectAltName"),te("2.5.29.8","issuerAltName"),te("2.5.29.9","subjectDirectoryAttributes"),te("2.5.29.10","basicConstraints"),te("2.5.29.11","nameConstraints"),te("2.5.29.12","policyConstraints"),te("2.5.29.13","basicConstraints"),R("2.5.29.14","subjectKeyIdentifier"),R("2.5.29.15","keyUsage"),te("2.5.29.16","privateKeyUsagePeriod"),R("2.5.29.17","subjectAltName"),R("2.5.29.18","issuerAltName"),R("2.5.29.19","basicConstraints"),te("2.5.29.20","cRLNumber"),te("2.5.29.21","cRLReason"),te("2.5.29.22","expirationDate"),te("2.5.29.23","instructionCode"),te("2.5.29.24","invalidityDate"),te("2.5.29.25","cRLDistributionPoints"),te("2.5.29.26","issuingDistributionPoint"),te("2.5.29.27","deltaCRLIndicator"),te("2.5.29.28","issuingDistributionPoint"),te("2.5.29.29","certificateIssuer"),te("2.5.29.30","nameConstraints"),R("2.5.29.31","cRLDistributionPoints"),R("2.5.29.32","certificatePolicies"),te("2.5.29.33","policyMappings"),te("2.5.29.34","policyConstraints"),R("2.5.29.35","authorityKeyIdentifier"),te("2.5.29.36","policyConstraints"),R("2.5.29.37","extKeyUsage"),te("2.5.29.46","freshestCRL"),te("2.5.29.54","inhibitAnyPolicy"),R("1.3.6.1.4.1.11129.2.4.2","timestampList"),R("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),R("1.3.6.1.5.5.7.3.1","serverAuth"),R("1.3.6.1.5.5.7.3.2","clientAuth"),R("1.3.6.1.5.5.7.3.3","codeSigning"),R("1.3.6.1.5.5.7.3.4","emailProtection"),R("1.3.6.1.5.5.7.3.8","timeStamping");var fe=z,U=fe.asn1=fe.asn1||{};U.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},U.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},U.create=function(e,t,a,r,n){if(fe.util.isArray(r)){for(var s=[],i=0;it){var r=new Error("Too few bytes to parse DER.");throw r.available=e.length(),r.remaining=t,r.requested=a,r}}var jn=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;Wt(e,t,s),r=e.getInt(s<<3)}if(r<0)throw new Error("Negative length: "+r);return r}};U.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=fe.util.createBuffer(e));var a=e.length(),r=ur(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 ur(e,t,a,r){var n;Wt(e,t,2);var s=e.getByte();t--;var i=s&192,o=s&31;n=e.length();var f=jn(e,t);if(t-=n-e.length(),f!==void 0&&f>t){if(r.strict){var u=new Error("Too few bytes to read ASN.1 value.");throw u.available=e.length(),u.remaining=t,u.requested=f,u}f=t}var l,c,v=(s&32)===32;if(v)if(l=[],f===void 0)for(;;){if(Wt(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}n=e.length(),l.push(ur(e,t,a+1,r)),t-=n-e.length()}else for(;f>0;)n=e.length(),l.push(ur(e,f,a+1,r)),t-=n-e.length(),f-=n-e.length();if(l===void 0&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&(c=e.bytes(f)),l===void 0&&r.decodeBitStrings&&i===U.Class.UNIVERSAL&&o===U.Type.BITSTRING&&f>1){var C=e.read,y=t,x=0;if(o===U.Type.BITSTRING&&(Wt(e,t,1),x=e.getByte(),t--),x===0)try{n=e.length();var T={strict:!0,decodeBitStrings:!0},I=ur(e,t,a+1,T),B=n-e.length();t-=B,o==U.Type.BITSTRING&&B++;var N=I.tagClass;B===f&&(N===U.Class.UNIVERSAL||N===U.Class.CONTEXT_SPECIFIC)&&(l=[I])}catch{}l===void 0&&(e.read=C,t=y)}if(l===void 0){if(f===void 0){if(r.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(o===U.Type.BMPSTRING)for(l="";f>0;f-=2)Wt(e,t,2),l+=String.fromCharCode(e.getInt16()),t-=2;else l=e.getBytes(f),t-=f}var V=c===void 0?null:{bitStringContents:c};return U.create(i,o,v,l,V)}U.toDer=function(e){var t=fe.util.createBuffer(),a=e.tagClass|e.type,r=fe.util.createBuffer(),n=!1;if("bitStringContents"in e&&(n=!0,e.original&&(n=U.equals(e,e.original))),n)r.putBytes(e.bitStringContents);else if(e.composed){e.constructed?a|=32:r.putByte(0);for(var s=0;s1&&(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},U.oidToDer=function(e){var t=e.split("."),a=fe.util.createBuffer();a.putByte(40*parseInt(t[0],10)+parseInt(t[1],10));for(var r,n,s,i,o=2;o>>7,r||(i|=128),n.push(i),r=!1;while(s>0);for(var f=n.length-1;f>=0;--f)a.putByte(n[f])}return a},U.derToOid=function(e){var t;typeof e=="string"&&(e=fe.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},U.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 f=e.charAt(10),u=10;f!=="+"&&f!=="-"&&(o=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,0),u&&(f=e.charAt(u),f==="+"||f==="-")){var l=parseInt(e.substr(u+1,2),10),c=parseInt(e.substr(u+4,2),10),v=l*60+c;v*=6e4,f==="+"?t.setTime(+t-v):t.setTime(+t+v)}return t},U.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),f=0,u=0,l=!1;e.charAt(e.length-1)==="Z"&&(l=!0);var c=e.length-5,v=e.charAt(c);if(v==="+"||v==="-"){var C=parseInt(e.substr(c+1,2),10),y=parseInt(e.substr(c+4,2),10);u=C*60+y,u*=6e4,v==="+"&&(u*=-1),l=!0}return e.charAt(14)==="."&&(f=parseFloat(e.substr(14),10)*1e3),l?(t.setUTCFullYear(a,r,n),t.setUTCHours(s,i,o,f),t.setTime(+t+u)):(t.setFullYear(a,r,n),t.setHours(s,i,o,f)),t},U.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=-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},U.derToInteger=function(e){typeof e=="string"&&(e=fe.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)},U.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&&fe.util.isArray(t.value))for(var s=0,i=0;n&&i0&&(r+=` `);for(var n="",s=0;s1?r+="0x"+fe.util.bytesToHex(e.value.slice(1)):r+="(none)",e.value.length>0){var u=e.value.charCodeAt(0);u==1?r+=" (1 unused bit shown)":u>1&&(r+=" ("+u+" unused bits shown)")}}else if(e.type===U.Type.OCTETSTRING)ba.test(e.value)||(r+="("+e.value+") "),r+="0x"+fe.util.bytesToHex(e.value);else if(e.type===U.Type.UTF8)try{r+=fe.util.decodeUtf8(e.value)}catch(l){if(l.message==="URI malformed")r+="0x"+fe.util.bytesToHex(e.value)+" (malformed UTF8)";else throw l}else e.type===U.Type.PRINTABLESTRING||e.type===U.Type.IA5String?r+=e.value:ba.test(e.value)?r+="0x"+fe.util.bytesToHex(e.value):e.value.length===0?r+="[null]":r+=e.value}return r};var fr=z;fr.md=fr.md||{},fr.md.algorithms=fr.md.algorithms||{};var lt=z,$n=lt.hmac=lt.hmac||{};$n.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 lt.md.algorithms)t=lt.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=lt.util.createBuffer(i);else if(lt.util.isArray(i)){var o=i;i=lt.util.createBuffer();for(var f=0;ft.blockLength&&(t.start(),t.update(i.bytes()),i=t.digest()),a=lt.util.createBuffer(),r=lt.util.createBuffer(),u=i.length();for(var f=0;f>>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),Ra(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=rt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Mr.substr(0,r.blockLength-i));for(var o,f=0,u=r.fullMessageLength.length-1;u>=0;--u)o=r.fullMessageLength[u]*8+f,f=o/4294967296>>>0,n.putInt32Le(o>>>0);var l={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3};Ra(l,a,n);var c=rt.util.createBuffer();return c.putInt32Le(l.h0),c.putInt32Le(l.h1),c.putInt32Le(l.h2),c.putInt32Le(l.h3),c},r};var Mr=null,lr=null,jt=null,Ut=null,Na=!1;function Zn(){Mr=String.fromCharCode(128),Mr+=rt.util.fillString(String.fromCharCode(0),64),lr=[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],jt=[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],Ut=new Array(64);for(var e=0;e<64;++e)Ut[e]=Math.floor(Math.abs(Math.sin(e+1))*4294967296);Na=!0}function Ra(e,t,a){for(var r,n,s,i,o,f,u,l,c=a.length();c>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,l=0;l<16;++l)t[l]=a.getInt32Le(),f=o^s&(i^o),r=n+f+Ut[l]+t[l],u=jt[l],n=o,o=i,i=s,s+=r<>>32-u;for(;l<32;++l)f=i^o&(s^i),r=n+f+Ut[l]+t[lr[l]],u=jt[l],n=o,o=i,i=s,s+=r<>>32-u;for(;l<48;++l)f=s^i^o,r=n+f+Ut[l]+t[lr[l]],u=jt[l],n=o,o=i,i=s,s+=r<>>32-u;for(;l<64;++l)f=i^(s|~o),r=n+f+Ut[l]+t[lr[l]],u=jt[l],n=o,o=i,i=s,s+=r<>>32-u;e.h0=e.h0+n|0,e.h1=e.h1+s|0,e.h2=e.h2+i|0,e.h3=e.h3+o|0,c-=64}}var cr=z,wa=cr.pem=cr.pem||{};wa.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+=hr(r)),e.contentDomain&&(r={name:"Content-Domain",values:[e.contentDomain]},a+=hr(r)),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),a+=hr(r)),e.headers)for(var n=0;n65&&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 Jn(e){return e.replace(/^\s+/,"")}var ce=z;ce.des=ce.des||{},ce.des.startEncrypting=function(e,t,a,r){var n=dr({key:e,output:a,decrypt:!1,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ce.des.createEncryptionCipher=function(e,t){return dr({key:e,output:null,decrypt:!1,mode:t})},ce.des.startDecrypting=function(e,t,a,r){var n=dr({key:e,output:a,decrypt:!0,mode:r||(t===null?"ECB":"CBC")});return n.start(t),n},ce.des.createDecryptionCipher=function(e,t){return dr({key:e,output:null,decrypt:!0,mode:t})},ce.des.Algorithm=function(e,t){var a=this;a.name=e,a.mode=new t({blockSize:8,cipher:{encrypt:function(r,n){return La(a._keys,r,n,!1)},decrypt:function(r,n){return La(a._keys,r,n,!0)}}}),a._init=!1},ce.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=ce.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=ui(t),this._init=!0}},at("DES-ECB",ce.cipher.modes.ecb),at("DES-CBC",ce.cipher.modes.cbc),at("DES-CFB",ce.cipher.modes.cfb),at("DES-OFB",ce.cipher.modes.ofb),at("DES-CTR",ce.cipher.modes.ctr),at("3DES-ECB",ce.cipher.modes.ecb),at("3DES-CBC",ce.cipher.modes.cbc),at("3DES-CFB",ce.cipher.modes.cfb),at("3DES-OFB",ce.cipher.modes.ofb),at("3DES-CTR",ce.cipher.modes.ctr);function at(e,t){var a=function(){return new ce.des.Algorithm(e,t)};ce.cipher.registerAlgorithm(e,a)}var ei=[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],ti=[-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],ri=[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],ai=[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],ni=[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],ii=[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],oi=[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 ui(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],f=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],u=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],l=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],c=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],v=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],C=[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,T=[],I=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],B=0,N,V=0;V>>4^w)&252645135,w^=N,D^=N<<4,N=(w>>>-16^D)&65535,D^=N,w^=N<<-16,N=(D>>>2^w)&858993459,w^=N,D^=N<<2,N=(w>>>-16^D)&65535,D^=N,w^=N<<-16,N=(D>>>1^w)&1431655765,w^=N,D^=N<<1,N=(w>>>8^D)&16711935,D^=N,w^=N<<8,N=(D>>>1^w)&1431655765,w^=N,D^=N<<1,N=D<<8|w>>>20&240,D=w<<24|w<<8&16711680|w>>>8&65280|w>>>24&240,w=N;for(var q=0;q>>26,w=w<<2|w>>>26):(D=D<<1|D>>>27,w=w<<1|w>>>27),D&=-15,w&=-15;var j=t[D>>>28]|a[D>>>24&15]|r[D>>>20&15]|n[D>>>16&15]|s[D>>>12&15]|i[D>>>8&15]|o[D>>>4&15],re=f[w>>>28]|u[w>>>24&15]|l[w>>>20&15]|c[w>>>16&15]|v[w>>>12&15]|C[w>>>8&15]|y[w>>>4&15];N=(re>>>16^j)&65535,T[B++]=j^N,T[B++]=re^N<<16}}return T}function La(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],f=t[1];i=(o>>>4^f)&252645135,f^=i,o^=i<<4,i=(o>>>16^f)&65535,f^=i,o^=i<<16,i=(f>>>2^o)&858993459,o^=i,f^=i<<2,i=(f>>>8^o)&16711935,o^=i,f^=i<<8,i=(o>>>1^f)&1431655765,f^=i,o^=i<<1,o=o<<1|o>>>31,f=f<<1|f>>>31;for(var u=0;u>>4|f<<28)^e[v+1];i=o,o=f,f=i^(ti[C>>>24&63]|ai[C>>>16&63]|ii[C>>>8&63]|oi[C&63]|ei[y>>>24&63]|ri[y>>>16&63]|ni[y>>>8&63]|si[y&63])}i=o,o=f,f=i}o=o>>>1|o<<31,f=f>>>1|f<<31,i=(o>>>1^f)&1431655765,f^=i,o^=i<<1,i=(f>>>8^o)&16711935,o^=i,f^=i<<8,i=(f>>>2^o)&858993459,o^=i,f^=i<<2,i=(o>>>16^f)&65535,f^=i,o^=i<<16,i=(o>>>4^f)&252645135,f^=i,o^=i<<4,a[0]=o,a[1]=f}function dr(e){e=e||{};var t=(e.mode||"CBC").toUpperCase(),a="DES-"+t,r;e.decrypt?r=ce.cipher.createDecipher(a,e.key):r=ce.cipher.createCipher(a,e.key);var n=r.start;return r.start=function(s,i){var o=null;i instanceof ce.util.ByteBuffer&&(o=i,i={}),i=i||{},i.output=o,i.iv=s,n.call(r,i)},r}var fi={},li=Object.freeze({__proto__:null,default:fi}),Hr=Mn(li),Fe=z,ci=Fe.pkcs5=Fe.pkcs5||{},ct;Fe.util.isNodejs&&!Fe.options.usePureJavaScript&&(ct=Hr),Fe.pbkdf2=ci.pbkdf2=function(e,t,a,r,n,s){if(typeof n=="function"&&(s=n,n=null),Fe.util.isNodejs&&!Fe.options.usePureJavaScript&&ct.pbkdf2&&(n===null||typeof n!="object")&&(ct.pbkdf2Sync.length>4||!n||n==="sha1"))return typeof n!="string"&&(n="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),s?ct.pbkdf2Sync.length===4?ct.pbkdf2(e,t,a,r,function(N,V){if(N)return s(N);s(null,V.toString("binary"))}):ct.pbkdf2(e,t,a,r,n,function(N,V){if(N)return s(N);s(null,V.toString("binary"))}):ct.pbkdf2Sync.length===4?ct.pbkdf2Sync(e,t,a,r).toString("binary"):ct.pbkdf2Sync(e,t,a,r,n).toString("binary");if((typeof n>"u"||n===null)&&(n="sha1"),typeof n=="string"){if(!(n in Fe.md.algorithms))throw new Error("Unknown hash algorithm: "+n);n=Fe.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 f=Math.ceil(r/i),u=r-(f-1)*i,l=Fe.hmac.create();l.start(n,e);var c="",v,C,y;if(!s){for(var x=1;x<=f;++x){l.start(null,null),l.update(t),l.update(Fe.util.int32ToBytes(x)),v=y=l.digest().getBytes();for(var T=2;T<=a;++T)l.start(null,null),l.update(y),C=l.digest().getBytes(),v=Fe.util.xorBytes(v,C,i),y=C;c+=xf)return s(null,c);l.start(null,null),l.update(t),l.update(Fe.util.int32ToBytes(x)),v=y=l.digest().getBytes(),T=2,B()}function B(){if(T<=a)return l.start(null,null),l.update(y),C=l.digest().getBytes(),v=Fe.util.xorBytes(v,C,i),y=C,++T,Fe.util.setImmediate(B);c+=x>>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),Pa(e,a,t),(t.read>2048||t.length()===0)&&t.compact(),r},r.digest=function(){var n=nt.util.createBuffer();n.putBytes(t.bytes());var s=r.fullMessageLength[r.fullMessageLength.length-1]+r.messageLengthSize,i=s&r.blockLength-1;n.putBytes(Gr.substr(0,r.blockLength-i));for(var o,f,u=r.fullMessageLength[0]*8,l=0;l>>0,u+=f,n.putInt32(u>>>0),u=o>>>0;n.putInt32(u);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};Pa(c,a,n);var v=nt.util.createBuffer();return v.putInt32(c.h0),v.putInt32(c.h1),v.putInt32(c.h2),v.putInt32(c.h3),v.putInt32(c.h4),v.putInt32(c.h5),v.putInt32(c.h6),v.putInt32(c.h7),v},r};var Gr=null,ka=!1,Ua=null;function hi(){Gr=String.fromCharCode(128),Gr+=nt.util.fillString(String.fromCharCode(0),64),Ua=[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],ka=!0}function Pa(e,t,a){for(var r,n,s,i,o,f,u,l,c,v,C,y,x,T,I,B=a.length();B>=64;){for(u=0;u<16;++u)t[u]=a.getInt32();for(;u<64;++u)r=t[u-2],r=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10,n=t[u-15],n=(n>>>7|n<<25)^(n>>>18|n<<14)^n>>>3,t[u]=r+t[u-7]+n+t[u-16]|0;for(l=e.h0,c=e.h1,v=e.h2,C=e.h3,y=e.h4,x=e.h5,T=e.h6,I=e.h7,u=0;u<64;++u)i=(y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7),o=T^y&(x^T),s=(l>>>2|l<<30)^(l>>>13|l<<19)^(l>>>22|l<<10),f=l&c|v&(l^c),r=I+i+o+Ua[u]+t[u],n=s+f,I=T,T=x,x=y,y=C+r>>>0,C=v,v=c,c=l,l=r+n>>>0;e.h0=e.h0+l|0,e.h1=e.h1+c|0,e.h2=e.h2+v|0,e.h3=e.h3+C|0,e.h4=e.h4+y|0,e.h5=e.h5+x|0,e.h6=e.h6+T|0,e.h7=e.h7+I|0,B-=64}}var it=z,pr=null;it.util.isNodejs&&!it.options.usePureJavaScript&&!process.versions["node-webkit"]&&(pr=Hr);var di=it.prng=it.prng||{};di.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(u,l){if(!l)return t.generateSync(u);var c=t.plugin.cipher,v=t.plugin.increment,C=t.plugin.formatKey,y=t.plugin.formatSeed,x=it.util.createBuffer();t.key=null,T();function T(I){if(I)return l(I);if(x.length()>=u)return l(null,x.getBytes(u));if(t.generated>1048575&&(t.key=null),t.key===null)return it.util.nextTick(function(){s(T)});var B=c(t.key,t.seed);t.generated+=B.length,x.putBytes(B),t.key=C(c(t.key,v(t.seed))),t.seed=y(c(t.key,t.seed)),it.util.setImmediate(T)}},t.generateSync=function(u){var l=t.plugin.cipher,c=t.plugin.increment,v=t.plugin.formatKey,C=t.plugin.formatSeed;t.key=null;for(var y=it.util.createBuffer();y.length()1048575&&(t.key=null),t.key===null&&i();var x=l(t.key,t.seed);t.generated+=x.length,y.putBytes(x),t.key=v(l(t.key,c(t.seed))),t.seed=C(l(t.key,t.seed))}return y.getBytes(u)};function s(u){if(t.pools[0].messageLength>=32)return o(),u();var l=32-t.pools[0].messageLength<<5;t.seedFile(l,function(c,v){if(c)return u(c);t.collect(v),o(),u()})}function i(){if(t.pools[0].messageLength>=32)return o();var u=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(u)),o()}function o(){t.reseeds=t.reseeds===4294967295?0:t.reseeds+1;var u=t.plugin.md.create();u.update(t.keyBytes);for(var l=1,c=0;c<32;++c)t.reseeds%l===0&&(u.update(t.pools[c].digest().getBytes()),t.pools[c].start()),l=l<<1;t.keyBytes=u.digest().getBytes(),u.start(),u.update(t.keyBytes);var v=u.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(v),t.generated=0}function f(u){var l=null,c=it.util.globalScope,v=c.crypto||c.msCrypto;v&&v.getRandomValues&&(l=function(D){return v.getRandomValues(D)});var C=it.util.createBuffer();if(l)for(;C.length()>16),B+=(I&32767)<<16,B+=I>>15,B=(B&2147483647)+(B>>31),V=B&4294967295;for(var T=0;T<3;++T)N=V>>>(T<<3),N^=Math.floor(Math.random()*256),C.putByte(N&255)}return C.getBytes(u)}return pr?(t.seedFile=function(u,l){pr.randomBytes(u,function(c,v){if(c)return l(c);l(null,v.toString())})},t.seedFileSync=function(u){return pr.randomBytes(u).toString()}):(t.seedFile=function(u,l){try{l(null,f(u))}catch(c){l(c)}},t.seedFileSync=f),t.collect=function(u){for(var l=u.length,c=0;c>v&255);t.collect(c)},t.registerWorker=function(u){if(u===self)t.seedFile=function(c,v){function C(y){var x=y.data;x.forge&&x.forge.prng&&(self.removeEventListener("message",C),v(x.forge.prng.err,x.forge.prng.bytes))}self.addEventListener("message",C),self.postMessage({forge:{prng:{needed:c}}})};else{var l=function(c){var v=c.data;v.forge&&v.forge.prng&&t.seedFile(v.forge.prng.needed,function(C,y){u.postMessage({forge:{prng:{err:C,bytes:y}}})})};u.addEventListener("message",l)}},t};var xe=z;(function(){if(xe.random&&xe.random.getBytes){xe.random;return}(function(e){var t={},a=new Array(4),r=xe.util.createBuffer();t.formatKey=function(c){var v=xe.util.createBuffer(c);return c=new Array(4),c[0]=v.getInt32(),c[1]=v.getInt32(),c[2]=v.getInt32(),c[3]=v.getInt32(),xe.aes._expandKey(c,!1)},t.formatSeed=function(c){var v=xe.util.createBuffer(c);return c=new Array(4),c[0]=v.getInt32(),c[1]=v.getInt32(),c[2]=v.getInt32(),c[3]=v.getInt32(),c},t.cipher=function(c,v){return xe.aes._updateBlock(c,v,a,!1),r.putInt32(a[0]),r.putInt32(a[1]),r.putInt32(a[2]),r.putInt32(a[3]),r.getBytes()},t.increment=function(c){return++c[3],c},t.md=xe.md.sha256;function n(){var c=xe.prng.create(t);return c.getBytes=function(v,C){return c.generate(v,C)},c.getBytesSync=function(v){return c.generate(v)},c}var s=n(),i=null,o=xe.util.globalScope,f=o.crypto||o.msCrypto;if(f&&f.getRandomValues&&(i=function(c){return f.getRandomValues(c)}),xe.options.usePureJavaScript||!xe.util.isNodejs&&!i){if(s.collectInt(+new Date,32),typeof navigator<"u"){var u="";for(var l in navigator)try{typeof navigator[l]=="string"&&(u+=navigator[l])}catch{}s.collect(u),u=null}e&&(e().mousemove(function(c){s.collectInt(c.clientX,16),s.collectInt(c.clientY,16)}),e().keypress(function(c){s.collectInt(c.charCode,8)}))}if(!xe.random)xe.random=s;else for(var l in s)xe.random[l]=s[l];xe.random.createInstance=n,xe.random})(typeof jQuery<"u"?jQuery:null)})();var Ge=z,qr=[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],Va=[1,2,3,5],pi=function(e,t){return e<>16-t},vi=function(e,t){return(e&65535)>>t|e<<16-t&65535};Ge.rc2=Ge.rc2||{},Ge.rc2.expandKey=function(e,t){typeof e=="string"&&(e=Ge.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(qr[a.at(o-1)+a.at(o-r)&255]);for(a.setAt(128-s,qr[a.at(128-s)&i]),o=127-s;o>=0;o--)a.setAt(o,qr[a.at(o+1)^a.at(o+s)]);return a};var Oa=function(e,t,a){var r=!1,n=null,s=null,i=null,o,f,u,l,c=[];for(e=Ge.rc2.expandKey(e,t),u=0;u<64;u++)c.push(e.getInt16Le());a?(o=function(y){for(u=0;u<4;u++)y[u]+=c[l]+(y[(u+3)%4]&y[(u+2)%4])+(~y[(u+3)%4]&y[(u+1)%4]),y[u]=pi(y[u],Va[u]),l++},f=function(y){for(u=0;u<4;u++)y[u]+=c[y[(u+3)%4]&63]}):(o=function(y){for(u=3;u>=0;u--)y[u]=vi(y[u],Va[u]),y[u]-=c[l]+(y[(u+3)%4]&y[(u+2)%4])+(~y[(u+3)%4]&y[(u+1)%4]),l--},f=function(y){for(u=3;u>=0;u--)y[u]-=c[y[(u+3)%4]&63]});var v=function(y){var x=[];for(u=0;u<4;u++){var T=n.getInt16Le();i!==null&&(a?T^=i.getInt16Le():i.putInt16Le(T)),x.push(T&65535)}l=a?0:63;for(var I=0;I=8;)v([[5,o],[1,f],[6,o],[1,f],[5,o]])},finish:function(y){var x=!0;if(a)if(y)x=y(8,n,!a);else{var T=n.length()===8?8:8-n.length();n.fillWithByte(T,T)}if(x&&(r=!0,C.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}},C};Ge.rc2.startEncrypting=function(e,t,a){var r=Ge.rc2.createEncryptionCipher(e,128);return r.start(t,a),r},Ge.rc2.createEncryptionCipher=function(e,t){return Oa(e,t,!0)},Ge.rc2.startDecrypting=function(e,t,a){var r=Ge.rc2.createDecryptionCipher(e,128);return r.start(t,a),r},Ge.rc2.createDecryptionCipher=function(e,t){return Oa(e,t,!1)};var Qr=z;Qr.jsbn=Qr.jsbn||{};var ht;function b(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))}Qr.jsbn.BigInteger=b;function J(){return new b(null)}function yi(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 gi(e,t,a,r,n,s){for(var i=t&32767,o=t>>15;--s>=0;){var f=this.data[e]&32767,u=this.data[e++]>>15,l=o*f+u*i;f=i*f+((l&32767)<<15)+a.data[r]+(n&1073741823),n=(f>>>30)+(l>>>15)+o*u+(n>>>30),a.data[r++]=f&1073741823}return n}function Ka(e,t,a,r,n,s){for(var i=t&16383,o=t>>14;--s>=0;){var f=this.data[e]&16383,u=this.data[e++]>>14,l=o*f+u*i;f=i*f+((l&16383)<<14)+a.data[r]+n,n=(f>>28)+(l>>14)+o*u,a.data[r++]=f&268435455}return n}typeof navigator>"u"?(b.prototype.am=Ka,ht=28):navigator.appName=="Microsoft Internet Explorer"?(b.prototype.am=gi,ht=30):navigator.appName!="Netscape"?(b.prototype.am=yi,ht=26):(b.prototype.am=Ka,ht=28),b.prototype.DB=ht,b.prototype.DM=(1<=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s}function Ei(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 yt(e){var t=J();return t.fromInt(e),t}function xi(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:Ma(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):this.data[this.t-1]|=i<=this.DB&&(s-=this.DB)}a==8&&e[0]&128&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<0&&this.data[this.t-1]==e;)--this.t}function Ti(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<0)for(o>o)>0&&(n=!0,s=Fa(r));i>=0;)o>(o+=this.DB-t)):(r=this.data[i]>>(o-=t)&a,o<=0&&(o+=this.DB,--i)),r>0&&(n=!0),n&&(s+=Fa(r));return n?s:"0"}function Ii(){var e=J();return b.ZERO.subTo(this,e),e}function Ai(){return this.s<0?this.negate():this}function Bi(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 yr(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 bi(){return this.t<=0?0:this.DB*(this.t-1)+yr(this.data[this.t-1]^this.s&this.DM)}function _i(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 Ni(e,t){for(var a=e;a=0;--o)t.data[o+s+1]=this.data[o]>>r|i,i=(this.data[o]&n)<=0;--o)t.data[o]=0;t.data[s]=i,t.t=this.t+s+1,t.s=this.s,t.clamp()}function wi(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;for(var i=a+1;i>r;r>0&&(t.data[this.t-a-1]|=(this.s&s)<>=this.DB;if(e.t>=this.DB;r+=this.s}else{for(r+=this.s;a>=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 Di(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=0;)e.data[a]=0;for(a=0;a=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 Ui(e,t,a){var r=e.abs();if(!(r.t<=0)){var n=this.abs();if(n.t0?(r.lShiftTo(f,s),n.lShiftTo(f,a)):(r.copyTo(s),n.copyTo(a));var u=s.t,l=s.data[u-1];if(l!=0){var c=l*(1<1?s.data[u-2]>>this.F2:0),v=this.FV/c,C=(1<=0&&(a.data[a.t++]=1,a.subTo(I,a)),b.ONE.dlShiftTo(u,I),I.subTo(s,s);s.t=0;){var B=a.data[--x]==l?this.DM:Math.floor(a.data[x]*v+(a.data[x-1]+y)*C);if((a.data[x]+=s.am(0,B,a,T,0,u))0&&a.rShiftTo(f,a),i<0&&b.ZERO.subTo(a,a)}}}function Pi(e){var t=J();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(b.ZERO)>0&&e.subTo(t,t),t}function At(e){this.m=e}function Vi(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function Oi(e){return e}function Ki(e){e.divRemTo(this.m,null,e)}function Fi(e,t,a){e.multiplyTo(t,a),this.reduce(a)}function Mi(e,t){e.squareTo(t),this.reduce(t)}At.prototype.convert=Vi,At.prototype.revert=Oi,At.prototype.reduce=Ki,At.prototype.mulTo=Fi,At.prototype.sqrTo=Mi;function Hi(){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 Bt(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function qi(e){var t=J();return e.copyTo(t),this.reduce(t),t}function Qi(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;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 zi(e,t){e.squareTo(t),this.reduce(t)}function Yi(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Bt.prototype.convert=Gi,Bt.prototype.revert=qi,Bt.prototype.reduce=Qi,Bt.prototype.mulTo=Yi,Bt.prototype.sqrTo=zi;function Xi(){return(this.t>0?this.data[0]&1:this.s)==0}function Wi(e,t){if(e>4294967295||e<1)return b.ONE;var a=J(),r=J(),n=t.convert(this),s=yr(e)-1;for(n.copyTo(a);--s>=0;)if(t.sqrTo(a,r),(e&1<0)t.mulTo(r,n,a);else{var i=a;a=r,r=i}return t.revert(a)}function ji(e,t){var a;return e<256||t.isEven()?a=new At(t):a=new Bt(t),this.exp(e,a)}b.prototype.copyTo=mi,b.prototype.fromInt=Ei,b.prototype.fromString=xi,b.prototype.clamp=Si,b.prototype.dlShiftTo=_i,b.prototype.drShiftTo=Ni,b.prototype.lShiftTo=Ri,b.prototype.rShiftTo=wi,b.prototype.subTo=Li,b.prototype.multiplyTo=Di,b.prototype.squareTo=ki,b.prototype.divRemTo=Ui,b.prototype.invDigit=Hi,b.prototype.isEven=Xi,b.prototype.exp=Wi,b.prototype.toString=Ti,b.prototype.negate=Ii,b.prototype.abs=Ai,b.prototype.compareTo=Bi,b.prototype.bitLength=bi,b.prototype.mod=Pi,b.prototype.modPowInt=ji,b.ZERO=yt(0),b.ONE=yt(1);function $i(){var e=J();return this.copyTo(e),e}function Zi(){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)<>24}function es(){return this.t==0?this.s:this.data[0]<<16>>16}function ts(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function rs(){return this.s<0?-1:this.t<=0||this.t==1&&this.data[0]<=0?0:1}function as(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=yt(a),n=J(),s=J(),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 ns(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=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&&b.ZERO.subTo(this,this)}function is(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(b.ONE.shiftLeft(e-1),Yr,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(b.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<0)for(a>a)!=(this.s&this.DM)>>a&&(t[n++]=r|this.s<=0;)a<8?(r=(this.data[e]&(1<>(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 os(e){return this.compareTo(e)==0}function us(e){return this.compareTo(e)<0?this:e}function fs(e){return this.compareTo(e)>0?this:e}function ls(e,t,a){var r,n,s=Math.min(e.t,this.t);for(r=0;r>=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 Es(){for(var e=0;e=this.t?this.s!=0:(this.data[t]&1<>=this.DB;if(e.t>=this.DB;r+=this.s}else{for(r+=this.s;a>=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 Ns(e){var t=J();return this.addTo(e,t),t}function Rs(e){var t=J();return this.subTo(e,t),t}function ws(e){var t=J();return this.multiplyTo(e,t),t}function Ls(e){var t=J();return this.divRemTo(e,t,null),t}function Ds(e){var t=J();return this.divRemTo(e,null,t),t}function ks(e){var t=J(),a=J();return this.divRemTo(e,t,a),new Array(t,a)}function Us(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function Ps(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 $t(){}function qa(e){return e}function Vs(e,t,a){e.multiplyTo(t,a)}function Os(e,t){e.squareTo(t)}$t.prototype.convert=qa,$t.prototype.revert=qa,$t.prototype.mulTo=Vs,$t.prototype.sqrTo=Os;function Ks(e){return this.exp(e,new $t)}function Fs(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=0;)a.data[r]=0;for(r=Math.max(t-this.t,0);r2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=J();return e.copyTo(t),this.reduce(t),t}function Gs(e){return e}function qs(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 Qs(e,t){e.squareTo(t),this.reduce(t)}function zs(e,t,a){e.multiplyTo(t,a),this.reduce(a)}Vt.prototype.convert=Hs,Vt.prototype.revert=Gs,Vt.prototype.reduce=qs,Vt.prototype.mulTo=zs,Vt.prototype.sqrTo=Qs;function Ys(e,t){var a=e.bitLength(),r,n=yt(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 At(t):t.isEven()?s=new Vt(t):s=new Bt(t);var i=new Array,o=3,f=r-1,u=(1<1){var l=J();for(s.sqrTo(i[1],l);o<=u;)i[o]=J(),s.mulTo(l,i[o-2],i[o]),o+=2}var c=e.t-1,v,C=!0,y=J(),x;for(a=yr(e.data[c])-1;c>=0;){for(a>=f?v=e.data[c]>>a-f&u:(v=(e.data[c]&(1<0&&(v|=e.data[c-1]>>this.DB+a-f)),o=r;!(v&1);)v>>=1,--o;if((a-=o)<0&&(a+=this.DB,--c),C)i[v].copyTo(n),C=!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[v],n)}for(;c>=0&&!(e.data[c]&1<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 Ws(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 js(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return b.ZERO;for(var a=e.clone(),r=this.clone(),n=yt(1),s=yt(0),i=yt(0),o=yt(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(b.ONE)!=0)return b.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 tt=[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],$s=(1<<26)/tt[tt.length-1];function Zs(e){var t,a=this.abs();if(a.t==1&&a.data[0]<=tt[tt.length-1]){for(t=0;t=0);var o=s.modPow(r,this);if(o.compareTo(b.ONE)!=0&&o.compareTo(t)!=0){for(var f=1;f++>>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),Ya(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(Xr.substr(0,r.blockLength-i));for(var o,f,u=r.fullMessageLength[0]*8,l=0;l>>0,u+=f,n.putInt32(u>>>0),u=o>>>0;n.putInt32(u);var c={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};Ya(c,a,n);var v=st.util.createBuffer();return v.putInt32(c.h0),v.putInt32(c.h1),v.putInt32(c.h2),v.putInt32(c.h3),v.putInt32(c.h4),v},r};var Xr=null,za=!1;function t0(){Xr=String.fromCharCode(128),Xr+=st.util.fillString(String.fromCharCode(0),64),za=!0}function Ya(e,t,a){for(var r,n,s,i,o,f,u,l,c=a.length();c>=64;){for(n=e.h0,s=e.h1,i=e.h2,o=e.h3,f=e.h4,l=0;l<16;++l)r=a.getInt32(),t[l]=r,u=o^s&(i^o),r=(n<<5|n>>>27)+u+f+1518500249+r,f=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;l<20;++l)r=t[l-3]^t[l-8]^t[l-14]^t[l-16],r=r<<1|r>>>31,t[l]=r,u=o^s&(i^o),r=(n<<5|n>>>27)+u+f+1518500249+r,f=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;l<32;++l)r=t[l-3]^t[l-8]^t[l-14]^t[l-16],r=r<<1|r>>>31,t[l]=r,u=s^i^o,r=(n<<5|n>>>27)+u+f+1859775393+r,f=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;l<40;++l)r=t[l-6]^t[l-16]^t[l-28]^t[l-32],r=r<<2|r>>>30,t[l]=r,u=s^i^o,r=(n<<5|n>>>27)+u+f+1859775393+r,f=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;l<60;++l)r=t[l-6]^t[l-16]^t[l-28]^t[l-32],r=r<<2|r>>>30,t[l]=r,u=s&i|o&(s^i),r=(n<<5|n>>>27)+u+f+2400959708+r,f=o,o=i,i=(s<<30|s>>>2)>>>0,s=n,n=r;for(;l<80;++l)r=t[l-6]^t[l-16]^t[l-28]^t[l-32],r=r<<2|r>>>30,t[l]=r,u=s^i^o,r=(n<<5|n>>>27)+u+f+3395469782+r,f=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+f|0,c-=64}}var ot=z,Xa=ot.pkcs1=ot.pkcs1||{};Xa.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=ot.md.sha1.create(),i||(i=s);var o=Math.ceil(e.n.bitLength()/8),f=o-2*s.digestLength-2;if(t.length>f){var u=new Error("RSAES-OAEP input message length is too long.");throw u.length=t.length,u.maxLength=f,u}r||(r=""),s.update(r,"raw");for(var l=s.digest(),c="",v=f-t.length,C=0;C>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 gt=z;(function(){if(gt.prime){gt.prime;return}var e=gt.prime=gt.prime||{},t=gt.jsbn.BigInteger,a=[6,4,2,4,2,4,6,2],r=new t(null);r.fromInt(30);var n=function(c,v){return c|v};e.generateProbablePrime=function(c,v,C){typeof v=="function"&&(C=v,v={}),v=v||{};var y=v.algorithm||"PRIMEINC";typeof y=="string"&&(y={name:y}),y.options=y.options||{};var x=v.prng||gt.random,T={nextBytes:function(I){for(var B=x.getBytesSync(I.length),N=0;Nv&&(c=u(v,C)),c.isProbablePrime(x))return I(null,c);c.dAddOffset(a[y++%8],0)}while(T<0||+new Date-B"u")return i(c,v,C,y);var x=u(c,v),T=C.workers,I=C.workLoad||100,B=I*30/8,N=C.workerScript||"forge/prime.worker.js";if(T===-1)return gt.util.estimateCores(function(D,w){D&&(w=2),T=w-1,V()});V();function V(){T=Math.max(1,T);for(var D=[],w=0;wc&&(x=u(c,v));var he=x.toString(16);re.target.postMessage({hex:he,workLoad:I}),x.dAddOffset(B,0)}}}}function u(c,v){var C=new t(c,v),y=c-1;return C.testBit(y)||C.bitwiseTo(t.ONE.shiftLeft(y),n,C),C.dAddOffset(31-C.mod(r).byteValue(),0),C}function l(c){return c<=100?27:c<=150?18:c<=200?15:c<=250?12:c<=300?9:c<=350?8:c<=400?7:c<=500?6:c<=600?5:c<=800?4:c<=1250?3:2}})();var F=z;if(typeof ee>"u")var ee=F.jsbn.BigInteger;var Wr=F.util.isNodejs?Hr:null,S=F.asn1,We=F.util;F.pki=F.pki||{},F.pki.rsa=F.rsa=F.rsa||{};var G=F.pki,r0=[6,4,2,4,2,4,6,2],a0={name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},n0={name:"RSAPrivateKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},i0={name:"RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:S.Class.UNIVERSAL,type:S.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},s0=F.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},o0={name:"DigestInfo",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:S.Class.UNIVERSAL,type:S.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:S.Class.UNIVERSAL,type:S.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:S.Class.UNIVERSAL,type:S.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:S.Class.UNIVERSAL,type:S.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},u0=function(e){var t;if(e.algorithm in G.oids)t=G.oids[e.algorithm];else{var a=new Error("Unknown message digest algorithm.");throw a.algorithm=e.algorithm,a}var r=S.oidToDer(t).getBytes(),n=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]),s=S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[]);s.value.push(S.create(S.Class.UNIVERSAL,S.Type.OID,!1,r)),s.value.push(S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,""));var i=S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,e.digest().getBytes());return n.value.push(s),n.value.push(i),S.toDer(n).getBytes()},Wa=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(ee.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(ee.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));var r;do r=new ee(F.util.bytesToHex(F.random.getBytes(t.n.bitLength()/8)),16);while(r.compareTo(t.n)>=0||!r.gcd(t.n).equals(ee.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};G.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=ja(e,t,a)):(n=F.util.createBuffer(),n.putBytes(e));for(var i=new ee(n.toHex(),16),o=Wa(i,t,r),f=o.toString(16),u=F.util.createBuffer(),l=s-Math.ceil(f.length/2);l>0;)u.putByte(0),--l;return u.putBytes(F.util.hexToBytes(f)),u.getBytes()},G.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 ee(F.util.createBuffer(e).toHex(),16);if(i.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var o=Wa(i,t,a),f=o.toString(16),u=F.util.createBuffer(),l=n-Math.ceil(f.length/2);l>0;)u.putByte(0),--l;return u.putBytes(F.util.hexToBytes(f)),r!==!1?Cr(u.getBytes(),t,a):u.getBytes()},G.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 f=r.getBytesSync(o.length),u=0;u>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},G.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var a=new ee(null);a.fromInt(30);for(var r=0,n=function(c,v){return c|v},s=+new Date,i,o=0;e.keys===null&&(t<=0||of?e.pqState=0:e.num.isProbablePrime(l0(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(r0[r++%8],0):e.pqState===2?e.pqState=e.num.subtract(ee.ONE).gcd(e.e).compareTo(ee.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(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(e.state===3)e.phi.gcd(e.e).compareTo(ee.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 l=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)}}i=+new Date,o+=i-s,s=i}return e.keys!==null},G.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($a("generateKeyPair"))return Wr.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(o,f,u){if(o)return r(o);r(null,{privateKey:G.privateKeyFromPem(u),publicKey:G.publicKeyFromPem(f)})});if(Za("generateKey")&&Za("exportKey"))return We.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:en(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(o){return We.globalScope.crypto.subtle.exportKey("pkcs8",o.privateKey)}).then(void 0,function(o){r(o)}).then(function(o){if(o){var f=G.privateKeyFromAsn1(S.fromDer(F.util.createBuffer(o)));r(null,{privateKey:f,publicKey:G.setRsaPublicKey(f.n,f.e)})}});if(Ja("generateKey")&&Ja("exportKey")){var n=We.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:en(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);n.oncomplete=function(o){var f=o.target.result,u=We.globalScope.msCrypto.subtle.exportKey("pkcs8",f.privateKey);u.oncomplete=function(l){var c=l.target.result,v=G.privateKeyFromAsn1(S.fromDer(F.util.createBuffer(c)));r(null,{privateKey:v,publicKey:G.setRsaPublicKey(v.n,v.e)})},u.onerror=function(l){r(l)}},n.onerror=function(o){r(o)};return}}else if($a("generateKeyPairSync")){var s=Wr.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:G.privateKeyFromPem(s.privateKey),publicKey:G.publicKeyFromPem(s.publicKey)}}}var i=G.rsa.createKeyPairGenerationState(e,t,a);if(!r)return G.rsa.stepKeyPairGenerationState(i,0),i.keys;f0(i,a,r)},G.setRsaPublicKey=G.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,f,u){return ja(o,f,2).getBytes()}};else if(n==="RSA-OAEP"||n==="RSAES-OAEP")n={encode:function(o,f){return F.pkcs1.encode_rsa_oaep(f,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 G.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(f,u){u=Cr(u,a,!0);var l=S.fromDer(u,{parseAllBytes:i._parseAllDigestBytes}),c={},v=[];if(!S.validate(l,o0,c,v)){var C=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.");throw C.errors=v,C}var y=S.derToOid(c.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 C=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.");throw C.oid=y,C}if((y===F.oids.md2||y===F.oids.md5)&&!("parameters"in c))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return f===c.digest}}:(s==="NONE"||s==="NULL"||s===null)&&(s={verify:function(f,u){return u=Cr(u,a,!0),f===u}});var o=G.rsa.decrypt(n,a,!0,!1);return s.verify(r,o,a.n.bitLength())},a},G.setRsaPrivateKey=G.rsa.setPrivateKey=function(e,t,a,r,n,s,i,o){var f={n:e,e:t,d:a,p:r,q:n,dP:s,dQ:i,qInv:o};return f.decrypt=function(u,l,c){typeof l=="string"?l=l.toUpperCase():l===void 0&&(l="RSAES-PKCS1-V1_5");var v=G.rsa.decrypt(u,f,!1,!1);if(l==="RSAES-PKCS1-V1_5")l={decode:Cr};else if(l==="RSA-OAEP"||l==="RSAES-OAEP")l={decode:function(C,y){return F.pkcs1.decode_rsa_oaep(y,C,c)}};else if(["RAW","NONE","NULL",null].indexOf(l)!==-1)l={decode:function(C){return C}};else throw new Error('Unsupported encryption scheme: "'+l+'".');return l.decode(v,f,!1)},f.sign=function(u,l){var c=!1;typeof l=="string"&&(l=l.toUpperCase()),l===void 0||l==="RSASSA-PKCS1-V1_5"?(l={encode:u0},c=1):(l==="NONE"||l==="NULL"||l===null)&&(l={encode:function(){return u}},c=1);var v=l.encode(u,f.n.bitLength());return G.rsa.encrypt(v,f,c)},f},G.wrapRsaPrivateKey=function(e){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(G.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.OCTETSTRING,!1,S.toDer(e).getBytes())])},G.privateKeyFromAsn1=function(e){var t={},a=[];if(S.validate(e,a0,t,a)&&(e=S.fromDer(F.util.createBuffer(t.privateKey))),t={},a=[],!S.validate(e,n0,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,f,u,l,c;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(),f=F.util.createBuffer(t.privateKeyPrime2).toHex(),u=F.util.createBuffer(t.privateKeyExponent1).toHex(),l=F.util.createBuffer(t.privateKeyExponent2).toHex(),c=F.util.createBuffer(t.privateKeyCoefficient).toHex(),G.setRsaPrivateKey(new ee(n,16),new ee(s,16),new ee(i,16),new ee(o,16),new ee(f,16),new ee(u,16),new ee(l,16),new ee(c,16))},G.privateKeyToAsn1=G.privateKeyToRSAPrivateKey=function(e){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,S.integerToDer(0).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.e)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.d)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.p)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.q)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.dP)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.dQ)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.qInv))])},G.publicKeyFromAsn1=function(e){var t={},a=[];if(S.validate(e,s0,t,a)){var r=S.derToOid(t.publicKeyOid);if(r!==G.oids.rsaEncryption){var n=new Error("Cannot read public key. Unknown OID.");throw n.oid=r,n}e=t.rsaPublicKey}if(a=[],!S.validate(e,i0,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 G.setRsaPublicKey(new ee(s,16),new ee(i,16))},G.publicKeyToAsn1=G.publicKeyToSubjectPublicKeyInfo=function(e){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.OID,!1,S.oidToDer(G.oids.rsaEncryption).getBytes()),S.create(S.Class.UNIVERSAL,S.Type.NULL,!1,"")]),S.create(S.Class.UNIVERSAL,S.Type.BITSTRING,!1,[G.publicKeyToRSAPublicKey(e)])])},G.publicKeyToRSAPublicKey=function(e){return S.create(S.Class.UNIVERSAL,S.Type.SEQUENCE,!0,[S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.n)),S.create(S.Class.UNIVERSAL,S.Type.INTEGER,!1,ut(e.e))])};function ja(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 f=0;f0;){for(var u=0,l=F.random.getBytes(i),f=0;f"u")throw new Error("Encryption block is invalid.");var f=0;if(o===0){f=n-3-r;for(var u=0;u1;){if(s.getByte()!==255){--s.read;break}++f}else if(o===2)for(f=0;s.length()>1;){if(s.getByte()===0){--s.read;break}++f}var l=s.getByte();if(l!==0||f!==n-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function f0(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,f){if(o)return a(o);if(e.p=f,e.q!==null)return i(o,e.q);s(e.qBits,i)})}function s(o,f){F.prime.generateProbablePrime(o,r,f)}function i(o,f){if(o)return a(o);if(e.q=f,e.p.compareTo(e.q)<0){var u=e.p;e.p=e.q,e.q=u}if(e.p.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.p=null,n();return}if(e.q.subtract(ee.ONE).gcd(e.e).compareTo(ee.ONE)!==0){e.q=null,s(e.qBits,i);return}if(e.p1=e.p.subtract(ee.ONE),e.q1=e.q.subtract(ee.ONE),e.phi=e.p1.multiply(e.q1),e.phi.gcd(e.e).compareTo(ee.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 l=e.e.modInverse(e.phi);e.keys={privateKey:G.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:G.rsa.setPublicKey(e.n,e.e)},a(null,e.keys)}}function ut(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 l0(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 $a(e){return F.util.isNodejs&&typeof Wr[e]=="function"}function Za(e){return typeof We.globalScope<"u"&&typeof We.globalScope.crypto=="object"&&typeof We.globalScope.crypto.subtle=="object"&&typeof We.globalScope.crypto.subtle[e]=="function"}function Ja(e){return typeof We.globalScope<"u"&&typeof We.globalScope.msCrypto=="object"&&typeof We.globalScope.msCrypto.subtle=="object"&&typeof We.globalScope.msCrypto.subtle[e]=="function"}function en(e){for(var t=F.util.hexToBytes(e.toString(16)),a=new Uint8Array(t.length),r=0;r"u")var c0=O.jsbn.BigInteger;var A=O.asn1,Q=O.pki=O.pki||{};Q.pbe=O.pbe=O.pbe||{};var bt=Q.oids,h0={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"}]},d0={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"}]}]},p0={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"}]};Q.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,f;if(a.algorithm.indexOf("aes")===0||a.algorithm==="des"){var u,l,c;switch(a.algorithm){case"aes128":i=16,u=16,l=bt["aes128-CBC"],c=O.aes.createEncryptionCipher;break;case"aes192":i=24,u=16,l=bt["aes192-CBC"],c=O.aes.createEncryptionCipher;break;case"aes256":i=32,u=16,l=bt["aes256-CBC"],c=O.aes.createEncryptionCipher;break;case"des":i=8,u=8,l=bt.desCBC,c=O.des.createEncryptionCipher;break;default:var v=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw v.algorithm=a.algorithm,v}var C="hmacWith"+a.prfAlgorithm.toUpperCase(),y=an(C),x=O.pkcs5.pbkdf2(t,r,n,i,y),T=O.random.getBytesSync(u),I=c(x);I.start(T),I.update(A.toDer(e)),I.finish(),f=I.output.getBytes();var B=v0(r,s,i,C);o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(bt.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(bt.pkcs5PBKDF2).getBytes()),B]),A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(l).getBytes()),A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,T)])])])}else if(a.algorithm==="3des"){i=24;var N=new O.util.ByteBuffer(r),x=Q.pbe.generatePkcs12Key(t,N,1,n,i),T=Q.pbe.generatePkcs12Key(t,N,2,n,i),I=O.des.createEncryptionCipher(x);I.start(T),I.update(A.toDer(e)),I.finish(),f=I.output.getBytes(),o=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[A.create(A.Class.UNIVERSAL,A.Type.OID,!1,A.oidToDer(bt["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 v=new Error("Cannot encrypt private key. Unknown encryption algorithm.");throw v.algorithm=a.algorithm,v}var V=A.create(A.Class.UNIVERSAL,A.Type.SEQUENCE,!0,[o,A.create(A.Class.UNIVERSAL,A.Type.OCTETSTRING,!1,f)]);return V},Q.decryptPrivateKeyInfo=function(e,t){var a=null,r={},n=[];if(!A.validate(e,h0,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=Q.pbe.getCipher(i,r.encryptionParams,t),f=O.util.createBuffer(r.encryptedData);return o.update(f),o.finish()&&(a=A.fromDer(o.output)),a},Q.encryptedPrivateKeyToPem=function(e,t){var a={type:"ENCRYPTED PRIVATE KEY",body:A.toDer(e).getBytes()};return O.pem.encode(a,{maxline:t})},Q.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)},Q.encryptRsaPrivateKey=function(e,t,a){if(a=a||{},!a.legacy){var r=Q.wrapRsaPrivateKey(Q.privateKeyToAsn1(e));return r=Q.encryptPrivateKeyInfo(r,t,a),Q.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 f=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw f.algorithm=a.algorithm,f}var u=O.pbe.opensslDeriveBytes(t,s.substr(0,8),i),l=o(u);l.start(s),l.update(A.toDer(Q.privateKeyToAsn1(e))),l.finish();var c={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:n,parameters:O.util.bytesToHex(s).toUpperCase()},body:l.output.getBytes()};return O.pem.encode(c)},Q.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(c){return O.rc2.createDecryptionCipher(c,40)};break;case"RC2-64-CBC":s=8,i=function(c){return O.rc2.createDecryptionCipher(c,64)};break;case"RC2-128-CBC":s=16,i=function(c){return O.rc2.createDecryptionCipher(c,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),f=O.pbe.opensslDeriveBytes(t,o.substr(0,8),s),u=i(f);if(u.start(o),u.update(O.util.createBuffer(r.body)),u.finish())a=u.output.getBytes();else return a}else a=r.body;return r.type==="ENCRYPTED PRIVATE KEY"?a=Q.decryptPrivateKeyInfo(A.fromDer(a),t):a=A.fromDer(a),a!==null&&(a=Q.privateKeyFromAsn1(a)),a},Q.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 f=s.digestLength,u=s.blockLength,l=new O.util.ByteBuffer,c=new O.util.ByteBuffer;if(e!=null){for(o=0;o=0;o--)he=he>>8,he+=j.at(o)+ie.at(o),ie.setAt(o,he&255);ne.putBuffer(ie)}N=ne,l.putBuffer(w)}return l.truncate(l.length()-n),l},Q.pbe.getCipher=function(e,t,a){switch(e){case Q.oids.pkcs5PBES2:return Q.pbe.getCipherForPBES2(e,t,a);case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:return Q.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}},Q.pbe.getCipherForPBES2=function(e,t,a){var r={},n=[];if(!A.validate(t,d0,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!==Q.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!==Q.oids["aes128-CBC"]&&e!==Q.oids["aes192-CBC"]&&e!==Q.oids["aes256-CBC"]&&e!==Q.oids["des-EDE3-CBC"]&&e!==Q.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 f,u;switch(Q.oids[e]){case"aes128-CBC":f=16,u=O.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,u=O.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,u=O.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,u=O.des.createDecryptionCipher;break;case"desCBC":f=8,u=O.des.createDecryptionCipher;break}var l=rn(r.prfOid),c=O.pkcs5.pbkdf2(a,i,o,f,l),v=r.encIv,C=u(c);return C.start(v),C},Q.pbe.getCipherForPKCS12PBE=function(e,t,a){var r={},n=[];if(!A.validate(t,p0,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 f,u,l;switch(e){case Q.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:f=24,u=8,l=O.des.startDecrypting;break;case Q.oids["pbewithSHAAnd40BitRC2-CBC"]:f=5,u=8,l=function(x,T){var I=O.rc2.createDecryptionCipher(x,40);return I.start(T,null),I};break;default:var s=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.");throw s.oid=e,s}var c=rn(r.prfOid),v=Q.pbe.generatePkcs12Key(a,i,1,o,f,c);c.start();var C=Q.pbe.generatePkcs12Key(a,i,2,o,u,c);return l(v,C)},Q.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=[tn(r,e+t)],s=16,i=1;s>8*v-c&255;return D=String.fromCharCode(D.charCodeAt(0)&~w)+D.substr(1),D+T+String.fromCharCode(188)},o.verify=function(f,u,l){var c,v=l-1,C=Math.ceil(v/8);if(u=u.substr(-C),C>8*C-v&255;if(x.charCodeAt(0)&I)throw new Error("Bits beyond keysize not zero as expected.");var B=a.generate(T,y),N="";for(c=0;c2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(f.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(i.validity.notBefore=f[0],i.validity.notAfter=f[1],i.tbsCertificate=a.tbsCertificate,t){i.md=xr({signatureOid:i.signatureOid,type:"certificate"});var u=h.toDer(i.tbsCertificate);i.md.update(u.getBytes())}var l=M.md.sha1.create(),c=h.toDer(a.certIssuer);l.update(c.getBytes()),i.issuer.getField=function(y){return Ct(i.issuer,y)},i.issuer.addField=function(y){je([y]),i.issuer.attributes.push(y)},i.issuer.attributes=L.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(i.issuer.uniqueId=a.certIssuerUniqueId),i.issuer.hash=l.digest().toHex();var v=M.md.sha1.create(),C=h.toDer(a.certSubject);return v.update(C.getBytes()),i.subject.getField=function(y){return Ct(i.subject,y)},i.subject.addField=function(y){je([y]),i.subject.attributes.push(y)},i.subject.attributes=L.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(i.subject.uniqueId=a.certSubjectUniqueId),i.subject.hash=v.digest().toHex(),a.certExtensions?i.extensions=L.certificateExtensionsFromAsn1(a.certExtensions):i.extensions=[],i.publicKey=L.publicKeyFromAsn1(a.subjectPublicKeyInfo),i},L.certificateExtensionsFromAsn1=function(e){for(var t=[],a=0;a1&&(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=h.fromDer(t.value);a.value.length>0&&a.value[0].type===h.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===h.Type.INTEGER?s=a.value[0].value:a.value.length>1&&(s=a.value[1].value),s!==null&&(t.pathLenConstraint=h.derToInteger(s))}else if(t.name==="extKeyUsage")for(var a=h.fromDer(t.value),i=0;i1&&(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 f,a=h.fromDer(t.value),u=0;u"u"&&(t.type&&t.type in L.oids?t.name=L.oids[t.type]:t.shortName&&t.shortName in de&&(t.name=L.oids[de[t.shortName]])),typeof t.type>"u")if(t.name&&t.name in L.oids)t.type=L.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 de&&(t.shortName=de[t.name]),t.type===Z.extensionRequest&&(t.valueConstructed=!0,t.valueTagClass=h.Type.SEQUENCE,!t.value&&t.extensions)){t.value=[];for(var n=0;n"u"){var r=new Error("Attribute value not specified.");throw r.attribute=t,r}}}function fn(e,t){if(t=t||{},typeof e.name>"u"&&e.id&&e.id in L.oids&&(e.name=L.oids[e.id]),typeof e.id>"u")if(e.name&&e.name in L.oids)e.id=L.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=h.create(h.Class.UNIVERSAL,h.Type.BITSTRING,!1,i)}else if(e.name==="basicConstraints")e.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]),e.cA&&e.value.value.push(h.create(h.Class.UNIVERSAL,h.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in e&&e.value.value.push(h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(e.pathLenConstraint).getBytes()));else if(e.name==="extKeyUsage"){e.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]);var o=e.value.value;for(var f in e)e[f]===!0&&(f in Z?o.push(h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(Z[f]).getBytes())):f.indexOf(".")!==-1&&o.push(h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(f).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=h.create(h.Class.UNIVERSAL,h.Type.BITSTRING,!1,i)}else if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]);for(var u,l=0;l128)throw new Error('Invalid "nsComment" content.');e.value=h.create(h.Class.UNIVERSAL,h.Type.IA5STRING,!1,e.comment)}else if(e.name==="subjectKeyIdentifier"&&t.cert){var c=t.cert.generateSubjectKeyIdentifier();e.subjectKeyIdentifier=c.toHex(),e.value=h.create(h.Class.UNIVERSAL,h.Type.OCTETSTRING,!1,c.getBytes())}else if(e.name==="authorityKeyIdentifier"&&t.cert){e.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]);var o=e.value.value;if(e.keyIdentifier){var v=e.keyIdentifier===!0?t.cert.generateSubjectKeyIdentifier().getBytes():e.keyIdentifier;o.push(h.create(h.Class.CONTEXT_SPECIFIC,0,!1,v))}if(e.authorityCertIssuer){var C=[h.create(h.Class.CONTEXT_SPECIFIC,4,!0,[Ft(e.authorityCertIssuer===!0?t.cert.issuer:e.authorityCertIssuer)])];o.push(h.create(h.Class.CONTEXT_SPECIFIC,1,!0,C))}if(e.serialNumber){var y=M.util.hexToBytes(e.serialNumber===!0?t.cert.serialNumber:e.serialNumber);o.push(h.create(h.Class.CONTEXT_SPECIFIC,2,!1,y))}}else if(e.name==="cRLDistributionPoints"){e.value=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]);for(var o=e.value.value,x=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]),T=h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[]),u,l=0;l"u"){var a=new Error("Extension value not specified.");throw a.extension=e,a}return e}function jr(e,t){switch(e){case Z["RSASSA-PSS"]:var a=[];return t.hash.algorithmOid!==void 0&&a.push(h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(t.hash.algorithmOid).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,"")])])),t.mgf.algorithmOid!==void 0&&a.push(h.create(h.Class.CONTEXT_SPECIFIC,1,!0,[h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(t.mgf.algorithmOid).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(t.mgf.hash.algorithmOid).getBytes()),h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,"")])])])),t.saltLength!==void 0&&a.push(h.create(h.Class.CONTEXT_SPECIFIC,2,!0,[h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(t.saltLength).getBytes())])),h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,a);default:return h.create(h.Class.UNIVERSAL,h.Type.NULL,!1,"")}}function T0(e){var t=h.create(h.Class.CONTEXT_SPECIFIC,0,!0,[]);if(e.attributes.length===0)return t;for(var a=e.attributes,r=0;r=I0&&e0&&r.value.push(L.certificateExtensionsToAsn1(e.extensions)),r},L.getCertificationRequestInfo=function(e){var t=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.INTEGER,!1,h.integerToDer(e.version).getBytes()),Ft(e.subject),L.publicKeyToAsn1(e.publicKey),T0(e)]);return t},L.distinguishedNameToAsn1=function(e){return Ft(e)},L.certificateToAsn1=function(e){var t=e.tbsCertificate||L.getTBSCertificate(e);return h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[t,h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[h.create(h.Class.UNIVERSAL,h.Type.OID,!1,h.oidToDer(e.signatureOid).getBytes()),jr(e.signatureOid,e.signatureParameters)]),h.create(h.Class.UNIVERSAL,h.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},L.certificateExtensionsToAsn1=function(e){var t=h.create(h.Class.CONTEXT_SPECIFIC,3,!0,[]),a=h.create(h.Class.UNIVERSAL,h.Type.SEQUENCE,!0,[]);t.value.push(a);for(var r=0;r"u"&&(n=new Date);var s=!0,i=null,o=0;do{var f=t.shift(),u=null,l=!1;if(n&&(nf.validity.notAfter)&&(i={message:"Certificate is not valid yet or has expired.",error:L.certificateError.certificate_expired,notBefore:f.validity.notBefore,notAfter:f.validity.notAfter,now:n}),i===null){if(u=t[0]||e.getIssuer(f),u===null&&f.isIssuer(f)&&(l=!0,u=f),u){var c=u;M.util.isArray(c)||(c=[c]);for(var v=!1;!v&&c.length>0;){u=c.shift();try{v=u.verify(f)}catch{}}v||(i={message:"Certificate signature is invalid.",error:L.certificateError.bad_certificate})}i===null&&(!u||l)&&!e.hasCertificate(f)&&(i={message:"Certificate is not trusted.",error:L.certificateError.unknown_ca})}if(i===null&&u&&!f.isIssuer(u)&&(i={message:"Certificate issuer is invalid.",error:L.certificateError.bad_certificate}),i===null)for(var C={keyUsage:!0,basicConstraints:!0},y=0;i===null&&yT.pathLenConstraint&&(i={message:"Certificate basicConstraints pathLenConstraint violated.",error:L.certificateError.bad_certificate})}}var N=i===null?!0:i.error,V=a.verify?a.verify(N,o,r):N;if(V===!0)i=null;else throw N===!0&&(i={message:"The application rejected the certificate.",error:L.certificateError.bad_certificate}),(V||V===0)&&(typeof V=="object"&&!M.util.isArray(V)?(V.message&&(i.message=V.message),V.error&&(i.error=V.error)):typeof V=="string"&&(i.error=V)),i;s=!1,++o}while(t.length>0);return!0};var ue=z,g=ue.asn1,X=ue.pki,Zt=ue.pkcs12=ue.pkcs12||{},cn={name:"ContentInfo",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:g.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},B0={name:"PFX",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,capture:"version"},cn,{name:"PFX.macData",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:g.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:g.Class.UNIVERSAL,type:g.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:g.Class.UNIVERSAL,type:g.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},b0={name:"SafeBag",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:g.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:g.Class.UNIVERSAL,type:g.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},_0={name:"Attribute",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:g.Class.UNIVERSAL,type:g.Type.SET,constructed:!0,capture:"values"}]},N0={name:"CertBag",tagClass:g.Class.UNIVERSAL,type:g.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:g.Class.UNIVERSAL,type:g.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:g.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:g.Class.UNIVERSAL,type:g.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function Jt(e,t,a,r){for(var n=[],s=0;s=0&&n.push(o)}}return n}Zt.pkcs12FromAsn1=function(e,t,a){typeof t=="string"?(a=t,t=!0):t===void 0&&(t=!0);var r={},n=[];if(!g.validate(e,B0,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(T){var I={},B;return"localKeyId"in T?B=T.localKeyId:"localKeyIdHex"in T&&(B=ue.util.hexToBytes(T.localKeyIdHex)),B===void 0&&!("friendlyName"in T)&&"bagType"in T&&(I[T.bagType]=Jt(i.safeContents,null,null,T.bagType)),B!==void 0&&(I.localKeyId=Jt(i.safeContents,"localKeyId",B,T.bagType)),"friendlyName"in T&&(I.friendlyName=Jt(i.safeContents,"friendlyName",T.friendlyName,T.bagType)),I},getBagsByFriendlyName:function(T,I){return Jt(i.safeContents,"friendlyName",T,I)},getBagsByLocalKeyId:function(T,I){return Jt(i.safeContents,"localKeyId",T,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(g.derToOid(r.contentType)!==X.oids.data){var s=new Error("Only PKCS#12 PFX in password integrity mode supported.");throw s.oid=g.derToOid(r.contentType),s}var o=r.content.value[0];if(o.tagClass!==g.Class.UNIVERSAL||o.type!==g.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(o=$r(o),r.mac){var f=null,u=0,l=g.derToOid(r.macAlgorithm);switch(l){case X.oids.sha1:f=ue.md.sha1.create(),u=20;break;case X.oids.sha256:f=ue.md.sha256.create(),u=32;break;case X.oids.sha384:f=ue.md.sha384.create(),u=48;break;case X.oids.sha512:f=ue.md.sha512.create(),u=64;break;case X.oids.md5:f=ue.md.md5.create(),u=16;break}if(f===null)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+l);var c=new ue.util.ByteBuffer(r.macSalt),v="macIterations"in r?parseInt(ue.util.bytesToHex(r.macIterations),16):1,C=Zt.generateKey(a,c,3,v,u,f),y=ue.hmac.create();y.start(f,C),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 R0(i,o.value,t,a),i};function $r(e){if(e.composed||e.constructed){for(var t=ue.util.createBuffer(),a=0;a0&&(s=g.create(g.Class.UNIVERSAL,g.Type.SET,!0,f));var u=[],l=[];t!==null&&(ue.util.isArray(t)?l=t:l=[t]);for(var c=[],v=0;v0){var T=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,c),I=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.data).getBytes()),g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,g.toDer(T).getBytes())])]);u.push(I)}var B=null;if(e!==null){var N=X.wrapRsaPrivateKey(X.privateKeyToAsn1(e));a===null?B=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.keyBag).getBytes()),g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[N]),s]):B=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.pkcs8ShroudedKeyBag).getBytes()),g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[X.encryptPrivateKeyInfo(N,a,r)]),s]);var V=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[B]),D=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.data).getBytes()),g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,g.toDer(V).getBytes())])]);u.push(D)}var w=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,u),q;if(r.useMac){var o=ue.md.sha1.create(),j=new ue.util.ByteBuffer(ue.random.getBytes(r.saltSize)),re=r.count,e=Zt.generateKey(a,j,3,re,20),ne=ue.hmac.create();ne.start(o,e),ne.update(g.toDer(w).getBytes());var ie=ne.getMac();q=g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.sha1).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.NULL,!1,"")]),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,ie.getBytes())]),g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,j.getBytes()),g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(re).getBytes())])}return g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.INTEGER,!1,g.integerToDer(3).getBytes()),g.create(g.Class.UNIVERSAL,g.Type.SEQUENCE,!0,[g.create(g.Class.UNIVERSAL,g.Type.OID,!1,g.oidToDer(X.oids.data).getBytes()),g.create(g.Class.CONTEXT_SPECIFIC,0,!0,[g.create(g.Class.UNIVERSAL,g.Type.OCTETSTRING,!1,g.toDer(w).getBytes())])]),q])},Zt.generateKey=ue.pbe.generatePkcs12Key;var mt=z,Zr=mt.asn1,Mt=mt.pki=mt.pki||{};Mt.pemToDer=function(e){var t=mt.pem.decode(e)[0];if(t.procType&&t.procType.type==="ENCRYPTED")throw new Error("Could not convert PEM to DER; PEM is encrypted.");return mt.util.createBuffer(t.body)},Mt.privateKeyFromPem=function(e){var t=mt.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=Zr.fromDer(t.body);return Mt.privateKeyFromAsn1(r)},Mt.privateKeyToPem=function(e,t){var a={type:"RSA PRIVATE KEY",body:Zr.toDer(Mt.privateKeyToAsn1(e)).getBytes()};return mt.pem.encode(a,{maxline:t})},Mt.privateKeyInfoToPem=function(e,t){var a={type:"PRIVATE KEY",body:Zr.toDer(e).getBytes()};return mt.pem.encode(a,{maxline:t})};var _=z,Sr=function(e,t,a,r){var n=_.util.createBuffer(),s=e.length>>1,i=s+(e.length&1),o=e.substr(0,i),f=e.substr(s,i),u=_.util.createBuffer(),l=_.hmac.create();a=t+a;var c=Math.ceil(r/16),v=Math.ceil(r/20);l.start("MD5",o);var C=_.util.createBuffer();u.putBytes(a);for(var y=0;y0&&(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:Qe(s,1),extensions:[]},n?(r.cipher_suite=s.getBytes(2),r.compression_method=s.getByte()):(r.cipher_suites=Qe(s,2),r.compression_methods=Qe(s,1)),i=a-(i-s.length()),i>0){for(var o=Qe(s,2);o.length()>0;)r.extensions.push({type:[o.getByte(),o.getByte()],data:Qe(o,2)});if(!n)for(var f=0;f0;){var c=l.getByte();if(c!==0)break;e.session.extensions.server_name.serverNameList.push(Qe(l,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 v=_.util.createBuffer(r.cipher_suites.bytes());v.length()>0&&(e.session.cipherSuite=p.getCipherSuite(v.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=dn,e.session.resuming=!0,e.session.sp.server_random=r.random.bytes()):(e.expect=O0,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;o0;)s=Qe(n.certificate_list,3),i=_.asn1.fromDer(s),s=_.pki.certificateFromAsn1(i,!0),o.push(s)}catch(u){return e.error(e,{message:"Could not parse certificate list.",cause:u,send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.bad_certificate}})}var f=e.entity===p.ConnectionEnd.client;(f||e.verifyClient===!0)&&o.length===0?e.error(e,{message:f?"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=f?hn:Jr:(f?e.session.serverCertificate=o[0]:e.session.clientCertificate=o[0],p.verifyCertificateChain(e,o)&&(e.expect=f?hn:Jr)),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=K0,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:Qe(r,2).getBytes()},s=null;if(e.getPrivateKey)try{s=e.getPrivateKey(e,e.session.serverCertificate),s=_.pki.privateKeyFromPem(s)}catch(f){e.error(e,{message:"Could not get private key.",cause:f,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=ea,e.session.clientCertificate!==null&&(e.expect=z0),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:Qe(r,1),certificate_authorities:Qe(r,2)};e.session.certificateRequest=n,e.expect=F0,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:Qe(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=ea,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=G0;var i=function(o,f){o.session.certificateRequest!==null&&o.session.clientCertificate!==null&&p.queue(o,p.createRecord(o,{type:p.ContentType.handshake,data:p.createCertificateVerify(o,f)})),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=dn,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?M0:Y0,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",f=e.session.sp,u=12,l=Sr;if(r=l(f.master_secret,o,r.getBytes(),u),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?H0:X0,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 Ir[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)),Ir[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 V0=0,O0=1,hn=2,K0=3,F0=4,dn=5,M0=6,H0=7,G0=8,q0=0,Q0=1,Jr=2,z0=3,ea=4,Y0=5,X0=6,d=p.handleUnexpected,pn=p.handleChangeCipherSpec,Te=p.handleAlert,Me=p.handleHandshake,vn=p.handleApplicationData,Ie=p.handleHeartbeat,ta=[];ta[p.ConnectionEnd.client]=[[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[pn,Te,d,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,vn,Ie],[d,Te,Me,d,Ie]],ta[p.ConnectionEnd.server]=[[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,d,Ie],[pn,Te,d,d,Ie],[d,Te,Me,d,Ie],[d,Te,Me,vn,Ie],[d,Te,Me,d,Ie]];var Et=p.handleHelloRequest,W0=p.handleServerHello,yn=p.handleCertificate,gn=p.handleServerKeyExchange,ra=p.handleCertificateRequest,Tr=p.handleServerHelloDone,Cn=p.handleFinished,Ir=[];Ir[p.ConnectionEnd.client]=[[d,d,W0,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,yn,gn,ra,Tr,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,gn,ra,Tr,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,d,ra,Tr,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,d,d,Tr,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,Cn],[Et,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[Et,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d]];var j0=p.handleClientHello,$0=p.handleClientKeyExchange,Z0=p.handleCertificateVerify;Ir[p.ConnectionEnd.server]=[[d,j0,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,yn,d,d,d,d,d,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,$0,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,Z0,d,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,Cn],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d],[d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d,d]],p.generateKeys=function(e,t){var a=Sr,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=P0,r.write.compressFunction=U0;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;a0&&(c+=2);var v=e.session.id,C=v.length+1+2+4+28+2+n+1+i+c,y=_.util.createBuffer();return y.putByte(p.HandshakeType.client_hello),y.putInt24(C),y.putByte(e.version.major),y.putByte(e.version.minor),y.putBytes(e.session.sp.client_random),$e(y,1,_.util.createBuffer(v)),$e(y,2,t),$e(y,1,s),c>0&&$e(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),$e(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"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;s0&&(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(l,c,v,C){return c},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(l,c){c.origin=c.origin||(l.entity===p.ConnectionEnd.client?"client":"server"),c.send&&(p.queue(l,p.createAlert(l,c.alert)),p.flush(l));var v=c.fatal!==!1;v&&(l.fail=!0),e.error(l,c),v&&l.close(!1)},deflate:e.deflate||null,inflate:e.inflate||null};i.reset=function(l){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?V0:q0,i.fragmented=null,i.records=[],i.open=!1,i.handshakes=0,i.handshaking=!1,i.isConnected=!1,i.fail=!(l||typeof l>"u"),i.input.clear(),i.tlsData.clear(),i.data.clear(),i.state.current=p.createConnectionState(i)},i.reset();var o=function(l,c){var v=c.type-p.ContentType.change_cipher_spec,C=ta[l.entity][l.expect];v in C?C[v](l,c):p.handleUnexpected(l,c)},f=function(l){var c=0,v=l.input,C=v.length();if(C<5)c=5-C;else{l.record={type:v.getByte(),version:{major:v.getByte(),minor:v.getByte()},length:v.getInt16(),fragment:_.util.createBuffer(),ready:!1};var y=l.record.version.major===l.version.major;y&&l.session&&l.session.version&&(y=l.record.version.minor===l.version.minor),y||l.error(l,{message:"Incompatible TLS version.",send:!0,alert:{level:p.Alert.Level.fatal,description:p.Alert.Description.protocol_version}})}return c},u=function(l){var c=0,v=l.input,C=v.length();if(C0&&(i.sessionCache&&(c=i.sessionCache.getSession(l)),c===null&&(l="")),l.length===0&&i.sessionCache&&(c=i.sessionCache.getSession(),c!==null&&(l=c.id)),i.session={id:l,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:_.md.md5.create(),sha1:_.md.sha1.create()},c&&(i.version=c.version,i.session.sp=c.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(l){var c=0;return l&&i.input.putBytes(l),i.fail||(i.record!==null&&i.record.ready&&i.record.fragment.isEmpty()&&(i.record=null),i.record===null&&(c=f(i)),!i.fail&&i.record!==null&&!i.record.ready&&(c=u(i)),!i.fail&&i.record!==null&&i.record.ready&&o(i,i.record)),c},i.prepare=function(l){return p.queue(i,p.createRecord(i,{type:p.ContentType.application_data,data:_.util.createBuffer(l)})),p.flush(i)},i.prepareHeartbeatRequest=function(l,c){return l instanceof _.util.ByteBuffer&&(l=l.bytes()),typeof c>"u"&&(c=l.length),i.expectedHeartbeatPayload=l,p.queue(i,p.createRecord(i,{type:p.ContentType.heartbeat,data:p.createHeartbeat(p.HeartbeatMessageType.heartbeat_request,l,c)})),p.flush(i)},i.close=function(l){if(!i.fail&&i.sessionCache&&i.session){var c={id:i.session.id,version:i.session.version,sp:i.session.sp};c.sp.keys=null,i.sessionCache.setSession(c.id,c)}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(l)},i},_.tls=_.tls||{};for(var na in p)typeof p[na]!="function"&&(_.tls[na]=p[na]);_.tls.prf_tls1=Sr,_.tls.hmac_sha1=k0,_.tls.createSessionCache=p.createSessionCache,_.tls.createConnection=p.createConnection;var xt=z,Ze=xt.tls;Ze.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=Ze.BulkCipherAlgorithm.aes,e.cipher_type=Ze.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=Ze.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:mn},Ze.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=Ze.BulkCipherAlgorithm.aes,e.cipher_type=Ze.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=Ze.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:mn};function mn(e,t,a){var r=t.entity===xt.tls.ConnectionEnd.client;e.read.cipherState={init:!1,cipher:xt.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:xt.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=ao,e.write.cipherFunction=eo,e.read.macLength=e.write.macLength=a.mac_length,e.read.macFunction=e.write.macFunction=Ze.hmac_sha1}function eo(e,t){var a=!1,r=t.macFunction(t.macKey,t.sequenceNumber,e);e.fragment.putBytes(r),t.updateSequenceNumber();var n;e.version.minor===Ze.Versions.TLS_1_0.minor?n=t.cipherState.init?null:t.cipherState.iv:n=xt.random.getBytesSync(16),t.cipherState.init=!0;var s=t.cipherState.cipher;return s.start({iv:n}),e.version.minor>=Ze.Versions.TLS_1_1.minor&&s.output.putBytes(n),s.update(e.fragment),s.finish(to)&&(e.fragment=s.output,e.length=e.fragment.length(),a=!0),a}function to(e,t,a){if(!a){var r=e-t.length()%e;t.fillWithByte(r-1,r)}return!0}function ro(e,t,a){var r=!0;if(a){for(var n=t.length(),s=t.last(),i=n-1-s;i=s?(e.fragment=n.output.getBytes(o-s),i=n.output.getBytes(s)):e.fragment=n.output.getBytes(),e.fragment=xt.util.createBuffer(e.fragment),e.length=e.fragment.length();var f=t.macFunction(t.macKey,t.sequenceNumber,e);return t.updateSequenceNumber(),a=no(t.macKey,i,f)&&a,a}function no(e,t,a){var r=xt.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 le=z,er=le.sha512=le.sha512||{};le.md.sha512=le.md.algorithms.sha512=er;var En=le.sha384=le.sha512.sha384=le.sha512.sha384||{};En.create=function(){return er.create("SHA-384")},le.md.sha384=le.md.algorithms.sha384=En,le.sha512.sha256=le.sha512.sha256||{create:function(){return er.create("SHA-512/256")}},le.md["sha512/256"]=le.md.algorithms["sha512/256"]=le.sha512.sha256,le.sha512.sha224=le.sha512.sha224||{create:function(){return er.create("SHA-512/224")}},le.md["sha512/224"]=le.md.algorithms["sha512/224"]=le.sha512.sha224,er.create=function(e){if(xn||io(),typeof e>"u"&&(e="SHA-512"),!(e in Rt))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=Rt[e],a=null,r=le.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 f=o.messageLengthSize/4,u=0;u>>0,l>>>0];for(var c=o.fullMessageLength.length-1;c>=0;--c)o.fullMessageLength[c]+=l[1],l[1]=l[0]+(o.fullMessageLength[c]/4294967296>>>0),o.fullMessageLength[c]=o.fullMessageLength[c]>>>0,l[0]=l[1]/4294967296>>>0;return r.putBytes(f),Sn(a,n,r),(r.read>2048||r.length()===0)&&r.compact(),o},o.digest=function(){var f=le.util.createBuffer();f.putBytes(r.bytes());var u=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize,l=u&o.blockLength-1;f.putBytes(ia.substr(0,o.blockLength-l));for(var c,v,C=o.fullMessageLength[0]*8,y=0;y>>0,C+=v,f.putInt32(C>>>0),C=c>>>0;f.putInt32(C);for(var x=new Array(a.length),y=0;y=128;){for(se=0;se<16;++se)t[se][0]=a.getInt32()>>>0,t[se][1]=a.getInt32()>>>0;for(;se<80;++se)Lt=t[se-2],ve=Lt[0],K=Lt[1],r=((ve>>>19|K<<13)^(K>>>29|ve<<3)^ve>>>6)>>>0,n=((ve<<13|K>>>19)^(K<<3|ve>>>29)^(ve<<26|K>>>6))>>>0,ye=t[se-15],ve=ye[0],K=ye[1],s=((ve>>>1|K<<31)^(ve>>>8|K<<24)^ve>>>7)>>>0,i=((ve<<31|K>>>1)^(ve<<24|K>>>8)^(ve<<25|K>>>7))>>>0,zt=t[se-7],ge=t[se-16],K=n+zt[1]+i+ge[1],t[se][0]=r+zt[0]+s+ge[0]+(K/4294967296>>>0)>>>0,t[se][1]=K>>>0;for(x=e[0][0],T=e[0][1],I=e[1][0],B=e[1][1],N=e[2][0],V=e[2][1],D=e[3][0],w=e[3][1],q=e[4][0],j=e[4][1],re=e[5][0],ne=e[5][1],ie=e[6][0],he=e[6][1],Ye=e[7][0],Je=e[7][1],se=0;se<80;++se)u=((q>>>14|j<<18)^(q>>>18|j<<14)^(j>>>9|q<<23))>>>0,l=((q<<18|j>>>14)^(q<<14|j>>>18)^(j<<23|q>>>9))>>>0,c=(ie^q&(re^ie))>>>0,v=(he^j&(ne^he))>>>0,o=((x>>>28|T<<4)^(T>>>2|x<<30)^(T>>>7|x<<25))>>>0,f=((x<<4|T>>>28)^(T<<30|x>>>2)^(T<<25|x>>>7))>>>0,C=(x&I|N&(x^I))>>>0,y=(T&B|V&(T^B))>>>0,K=Je+l+v+sa[se][1]+t[se][1],r=Ye+u+c+sa[se][0]+t[se][0]+(K/4294967296>>>0)>>>0,n=K>>>0,K=f+y,s=o+C+(K/4294967296>>>0)>>>0,i=K>>>0,Ye=ie,Je=he,ie=re,he=ne,re=q,ne=j,K=w+n,q=D+r+(K/4294967296>>>0)>>>0,j=K>>>0,D=N,w=V,N=I,V=B,I=x,B=T,K=n+i,x=r+s+(K/4294967296>>>0)>>>0,T=K>>>0;K=e[0][1]+T,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]+V,e[2][0]=e[2][0]+N+(K/4294967296>>>0)>>>0,e[2][1]=K>>>0,K=e[3][1]+w,e[3][0]=e[3][0]+D+(K/4294967296>>>0)>>>0,e[3][1]=K>>>0,K=e[4][1]+j,e[4][0]=e[4][0]+q+(K/4294967296>>>0)>>>0,e[4][1]=K>>>0,K=e[5][1]+ne,e[5][0]=e[5][0]+re+(K/4294967296>>>0)>>>0,e[5][1]=K>>>0,K=e[6][1]+he,e[6][0]=e[6][0]+ie+(K/4294967296>>>0)>>>0,e[6][1]=K>>>0,K=e[7][1]+Je,e[7][0]=e[7][0]+Ye+(K/4294967296>>>0)>>>0,e[7][1]=K>>>0,Ce-=128}}var oa={},so=z,Se=so.asn1;oa.privateKeyValidator={name:"PrivateKeyInfo",tagClass:Se.Class.UNIVERSAL,type:Se.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:Se.Class.UNIVERSAL,type:Se.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:Se.Class.UNIVERSAL,type:Se.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Se.Class.UNIVERSAL,type:Se.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:Se.Class.UNIVERSAL,type:Se.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},oa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:Se.Class.UNIVERSAL,type:Se.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:Se.Class.UNIVERSAL,type:Se.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:Se.Class.UNIVERSAL,type:Se.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:Se.Class.UNIVERSAL,type:Se.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]};var Ae=z,Tn=oa,oo=Tn.publicKeyValidator,uo=Tn.privateKeyValidator;if(typeof fo>"u")var fo=Ae.jsbn.BigInteger;var ua=Ae.util.ByteBuffer,qe=typeof Buffer>"u"?Uint8Array:Buffer;Ae.pki=Ae.pki||{},Ae.pki.ed25519=Ae.ed25519=Ae.ed25519||{};var W=Ae.ed25519;W.constants={},W.constants.PUBLIC_KEY_BYTE_LENGTH=32,W.constants.PRIVATE_KEY_BYTE_LENGTH=64,W.constants.SEED_BYTE_LENGTH=32,W.constants.SIGN_BYTE_LENGTH=64,W.constants.HASH_BYTE_LENGTH=64,W.generateKeyPair=function(e){e=e||{};var t=e.seed;if(t===void 0)t=Ae.random.getBytesSync(W.constants.SEED_BYTE_LENGTH);else if(typeof t=="string"){if(t.length!==W.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+W.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=dt({message:t,encoding:"binary"});for(var a=new qe(W.constants.PUBLIC_KEY_BYTE_LENGTH),r=new qe(W.constants.PRIVATE_KEY_BYTE_LENGTH),n=0;n<32;++n)r[n]=t[n];return po(a,r),{publicKey:a,privateKey:r}},W.privateKeyFromAsn1=function(e){var t={},a=[],r=Ae.asn1.validate(e,uo,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=Ae.asn1.derToOid(t.privateKeyOid),i=Ae.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.privateKey,f=dt({message:Ae.asn1.fromDer(o).value,encoding:"binary"});return{privateKeyBytes:f}},W.publicKeyFromAsn1=function(e){var t={},a=[],r=Ae.asn1.validate(e,oo,t,a);if(!r){var n=new Error("Invalid Key.");throw n.errors=a,n}var s=Ae.asn1.derToOid(t.publicKeyOid),i=Ae.oids.EdDSA25519;if(s!==i)throw new Error('Invalid OID "'+s+'"; OID must be "'+i+'".');var o=t.ed25519PublicKey;if(o.length!==W.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return dt({message:o,encoding:"binary"})},W.publicKeyFromPrivateKey=function(e){e=e||{};var t=dt({message:e.privateKey,encoding:"binary"});if(t.length!==W.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+W.constants.PRIVATE_KEY_BYTE_LENGTH);for(var a=new qe(W.constants.PUBLIC_KEY_BYTE_LENGTH),r=0;r=0};function dt(e){var t=e.message;if(t instanceof Uint8Array||t instanceof qe)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 ua(t,a)}else if(!(t instanceof ua))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 qe(t.length()),n=0;n=32;--r){for(a=0,n=r-32,s=r-12;n>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)*la[n],a=t[n]>>8,t[n]&=255;for(n=0;n<32;++n)t[n]-=a*la[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;Bn(e,t)}function ha(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),f=H(),u=H(),l=H();Gt(a,e[1],e[0]),Gt(l,t[1],t[0]),ae(a,a,l),Ht(r,e[0],e[1]),Ht(l,t[0],t[1]),ae(r,r,l),ae(n,e[3],t[3]),ae(n,n,co),ae(s,e[2],t[2]),Ht(s,s,s),Gt(i,r,a),Gt(o,s,n),Ht(f,s,n),Ht(u,r,a),ae(e[0],i,o),ae(e[1],u,f),ae(e[2],f,o),ae(e[3],i,u)}function bn(e,t,a){for(var r=0;r<4;++r)Ln(e[r],t[r],a)}function da(e,t){var a=H(),r=H(),n=H();xo(n,t[2]),ae(a,t[0],n),ae(r,t[1],n),Br(e,r),e[31]^=Rn(a)<<7}function Br(e,t){var a,r,n,s=H(),i=H();for(a=0;a<16;++a)i[a]=t[a];for(va(i),va(i),va(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,Ln(i,s,1-n)}for(a=0;a<16;a++)e[2*a]=i[a]&255,e[2*a+1]=i[a]>>8}function go(e,t){var a=H(),r=H(),n=H(),s=H(),i=H(),o=H(),f=H();return St(e[2],Ar),Co(e[1],t),wt(n,e[1]),ae(s,n,lo),Gt(n,n,e[2]),Ht(s,e[2],s),wt(i,s),wt(o,i),ae(f,o,i),ae(a,f,n),ae(a,a,s),mo(a,a),ae(a,a,n),ae(a,a,s),ae(a,a,s),ae(e[0],a,s),wt(r,e[0]),ae(r,r,s),_n(r,n)&&ae(e[0],e[0],ho),wt(r,e[0]),ae(r,r,s),_n(r,n)?-1:(Rn(e[0])===t[31]>>7&&Gt(e[0],fa,e[0]),ae(e[3],e[0],e[1]),0)}function Co(e,t){var a;for(a=0;a<16;++a)e[a]=t[2*a]+(t[2*a+1]<<8);e[15]&=32767}function mo(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=250;r>=0;--r)wt(a,a),r!==1&&ae(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function _n(e,t){var a=new qe(32),r=new qe(32);return Br(a,e),Br(r,t),Nn(a,0,r,0)}function Nn(e,t,a,r){return Eo(e,t,a,r,32)}function Eo(e,t,a,r,n){var s,i=0;for(s=0;s>>8)-1}function Rn(e){var t=new qe(32);return Br(t,e),t[0]&1}function wn(e,t,a){var r,n;for(St(e[0],fa),St(e[1],Ar),St(e[2],Ar),St(e[3],fa),n=255;n>=0;--n)r=a[n/8|0]>>(n&7)&1,bn(e,t,r),ha(t,e),ha(e,e),bn(e,t,r)}function pa(e,t){var a=[H(),H(),H(),H()];St(a[0],In),St(a[1],An),St(a[2],Ar),ae(a[3],In,An),wn(e,a,t)}function St(e,t){var a;for(a=0;a<16;a++)e[a]=t[a]|0}function xo(e,t){var a=H(),r;for(r=0;r<16;++r)a[r]=t[r];for(r=253;r>=0;--r)wt(a,a),r!==2&&r!==4&&ae(a,a,t);for(r=0;r<16;++r)e[r]=a[r]}function va(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 Ln(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 H(e){var t,a=new Float64Array(16);if(e)for(t=0;t0&&(o=ze.util.fillString(String.fromCharCode(0),f)+o);var u=n.encrypt(o,"NONE"),l=e.generate(o,s);return{encapsulation:u,key:l}},r.decrypt=function(n,s,i){var o=n.decrypt(s,"NONE");return e.generate(o,i)},r},ze.kem.kdf1=function(e,t){kn(this,e,0,t||e.digestLength)},ze.kem.kdf2=function(e,t){kn(this,e,1,t||e.digestLength)};function kn(e,t,a,r){e.generate=function(n,s){for(var i=new ze.util.ByteBuffer,o=Math.ceil(s/r)+a,f=new ze.util.ByteBuffer,u=a;u"u"||t?e.flags|=$.log.LEVEL_LOCKED:e.flags&=~$.log.LEVEL_LOCKED},$.log.addLogger=function(e){ya.push(e)},typeof console<"u"&&"log"in console){var ar;if(console.error&&console.warn&&console.info&&console.debug){var So={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},ga=function(e,t){$.log.prepareStandard(t);var a=So[t.level],r=[t.standard];r=r.concat(t.arguments.slice()),a.apply(console,r)};ar=$.log.makeLogger(ga)}else{var ga=function(t,a){$.log.prepareStandardFull(a),console.log(a.standardFull)};ar=$.log.makeLogger(ga)}$.log.setLevel(ar,"debug"),$.log.addLogger(ar),rr=ar}else console={log:function(){}};if(rr!==null&&typeof window<"u"&&window.location){var _r=new URL(window.location.href).searchParams;if(_r.has("console.level")&&$.log.setLevel(rr,_r.get("console.level").slice(-1)[0]),_r.has("console.lock")){var To=_r.get("console.lock").slice(-1)[0];To=="true"&&$.log.lock(rr)}}$.log.consoleLogger=rr;var k=z,m=k.asn1,He=k.pkcs7=k.pkcs7||{};He.messageFromPem=function(e){var t=k.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=m.fromDer(t.body);return He.messageFromAsn1(r)},He.messageToPem=function(e,t){var a={type:"PKCS7",body:m.toDer(e.toAsn1()).getBytes()};return k.pem.encode(a,{maxline:t})},He.messageFromAsn1=function(e){var t={},a=[];if(!m.validate(e,He.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=m.derToOid(t.contentType),s;switch(n){case k.pki.oids.envelopedData:s=He.createEnvelopedData();break;case k.pki.oids.encryptedData:s=He.createEncryptedData();break;case k.pki.oids.signedData:s=He.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},He.createSignedData=function(){var e=null;return e={type:k.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(r){if(ma(e,r,He.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;s0&&i.value[0].value.push(m.create(m.Class.CONTEXT_SPECIFIC,0,!0,r)),s.length>0&&i.value[0].value.push(m.create(m.Class.CONTEXT_SPECIFIC,1,!0,s)),i.value[0].value.push(m.create(m.Class.UNIVERSAL,m.Type.SET,!0,e.signerInfos)),m.create(m.Class.UNIVERSAL,m.Type.SEQUENCE,!0,[m.create(m.Class.UNIVERSAL,m.Type.OID,!1,m.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=k.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=k.pki.privateKeyFromPem(o));var f=r.digestAlgorithm||k.pki.oids.sha1;switch(f){case k.pki.oids.sha1:case k.pki.oids.sha256:case k.pki.oids.sha384:case k.pki.oids.sha512:case k.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+f)}var u=r.authenticatedAttributes||[];if(u.length>0){for(var l=!1,c=!1,v=0;v0){for(var a=m.create(m.Class.CONTEXT_SPECIFIC,1,!0,[]),r=0;r=a&&n="8"&&(a="00"+a);var r=pe.util.hexToBytes(a);e.putInt32(r.length),e.putBytes(r)}function qt(e,t){e.putInt32(t.length),e.putString(t)}function Rr(){for(var e=pe.md.sha1.create(),t=arguments.length,a=0;a{const t=Do(e.data);self.postMessage(t)};const Lo=e=>{const t=self.crypto,a=65536,r=new Uint8Array(e);for(let n=0;n{const a=Qt.pki.rsa.generateKeyPair(2048),r=Qt.pki.createCertificate();r.publicKey=a.publicKey,r.serialNumber="01"+Lo(20).toString().substring(0,30),r.validity.notBefore=new Date,r.validity.notAfter=new Date(Date.now()+1e3*60*60*24*1e3),r.setSubject(On),r.setIssuer(On),r.sign(a.privateKey);const n=Qt.pki.certificateToPem(r),s=Qt.pkcs12.toPkcs12Asn1(a.privateKey,[r],e,{algorithm:"3des",generateLocalKeyId:!0,friendlyName:"LXD-UI"}),i=Qt.asn1.toDer(s).getBytes(),o=Qt.util.encode64(i);return{crt:n,pfx:o}}})();