@protontech/openpgp
Version:
OpenPGP.js is a Javascript implementation of the OpenPGP protocol. This is defined in RFC 4880.
4 lines (3 loc) • 4.24 kB
JavaScript
/*! OpenPGP.js v6.1.1-patch.4 - 2025-07-14 - 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{H as t,C as s,M as h,c as i,s as e,a as r,b as n}from"./sha512.min.mjs";import{w as o,e as a,f as l,g as f}from"./sha3.min.mjs";const c=/* @__PURE__ */new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),p=/* @__PURE__ */new Uint32Array(80);class A extends t{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,i){for(let s=0;s<16;s++,i+=4)p[s]=t.getUint32(i,!1);for(let t=16;t<80;t++)p[t]=a(p[t-3]^p[t-8]^p[t-14]^p[t-16],1);let{A:e,B:r,C:n,D:o,E:l}=this;for(let t=0;t<80;t++){let i,f;t<20?(i=s(r,n,o),f=1518500249):t<40?(i=r^n^o,f=1859775393):t<60?(i=h(r,n,o),f=2400959708):(i=r^n^o,f=3395469782);const c=a(e,5)+i+l+f+p[t]|0;l=o,o=n,n=a(r,30),r=e,e=c}e=e+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,l=l+this.E|0,this.set(e,r,n,o,l)}roundClean(){p.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}const d=/* @__PURE__ */o((()=>new A)),u=/* @__PURE__ */new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),m=/* @__PURE__ */new Uint8Array(Array(16).fill(0).map(((t,s)=>s)));let w=[m],y=[/* @__PURE__ */m.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let s of[w,y])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__ */w.map(((t,s)=>t.map((t=>C[s][t])))),g=/* @__PURE__ */y.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 t{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 h=0|this.h0,i=h,e=0|this.h1,r=e,n=0|this.h2,o=n,l=0|this.h3,f=l,c=0|this.h4,p=c;for(let t=0;t<5;t++){const s=4-t,A=B[t],d=D[t],u=w[t],m=y[t],C=U[t],M=g[t];for(let s=0;s<16;s++){const i=a(h+b(t,e,n,l)+E[u[s]]+A,C[s])+c|0;h=c,c=l,l=0|a(n,10),n=e,e=i}for(let t=0;t<16;t++){const h=a(i+b(s,r,o,f)+E[m[t]]+d,M[t])+p|0;i=p,p=f,f=0|a(o,10),o=r,r=h}}this.set(this.h1+n+f|0,this.h2+l+p|0,this.h3+c+i|0,this.h4+h+r|0,this.h0+e+o|0)}roundClean(){E.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}const x=/* @__PURE__ */o((()=>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,H=/* @__PURE__ */new Uint32Array([1732584193,4023233417,2562383102,271733878]),O=/* @__PURE__ */new Uint32Array(16);class k extends t{constructor(){super(64,16,8,!0),this.A=0|H[0],this.B=0|H[1],this.C=0|H[2],this.D=0|H[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:h,B:i,C:e,D:r}=this;for(let t=0;t<64;t++){let s,n,o;t<16?(s=_(i,e,r),n=t,o=[7,12,17,22]):t<32?(s=_(r,i,e),n=(5*t+1)%16,o=[5,9,14,20]):t<48?(s=i^e^r,n=(3*t+5)%16,o=[4,11,16,23]):(s=e^(i|~r),n=7*t%16,o=[6,10,15,21]),s=s+h+j[t]+O[n],h=r,r=e,e=i,i+=a(s,o[t%4])}h=h+this.A|0,i=i+this.B|0,e=e+this.C|0,r=r+this.D|0,this.set(h,i,e,r)}roundClean(){O.fill(0)}destroy(){this.set(0,0,0,0),this.buffer.fill(0)}}const q=new Map(Object.entries({md5:/* @__PURE__ */o((()=>new k)),sha1:d,sha224:i,sha256:e,sha384:r,sha512:n,sha3_256:l,sha3_512:f,ripemd160:x}));export{q as nobleHashes};
//# sourceMappingURL=noble_hashes.min.mjs.map