UNPKG

openpgp

Version:

OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.

2 lines 365 kB
/*! OpenPGP.js v5.5.0 - 2022-08-31 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */ const t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=Symbol("doneWritingPromise"),r=Symbol("doneWritingResolve"),n=Symbol("doneWritingReject"),i=Symbol("readingIndex");class a extends Array{constructor(){super(),this[e]=new Promise(((t,e)=>{this[r]=t,this[n]=e})),this[e].catch((()=>{}))}}function s(t){return t&&t.getReader&&Array.isArray(t)}function o(t){if(!s(t)){const e=t.getWriter(),r=e.releaseLock;return e.releaseLock=()=>{e.closed.catch((function(){})),r.call(e)},e}this.stream=t}a.prototype.getReader=function(){return void 0===this[i]&&(this[i]=0),{read:async()=>(await this[e],this[i]===this.length?{value:void 0,done:!0}:{value:this[this[i]++],done:!1})}},a.prototype.readToEnd=async function(t){await this[e];const r=t(this.slice(this[i]));return this.length=0,r},a.prototype.clone=function(){const t=new a;return t[e]=this[e].then((()=>{t.push(...this)})),t},o.prototype.write=async function(t){this.stream.push(t)},o.prototype.close=async function(){this.stream[r]()},o.prototype.abort=async function(t){return this.stream[n](t),t},o.prototype.releaseLock=function(){};const c="object"==typeof t.process&&"object"==typeof t.process.versions,h=c&&void 0;function u(e){return s(e)?"array":t.ReadableStream&&t.ReadableStream.prototype.isPrototypeOf(e)?"web":A&&A.prototype.isPrototypeOf(e)?"ponyfill":h&&h.prototype.isPrototypeOf(e)?"node":!(!e||!e.getReader)&&"web-like"}function l(t){return Uint8Array.prototype.isPrototypeOf(t)}function y(t){if(1===t.length)return t[0];let e=0;for(let r=0;r<t.length;r++){if(!l(t[r]))throw Error("concatUint8Array: Data must be in the form of a Uint8Array");e+=t[r].length}const r=new Uint8Array(e);let n=0;return t.forEach((function(t){r.set(t,n),n+=t.length})),r}const d=c&&void 0,p=c&&void 0;let f,g;if(p){f=function(t){let e=!1;return new A({start(r){t.pause(),t.on("data",(n=>{e||(d.isBuffer(n)&&(n=new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),r.enqueue(n),t.pause())})),t.on("end",(()=>{e||r.close()})),t.on("error",(t=>r.error(t)))},pull(){t.resume()},cancel(r){e=!0,t.destroy(r)}})};class t extends p{constructor(t,e){super(e),this._reader=D(t)}async _read(t){try{for(;;){const{done:t,value:e}=await this._reader.read();if(t){this.push(null);break}if(!this.push(e)||this._cancelling){this._reading=!1;break}}}catch(t){this.emit("error",t)}}_destroy(t){this._reader.cancel(t)}}g=function(e,r){return new t(e,r)}}const m=new WeakSet,w=Symbol("externalBuffer");function b(t){if(this.stream=t,t[w]&&(this[w]=t[w].slice()),s(t)){const e=t.getReader();return this._read=e.read.bind(e),this._releaseLock=()=>{},void(this._cancel=()=>{})}let e=u(t);if("node"===e&&(t=f(t)),e){const e=t.getReader();return this._read=e.read.bind(e),this._releaseLock=()=>{e.closed.catch((function(){})),e.releaseLock()},void(this._cancel=e.cancel.bind(e))}let r=!1;this._read=async()=>r||m.has(t)?{value:void 0,done:!0}:(r=!0,{value:t,done:!1}),this._releaseLock=()=>{if(r)try{m.add(t)}catch(t){}}}b.prototype.read=async function(){if(this[w]&&this[w].length){return{done:!1,value:this[w].shift()}}return this._read()},b.prototype.releaseLock=function(){this[w]&&(this.stream[w]=this[w]),this._releaseLock()},b.prototype.cancel=function(t){return this._cancel(t)},b.prototype.readLine=async function(){let t,e=[];for(;!t;){let{done:r,value:n}=await this.read();if(n+="",r)return e.length?U(e):void 0;const i=n.indexOf("\n")+1;i&&(t=U(e.concat(n.substr(0,i))),e=[]),i!==n.length&&e.push(n.substr(i))}return this.unshift(...e),t},b.prototype.readByte=async function(){const{done:t,value:e}=await this.read();if(t)return;const r=e[0];return this.unshift(j(e,1)),r},b.prototype.readBytes=async function(t){const e=[];let r=0;for(;;){const{done:n,value:i}=await this.read();if(n)return e.length?U(e):void 0;if(e.push(i),r+=i.length,r>=t){const r=U(e);return this.unshift(j(r,t)),j(r,0,t)}}},b.prototype.peekBytes=async function(t){const e=await this.readBytes(t);return this.unshift(e),e},b.prototype.unshift=function(...t){this[w]||(this[w]=[]),1===t.length&&l(t[0])&&this[w].length&&t[0].length&&this[w][0].byteOffset>=t[0].length?this[w][0]=new Uint8Array(this[w][0].buffer,this[w][0].byteOffset-t[0].length,this[w][0].byteLength+t[0].length):this[w].unshift(...t.filter((t=>t&&t.length)))},b.prototype.readToEnd=async function(t=U){const e=[];for(;;){const{done:t,value:r}=await this.read();if(t)break;e.push(r)}return t(e)};let k,v,{ReadableStream:A,WritableStream:_,TransformStream:E}=t;async function S(){if(E)return;const[e,r]=await Promise.all([import("./ponyfill.es6.min.mjs"),import("./web-streams-adapter.min.mjs")]);({ReadableStream:A,WritableStream:_,TransformStream:E}=e);const{createReadableStreamWrapper:n}=r;t.ReadableStream&&A!==t.ReadableStream&&(k=n(A),v=n(t.ReadableStream))}const x=c&&void 0;function K(t){let e=u(t);return"node"===e?f(t):"web"===e&&k?k(t):e?t:new A({start(e){e.enqueue(t),e.close()}})}function P(t){if(u(t))return t;const e=new a;return(async()=>{const r=C(e);await r.write(t),await r.close()})(),e}function U(t){return t.some((t=>u(t)&&!s(t)))?function(t){t=t.map(K);const e=B((async function(t){await Promise.all(n.map((e=>H(e,t))))}));let r=Promise.resolve();const n=t.map(((n,i)=>R(n,((n,a)=>(r=r.then((()=>I(n,e.writable,{preventClose:i!==t.length-1}))),r)))));return e.readable}(t):t.some((t=>s(t)))?function(t){const e=new a;let r=Promise.resolve();return t.forEach(((n,i)=>(r=r.then((()=>I(n,e,{preventClose:i!==t.length-1}))),r))),e}(t):"string"==typeof t[0]?t.join(""):x&&x.isBuffer(t[0])?x.concat(t):y(t)}function D(t){return new b(t)}function C(t){return new o(t)}async function I(t,e,{preventClose:r=!1,preventAbort:n=!1,preventCancel:i=!1}={}){if(u(t)&&!s(t)){t=K(t);try{if(t[w]){const r=C(e);for(let e=0;e<t[w].length;e++)await r.ready,await r.write(t[w][e]);r.releaseLock()}await t.pipeTo(e,{preventClose:r,preventAbort:n,preventCancel:i})}catch(t){}return}const a=D(t=P(t)),o=C(e);try{for(;;){await o.ready;const{done:t,value:e}=await a.read();if(t){r||await o.close();break}await o.write(e)}}catch(t){n||await o.abort(t)}finally{a.releaseLock(),o.releaseLock()}}function T(t,e){const r=new E(e);return I(t,r.writable),r.readable}function B(t){let e,r,n=!1;return{readable:new A({start(t){r=t},pull(){e?e():n=!0},cancel:t},{highWaterMark:0}),writable:new _({write:async function(t){r.enqueue(t),n?n=!1:(await new Promise((t=>{e=t})),e=null)},close:r.close.bind(r),abort:r.error.bind(r)})}}function z(t,e=(()=>{}),r=(()=>{})){if(s(t)){const n=new a;return(async()=>{const i=C(n);try{const n=await F(t),a=e(n),s=r();let o;o=void 0!==a&&void 0!==s?U([a,s]):void 0!==a?a:s,await i.write(o),await i.close()}catch(t){await i.abort(t)}})(),n}if(u(t))return T(t,{async transform(t,r){try{const n=await e(t);void 0!==n&&r.enqueue(n)}catch(t){r.error(t)}},async flush(t){try{const e=await r();void 0!==e&&t.enqueue(e)}catch(e){t.error(e)}}});const n=e(t),i=r();return void 0!==n&&void 0!==i?U([n,i]):void 0!==n?n:i}function R(t,e){if(u(t)&&!s(t)){let r;const n=new E({start(t){r=t}}),i=I(t,n.writable),a=B((async function(t){r.error(t),await i,await new Promise(setTimeout)}));return e(n.readable,a.writable),a.readable}t=P(t);const r=new a;return e(t,r),r}function M(t,e){let r;const n=R(t,((t,i)=>{const a=D(t);a.remainder=()=>(a.releaseLock(),I(t,i),n),r=e(a)}));return r}function N(t){if(s(t))return t.clone();if(u(t)){const e=function(t){if(s(t))throw Error("ArrayStream cannot be tee()d, use clone() instead");if(u(t)){const e=K(t).tee();return e[0][w]=e[1][w]=t[w],e}return[j(t),j(t)]}(t);return L(t,e[0]),e[1]}return j(t)}function O(t){return s(t)?N(t):u(t)?new A({start(e){const r=R(t,(async(t,r)=>{const n=D(t),i=C(r);try{for(;;){await i.ready;const{done:t,value:r}=await n.read();if(t){try{e.close()}catch(t){}return void await i.close()}try{e.enqueue(r)}catch(t){}await i.write(r)}}catch(t){e.error(t),await i.abort(t)}}));L(t,r)}}):j(t)}function L(t,e){Object.entries(Object.getOwnPropertyDescriptors(t.constructor.prototype)).forEach((([r,n])=>{"constructor"!==r&&(n.value?n.value=n.value.bind(e):n.get=n.get.bind(e),Object.defineProperty(t,r,n))}))}function j(t,e=0,r=1/0){if(s(t))throw Error("Not implemented");if(u(t)){if(e>=0&&r>=0){let n=0;return T(t,{transform(t,i){n<r?(n+t.length>=e&&i.enqueue(j(t,Math.max(e-n,0),r-n)),n+=t.length):i.terminate()}})}if(e<0&&(r<0||r===1/0)){let n=[];return z(t,(t=>{t.length>=-e?n=[t]:n.push(t)}),(()=>j(U(n),e,r)))}if(0===e&&r<0){let n;return z(t,(t=>{const i=n?U([n,t]):t;if(i.length>=-r)return n=j(i,r),j(i,e,r);n=i}))}return console.warn(`stream.slice(input, ${e}, ${r}) not implemented efficiently.`),q((async()=>j(await F(t),e,r)))}return t[w]&&(t=U(t[w].concat([t]))),!l(t)||x&&x.isBuffer(t)?t.slice(e,r):(r===1/0&&(r=t.length),t.subarray(e,r))}async function F(t,e=U){return s(t)?t.readToEnd(e):u(t)?D(t).readToEnd(e):t}async function H(t,e){if(u(t)){if(t.cancel)return t.cancel(e);if(t.destroy)return t.destroy(e),await new Promise(setTimeout),e}}function q(t){const e=new a;return(async()=>{const r=C(e);try{await r.write(await t()),await r.close()}catch(t){await r.abort(t)}})(),e}class G{constructor(t){if(void 0===t)throw Error("Invalid BigInteger input");if(t instanceof Uint8Array){const e=t,r=Array(e.length);for(let t=0;t<e.length;t++){const n=e[t].toString(16);r[t]=e[t]<=15?"0"+n:n}this.value=BigInt("0x0"+r.join(""))}else this.value=BigInt(t)}clone(){return new G(this.value)}iinc(){return this.value++,this}inc(){return this.clone().iinc()}idec(){return this.value--,this}dec(){return this.clone().idec()}iadd(t){return this.value+=t.value,this}add(t){return this.clone().iadd(t)}isub(t){return this.value-=t.value,this}sub(t){return this.clone().isub(t)}imul(t){return this.value*=t.value,this}mul(t){return this.clone().imul(t)}imod(t){return this.value%=t.value,this.isNegative()&&this.iadd(t),this}mod(t){return this.clone().imod(t)}modExp(t,e){if(e.isZero())throw Error("Modulo cannot be zero");if(e.isOne())return new G(0);if(t.isNegative())throw Error("Unsopported negative exponent");let r=t.value,n=this.value;n%=e.value;let i=BigInt(1);for(;r>BigInt(0);){const t=r&BigInt(1);r>>=BigInt(1);const a=i*n%e.value;i=t?a:i,n=n*n%e.value}return new G(i)}modInv(t){const{gcd:e,x:r}=this._egcd(t);if(!e.isOne())throw Error("Inverse does not exist");return r.add(t).mod(t)}_egcd(t){let e=BigInt(0),r=BigInt(1),n=BigInt(1),i=BigInt(0),a=this.value;for(t=t.value;t!==BigInt(0);){const s=a/t;let o=e;e=n-s*e,n=o,o=r,r=i-s*r,i=o,o=t,t=a%t,a=o}return{x:new G(n),y:new G(i),gcd:new G(a)}}gcd(t){let e=this.value;for(t=t.value;t!==BigInt(0);){const r=t;t=e%t,e=r}return new G(e)}ileftShift(t){return this.value<<=t.value,this}leftShift(t){return this.clone().ileftShift(t)}irightShift(t){return this.value>>=t.value,this}rightShift(t){return this.clone().irightShift(t)}equal(t){return this.value===t.value}lt(t){return this.value<t.value}lte(t){return this.value<=t.value}gt(t){return this.value>t.value}gte(t){return this.value>=t.value}isZero(){return this.value===BigInt(0)}isOne(){return this.value===BigInt(1)}isNegative(){return this.value<BigInt(0)}isEven(){return!(this.value&BigInt(1))}abs(){const t=this.clone();return this.isNegative()&&(t.value=-t.value),t}toString(){return this.value.toString()}toNumber(){const t=Number(this.value);if(t>Number.MAX_SAFE_INTEGER)throw Error("Number can only safely store up to 53 bits");return t}getBit(t){return(this.value>>BigInt(t)&BigInt(1))===BigInt(0)?0:1}bitLength(){const t=new G(0),e=new G(1),r=new G(-1),n=this.isNegative()?r:t;let i=1;const a=this.clone();for(;!a.irightShift(e).equal(n);)i++;return i}byteLength(){const t=new G(0),e=new G(-1),r=this.isNegative()?e:t,n=new G(8);let i=1;const a=this.clone();for(;!a.irightShift(n).equal(r);)i++;return i}toUint8Array(t="be",e){let r=this.value.toString(16);r.length%2==1&&(r="0"+r);const n=r.length/2,i=new Uint8Array(e||n),a=e?e-n:0;let s=0;for(;s<n;)i[s+a]=parseInt(r.slice(2*s,2*s+2),16),s++;return"be"!==t&&i.reverse(),i}}const V=(()=>{try{return"development"===process.env.NODE_ENV}catch(t){}return!1})(),W={isString:function(t){return"string"==typeof t||String.prototype.isPrototypeOf(t)},isArray:function(t){return Array.prototype.isPrototypeOf(t)},isUint8Array:l,isStream:u,readNumber:function(t){let e=0;for(let r=0;r<t.length;r++)e+=256**r*t[t.length-1-r];return e},writeNumber:function(t,e){const r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=t>>8*(e-n-1)&255;return r},readDate:function(t){const e=W.readNumber(t);return new Date(1e3*e)},writeDate:function(t){const e=Math.floor(t.getTime()/1e3);return W.writeNumber(e,4)},normalizeDate:function(t=Date.now()){return null===t||t===1/0?t:new Date(1e3*Math.floor(+t/1e3))},readMPI:function(t){const e=(t[0]<<8|t[1])+7>>>3;return t.subarray(2,2+e)},leftPad(t,e){const r=new Uint8Array(e),n=e-t.length;return r.set(t,n),r},uint8ArrayToMPI:function(t){const e=W.uint8ArrayBitLength(t);if(0===e)throw Error("Zero MPI");const r=t.subarray(t.length-Math.ceil(e/8)),n=new Uint8Array([(65280&e)>>8,255&e]);return W.concatUint8Array([n,r])},uint8ArrayBitLength:function(t){let e;for(e=0;e<t.length&&0===t[e];e++);if(e===t.length)return 0;const r=t.subarray(e);return 8*(r.length-1)+W.nbits(r[0])},hexToUint8Array:function(t){const e=new Uint8Array(t.length>>1);for(let r=0;r<t.length>>1;r++)e[r]=parseInt(t.substr(r<<1,2),16);return e},uint8ArrayToHex:function(t){const e=[],r=t.length;let n,i=0;for(;i<r;){for(n=t[i++].toString(16);n.length<2;)n="0"+n;e.push(""+n)}return e.join("")},stringToUint8Array:function(t){return z(t,(t=>{if(!W.isString(t))throw Error("stringToUint8Array: Data must be in the form of a string");const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}))},uint8ArrayToString:function(t){const e=[],r=16384,n=(t=new Uint8Array(t)).length;for(let i=0;i<n;i+=r)e.push(String.fromCharCode.apply(String,t.subarray(i,i+r<n?i+r:n)));return e.join("")},encodeUTF8:function(t){const e=new TextEncoder("utf-8");function r(t,r=!1){return e.encode(t,{stream:!r})}return z(t,r,(()=>r("",!0)))},decodeUTF8:function(t){const e=new TextDecoder("utf-8");function r(t,r=!1){return e.decode(t,{stream:!r})}return z(t,r,(()=>r(new Uint8Array,!0)))},concat:U,concatUint8Array:y,equalsUint8Array:function(t,e){if(!W.isUint8Array(t)||!W.isUint8Array(e))throw Error("Data must be in the form of a Uint8Array");if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0},writeChecksum:function(t){let e=0;for(let r=0;r<t.length;r++)e=e+t[r]&65535;return W.writeNumber(e,2)},printDebug:function(t){V&&console.log("[OpenPGP.js debug]",t)},printDebugError:function(t){V&&console.error("[OpenPGP.js debug]",t)},nbits:function(t){let e=1,r=t>>>16;return 0!==r&&(t=r,e+=16),r=t>>8,0!==r&&(t=r,e+=8),r=t>>4,0!==r&&(t=r,e+=4),r=t>>2,0!==r&&(t=r,e+=2),r=t>>1,0!==r&&(t=r,e+=1),e},double:function(t){const e=new Uint8Array(t.length),r=t.length-1;for(let n=0;n<r;n++)e[n]=t[n]<<1^t[n+1]>>7;return e[r]=t[r]<<1^135*(t[0]>>7),e},shiftRight:function(t,e){if(e)for(let r=t.length-1;r>=0;r--)t[r]>>=e,r>0&&(t[r]|=t[r-1]<<8-e);return t},getWebCrypto:function(){return void 0!==t&&t.crypto&&t.crypto.subtle},detectBigInt:()=>"undefined"!=typeof BigInt,getBigInteger:async function(){if(W.detectBigInt())return G;{const{default:t}=await import("./bn.interface.min.mjs");return t}},getNodeCrypto:function(){},getNodeZlib:function(){},getNodeBuffer:function(){return{}.Buffer},getHardwareConcurrency:function(){if("undefined"!=typeof navigator)return navigator.hardwareConcurrency||1;return(void 0).cpus().length},isEmailAddress:function(t){if(!W.isString(t))return!1;return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+([a-zA-Z]{2,}|xn--[a-zA-Z\-0-9]+)))$/.test(t)},canonicalizeEOL:function(t){let e=!1;return z(t,(t=>{let r;e&&(t=W.concatUint8Array([new Uint8Array([13]),t])),13===t[t.length-1]?(e=!0,t=t.subarray(0,-1)):e=!1;const n=[];for(let e=0;r=t.indexOf(10,e)+1,r;e=r)13!==t[r-2]&&n.push(r);if(!n.length)return t;const i=new Uint8Array(t.length+n.length);let a=0;for(let e=0;e<n.length;e++){const r=t.subarray(n[e-1]||0,n[e]);i.set(r,a),a+=r.length,i[a-1]=13,i[a]=10,a++}return i.set(t.subarray(n[n.length-1]||0),a),i}),(()=>e?new Uint8Array([13]):void 0))},nativeEOL:function(t){let e=!1;return z(t,(t=>{let r;13===(t=e&&10!==t[0]?W.concatUint8Array([new Uint8Array([13]),t]):new Uint8Array(t))[t.length-1]?(e=!0,t=t.subarray(0,-1)):e=!1;let n=0;for(let e=0;e!==t.length;e=r){r=t.indexOf(13,e)+1,r||(r=t.length);const i=r-(10===t[r]?1:0);e&&t.copyWithin(n,e,i),n+=i-e}return t.subarray(0,n)}),(()=>e?new Uint8Array([13]):void 0))},removeTrailingSpaces:function(t){return t.split("\n").map((t=>{let e=t.length-1;for(;e>=0&&(" "===t[e]||"\t"===t[e]||"\r"===t[e]);e--);return t.substr(0,e+1)})).join("\n")},wrapError:function(t,e){if(!e)return Error(t);try{e.message=t+": "+e.message}catch(t){}return e},constructAllowedPackets:function(t){const e={};return t.forEach((t=>{if(!t.tag)throw Error("Invalid input: expected a packet class");e[t.tag]=t})),e},anyPromise:function(t){return new Promise((async(e,r)=>{let n;await Promise.all(t.map((async t=>{try{e(await t)}catch(t){n=t}}))),r(n)}))},selectUint8Array:function(t,e,r){const n=Math.max(e.length,r.length),i=new Uint8Array(n);let a=0;for(let n=0;n<i.length;n++)i[n]=e[n]&256-t|r[n]&255+t,a+=t&n<e.length|1-t&n<r.length;return i.subarray(0,a)},selectUint8:function(t,e,r){return e&256-t|r&255+t}},$=W.getNodeBuffer();let Z,Q;function Y(t){let e=new Uint8Array;return z(t,(t=>{e=W.concatUint8Array([e,t]);const r=[],n=Math.floor(e.length/45),i=45*n,a=Z(e.subarray(0,i));for(let t=0;t<n;t++)r.push(a.substr(60*t,60)),r.push("\n");return e=e.subarray(i),r.join("")}),(()=>e.length?Z(e)+"\n":""))}function X(t){let e="";return z(t,(t=>{e+=t;let r=0;const n=[" ","\t","\r","\n"];for(let t=0;t<n.length;t++){const i=n[t];for(let t=e.indexOf(i);-1!==t;t=e.indexOf(i,t+1))r++}let i=e.length;for(;i>0&&(i-r)%4!=0;i--)n.includes(e[i])&&r--;const a=Q(e.substr(0,i));return e=e.substr(i),a}),(()=>Q(e)))}function J(t){return X(t.replace(/-/g,"+").replace(/_/g,"/"))}function tt(t,e){let r=Y(t).replace(/[\r\n]/g,"");return e&&(r=r.replace(/[+]/g,"-").replace(/[/]/g,"_").replace(/[=]/g,"")),r}$?(Z=t=>$.from(t).toString("base64"),Q=t=>{const e=$.from(t,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}):(Z=t=>btoa(W.uint8ArrayToString(t)),Q=t=>W.stringToUint8Array(atob(t)));const et=Symbol("byValue");var rt={curve:{p256:"p256","P-256":"p256",secp256r1:"p256",prime256v1:"p256","1.2.840.10045.3.1.7":"p256","2a8648ce3d030107":"p256","2A8648CE3D030107":"p256",p384:"p384","P-384":"p384",secp384r1:"p384","1.3.132.0.34":"p384","2b81040022":"p384","2B81040022":"p384",p521:"p521","P-521":"p521",secp521r1:"p521","1.3.132.0.35":"p521","2b81040023":"p521","2B81040023":"p521",secp256k1:"secp256k1","1.3.132.0.10":"secp256k1","2b8104000a":"secp256k1","2B8104000A":"secp256k1",ED25519:"ed25519",ed25519:"ed25519",Ed25519:"ed25519","1.3.6.1.4.1.11591.15.1":"ed25519","2b06010401da470f01":"ed25519","2B06010401DA470F01":"ed25519",X25519:"curve25519",cv25519:"curve25519",curve25519:"curve25519",Curve25519:"curve25519","1.3.6.1.4.1.3029.1.5.1":"curve25519","2b060104019755010501":"curve25519","2B060104019755010501":"curve25519",brainpoolP256r1:"brainpoolP256r1","1.3.36.3.3.2.8.1.1.7":"brainpoolP256r1","2b2403030208010107":"brainpoolP256r1","2B2403030208010107":"brainpoolP256r1",brainpoolP384r1:"brainpoolP384r1","1.3.36.3.3.2.8.1.1.11":"brainpoolP384r1","2b240303020801010b":"brainpoolP384r1","2B240303020801010B":"brainpoolP384r1",brainpoolP512r1:"brainpoolP512r1","1.3.36.3.3.2.8.1.1.13":"brainpoolP512r1","2b240303020801010d":"brainpoolP512r1","2B240303020801010D":"brainpoolP512r1"},s2k:{simple:0,salted:1,iterated:3,gnu:101},publicKey:{rsaEncryptSign:1,rsaEncrypt:2,rsaSign:3,elgamal:16,dsa:17,ecdh:18,ecdsa:19,eddsa:22,aedh:23,aedsa:24},symmetric:{plaintext:0,idea:1,tripledes:2,cast5:3,blowfish:4,aes128:7,aes192:8,aes256:9,twofish:10},compression:{uncompressed:0,zip:1,zlib:2,bzip2:3},hash:{md5:1,sha1:2,ripemd:3,sha256:8,sha384:9,sha512:10,sha224:11},webHash:{"SHA-1":2,"SHA-256":8,"SHA-384":9,"SHA-512":10},aead:{eax:1,ocb:2,experimentalGCM:100},packet:{publicKeyEncryptedSessionKey:1,signature:2,symEncryptedSessionKey:3,onePassSignature:4,secretKey:5,publicKey:6,secretSubkey:7,compressedData:8,symmetricallyEncryptedData:9,marker:10,literalData:11,trust:12,userID:13,publicSubkey:14,userAttribute:17,symEncryptedIntegrityProtectedData:18,modificationDetectionCode:19,aeadEncryptedData:20},literal:{binary:98,text:116,utf8:117,mime:109},signature:{binary:0,text:1,standalone:2,certGeneric:16,certPersona:17,certCasual:18,certPositive:19,certRevocation:48,subkeyBinding:24,keyBinding:25,key:31,keyRevocation:32,subkeyRevocation:40,timestamp:64,thirdParty:80},signatureSubpacket:{signatureCreationTime:2,signatureExpirationTime:3,exportableCertification:4,trustSignature:5,regularExpression:6,revocable:7,keyExpirationTime:9,placeholderBackwardsCompatibility:10,preferredSymmetricAlgorithms:11,revocationKey:12,issuer:16,notationData:20,preferredHashAlgorithms:21,preferredCompressionAlgorithms:22,keyServerPreferences:23,preferredKeyServer:24,primaryUserID:25,policyURI:26,keyFlags:27,signersUserID:28,reasonForRevocation:29,features:30,signatureTarget:31,embeddedSignature:32,issuerFingerprint:33,preferredAEADAlgorithms:34},keyFlags:{certifyKeys:1,signData:2,encryptCommunication:4,encryptStorage:8,splitPrivateKey:16,authentication:32,sharedPrivateKey:128},armor:{multipartSection:0,multipartLast:1,signed:2,message:3,publicKey:4,privateKey:5,signature:6},reasonForRevocation:{noReason:0,keySuperseded:1,keyCompromised:2,keyRetired:3,userIDInvalid:32},features:{modificationDetection:1,aead:2,v5Keys:4},write:function(t,e){if("number"==typeof e&&(e=this.read(t,e)),void 0!==t[e])return t[e];throw Error("Invalid enum value.")},read:function(t,e){if(t[et]||(t[et]=[],Object.entries(t).forEach((([e,r])=>{t[et][r]=e}))),void 0!==t[et][e])return t[et][e];throw Error("Invalid enum value.")}},nt={preferredHashAlgorithm:rt.hash.sha256,preferredSymmetricAlgorithm:rt.symmetric.aes256,preferredCompressionAlgorithm:rt.compression.uncompressed,deflateLevel:6,aeadProtect:!1,preferredAEADAlgorithm:rt.aead.eax,aeadChunkSizeByte:12,v5Keys:!1,s2kIterationCountByte:224,allowUnauthenticatedMessages:!1,allowUnauthenticatedStream:!1,checksumRequired:!1,minRSABits:2047,passwordCollisionCheck:!1,revocationsExpire:!1,allowInsecureDecryptionWithSigningKeys:!1,allowInsecureVerificationWithReformattedKeys:!1,constantTimePKCS1Decryption:!1,constantTimePKCS1DecryptionSupportedSymmetricAlgorithms:new Set([rt.symmetric.aes128,rt.symmetric.aes192,rt.symmetric.aes256]),minBytesForWebCrypto:1e3,ignoreUnsupportedPackets:!0,ignoreMalformedPackets:!1,showVersion:!1,showComment:!1,versionString:"OpenPGP.js 5.5.0",commentString:"https://openpgpjs.org",maxUserIDLength:5120,knownNotations:["preferred-email-encoding@pgp.com","pka-address@gnupg.org"],useIndutnyElliptic:!0,rejectHashAlgorithms:new Set([rt.hash.md5,rt.hash.ripemd]),rejectMessageHashAlgorithms:new Set([rt.hash.md5,rt.hash.ripemd,rt.hash.sha1]),rejectPublicKeyAlgorithms:new Set([rt.publicKey.elgamal,rt.publicKey.dsa]),rejectCurves:new Set([rt.curve.brainpoolP256r1,rt.curve.brainpoolP384r1,rt.curve.brainpoolP512r1,rt.curve.secp256k1])};function it(t){const e=t.match(/^-----BEGIN PGP (MESSAGE, PART \d+\/\d+|MESSAGE, PART \d+|SIGNED MESSAGE|MESSAGE|PUBLIC KEY BLOCK|PRIVATE KEY BLOCK|SIGNATURE)-----$/m);if(!e)throw Error("Unknown ASCII armor type");return/MESSAGE, PART \d+\/\d+/.test(e[1])?rt.armor.multipartSection:/MESSAGE, PART \d+/.test(e[1])?rt.armor.multipartLast:/SIGNED MESSAGE/.test(e[1])?rt.armor.signed:/MESSAGE/.test(e[1])?rt.armor.message:/PUBLIC KEY BLOCK/.test(e[1])?rt.armor.publicKey:/PRIVATE KEY BLOCK/.test(e[1])?rt.armor.privateKey:/SIGNATURE/.test(e[1])?rt.armor.signature:void 0}function at(t,e){let r="";return e.showVersion&&(r+="Version: "+e.versionString+"\n"),e.showComment&&(r+="Comment: "+e.commentString+"\n"),t&&(r+="Comment: "+t+"\n"),r+="\n",r}function st(t){return Y(function(t){let e=13501623;return z(t,(t=>{const r=ct?Math.floor(t.length/4):0,n=new Uint32Array(t.buffer,t.byteOffset,r);for(let t=0;t<r;t++)e^=n[t],e=ot[0][e>>24&255]^ot[1][e>>16&255]^ot[2][e>>8&255]^ot[3][e>>0&255];for(let n=4*r;n<t.length;n++)e=e>>8^ot[0][255&e^t[n]]}),(()=>new Uint8Array([e,e>>8,e>>16])))}(t))}const ot=[Array(255),Array(255),Array(255),Array(255)];for(let t=0;t<=255;t++){let e=t<<16;for(let t=0;t<8;t++)e=e<<1^(0!=(8388608&e)?8801531:0);ot[0][t]=(16711680&e)>>16|65280&e|(255&e)<<16}for(let t=0;t<=255;t++)ot[1][t]=ot[0][t]>>8^ot[0][255&ot[0][t]];for(let t=0;t<=255;t++)ot[2][t]=ot[1][t]>>8^ot[0][255&ot[1][t]];for(let t=0;t<=255;t++)ot[3][t]=ot[2][t]>>8^ot[0][255&ot[2][t]];const ct=function(){const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,255,!0),255===new Int16Array(t)[0]}();function ht(t){for(let e=0;e<t.length;e++)/^([^\s:]|[^\s:][^:]*[^\s:]): .+$/.test(t[e])||W.printDebugError(Error("Improperly formatted armor header: "+t[e])),/^(Version|Comment|MessageID|Hash|Charset): .+$/.test(t[e])||W.printDebugError(Error("Unknown header: "+t[e]))}function ut(t){let e=t,r="";const n=t.lastIndexOf("=");return n>=0&&n!==t.length-1&&(e=t.slice(0,n),r=t.slice(n+1).substr(0,4)),{body:e,checksum:r}}function lt(t,e=nt){return new Promise((async(r,n)=>{try{const i=/^-----[^-]+-----$/m,a=/^[ \f\r\t\u00a0\u2000-\u200a\u202f\u205f\u3000]*$/;let s;const o=[];let c,h,u,l=o,y=[],d=X(R(t,(async(t,e)=>{const p=D(t);try{for(;;){let t=await p.readLine();if(void 0===t)throw Error("Misformed armored text");if(t=W.removeTrailingSpaces(t.replace(/[\r\n]/g,"")),s)if(c)h||2!==s||(i.test(t)?(y=y.join("\r\n"),h=!0,ht(l),l=[],c=!1):y.push(t.replace(/^- /,"")));else if(i.test(t)&&n(Error("Mandatory blank line missing between armor headers and armor data")),a.test(t)){if(ht(l),c=!0,h||2!==s){r({text:y,data:d,headers:o,type:s});break}}else l.push(t);else i.test(t)&&(s=it(t))}}catch(t){return void n(t)}const f=C(e);try{for(;;){await f.ready;const{done:t,value:e}=await p.read();if(t)throw Error("Misformed armored text");const r=e+"";if(-1!==r.indexOf("=")||-1!==r.indexOf("-")){let t=await p.readToEnd();t.length||(t=""),t=r+t,t=W.removeTrailingSpaces(t.replace(/\r/g,""));const e=t.split(i);if(1===e.length)throw Error("Misformed armored text");const n=ut(e[0].slice(0,-1));u=n.checksum,await f.write(n.body);break}await f.write(r)}await f.ready,await f.close()}catch(t){await f.abort(t)}})));d=R(d,(async(t,r)=>{const n=F(st(O(t)));n.catch((()=>{})),await I(t,r,{preventClose:!0});const i=C(r);try{const t=(await n).replace("\n","");if(u!==t&&(u||e.checksumRequired))throw Error("Ascii armor integrity check failed");await i.ready,await i.close()}catch(t){await i.abort(t)}}))}catch(t){n(t)}})).then((async t=>(s(t.data)&&(t.data=await F(t.data)),t)))}function yt(t,e,r,n,i,a=nt){let s,o;t===rt.armor.signed&&(s=e.text,o=e.hash,e=e.data);const c=O(e),h=[];switch(t){case rt.armor.multipartSection:h.push("-----BEGIN PGP MESSAGE, PART "+r+"/"+n+"-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP MESSAGE, PART "+r+"/"+n+"-----\n");break;case rt.armor.multipartLast:h.push("-----BEGIN PGP MESSAGE, PART "+r+"-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP MESSAGE, PART "+r+"-----\n");break;case rt.armor.signed:h.push("-----BEGIN PGP SIGNED MESSAGE-----\n"),h.push("Hash: "+o+"\n\n"),h.push(s.replace(/^-/gm,"- -")),h.push("\n-----BEGIN PGP SIGNATURE-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP SIGNATURE-----\n");break;case rt.armor.message:h.push("-----BEGIN PGP MESSAGE-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP MESSAGE-----\n");break;case rt.armor.publicKey:h.push("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP PUBLIC KEY BLOCK-----\n");break;case rt.armor.privateKey:h.push("-----BEGIN PGP PRIVATE KEY BLOCK-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP PRIVATE KEY BLOCK-----\n");break;case rt.armor.signature:h.push("-----BEGIN PGP SIGNATURE-----\n"),h.push(at(i,a)),h.push(Y(e)),h.push("=",st(c)),h.push("-----END PGP SIGNATURE-----\n")}return W.concat(h)}class dt{constructor(){this.bytes=""}read(t){this.bytes=W.uint8ArrayToString(t.subarray(0,8))}write(){return W.stringToUint8Array(this.bytes)}toHex(){return W.uint8ArrayToHex(W.stringToUint8Array(this.bytes))}equals(t,e=!1){return e&&(t.isWildcard()||this.isWildcard())||this.bytes===t.bytes}isNull(){return""===this.bytes}isWildcard(){return/^0+$/.test(this.toHex())}static mapToHex(t){return t.toHex()}static fromID(t){const e=new dt;return e.read(W.hexToUint8Array(t)),e}static wildcard(){const t=new dt;return t.read(new Uint8Array(8)),t}}var pt=function(){var t,e,r=!1;function n(r,n){var i=t[(e[r]+e[n])%255];return 0!==r&&0!==n||(i=0),i}var i,a,s,o,c=!1;function h(){function h(r){var n,i,a;for(i=a=function(r){var n=t[255-e[r]];return 0===r&&(n=0),n}(r),n=0;n<4;n++)a^=i=255&(i<<1|i>>>7);return a^=99}r||function(){t=[],e=[];var n,i,a=1;for(n=0;n<255;n++)t[n]=a,i=128&a,a<<=1,a&=255,128===i&&(a^=27),a^=t[n],e[t[n]]=n;t[255]=t[0],e[0]=0,r=!0}(),i=[],a=[],s=[[],[],[],[]],o=[[],[],[],[]];for(var u=0;u<256;u++){var l=h(u);i[u]=l,a[l]=u,s[0][u]=n(2,l)<<24|l<<16|l<<8|n(3,l),o[0][l]=n(14,u)<<24|n(9,u)<<16|n(13,u)<<8|n(11,u);for(var y=1;y<4;y++)s[y][u]=s[y-1][u]>>>8|s[y-1][u]<<24,o[y][l]=o[y-1][l]>>>8|o[y-1][l]<<24}c=!0}var u=function(t,e){c||h();var r=new Uint32Array(e);r.set(i,512),r.set(a,768);for(var n=0;n<4;n++)r.set(s[n],4096+1024*n>>2),r.set(o[n],8192+1024*n>>2);var u=function(t,e,r){"use asm";var n=0,i=0,a=0,s=0,o=0,c=0,h=0,u=0,l=0,y=0,d=0,p=0,f=0,g=0,m=0,w=0,b=0,k=0,v=0,A=0,_=0;var E=new t.Uint32Array(r),S=new t.Uint8Array(r);function x(t,e,r,o,c,h,u,l){t=t|0;e=e|0;r=r|0;o=o|0;c=c|0;h=h|0;u=u|0;l=l|0;var y=0,d=0,p=0,f=0,g=0,m=0,w=0,b=0;y=r|0x400,d=r|0x800,p=r|0xc00;c=c^E[(t|0)>>2],h=h^E[(t|4)>>2],u=u^E[(t|8)>>2],l=l^E[(t|12)>>2];for(b=16;(b|0)<=o<<4;b=b+16|0){f=E[(r|c>>22&1020)>>2]^E[(y|h>>14&1020)>>2]^E[(d|u>>6&1020)>>2]^E[(p|l<<2&1020)>>2]^E[(t|b|0)>>2],g=E[(r|h>>22&1020)>>2]^E[(y|u>>14&1020)>>2]^E[(d|l>>6&1020)>>2]^E[(p|c<<2&1020)>>2]^E[(t|b|4)>>2],m=E[(r|u>>22&1020)>>2]^E[(y|l>>14&1020)>>2]^E[(d|c>>6&1020)>>2]^E[(p|h<<2&1020)>>2]^E[(t|b|8)>>2],w=E[(r|l>>22&1020)>>2]^E[(y|c>>14&1020)>>2]^E[(d|h>>6&1020)>>2]^E[(p|u<<2&1020)>>2]^E[(t|b|12)>>2];c=f,h=g,u=m,l=w}n=E[(e|c>>22&1020)>>2]<<24^E[(e|h>>14&1020)>>2]<<16^E[(e|u>>6&1020)>>2]<<8^E[(e|l<<2&1020)>>2]^E[(t|b|0)>>2],i=E[(e|h>>22&1020)>>2]<<24^E[(e|u>>14&1020)>>2]<<16^E[(e|l>>6&1020)>>2]<<8^E[(e|c<<2&1020)>>2]^E[(t|b|4)>>2],a=E[(e|u>>22&1020)>>2]<<24^E[(e|l>>14&1020)>>2]<<16^E[(e|c>>6&1020)>>2]<<8^E[(e|h<<2&1020)>>2]^E[(t|b|8)>>2],s=E[(e|l>>22&1020)>>2]<<24^E[(e|c>>14&1020)>>2]<<16^E[(e|h>>6&1020)>>2]<<8^E[(e|u<<2&1020)>>2]^E[(t|b|12)>>2]}function K(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;x(0x0000,0x0800,0x1000,_,t,e,r,n)}function P(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;var a=0;x(0x0400,0x0c00,0x2000,_,t,n,r,e);a=i,i=s,s=a}function U(t,e,r,l){t=t|0;e=e|0;r=r|0;l=l|0;x(0x0000,0x0800,0x1000,_,o^t,c^e,h^r,u^l);o=n,c=i,h=a,u=s}function D(t,e,r,l){t=t|0;e=e|0;r=r|0;l=l|0;var y=0;x(0x0400,0x0c00,0x2000,_,t,l,r,e);y=i,i=s,s=y;n=n^o,i=i^c,a=a^h,s=s^u;o=t,c=e,h=r,u=l}function C(t,e,r,l){t=t|0;e=e|0;r=r|0;l=l|0;x(0x0000,0x0800,0x1000,_,o,c,h,u);o=n=n^t,c=i=i^e,h=a=a^r,u=s=s^l}function I(t,e,r,l){t=t|0;e=e|0;r=r|0;l=l|0;x(0x0000,0x0800,0x1000,_,o,c,h,u);n=n^t,i=i^e,a=a^r,s=s^l;o=t,c=e,h=r,u=l}function T(t,e,r,l){t=t|0;e=e|0;r=r|0;l=l|0;x(0x0000,0x0800,0x1000,_,o,c,h,u);o=n,c=i,h=a,u=s;n=n^t,i=i^e,a=a^r,s=s^l}function B(t,e,r,o){t=t|0;e=e|0;r=r|0;o=o|0;x(0x0000,0x0800,0x1000,_,l,y,d,p);p=~w&p|w&p+1;d=~m&d|m&d+((p|0)==0);y=~g&y|g&y+((d|0)==0);l=~f&l|f&l+((y|0)==0);n=n^t;i=i^e;a=a^r;s=s^o}function z(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;var i=0,a=0,s=0,l=0,y=0,d=0,p=0,f=0,g=0,m=0;t=t^o,e=e^c,r=r^h,n=n^u;i=b|0,a=k|0,s=v|0,l=A|0;for(;(g|0)<128;g=g+1|0){if(i>>>31){y=y^t,d=d^e,p=p^r,f=f^n}i=i<<1|a>>>31,a=a<<1|s>>>31,s=s<<1|l>>>31,l=l<<1;m=n&1;n=n>>>1|r<<31,r=r>>>1|e<<31,e=e>>>1|t<<31,t=t>>>1;if(m)t=t^0xe1000000}o=y,c=d,h=p,u=f}function R(t){t=t|0;_=t}function M(t,e,r,o){t=t|0;e=e|0;r=r|0;o=o|0;n=t,i=e,a=r,s=o}function N(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;o=t,c=e,h=r,u=n}function O(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;l=t,y=e,d=r,p=n}function L(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;f=t,g=e,m=r,w=n}function j(t,e,r,n){t=t|0;e=e|0;r=r|0;n=n|0;p=~w&p|w&n,d=~m&d|m&r,y=~g&y|g&e,l=~f&l|f&t}function F(t){t=t|0;if(t&15)return-1;S[t|0]=n>>>24,S[t|1]=n>>>16&255,S[t|2]=n>>>8&255,S[t|3]=n&255,S[t|4]=i>>>24,S[t|5]=i>>>16&255,S[t|6]=i>>>8&255,S[t|7]=i&255,S[t|8]=a>>>24,S[t|9]=a>>>16&255,S[t|10]=a>>>8&255,S[t|11]=a&255,S[t|12]=s>>>24,S[t|13]=s>>>16&255,S[t|14]=s>>>8&255,S[t|15]=s&255;return 16}function H(t){t=t|0;if(t&15)return-1;S[t|0]=o>>>24,S[t|1]=o>>>16&255,S[t|2]=o>>>8&255,S[t|3]=o&255,S[t|4]=c>>>24,S[t|5]=c>>>16&255,S[t|6]=c>>>8&255,S[t|7]=c&255,S[t|8]=h>>>24,S[t|9]=h>>>16&255,S[t|10]=h>>>8&255,S[t|11]=h&255,S[t|12]=u>>>24,S[t|13]=u>>>16&255,S[t|14]=u>>>8&255,S[t|15]=u&255;return 16}function q(){K(0,0,0,0);b=n,k=i,v=a,A=s}function G(t,e,r){t=t|0;e=e|0;r=r|0;var o=0;if(e&15)return-1;while((r|0)>=16){W[t&7](S[e|0]<<24|S[e|1]<<16|S[e|2]<<8|S[e|3],S[e|4]<<24|S[e|5]<<16|S[e|6]<<8|S[e|7],S[e|8]<<24|S[e|9]<<16|S[e|10]<<8|S[e|11],S[e|12]<<24|S[e|13]<<16|S[e|14]<<8|S[e|15]);S[e|0]=n>>>24,S[e|1]=n>>>16&255,S[e|2]=n>>>8&255,S[e|3]=n&255,S[e|4]=i>>>24,S[e|5]=i>>>16&255,S[e|6]=i>>>8&255,S[e|7]=i&255,S[e|8]=a>>>24,S[e|9]=a>>>16&255,S[e|10]=a>>>8&255,S[e|11]=a&255,S[e|12]=s>>>24,S[e|13]=s>>>16&255,S[e|14]=s>>>8&255,S[e|15]=s&255;o=o+16|0,e=e+16|0,r=r-16|0}return o|0}function V(t,e,r){t=t|0;e=e|0;r=r|0;var n=0;if(e&15)return-1;while((r|0)>=16){$[t&1](S[e|0]<<24|S[e|1]<<16|S[e|2]<<8|S[e|3],S[e|4]<<24|S[e|5]<<16|S[e|6]<<8|S[e|7],S[e|8]<<24|S[e|9]<<16|S[e|10]<<8|S[e|11],S[e|12]<<24|S[e|13]<<16|S[e|14]<<8|S[e|15]);n=n+16|0,e=e+16|0,r=r-16|0}return n|0}var W=[K,P,U,D,C,I,T,B];var $=[U,z];return{set_rounds:R,set_state:M,set_iv:N,set_nonce:O,set_mask:L,set_counter:j,get_state:F,get_iv:H,gcm_init:q,cipher:G,mac:V}}({Uint8Array,Uint32Array},t,e);return u.set_key=function(t,e,n,a,s,c,h,l,y){var d=r.subarray(0,60),p=r.subarray(256,316);d.set([e,n,a,s,c,h,l,y]);for(var f=t,g=1;f<4*t+28;f++){var m=d[f-1];(f%t==0||8===t&&f%t==4)&&(m=i[m>>>24]<<24^i[m>>>16&255]<<16^i[m>>>8&255]<<8^i[255&m]),f%t==0&&(m=m<<8^m>>>24^g<<24,g=g<<1^(128&g?27:0)),d[f]=d[f-t]^m}for(var w=0;w<f;w+=4)for(var b=0;b<4;b++){m=d[f-(4+w)+(4-b)%4];p[w+b]=w<4||w>=f-4?m:o[0][i[m>>>24]]^o[1][i[m>>>16&255]]^o[2][i[m>>>8&255]]^o[3][i[255&m]]}u.set_rounds(t+5)},u};return u.ENC={ECB:0,CBC:2,CFB:4,OFB:6,CTR:7},u.DEC={ECB:1,CBC:3,CFB:5,OFB:6,CTR:7},u.MAC={CBC:0,GCM:1},u.HEAP_DATA=16384,u}();function ft(t){return t instanceof Uint8Array}function gt(t,e){const r=t?t.byteLength:e||65536;if(4095&r||r<=0)throw Error("heap size must be a positive integer and a multiple of 4096");return t=t||new Uint8Array(new ArrayBuffer(r))}function mt(t,e,r,n,i){const a=t.length-e,s=a<i?a:i;return t.set(r.subarray(n,n+s),e),s}function wt(...t){const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);let n=0;for(let e=0;e<t.length;e++)r.set(t[e],n),n+=t[e].length;return r}class bt extends Error{constructor(...t){super(...t)}}class kt extends Error{constructor(...t){super(...t)}}class vt extends Error{constructor(...t){super(...t)}}const At=[],_t=[];class Et{constructor(t,e,r=!0,n,i,a){this.pos=0,this.len=0,this.mode=n,this.pos=0,this.len=0,this.key=t,this.iv=e,this.padding=r,this.acquire_asm(i,a)}acquire_asm(t,e){return void 0!==this.heap&&void 0!==this.asm||(this.heap=t||At.pop()||gt().subarray(pt.HEAP_DATA),this.asm=e||_t.pop()||new pt(null,this.heap.buffer),this.reset(this.key,this.iv)),{heap:this.heap,asm:this.asm}}release_asm(){void 0!==this.heap&&void 0!==this.asm&&(At.push(this.heap),_t.push(this.asm)),this.heap=void 0,this.asm=void 0}reset(t,e){const{asm:r}=this.acquire_asm(),n=t.length;if(16!==n&&24!==n&&32!==n)throw new kt("illegal key size");const i=new DataView(t.buffer,t.byteOffset,t.byteLength);if(r.set_key(n>>2,i.getUint32(0),i.getUint32(4),i.getUint32(8),i.getUint32(12),n>16?i.getUint32(16):0,n>16?i.getUint32(20):0,n>24?i.getUint32(24):0,n>24?i.getUint32(28):0),void 0!==e){if(16!==e.length)throw new kt("illegal iv size");let t=new DataView(e.buffer,e.byteOffset,e.byteLength);r.set_iv(t.getUint32(0),t.getUint32(4),t.getUint32(8),t.getUint32(12))}else r.set_iv(0,0,0,0)}AES_Encrypt_process(t){if(!ft(t))throw new TypeError("data isn't of expected type");let{heap:e,asm:r}=this.acquire_asm(),n=pt.ENC[this.mode],i=pt.HEAP_DATA,a=this.pos,s=this.len,o=0,c=t.length||0,h=0,u=0,l=new Uint8Array(s+c&-16);for(;c>0;)u=mt(e,a+s,t,o,c),s+=u,o+=u,c-=u,u=r.cipher(n,i+a,s),u&&l.set(e.subarray(a,a+u),h),h+=u,u<s?(a+=u,s-=u):(a=0,s=0);return this.pos=a,this.len=s,l}AES_Encrypt_finish(){let{heap:t,asm:e}=this.acquire_asm(),r=pt.ENC[this.mode],n=pt.HEAP_DATA,i=this.pos,a=this.len,s=16-a%16,o=a;if(this.hasOwnProperty("padding")){if(this.padding){for(let e=0;e<s;++e)t[i+a+e]=s;a+=s,o=a}else if(a%16)throw new kt("data length must be a multiple of the block size")}else a+=s;const c=new Uint8Array(o);return a&&e.cipher(r,n+i,a),o&&c.set(t.subarray(i,i+o)),this.pos=0,this.len=0,this.release_asm(),c}AES_Decrypt_process(t){if(!ft(t))throw new TypeError("data isn't of expected type");let{heap:e,asm:r}=this.acquire_asm(),n=pt.DEC[this.mode],i=pt.HEAP_DATA,a=this.pos,s=this.len,o=0,c=t.length||0,h=0,u=s+c&-16,l=0,y=0;this.padding&&(l=s+c-u||16,u-=l);const d=new Uint8Array(u);for(;c>0;)y=mt(e,a+s,t,o,c),s+=y,o+=y,c-=y,y=r.cipher(n,i+a,s-(c?0:l)),y&&d.set(e.subarray(a,a+y),h),h+=y,y<s?(a+=y,s-=y):(a=0,s=0);return this.pos=a,this.len=s,d}AES_Decrypt_finish(){let{heap:t,asm:e}=this.acquire_asm(),r=pt.DEC[this.mode],n=pt.HEAP_DATA,i=this.pos,a=this.len,s=a;if(a>0){if(a%16){if(this.hasOwnProperty("padding"))throw new kt("data length must be a multiple of the block size");a+=16-a%16}if(e.cipher(r,n+i,a),this.hasOwnProperty("padding")&&this.padding){let e=t[i+s-1];if(e<1||e>16||e>s)throw new vt("bad padding");let r=0;for(let n=e;n>1;n--)r|=e^t[i+s-n];if(r)throw new vt("bad padding");s-=e}}const o=new Uint8Array(s);return s>0&&o.set(t.subarray(i,i+s)),this.pos=0,this.len=0,this.release_asm(),o}}class St{static encrypt(t,e,r=!1){return new St(e,r).encrypt(t)}static decrypt(t,e,r=!1){return new St(e,r).decrypt(t)}constructor(t,e=!1,r){this.aes=r||new Et(t,void 0,e,"ECB")}encrypt(t){return wt(this.aes.AES_Encrypt_process(t),this.aes.AES_Encrypt_finish())}decrypt(t){return wt(this.aes.AES_Decrypt_process(t),this.aes.AES_Decrypt_finish())}}function xt(t){const e=function(t){const e=new St(t);this.encrypt=function(t){return e.encrypt(t)},this.decrypt=function(t){return e.decrypt(t)}};return e.blockSize=e.prototype.blockSize=16,e.keySize=e.prototype.keySize=t/8,e}function Kt(t,e,r,n,i,a){const s=[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],o=[-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],c=[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],h=[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],u=[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],l=[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],y=[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],d=[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];let p,f,g,m,w,b,k,v,A,_,E,S,x,K,P=0,U=e.length;const D=32===t.length?3:9;v=3===D?r?[0,32,2]:[30,-2,-2]:r?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2],r&&(U=(e=function(t,e){const r=8-t.length%8;let n;if(2===e&&r<8)n=32;else if(1===e)n=r;else{if(e||!(r<8)){if(8===r)return t;throw Error("des: invalid padding")}n=0}const i=new Uint8Array(t.length+r);for(let e=0;e<t.length;e++)i[e]=t[e];for(let e=0;e<r;e++)i[t.length+e]=n;return i}(e,a)).length);let C=new Uint8Array(U),I=0;for(1===n&&(A=i[P++]<<24|i[P++]<<16|i[P++]<<8|i[P++],E=i[P++]<<24|i[P++]<<16|i[P++]<<8|i[P++],P=0);P<U;){for(b=e[P++]<<24|e[P++]<<16|e[P++]<<8|e[P++],k=e[P++]<<24|e[P++]<<16|e[P++]<<8|e[P++],1===n&&(r?(b^=A,k^=E):(_=A,S=E,A=b,E=k)),g=252645135&(b>>>4^k),k^=g,b^=g<<4,g=65535&(b>>>16^k),k^=g,b^=g<<16,g=858993459&(k>>>2^b),b^=g,k^=g<<2,g=16711935&(k>>>8^b),b^=g,k^=g<<8,g=1431655765&(b>>>1^k),k^=g,b^=g<<1,b=b<<1|b>>>31,k=k<<1|k>>>31,f=0;f<D;f+=3){for(x=v[f+1],K=v[f+2],p=v[f];p!==x;p+=K)m=k^t[p],w=(k>>>4|k<<28)^t[p+1],g=b,b=k,k=g^(o[m>>>24&63]|h[m>>>16&63]|l[m>>>8&63]|d[63&m]|s[w>>>24&63]|c[w>>>16&63]|u[w>>>8&63]|y[63&w]);g=b,b=k,k=g}b=b>>>1|b<<31,k=k>>>1|k<<31,g=1431655765&(b>>>1^k),k^=g,b^=g<<1,g=16711935&(k>>>8^b),b^=g,k^=g<<8,g=858993459&(k>>>2^b),b^=g,k^=g<<2,g=65535&(b>>>16^k),k^=g,b^=g<<16,g=252645135&(b>>>4^k),k^=g,b^=g<<4,1===n&&(r?(A=b,E=k):(b^=_,k^=S)),C[I++]=b>>>24,C[I++]=b>>>16&255,C[I++]=b>>>8&255,C[I++]=255&b,C[I++]=k>>>24,C[I++]=k>>>16&255,C[I++]=k>>>8&255,C[I++]=255&k}return r||(C=function(t,e){let r,n=null;if(2===e)r=32;else if(1===e)n=t[t.length-1];else{if(e)throw Error("des: invalid padding");r=0}if(!n){for(n=1;t[t.length-n]===r;)n++;n--}return t.subarray(0,t.length-n)}(C,a)),C}function Pt(t){const e=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],r=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],n=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],i=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],a=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],s=[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],c=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],h=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],u=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],l=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],y=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],p=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],f=t.length>8?3:1,g=Array(32*f),m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];let w,b,k,v=0,A=0;for(let _=0;_<f;_++){let f=t[v++]<<24|t[v++]<<16|t[v++]<<8|t[v++],_=t[v++]<<24|t[v++]<<16|t[v++]<<8|t[v++];k=252645135&(f>>>4^_),_^=k,f^=k<<4,k=65535&(_>>>-16^f),f^=k,_^=k<<-16,k=858993459&(f>>>2^_),_^=k,f^=k<<2,k=65535&(_>>>-16^f),f^=k,_^=k<<-16,k=1431655765&(f>>>1^_),_^=k,f^=k<<1,k=16711935&(_>>>8^f),f^=k,_^=k<<8,k=1431655765&(f>>>1^_),_^=k,f^=k<<1,k=f<<8|_>>>20&240,f=_<<24|_<<8&16711680|_>>>8&65280|_>>>24&240,_=k;for(let t=0;t<16;t++)m[t]?(f=f<<2|f>>>26,_=_<<2|_>>>26):(f=f<<1|f>>>27,_=_<<1|_>>>27),f&=-15,_&=-15,w=e[f>>>28]|r[f>>>24&15]|n[f>>>20&15]|i[f>>>16&15]|a[f>>>12&15]|s[f>>>8&15]|o[f>>>4&15],b=c[_>>>28]|h[_>>>24&15]|u[_>>>20&15]|l[_>>>16&15]|y[_>>>12&15]|d[_>>>8&15]|p[_>>>4&15],k=65535&(b>>>16^w),g[A++]=w^k,g[A++]=b^k<<16}return g}function Ut(t){this.key=[];for(let e=0;e<3;e++)this.key.push(new Uint8Array(t.subarray(8*e,8*e+8)));this.encrypt=function(t){return Kt(Pt(this.key[2]),Kt(Pt(this.key[1]),Kt(Pt(this.key[0]),t,!0,0,null,null),!1,0,null,null),!0,0,null,null)}}function Dt(){this.BlockSize=8,this.KeySize=16,this.setKey=function(t){if(this.masking=Array(16),this.rotate=Array(16),this.reset(),t.length!==this.KeySize)throw Error("CAST-128: keys must be 16 bytes");return this.keySchedule(t),!0},this.reset=function(){for(let t=0;t<16;t++)this.masking[t]=0,this.rotate[t]=0},this.getBlockSize=function(){return this.BlockSize},this.encrypt=function(t){const e=Array(t.length);for(let a=0;a<t.length;a+=8){let s,o=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3],c=t[a+4]<<24|t[a+5]<<16|t[a+6]<<8|t[a+7];s=c,c=o^r(c,this.masking[0],this.rotate[0]),o=s,s=c,c=o^n(c,this.masking[1],this.rotate[1]),o=s,s=c,c=o^i(c,this.masking[2],this.rotate[2]),o=s,s=c,c=o^r(c,this.masking[3],this.rotate[3]),o=s,s=c,c=o^n(c,this.masking[4],this.rotate[4]),o=s,s=c,c=o^i(c,this.masking[5],this.rotate[5]),o=s,s=c,c=o^r(c,this.masking[6],this.rotate[6]),o=s,s=c,c=o^n(c,this.masking[7],this.rotate[7]),o=s,s=c,c=o^i(c,this.masking[8],this.rotate[8]),o=s,s=c,c=o^r(c,this.masking[9],this.rotate[9]),o=s,s=c,c=o^n(c,this.masking[10],this.rotate[10]),o=s,s=c,c=o^i(c,this.masking[11],this.rotate[11]),o=s,s=c,c=o^r(c,this.masking[12],this.rotate[12]),o=s,s=c,c=o^n(c,this.masking[13],this.rotate[13]),o=s,s=c,c=o^i(c,this.masking[14],this.rotate[14]),o=s,s=c,c=o^r(c,this.masking[15],this.rotate[15]),o=s,e[a]=c>>>24&255,e[a+1]=c>>>16&255,e[a+2]=c>>>8&255,e[a+3]=255&c,e[a+4]=o>>>24&255,e[a+5]=o>>>16&255,e[a+6]=o>>>8&255,e[a+7]=255&o}return e},this.decrypt=function(t){const e=Array(t.length);for(let a=0;a<t.length;a+=8){let s,o=t[a]<<24|t[a+1]<<16|t[a+2]<<8|t[a+3],c=t[a+4]<<24|t[a+5]<<16|t[a+6]<<8|t[a+7];s=c,c=o^r(c,this.masking[15],this.rotate[15]),o=s,s=c,c=o^i(c,this.masking[14],this.rotate[14]),o=s,s=c,c=o^n(c,this.masking[13],this.rotate[13]),o=s,s=c,c=o^r(c,this.masking[12],this.rotate[12]),o=s,s=c,c=o^i(c,this.masking[11],this.rotate[11]),o=s,s=c,c=o^n(c,this.masking[10],this.rotate[10]),o=s,s=c,c=o^r(c,this.masking[9],this.rotate[9]),o=s,s=c,c=o^i(c,this.masking[8],this.rotate[8]),o=s,s=c,c=o^n(c,this.masking[7],this.rotate[7]),o=s,s=c,c=o^r(c,this.masking[6],this.rotate[6]),o=s,s=c,c=o^i(c,this.masking[5],this.rotate[5]),o=s,s=c,c=o^n(c,this.masking[4],this.rotate[4]),o=s,s=c,c=o^r(c,this.masking[3],this.rotate[3]),o=s,s=c,c=o^i(c,this.masking[2],this.rotate[2]),o=s,s=c,c=o^n(c,this.masking[1],this.rotate[1]),o=s,s=c,c=o^r(c,this.masking[0],this.rotate[0]),o=s,e[a]=c>>>24&255,e[a+1]=c>>>16&255,e[a+2]=c>>>8&255,e[a+3]=255&c,e[a+4]=o>>>24&255,e[a+5]=o>>16&255,e[a+6]=o>>8&255,e[a+7]=255&o}re