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