var forge=require("./forge");require("./md"),require("./util");var hmac=module.exports=forge.hmac=forge.hmac||{};hmac.create=function(){var e=null,t=null,r=null,a=null,u={};return u.start=function(u,f){if(null!==u)if("string"==typeof u)if((u=u.toLowerCase())in forge.md.algorithms)t=forge.md.algorithms[u].create();else throw Error('Unknown hash algorithm "'+u+'"');else t=u;if(null===f)f=e;else{if("string"==typeof f)f=forge.util.createBuffer(f);else if(forge.util.isArray(f)){var o=f;f=forge.util.createBuffer();for(var l=0;l<o.length;++l)f.putByte(o[l])}var i=f.length();i>t.blockLength&&(t.start(),t.update(f.bytes()),f=t.digest()),r=forge.util.createBuffer(),a=forge.util.createBuffer(),i=f.length();for(var l=0;l<i;++l){var o=f.at(l);r.putByte(54^o),a.putByte(92^o)}if(i<t.blockLength)for(var o=t.blockLength-i,l=0;l<o;++l)r.putByte(54),a.putByte(92);e=f,r=r.bytes(),a=a.bytes()}t.start(),t.update(r)},u.update=function(e){t.update(e)},u.getMac=function(){var e=t.digest().bytes();return t.start(),t.update(a),t.update(e),t.digest()},u.digest=u.getMac,u};