/* esm.sh - @noble/hashes@1.8.0/hmac */
import{abytes as d,aexists as r,ahash as u,clean as l,Hash as p,toBytes as H}from"./utils.mjs";var a=class extends p{constructor(t,i){super(),this.finished=!1,this.destroyed=!1,u(t);let h=H(i);if(this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let o=this.blockLen,e=new Uint8Array(o);e.set(h.length>o?t.create().update(h).digest():h);for(let s=0;s<e.length;s++)e[s]^=54;this.iHash.update(e),this.oHash=t.create();for(let s=0;s<e.length;s++)e[s]^=106;this.oHash.update(e),l(e)}update(t){return r(this),this.iHash.update(t),this}digestInto(t){r(this),d(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:i,iHash:h,finished:o,destroyed:e,blockLen:s,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=e,t.blockLen=s,t.outputLen=c,t.oHash=i._cloneInto(t.oHash),t.iHash=h._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},y=(n,t,i)=>new a(n,t).update(i).digest();y.create=(n,t)=>new a(n,t);export{a as HMAC,y as hmac};
//# sourceMappingURL=hmac.mjs.map