openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
4 lines (3 loc) • 4.21 kB
JavaScript
/*! OpenPGP.js v6.1.0 - 2025-01-30 - this is LGPL licensed code, see LICENSE/our website https://openpgpjs.org/ for more information. */
"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;import{w as t,g as s,i as h,C as i,M as e,j as r,s as n,a as o,d as a,k as l,l as f}from"./sha3.min.mjs";const c=/* @__PURE__ */new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),d=/* @__PURE__ */new Uint32Array(80);class p extends s{constructor(){super(64,20,8,!1),this.A=0|c[0],this.B=0|c[1],this.C=0|c[2],this.D=0|c[3],this.E=0|c[4]}get(){const{A:t,B:s,C:h,D:i,E:e}=this;return[t,s,h,i,e]}set(t,s,h,i,e){this.A=0|t,this.B=0|s,this.C=0|h,this.D=0|i,this.E=0|e}process(t,s){for(let h=0;h<16;h++,s+=4)d[h]=t.getUint32(s,!1);for(let t=16;t<80;t++)d[t]=h(d[t-3]^d[t-8]^d[t-14]^d[t-16],1);let{A:r,B:n,C:o,D:a,E:l}=this;for(let t=0;t<80;t++){let s,f;t<20?(s=i(n,o,a),f=1518500249):t<40?(s=n^o^a,f=1859775393):t<60?(s=e(n,o,a),f=2400959708):(s=n^o^a,f=3395469782);const c=h(r,5)+s+l+f+d[t]|0;l=a,a=o,o=h(n,30),n=r,r=c}r=r+this.A|0,n=n+this.B|0,o=o+this.C|0,a=a+this.D|0,l=l+this.E|0,this.set(r,n,o,a,l)}roundClean(){d.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const A=/* @__PURE__ */t((()=>new p)),u=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),w=/* @__PURE__ */new Uint8Array(Array(16).fill(0).map(((t,s)=>s)));let y=[w],m=[/* @__PURE__ */w.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let s of[y,m])s.push(s[t].map((t=>u[t])));const C=/* @__PURE__ */[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map((t=>new Uint8Array(t))),U=/* @__PURE__ */y.map(((t,s)=>t.map((t=>C[s][t])))),g=/* @__PURE__ */m.map(((t,s)=>t.map((t=>C[s][t])))),B=/* @__PURE__ */new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),D=/* @__PURE__ */new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function b(t,s,h,i){return 0===t?s^h^i:1===t?s&h|~s&i:2===t?(s|~h)^i:3===t?s&i|h&~i:s^(h|~i)}const E=/* @__PURE__ */new Uint32Array(16);class M extends s{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:s,h2:h,h3:i,h4:e}=this;return[t,s,h,i,e]}set(t,s,h,i,e){this.h0=0|t,this.h1=0|s,this.h2=0|h,this.h3=0|i,this.h4=0|e}process(t,s){for(let h=0;h<16;h++,s+=4)E[h]=t.getUint32(s,!0);let i=0|this.h0,e=i,r=0|this.h1,n=r,o=0|this.h2,a=o,l=0|this.h3,f=l,c=0|this.h4,d=c;for(let t=0;t<5;t++){const s=4-t,p=B[t],A=D[t],u=y[t],w=m[t],C=U[t],M=g[t];for(let s=0;s<16;s++){const e=h(i+b(t,r,o,l)+E[u[s]]+p,C[s])+c|0;i=c,c=l,l=0|h(o,10),o=r,r=e}for(let t=0;t<16;t++){const i=h(e+b(s,n,a,f)+E[w[t]]+A,M[t])+d|0;e=d,d=f,f=0|h(a,10),a=n,n=i}}this.set(this.h1+o+f|0,this.h2+l+d|0,this.h3+c+e|0,this.h4+i+n|0,this.h0+r+a|0)}roundClean(){E.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const x=/* @__PURE__ */t((()=>new M)),j=Array.from({length:64},((t,s)=>Math.floor(2**32*Math.abs(Math.sin(s+1))))),_=(t,s,h)=>t&s^~t&h,k=/* @__PURE__ */new Uint32Array([1732584193,4023233417,2562383102,271733878]),O=/* @__PURE__ */new Uint32Array(16);class q extends s{constructor(){super(64,16,8,!0),this.A=0|k[0],this.B=0|k[1],this.C=0|k[2],this.D=0|k[3]}get(){const{A:t,B:s,C:h,D:i}=this;return[t,s,h,i]}set(t,s,h,i){this.A=0|t,this.B=0|s,this.C=0|h,this.D=0|i}process(t,s){for(let h=0;h<16;h++,s+=4)O[h]=t.getUint32(s,!0);let{A:i,B:e,C:r,D:n}=this;for(let t=0;t<64;t++){let s,o,a;t<16?(s=_(e,r,n),o=t,a=[7,12,17,22]):t<32?(s=_(n,e,r),o=(5*t+1)%16,a=[5,9,14,20]):t<48?(s=e^r^n,o=(3*t+5)%16,a=[4,11,16,23]):(s=r^(e|~n),o=7*t%16,a=[6,10,15,21]),s=s+i+j[t]+O[o],i=n,n=r,r=e,e+=h(s,a[t%4])}i=i+this.A|0,e=e+this.B|0,r=r+this.C|0,n=n+this.D|0,this.set(i,e,r,n)}roundClean(){O.fill(0)}destroy(){this.set(0,0,0,0),this.buffer.fill(0)}}const v=new Map(Object.entries({md5:/* @__PURE__ */t((()=>new q)),sha1:A,sha224:r,sha256:n,sha384:o,sha512:a,sha3_256:l,sha3_512:f,ripemd160:x}));export{v as nobleHashes};
//# sourceMappingURL=noble_hashes.min.mjs.map