(function(){if(typeof forge==="undefined"){forge={disableNativeCode:false}}})();(function(){function initModule(forge){var util=forge.util=forge.util||{};util.setImmediate=function(callback){setTimeout(callback,0)};util.nextTick=util.setImmediate;util.isArray=Array.isArray||function(x){return Object.prototype.toString.call(x)==="[object Array]"};util.isArrayBuffer=function(x){return typeof ArrayBuffer!=="undefined"&&x instanceof ArrayBuffer};var _arrayBufferViews=[];if(typeof DataView!=="undefined"){_arrayBufferViews.push(DataView)}if(typeof Uint8Array!=="undefined"){_arrayBufferViews.push(Uint8Array)}if(typeof Uint16Array!=="undefined"){_arrayBufferViews.push(Uint16Array)}if(typeof Uint32Array!=="undefined"){_arrayBufferViews.push(Uint32Array)}util.isArrayBufferView=function(x){for(var i=0;i<_arrayBufferViews.length;++i){if(x instanceof _arrayBufferViews[i]){return true}}return false};util.ByteBuffer=ByteStringBuffer;function ByteStringBuffer(b,options){if(typeof options==="string"){options={encoding:options}}options=options||{};this.data="";this.read=0;if(typeof b==="string"){if(options.encoding==="utf8"){b=util.encodeUtf8(b)}else{if(options.encoding==="hex"){b=util.hexToBytes(b)}else{if(options.encoding==="base64"){b=util.decode64(b)}}}this.data=b}else{if(util.isArrayBuffer(b)||util.isArrayBufferView(b)){var arr=new Uint8Array(b);try{this.data=String.fromCharCode.apply(null,arr)}catch(e){for(var i=0;i0){if(n&1){d+=b}n>>>=1;if(n>0){b+=b}}this.data=d;return this};util.ByteStringBuffer.prototype.putBytes=function(bytes){this.data+=bytes;return this};util.ByteStringBuffer.prototype.putInt16=function(i){this.data+=String.fromCharCode(i>>8&255)+String.fromCharCode(i&255);return this};util.ByteStringBuffer.prototype.putInt32=function(i){this.data+=String.fromCharCode(i>>24&255)+String.fromCharCode(i>>16&255)+String.fromCharCode(i>>8&255)+String.fromCharCode(i&255);return this};util.ByteStringBuffer.prototype.putInt=function(i,n){do{n-=8;this.data+=String.fromCharCode((i>>n)&255)}while(n>0);return this};util.ByteStringBuffer.prototype.putSignedInt=function(i,n){if(i<0){i+=2<<(n-1)}return this.putInt(i,n)};util.ByteStringBuffer.prototype.putBuffer=function(buffer){this.data+=buffer.getBytes();return this};util.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)};util.ByteStringBuffer.prototype.getInt16=function(){var rval=(this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1));this.read+=2;return rval};util.ByteStringBuffer.prototype.getInt24=function(){var rval=(this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2));this.read+=3;return rval};util.ByteStringBuffer.prototype.getInt32=function(){var rval=(this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3));this.read+=4;return rval};util.ByteStringBuffer.prototype.getInt=function(n){var rval=0;do{rval=(rval<<8)+this.data.charCodeAt(this.read++);n-=8}while(n>0);return rval};util.ByteStringBuffer.prototype.getSignedInt=function(n){var x=this.getInt(n);var max=2<<(n-2);if(x>=max){x-=max<<1}return x};util.ByteStringBuffer.prototype.getBytes=function(count){var rval;if(count){count=Math.min(this.length(),count);rval=this.data.slice(this.read,this.read+count);this.read+=count}else{if(count===0){rval=""}else{rval=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return rval};util.ByteStringBuffer.prototype.bytes=function(count){return(typeof(count)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+count))};util.ByteStringBuffer.prototype.at=function(i){return this.data.charCodeAt(this.read+i)};util.ByteStringBuffer.prototype.setAt=function(i,b){this.data=this.data.substr(0,this.read+i)+String.fromCharCode(b)+this.data.substr(this.read+i+1);return this};util.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)};util.ByteStringBuffer.prototype.copy=function(){var c=util.createBuffer(this.data);c.read=this.read;return c};util.ByteStringBuffer.prototype.compact=function(){if(this.read>0){this.data=this.data.slice(this.read);this.read=0}return this};util.ByteStringBuffer.prototype.clear=function(){this.data="";this.read=0;return this};util.ByteStringBuffer.prototype.truncate=function(count){var len=Math.max(0,this.length()-count); this.data=this.data.substr(this.read,len);this.read=0;return this};util.ByteStringBuffer.prototype.toHex=function(){var rval="";for(var i=this.read;i=amount){return this}growSize=Math.max(growSize||this.growSize,amount);var src=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength);var dst=new Uint8Array(this.length()+growSize);dst.set(src);this.data=new DataView(dst.buffer);return this};util.DataBuffer.prototype.putByte=function(b){this.accommodate(1);this.data.setUint8(this.write++,b);return this};util.DataBuffer.prototype.fillWithByte=function(b,n){this.accommodate(n);for(var i=0;i>n)&255)}while(n>0);return this};util.DataBuffer.prototype.putSignedInt=function(i,n){this.accommodate(n/8);if(i<0){i+=2<<(n-1)}return this.putInt(i,n)};util.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)};util.DataBuffer.prototype.getInt16=function(){var rval=this.data.getInt16(this.read);this.read+=2;return rval};util.DataBuffer.prototype.getInt24=function(){var rval=(this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2));this.read+=3;return rval};util.DataBuffer.prototype.getInt32=function(){var rval=this.data.getInt32(this.read);this.read+=4;return rval};util.DataBuffer.prototype.getInt=function(n){var rval=0;do{rval=(rval<<8)+this.data.getInt8(this.read++);n-=8}while(n>0);return rval}; util.DataBuffer.prototype.getSignedInt=function(n){var x=this.getInt(n);var max=2<<(n-2);if(x>=max){x-=max<<1}return x};util.DataBuffer.prototype.getBytes=function(count){var rval;if(count){count=Math.min(this.length(),count);rval=this.data.slice(this.read,this.read+count);this.read+=count}else{if(count===0){rval=""}else{rval=(this.read===0)?this.data:this.data.slice(this.read);this.clear()}}return rval};util.DataBuffer.prototype.bytes=function(count){return(typeof(count)==="undefined"?this.data.slice(this.read):this.data.slice(this.read,this.read+count))};util.DataBuffer.prototype.at=function(i){return this.data.getUint8(this.read+i)};util.DataBuffer.prototype.setAt=function(i,b){this.data.setUint8(i,b);return this};util.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)};util.DataBuffer.prototype.copy=function(){return new util.DataBuffer(this)};util.DataBuffer.prototype.compact=function(){if(this.read>0){var src=new Uint8Array(this.data.buffer,this.read);var dst=new Uint8Array(src.byteLength);dst.set(src);this.data=new DataView(dst);this.write-=this.read;this.read=0}return this};util.DataBuffer.prototype.clear=function(){this.data=new DataView(new ArrayBuffer(0));this.read=this.write=0;return this};util.DataBuffer.prototype.truncate=function(count){this.write=Math.max(0,this.length()-count);this.read=Math.min(this.read,this.write);return this};util.DataBuffer.prototype.toHex=function(){var rval="";for(var i=this.read;i0){if(n&1){s+=c}n>>>=1;if(n>0){c+=c}}return s};util.xorBytes=function(s1,s2,n){var s3="";var b="";var t="";var i=0;var c=0;for(;n>0;--n,++i){b=s1.charCodeAt(i)^s2.charCodeAt(i);if(c>=10){s3+=t;t="";c=0}t+=String.fromCharCode(b);++c}s3+=t;return s3};util.hexToBytes=function(hex){var rval="";var i=0;if(hex.length&1==1){i=1;rval+=String.fromCharCode(parseInt(hex[0],16))}for(;i>2);line+=_base64.charAt(((chr1&3)<<4)|(chr2>>4));if(isNaN(chr2)){line+="=="}else{line+=_base64.charAt(((chr2&15)<<2)|(chr3>>6));line+=isNaN(chr3)?"=":_base64.charAt(chr3&63)}}output+=line;return output};util.decode64=function(input){input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");var output="";var enc1,enc2,enc3,enc4;var i=0;while(i>4));if(enc3!==64){output+=String.fromCharCode(((enc2&15)<<4)|(enc3>>2));if(enc4!==64){output+=String.fromCharCode(((enc3&3)<<6)|enc4)}}}return output};util.encodeUtf8=function(str){return unescape(encodeURIComponent(str))};util.decodeUtf8=function(str){return decodeURIComponent(escape(str))};util.binary={raw:{},hex:{},base64:{}};util.binary.raw.encode=function(bytes){return String.fromCharCode.apply(null,bytes)};util.binary.raw.decode=function(str,output,offset){var out=output;if(!out){out=new Uint8Array(str.length)}offset=offset||0;var j=offset;for(var i=0;i>2);line+=_base64.charAt(((chr1&3)<<4)|(chr2>>4));if(isNaN(chr2)){line+="=="}else{line+=_base64.charAt(((chr2&15)<<2)|(chr3>>6));line+=isNaN(chr3)?"=":_base64.charAt(chr3&63)}}output+=line;return output};util.binary.base64.decode=function(input,output,offset){var out=output;if(!out){out=new Uint8Array(Math.ceil(input.length/4)*3)}input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");offset=offset||0;var enc1,enc2,enc3,enc4;var i=0,j=offset;while(i>4);if(enc3!==64){out[j++]=((enc2&15)<<4)|(enc3>>2);if(enc4!==64){out[j++]=((enc3&3)<<6)|enc4}}}return output?(j-offset):out};util.text={utf8:{}};util.text.utf8.encode=function(str,output,offset){str=util.encodeUtf8(str);var out=output;if(!out){out=new Uint8Array(str.length)}offset=offset||0;var j=offset;for(var i=0;i0){parts.push(part)}last=re.lastIndex;var code=match[0][1];switch(code){case"s":case"o":if(argi")}break;case"%":parts.push("%");break;default:parts.push("<%"+code+"?>")}}parts.push(format.substring(last));return parts.join("")}}return initModule(forge)})();(function(){function initModule(forge){forge.md=forge.md||{};forge.md.algorithms=forge.md.algorithms||{};var ByteBuffer=forge.util.ByteBuffer;var _padding=null;forge.md.createMessageDigest=function(algorithm){var api=algorithm;if(typeof api==="string"){api=forge.md.getAlgorithm(api)}if(!api){throw new Error("Unsupported algorithm: "+algorithm)}if(!_padding||_padding.length>>0,len>>>0];for(var i=this.fullMessageLength.length-1;i>=0;--i){this.fullMessageLength[i]+=len[1];len[1]=len[0]+((this.fullMessageLength[i]/4294967296)>>>0);this.fullMessageLength[i]=this.fullMessageLength[i]>>>0;len[0]=((len[1]/4294967296)>>>0)}this._input.putBuffer(msg);while(this._input.length()>=this._algorithm.blockSize){this.state=this._algorithm.digest(this.state,this._input)}if(this._input.read>2048||this._input.length()===0){this._input.compact()}return this};MessageDigest.prototype.digest=function(){var finalBlock=new ByteBuffer();finalBlock.putBytes(this._input.bytes());var remaining=(this.fullMessageLength[this.fullMessageLength.length-1]+this._algorithm.messageLengthSize);var overflow=remaining&(this._algorithm.blockSize-1);finalBlock.putBytes(_padding.substr(0,this._algorithm.blockSize-overflow));var messageLength=new ByteBuffer();for(var i=0;i>>28))}this._algorithm.writeMessageLength(finalBlock,messageLength);var state=this._algorithm.digest(this.state.copy(),finalBlock);var rval=new ByteBuffer();state.write(rval);return rval};MessageDigest.prototype.copy=function(){var rval=new MessageDigest({algorithm:this._algorithm});rval.state=this.state.copy();return rval}}return initModule(forge)})();(function(){function initModule(forge){var sha1=forge.sha1=forge.sha1||{}; var _w;sha1.create=function(){return forge.md.createMessageDigest("sha1")};sha1.Algorithm=function(){this.name="sha1",this.blockSize=64;this.digestLength=20;this.messageLengthSize=8};sha1.Algorithm.prototype.start=function(){if(!_w){_w=new Array(80)}return _createState()};sha1.Algorithm.prototype.writeMessageLength=function(finalBlock,messageLength){finalBlock.putBuffer(messageLength)};sha1.Algorithm.prototype.digest=function(s,input){var t,a,b,c,d,e,f,i;var len=input.length();while(len>=64){a=s.h0;b=s.h1;c=s.h2;d=s.h3;e=s.h4;for(i=0;i<16;++i){t=input.getInt32();_w[i]=t;f=d^(b&(c^d));t=((a<<5)|(a>>>27))+f+e+1518500249+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}for(;i<20;++i){t=(_w[i-3]^_w[i-8]^_w[i-14]^_w[i-16]);t=(t<<1)|(t>>>31);_w[i]=t;f=d^(b&(c^d));t=((a<<5)|(a>>>27))+f+e+1518500249+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}for(;i<32;++i){t=(_w[i-3]^_w[i-8]^_w[i-14]^_w[i-16]);t=(t<<1)|(t>>>31);_w[i]=t;f=b^c^d;t=((a<<5)|(a>>>27))+f+e+1859775393+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}for(;i<40;++i){t=(_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32]);t=(t<<2)|(t>>>30);_w[i]=t;f=b^c^d;t=((a<<5)|(a>>>27))+f+e+1859775393+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}for(;i<60;++i){t=(_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32]);t=(t<<2)|(t>>>30);_w[i]=t;f=(b&c)|(d&(b^c));t=((a<<5)|(a>>>27))+f+e+2400959708+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}for(;i<80;++i){t=(_w[i-6]^_w[i-16]^_w[i-28]^_w[i-32]);t=(t<<2)|(t>>>30);_w[i]=t;f=b^c^d;t=((a<<5)|(a>>>27))+f+e+3395469782+t;e=d;d=c;c=(b<<30)|(b>>>2);b=a;a=t}s.h0=(s.h0+a)|0;s.h1=(s.h1+b)|0;s.h2=(s.h2+c)|0;s.h3=(s.h3+d)|0;s.h4=(s.h4+e)|0;len-=64}return s};forge.md.registerAlgorithm("sha1",new forge.sha1.Algorithm());function _createState(){var state={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520};state.copy=function(){var rval=_createState();rval.h0=state.h0;rval.h1=state.h1;rval.h2=state.h2;rval.h3=state.h3;rval.h4=state.h4;return rval};state.write=function(buffer){buffer.putInt32(state.h0);buffer.putInt32(state.h1);buffer.putInt32(state.h2);buffer.putInt32(state.h3);buffer.putInt32(state.h4)};return state}}return initModule(forge)})();(function(){function initModule(forge){forge.cipher=forge.cipher||{};var modes=forge.cipher.modes=forge.cipher.modes||{};var ByteBuffer=forge.util.ByteBuffer;modes.ecb=function(options){options=options||{};this.name="ECB";this.cipher=options.cipher;this.blockSize=options.blockSize||16;this._blocks=this.blockSize/4;this._inBlock=new Array(this._blocks);this._outBlock=new Array(this._blocks)};modes.ecb.prototype.start=function(options){};modes.ecb.prototype.encrypt=function(input,output){for(var i=0;i0){return false}var len=output.length();var count=output.at(len-1);if(count>(this.blockSize<<2)){return false}output.truncate(count);return true};modes.cbc=function(options){options=options||{};this.name="CBC";this.cipher=options.cipher;this.blockSize=options.blockSize||16;this._blocks=this.blockSize/4;this._inBlock=new Array(this._blocks);this._outBlock=new Array(this._blocks)};modes.cbc.prototype.start=function(options){if(options.iv===null){if(!this._prev){throw new Error("Invalid IV parameter.")}this._iv=this._prev.slice(0)}else{if("iv" in options){this._iv=transformIV(options.iv,this.blockSize);this._prev=this._iv.slice(0)}else{throw new Error("Invalid IV parameter.")}}};modes.cbc.prototype.encrypt=function(input,output){for(var i=0;i0){return false}var len=output.length();var count=output.at(len-1);if(count>(this.blockSize<<2)){return false}output.truncate(count);return true};function transformIV(iv,blockSize){if(!(iv instanceof ByteBuffer)){throw new TypeError("iv must be a ByteBuffer.") }if(iv.length()=this.blockSize||(this._input.length()>0&&this._finish)){this._op.call(this.mode,this._input,this.output)}this._input.compact();return this};BlockCipher.prototype.finish=function(pad){if(pad&&this.mode.name==="CBC"){this.mode.pad=function(input){return pad(this.blockSize,input,false)};this.mode.unpad=function(output){return pad(this.blockSize,output,true)}}var options={};options.decrypt=this._decrypt;options.overflow=this._input.length()%this.blockSize;if(!this._decrypt&&this.mode.pad){if(!this.mode.pad(this._input,options)){return false}}this._finish=true;this.update();if(this._decrypt&&this.mode.unpad){if(!this.mode.unpad(this.output,options)){return false}}if(this.mode.afterFinish){if(!this.mode.afterFinish(this.output,options)){return false}}return true}}return initModule(forge)})();(function(){function initModule(forge){forge.aes=forge.aes||{};var ByteBuffer=forge.util.ByteBuffer;forge.aes.Algorithm=function(name,mode){if(!init){initialize()}var self=this;self.name=name;self.mode=new mode({blockSize:16,cipher:{encrypt:function(inBlock,outBlock){return _updateBlock(self._w,inBlock,outBlock,false)},decrypt:function(inBlock,outBlock){return _updateBlock(self._w,inBlock,outBlock,true)}}});self._init=false};forge.aes.Algorithm.prototype.initialize=function(options){if(this._init){return}if(!(options.key instanceof ByteBuffer)){throw new TypeError("options.key must be a ByteBuffer.")}var key=[];var len=options.key.length();if(len!==16&&len!==24&&len!==32){throw new Error("options.key length must be 16 (AES-128), 24 (AES-192), "+"or 32 (AES-256) bytes, got "+len+" bytes.")}var buf=options.key.copy();len=len>>>2;for(var i=0;i>8)^(sx&255)^99;sbox[e]=sx;isbox[sx]=e;sx2=xtime[sx];e2=xtime[e]; e4=xtime[e2];e8=xtime[e4];me=(sx2<<24)^(sx<<16)^(sx<<8)^(sx^sx2);ime=(e2^e4^e8)<<24^(e^e8)<<16^(e^e4^e8)<<8^(e^e2^e8);for(var n=0;n<4;++n){mix[n][e]=me;imix[n][sx]=ime;me=me<<24|me>>>8;ime=ime<<24|ime>>>8}if(e===0){e=ei=1}else{e=e2^xtime[xtime[xtime[e2^e8]]];ei^=xtime[xtime[ei]]}}}function _expandKey(key,decrypt){var w=key.slice(0);var temp,iNk=1;var Nk=w.length;var Nr1=Nk+6+1;var end=Nb*Nr1;for(var i=Nk;i>>16&255]<<24^sbox[temp>>>8&255]<<16^sbox[temp&255]<<8^sbox[temp>>>24]^(rcon[iNk]<<24);iNk++}else{if(Nk>6&&(i%Nk===4)){temp=sbox[temp>>>24]<<24^sbox[temp>>>16&255]<<16^sbox[temp>>>8&255]<<8^sbox[temp&255]}}w[i]=w[i-Nk]^temp}if(decrypt){var tmp;var m0=imix[0];var m1=imix[1];var m2=imix[2];var m3=imix[3];var wnew=w.slice(0);end=w.length;for(var i=0,wi=end-Nb;i>>24]]^m1[sbox[tmp>>>16&255]]^m2[sbox[tmp>>>8&255]]^m3[sbox[tmp&255]]}}}w=wnew}return w}function _updateBlock(w,input,output,decrypt){var Nr=w.length/4-1;var m0,m1,m2,m3,sub;if(decrypt){m0=imix[0];m1=imix[1];m2=imix[2];m3=imix[3];sub=isbox}else{m0=mix[0];m1=mix[1];m2=mix[2];m3=mix[3];sub=sbox}var a,b,c,d,a2,b2,c2;a=input[0]^w[0];b=input[decrypt?3:1]^w[1];c=input[2]^w[2];d=input[decrypt?1:3]^w[3];var i=3;for(var round=1;round>>24]^m1[b>>>16&255]^m2[c>>>8&255]^m3[d&255]^w[++i];b2=m0[b>>>24]^m1[c>>>16&255]^m2[d>>>8&255]^m3[a&255]^w[++i];c2=m0[c>>>24]^m1[d>>>16&255]^m2[a>>>8&255]^m3[b&255]^w[++i];d=m0[d>>>24]^m1[a>>>16&255]^m2[b>>>8&255]^m3[c&255]^w[++i];a=a2;b=b2;c=c2}output[0]=(sub[a>>>24]<<24)^(sub[b>>>16&255]<<16)^(sub[c>>>8&255]<<8)^(sub[d&255])^w[++i];output[decrypt?3:1]=(sub[b>>>24]<<24)^(sub[c>>>16&255]<<16)^(sub[d>>>8&255]<<8)^(sub[a&255])^w[++i];output[2]=(sub[c>>>24]<<24)^(sub[d>>>16&255]<<16)^(sub[a>>>8&255]<<8)^(sub[b&255])^w[++i];output[decrypt?1:3]=(sub[d>>>24]<<24)^(sub[a>>>16&255]<<16)^(sub[b>>>8&255]<<8)^(sub[c&255])^w[++i]}}return initModule(forge)})();(function(){function initModule(forge){forge.des=forge.des||{};var ByteBuffer=forge.util.ByteBuffer;forge.des.Algorithm=function(name,mode){var self=this;self.name=name;self.mode=new mode({blockSize:8,cipher:{encrypt:function(inBlock,outBlock){return _updateBlock(self._keys,inBlock,outBlock,false)},decrypt:function(inBlock,outBlock){return _updateBlock(self._keys,inBlock,outBlock,true)}}});self._init=false};forge.des.Algorithm.prototype.initialize=function(options){if(this._init){return}if(!(options.key instanceof ByteBuffer)){throw new TypeError("options.key must be a ByteBuffer.")}var key=options.key;if(this.name.indexOf("3DES")===0&&key.length()!==24){throw new Error("Triple-DES key size must be 192 bits (24 bytes), got "+key.length()*8+" bits.")}this._keys=_createKeys(key.copy());this._init=true};registerAlgorithm("DES-ECB",forge.cipher.modes.ecb);registerAlgorithm("DES-CBC",forge.cipher.modes.cbc);registerAlgorithm("3DES-ECB",forge.cipher.modes.ecb);registerAlgorithm("3DES-CBC",forge.cipher.modes.cbc);function registerAlgorithm(name,mode){var factory=function(){return new forge.des.Algorithm(name,mode)};forge.cipher.registerAlgorithm(name,factory)}var spfunction1=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756];var spfunction2=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344];var spfunction3=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584];var spfunction4=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928]; var spfunction5=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080];var spfunction6=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312];var spfunction7=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154];var spfunction8=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function _createKeys(key){var pc2bytes0=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],pc2bytes1=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],pc2bytes2=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],pc2bytes3=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],pc2bytes4=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],pc2bytes5=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],pc2bytes6=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],pc2bytes7=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],pc2bytes8=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],pc2bytes9=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],pc2bytes10=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],pc2bytes11=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],pc2bytes12=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],pc2bytes13=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261];var iterations=key.length()>8?3:1;var keys=[];var shifts=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0];var n=0,tmp;for(var j=0;j>>4)^right)&252645135;right^=tmp;left^=(tmp<<4);tmp=((right>>>-16)^left)&65535;left^=tmp;right^=(tmp<<-16);tmp=((left>>>2)^right)&858993459;right^=tmp;left^=(tmp<<2);tmp=((right>>>-16)^left)&65535;left^=tmp;right^=(tmp<<-16);tmp=((left>>>1)^right)&1431655765;right^=tmp;left^=(tmp<<1);tmp=((right>>>8)^left)&16711935;left^=tmp;right^=(tmp<<8);tmp=((left>>>1)^right)&1431655765;right^=tmp;left^=(tmp<<1);tmp=(left<<8)|((right>>>20)&240);left=((right<<24)|((right<<8)&16711680)|((right>>>8)&65280)|((right>>>24)&240));right=tmp;for(var i=0;i>>26);right=(right<<2)|(right>>>26)}else{left=(left<<1)|(left>>>27);right=(right<<1)|(right>>>27)}left&=-15;right&=-15;var lefttmp=(pc2bytes0[left>>>28]|pc2bytes1[(left>>>24)&15]|pc2bytes2[(left>>>20)&15]|pc2bytes3[(left>>>16)&15]|pc2bytes4[(left>>>12)&15]|pc2bytes5[(left>>>8)&15]|pc2bytes6[(left>>>4)&15]);var righttmp=(pc2bytes7[right>>>28]|pc2bytes8[(right>>>24)&15]|pc2bytes9[(right>>>20)&15]|pc2bytes10[(right>>>16)&15]|pc2bytes11[(right>>>12)&15]|pc2bytes12[(right>>>8)&15]|pc2bytes13[(right>>>4)&15]); tmp=((righttmp>>>16)^lefttmp)&65535;keys[n++]=lefttmp^tmp;keys[n++]=righttmp^(tmp<<16)}}return keys}function _updateBlock(keys,input,output,decrypt){var iterations=keys.length===32?3:9;var looping;if(iterations===3){looping=decrypt?[30,-2,-2]:[0,32,2]}else{looping=(decrypt?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2])}var tmp;var left=input[0];var right=input[1];tmp=((left>>>4)^right)&252645135;right^=tmp;left^=(tmp<<4);tmp=((left>>>16)^right)&65535;right^=tmp;left^=(tmp<<16);tmp=((right>>>2)^left)&858993459;left^=tmp;right^=(tmp<<2);tmp=((right>>>8)^left)&16711935;left^=tmp;right^=(tmp<<8);tmp=((left>>>1)^right)&1431655765;right^=tmp;left^=(tmp<<1);left=((left<<1)|(left>>>31));right=((right<<1)|(right>>>31));for(var j=0;j>>4)|(right<<28))^keys[i+1];tmp=left;left=right;right=tmp^(spfunction2[(right1>>>24)&63]|spfunction4[(right1>>>16)&63]|spfunction6[(right1>>>8)&63]|spfunction8[right1&63]|spfunction1[(right2>>>24)&63]|spfunction3[(right2>>>16)&63]|spfunction5[(right2>>>8)&63]|spfunction7[right2&63])}tmp=left;left=right;right=tmp}left=((left>>>1)|(left<<31));right=((right>>>1)|(right<<31));tmp=((left>>>1)^right)&1431655765;right^=tmp;left^=(tmp<<1);tmp=((right>>>8)^left)&16711935;left^=tmp;right^=(tmp<<8);tmp=((right>>>2)^left)&858993459;left^=tmp;right^=(tmp<<2);tmp=((left>>>16)^right)&65535;right^=tmp;left^=(tmp<<16);tmp=((left>>>4)^right)&252645135;right^=tmp;left^=(tmp<<4);output[0]=left;output[1]=right}}return initModule(forge)})();(function(){function initModule(forge){var asn1=forge.asn1=forge.asn1||{};asn1.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192};asn1.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30};var ByteBuffer=forge.util.ByteBuffer;asn1.create=function(tagClass,type,constructed,value){var isArray=forge.util.isArray(value);if(isArray){var tmp=[];for(var i=0;i1){var read=der.read;var unused=der.getByte();if(unused===0){b1=der.getByte();var tc=(b1&192);if(tc===asn1.Class.UNIVERSAL||tc===asn1.Class.CONTEXT_SPECIFIC){try{var len=_getValueLength(der);composed=(len===length-(der.read-read));if(composed){++read;--length}}catch(ex){}}}der.read=read}if(composed){value=[];if(length===undefined){for(;;){if(der.bytes(2)===String.fromCharCode(0,0)){der.getBytes(2); break}value.push(asn1.fromDer(der,strict))}}else{var start=der.length();while(length>0){value.push(asn1.fromDer(der,strict));length-=start-der.length();start=der.length()}}}else{if(length===undefined){if(strict){throw new Error("Non-constructed ASN.1 object of indefinite length.")}length=der.length()}value=new ByteBuffer();value.putBytes(der.getBytes(length));value=asn1.derToNative(value,tagClass,type)}return asn1.create(tagClass,type,constructed,value)};asn1.toDer=function(obj){var der=new ByteBuffer();var b1=obj.tagClass|obj.type;var value=new ByteBuffer();if(obj.composed){if(obj.constructed){b1|=32}else{value.putByte(0)}for(var i=0;i>>8}while(len>0);der.putByte(lenBytes.length|128);for(var i=lenBytes.length-1;i>=0;--i){der.putByte(lenBytes.charCodeAt(i))}}return der.putBuffer(value)};asn1.derToNative=function(der,tagClass,type){if(tagClass!==asn1.Class.UNIVERSAL){return der}switch(type){case asn1.Type.OID:return asn1.derToOid(der);case asn1.Type.BOOLEAN:break;case asn1.Type.INTEGER:try{return asn1.derToInteger(der)}catch(e){return der}break;case asn1.Type.NULL:return null;case asn1.Type.UTF8:return der.toString("utf8");case asn1.Type.PRINTABLESTRING:case asn1.Type.IA5STRING:case asn1.Type.UTCTIME:case asn1.Type.GENERALIZEDTIME:return der.toString("binary");case asn1.Type.BMPSTRING:var value="";var bmp=der.copy();while(bmp.length()>0){value+=String.fromCharCode(bmp.getInt16())}return value}return der};asn1.nativeToDer=function(value,tagClass,type){if(tagClass!==asn1.Class.UNIVERSAL){if(value instanceof ByteBuffer){return value.copy()}throw new Error("Could not convert native value to DER-encoded ByteBuffer; "+'native type: "'+typeof value+'", ASN.1 class: "'+tagClass+'", ASN.1 type: "'+type+'".')}switch(type){case asn1.Type.OID:if(typeof value!=="string"){throw new TypeError("value must be a string for type OID.")}return asn1.oidToDer(value);case asn1.Type.BOOLEAN:if(typeof value!=="boolean"&&!(value instanceof ByteBuffer)){throw new TypeError("value must be a boolean or a ByteBuffer for type BOOLEAN.")}if(value instanceof ByteBuffer){return value.copy()}else{return asn1.booleanToDer(value)}break;case asn1.Type.INTEGER:if(typeof value!=="number"&&!(value instanceof ByteBuffer)){throw new TypeError("value must be a number or a ByteBuffer for type INTEGER.")}if(value instanceof ByteBuffer){return value.copy()}else{return asn1.integerToDer(value)}break;case asn1.Type.NULL:if(value!==null){throw new TypeError("value must be null for type NULL.")}return new ByteBuffer();case asn1.Type.UTF8:if(typeof value!=="string"){throw new TypeError("value must be a string for type UTF8.")}return new ByteBuffer(value,"utf8");case asn1.Type.PRINTABLESTRING:if(typeof value!=="string"){throw new TypeError("value must be a string for type PRINTABLESTRING.")}case asn1.Type.IA5STRING:if(typeof value!=="string"){throw new TypeError("value must be a string for type IA5STRING.")}return new ByteBuffer(value,"binary");case asn1.Type.UTCTIME:if(typeof value!=="string"&&!(value instanceof Date)){throw new TypeError("value must be a string or Date for type UTCTIME.")}return asn1.utcTimeToDer(value);case asn1.Type.GENERALIZEDTIME:if(typeof value!=="string"&&!(value instanceof Date)){throw new TypeError("value must be a string or Date for type GENERALIZEDTIME.")}return asn1.generalizedTimeToDer(value);case asn1.Type.BMPSTRING:if(typeof value!=="string"){throw new TypeError("value must be a string for type BMPSTRING.")}return asn1.bmpStringToDer(value);default:if(value instanceof ByteBuffer){return value.copy()}throw new Error("Could not convert native value to DER-encoded ByteBuffer; "+'native type: "'+typeof value+'", ASN.1 class: "'+tagClass+'", ASN.1 type: "'+type+'".')}};asn1.oidToDer=function(oid){if(typeof oid!=="string"){throw new TypeError("oid must be a string.")}var values=oid.split(".");var der=new ByteBuffer();der.putByte(40*parseInt(values[0],10)+parseInt(values[1],10));var last,valueBytes,value,b;for(var i=2;i>>7;if(!last){b|=128}valueBytes.push(b);last=false}while(value>0);for(var n=valueBytes.length-1;n>=0;--n){der.putByte(valueBytes[n])}}return der};asn1.derToOid=function(der){if(!(der instanceof ByteBuffer)){throw new TypeError("der must be a ByteBuffer.")}var oid;der=der.copy();var b=der.getByte();oid=Math.floor(b/40)+"."+(b%40);var value=0;while(der.length()>0){b=der.getByte();value=value<<7;if(b&128){value+=b&127}else{oid+="."+(value+b);value=0}}return oid};asn1.utcTimeToDate=function(utc){if(typeof utc!=="string"&&!(utc instanceof ByteBuffer)){throw new TypeError("utc must be a string or ByteBuffer.") }var date=new Date();if(utc instanceof ByteBuffer){utc=utc.toString("binary")}var year=parseInt(utc.substr(0,2),10);year=(year>=50)?1900+year:2000+year;var MM=parseInt(utc.substr(2,2),10)-1;var DD=parseInt(utc.substr(4,2),10);var hh=parseInt(utc.substr(6,2),10);var mm=parseInt(utc.substr(8,2),10);var ss=0;var end;var c;if(utc.length>11){c=utc.charAt(10);end=10;if(c!=="+"&&c!=="-"){ss=parseInt(utc.substr(10,2),10);end+=2}}date.setUTCFullYear(year,MM,DD);date.setUTCHours(hh,mm,ss,0);if(end){c=utc.charAt(end);if(c==="+"||c==="-"){var hhoffset=parseInt(utc.substr(end+1,2),10);var mmoffset=parseInt(utc.substr(end+4,2),10);var offset=hhoffset*60+mmoffset;offset*=60000;if(c==="+"){date.setTime(+date-offset)}else{date.setTime(+date+offset)}}}return date};asn1.generalizedTimeToDate=function(gentime){if(typeof gentime!=="string"&&!(gentime instanceof ByteBuffer)){throw new TypeError("generalized time must be a string or ByteBuffer.")}var date=new Date();if(gentime instanceof ByteBuffer){gentime=gentime.toString("binary")}var YYYY=parseInt(gentime.substr(0,4),10);var MM=parseInt(gentime.substr(4,2),10)-1;var DD=parseInt(gentime.substr(6,2),10);var hh=parseInt(gentime.substr(8,2),10);var mm=parseInt(gentime.substr(10,2),10);var ss=parseInt(gentime.substr(12,2),10);var fff=0;var offset=0;var isUTC=false;if(gentime.charAt(gentime.length-1)==="Z"){isUTC=true}var end=gentime.length-5;var c=gentime.charAt(end);if(c==="+"||c==="-"){var hhoffset=parseInt(gentime.substr(end+1,2),10);var mmoffset=parseInt(gentime.substr(end+4,2),10);offset=hhoffset*60+mmoffset;offset*=60000;if(c==="+"){offset*=-1}isUTC=true}if(gentime.charAt(14)==="."){fff=parseFloat(gentime.substr(14),10)*1000}if(isUTC){date.setUTCFullYear(YYYY,MM,DD);date.setUTCHours(hh,mm,ss,fff);date.setTime(+date+offset)}else{date.setFullYear(YYYY,MM,DD);date.setHours(hh,mm,ss,fff)}return date};asn1.dateToUtcTime=function(date){if(typeof date==="string"){return date}var rval="";var format=[];format.push((""+date.getUTCFullYear()).substr(2));format.push(""+(date.getUTCMonth()+1));format.push(""+date.getUTCDate());format.push(""+date.getUTCHours());format.push(""+date.getUTCMinutes());format.push(""+date.getUTCSeconds());for(var i=0;i=-128&&x<128){return rval.putSignedInt(x,8)}if(x>=-32768&&x<32768){return rval.putSignedInt(x,16)}if(x>=-8388608&&x<8388608){return rval.putSignedInt(x,24)}if(x>=-2147483648&&x<2147483648){return rval.putSignedInt(x,32)}var error=new Error("Integer too large; max is 32-bits.");error.integer=x;throw error};asn1.derToInteger=function(der){if(!(der instanceof ByteBuffer)){throw new TypeError("der must be a ByteBuffer.")}der=der.copy();var n=der.length()*8;if(n>32){throw new Error("Integer too large; max is 32-bits.")}return der.getSignedInt(n)};asn1.bmpStringToDer=function(value){if(typeof value!=="string"){throw new TypeError("value must be a string.")}var rval=new ByteBuffer();for(var i=0;i0){value+=String.fromCharCode(der.getInt16())}return value};asn1.validate=function(obj,v,capture,errors){var rval=false;if((obj.tagClass===v.tagClass||typeof(v.tagClass)==="undefined")&&(obj.type===v.type||typeof(v.type)==="undefined")){if(obj.constructed===v.constructed||typeof(v.constructed)==="undefined"){rval=true;if(v.value&&forge.util.isArray(v.value)){var j=0;for(var i=0;rval&&i0){rval+="\n"}var indent="";for(var i=0;i=0){var v=x*this.data[i++]+w.data[j]+c;c=Math.floor(v/67108864);w.data[j++]=v&67108863}return c}function am2(i,x,w,j,c,n){var xl=x&32767,xh=x>>15;while(--n>=0){var l=this.data[i]&32767;var h=this.data[i++]>>15;var m=xh*l+h*xl;l=xl*l+((m&32767)<<15)+w.data[j]+(c&1073741823);c=(l>>>30)+(m>>>15)+xh*h+(c>>>30);w.data[j++]=l&1073741823}return c}function am3(i,x,w,j,c,n){var xl=x&16383,xh=x>>14;while(--n>=0){var l=this.data[i]&16383;var h=this.data[i++]>>14;var m=xh*l+h*xl;l=xl*l+((m&16383)<<14)+w.data[j]+c;c=(l>>28)+(m>>14)+xh*h;w.data[j++]=l&268435455}return c}if(typeof(navigator)==="undefined"){BigInteger.prototype.am=am3;dbits=28}else{if(j_lm&&(navigator.appName=="Microsoft Internet Explorer")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator.appName!="Netscape")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}}BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=((1<=0;--i){r.data[i]=this.data[i]}r.t=this.t;r.s=this.s}function bnpFromInt(x){this.t=1;this.s=(x<0)?-1:0;if(x>0){this.data[0]=x}else{if(x<-1){this.data[0]=x+this.DV}else{this.t=0}}}function nbv(i){var r=nbi();r.fromInt(i);return r}function bnpFromString(s,b){var k;if(b==16){k=4}else{if(b==8){k=3}else{if(b==256){k=8}else{if(b==2){k=1}else{if(b==32){k=5}else{if(b==4){k=2}else{this.fromRadix(s,b);return}}}}}}this.t=0;this.s=0;var i=s.length,mi=false,sh=0;while(--i>=0){var x=(k==8)?s[i]&255:intAt(s,i);if(x<0){if(s.charAt(i)=="-"){mi=true}continue}mi=false;if(sh==0){this.data[this.t++]=x}else{if(sh+k>this.DB){this.data[this.t-1]|=(x&((1<<(this.DB-sh))-1))<>(this.DB-sh)) }else{this.data[this.t-1]|=x<=this.DB){sh-=this.DB}}if(k==8&&(s[0]&128)!=0){this.s=-1;if(sh>0){this.data[this.t-1]|=((1<<(this.DB-sh))-1)<0&&this.data[this.t-1]==c){--this.t}}function bnToString(b){if(this.s<0){return"-"+this.negate().toString(b)}var k;if(b==16){k=4}else{if(b==8){k=3}else{if(b==2){k=1}else{if(b==32){k=5}else{if(b==4){k=2}else{return this.toRadix(b)}}}}}var km=(1<0){if(p>p)>0){m=true;r=int2char(d)}while(i>=0){if(p>(p+=this.DB-k)}else{d=(this.data[i]>>(p-=k))&km;if(p<=0){p+=this.DB;--i}}if(d>0){m=true}if(m){r+=int2char(d)}}}return m?r:"0"}function bnNegate(){var r=nbi();BigInteger.ZERO.subTo(this,r);return r}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(a){var r=this.s-a.s;if(r!=0){return r}var i=this.t;r=i-a.t;if(r!=0){return(this.s<0)?-r:r}while(--i>=0){if((r=this.data[i]-a.data[i])!=0){return r}}return 0}function nbits(x){var r=1,t;if((t=x>>>16)!=0){x=t;r+=16}if((t=x>>8)!=0){x=t;r+=8}if((t=x>>4)!=0){x=t;r+=4}if((t=x>>2)!=0){x=t;r+=2}if((t=x>>1)!=0){x=t;r+=1}return r}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this.data[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(n,r){var i;for(i=this.t-1;i>=0;--i){r.data[i+n]=this.data[i]}for(i=n-1;i>=0;--i){r.data[i]=0}r.t=this.t+n;r.s=this.s}function bnpDRShiftTo(n,r){for(var i=n;i=0;--i){r.data[i+ds+1]=(this.data[i]>>cbs)|c;c=(this.data[i]&bm)<=0;--i){r.data[i]=0}r.data[ds]=c;r.t=this.t+ds+1;r.s=this.s;r.clamp()}function bnpRShiftTo(n,r){r.s=this.s;var ds=Math.floor(n/this.DB);if(ds>=this.t){r.t=0;return}var bs=n%this.DB;var cbs=this.DB-bs;var bm=(1<>bs;for(var i=ds+1;i>bs}if(bs>0){r.data[this.t-ds-1]|=(this.s&bm)<>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c-=a.s}r.s=(c<0)?-1:0;if(c<-1){r.data[i++]=this.DV+c}else{if(c>0){r.data[i++]=c}}r.t=i;r.clamp()}function bnpMultiplyTo(a,r){var x=this.abs(),y=a.abs();var i=x.t;r.t=i+y.t;while(--i>=0){r.data[i]=0}for(i=0;i=0){r.data[i]=0}for(i=0;i=x.DV){r.data[i+x.t]-=x.DV;r.data[i+x.t+1]=1}}if(r.t>0){r.data[r.t-1]+=x.am(i,x.data[i],r,2*i,0,1)}r.s=0;r.clamp()}function bnpDivRemTo(m,q,r){var pm=m.abs();if(pm.t<=0){return}var pt=this.abs();if(pt.t0){pm.lShiftTo(nsh,y);pt.lShiftTo(nsh,r)}else{pm.copyTo(y);pt.copyTo(r)}var ys=y.t;var y0=y.data[ys-1];if(y0==0){return}var yt=y0*(1<1)?y.data[ys-2]>>this.F2:0);var d1=this.FV/yt,d2=(1<=0){r.data[r.t++]=1;r.subTo(t,r)}BigInteger.ONE.dlShiftTo(ys,t);t.subTo(y,y);while(y.t=0){var qd=(r.data[--i]==y0)?this.DM:Math.floor(r.data[i]*d1+(r.data[i-1]+e)*d2);if((r.data[i]+=y.am(0,qd,r,j,0,ys))0){r.rShiftTo(nsh,r)}if(ts<0){BigInteger.ZERO.subTo(r,r)}}function bnMod(a){var r=nbi();this.abs().divRemTo(a,null,r);if(this.s<0&&r.compareTo(BigInteger.ZERO)>0){a.subTo(r,r)}return r}function Classic(m){this.m=m}function cConvert(x){if(x.s<0||x.compareTo(this.m)>=0){return x.mod(this.m)}else{return x}}function cRevert(x){return x}function cReduce(x){x.divRemTo(this.m,null,x)}function cMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}function cSqrTo(x,r){x.squareTo(r);this.reduce(r)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var x=this.data[0];if((x&1)==0){return 0}var y=x&3;y=(y*(2-(x&15)*y))&15;y=(y*(2-(x&255)*y))&255;y=(y*(2-(((x&65535)*y)&65535)))&65535; y=(y*(2-x*y%this.DV))%this.DV;return(y>0)?this.DV-y:-y}function Montgomery(m){this.m=m;this.mp=m.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(m.DB-15))-1;this.mt2=2*m.t}function montConvert(x){var r=nbi();x.abs().dlShiftTo(this.m.t,r);r.divRemTo(this.m,null,r);if(x.s<0&&r.compareTo(BigInteger.ZERO)>0){this.m.subTo(r,r)}return r}function montRevert(x){var r=nbi();x.copyTo(r);this.reduce(r);return r}function montReduce(x){while(x.t<=this.mt2){x.data[x.t++]=0}for(var i=0;i>15)*this.mpl)&this.um)<<15))&x.DM;j=i+this.m.t;x.data[j]+=this.m.am(0,u0,x,i,0,this.m.t);while(x.data[j]>=x.DV){x.data[j]-=x.DV;x.data[++j]++}}x.clamp();x.drShiftTo(this.m.t,x);if(x.compareTo(this.m)>=0){x.subTo(this.m,x)}}function montSqrTo(x,r){x.squareTo(r);this.reduce(r)}function montMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this.data[0]&1):this.s)==0}function bnpExp(e,z){if(e>4294967295||e<1){return BigInteger.ONE}var r=nbi(),r2=nbi(),g=z.convert(this),i=nbits(e)-1;g.copyTo(r);while(--i>=0){z.sqrTo(r,r2);if((e&(1<0){z.mulTo(r2,g,r)}else{var t=r;r=r2;r2=t}}return z.revert(r)}function bnModPowInt(e,m){var z;if(e<256||m.isEven()){z=new Classic(m)}else{z=new Montgomery(m)}return this.exp(e,z)}BigInteger.prototype.copyTo=bnpCopyTo;BigInteger.prototype.fromInt=bnpFromInt;BigInteger.prototype.fromString=bnpFromString;BigInteger.prototype.clamp=bnpClamp;BigInteger.prototype.dlShiftTo=bnpDLShiftTo;BigInteger.prototype.drShiftTo=bnpDRShiftTo;BigInteger.prototype.lShiftTo=bnpLShiftTo;BigInteger.prototype.rShiftTo=bnpRShiftTo;BigInteger.prototype.subTo=bnpSubTo;BigInteger.prototype.multiplyTo=bnpMultiplyTo;BigInteger.prototype.squareTo=bnpSquareTo;BigInteger.prototype.divRemTo=bnpDivRemTo;BigInteger.prototype.invDigit=bnpInvDigit;BigInteger.prototype.isEven=bnpIsEven;BigInteger.prototype.exp=bnpExp;BigInteger.prototype.toString=bnToString;BigInteger.prototype.negate=bnNegate;BigInteger.prototype.abs=bnAbs;BigInteger.prototype.compareTo=bnCompareTo;BigInteger.prototype.bitLength=bnBitLength;BigInteger.prototype.mod=bnMod;BigInteger.prototype.modPowInt=bnModPowInt;BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function bnClone(){var r=nbi();this.copyTo(r);return r}function bnIntValue(){if(this.s<0){if(this.t==1){return this.data[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this.data[0]}else{if(this.t==0){return 0}}}return((this.data[1]&((1<<(32-this.DB))-1))<>24}function bnShortValue(){return(this.t==0)?this.s:(this.data[0]<<16)>>16}function bnpChunkSize(r){return Math.floor(Math.LN2*this.DB/Math.log(r))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this.data[0]<=0)){return 0}else{return 1}}}function bnpToRadix(b){if(b==null){b=10}if(this.signum()==0||b<2||b>36){return"0"}var cs=this.chunkSize(b);var a=Math.pow(b,cs);var d=nbv(a),y=nbi(),z=nbi(),r="";this.divRemTo(d,y,z);while(y.signum()>0){r=(a+z.intValue()).toString(b).substr(1)+r;y.divRemTo(d,y,z)}return z.intValue().toString(b)+r}function bnpFromRadix(s,b){this.fromInt(0);if(b==null){b=10}var cs=this.chunkSize(b);var d=Math.pow(b,cs),mi=false,j=0,w=0;for(var i=0;i=cs){this.dMultiply(d);this.dAddOffset(w,0);j=0;w=0}}if(j>0){this.dMultiply(Math.pow(b,j));this.dAddOffset(w,0)}if(mi){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(a,b,c){if("number"==typeof b){if(a<2){this.fromInt(1)}else{this.fromNumber(a,c);if(!this.testBit(a-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(b)){this.dAddOffset(2,0);if(this.bitLength()>a){this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}}}}else{var x=new Array(),t=a&7;x.length=(a>>3)+1;b.nextBytes(x);if(t>0){x[0]&=((1<0){if(p>p)!=(this.s&this.DM)>>p){r[k++]=d|(this.s<<(this.DB-p))}while(i>=0){if(p<8){d=(this.data[i]&((1<>(p+=this.DB-8)}else{d=(this.data[i]>>(p-=8))&255;if(p<=0){p+=this.DB;--i}}if((d&128)!=0){d|=-256}if(k==0&&(this.s&128)!=(d&128)){++k}if(k>0||d!=this.s){r[k++]=d}}}return r}function bnEquals(a){return(this.compareTo(a)==0)}function bnMin(a){return(this.compareTo(a)<0)?this:a}function bnMax(a){return(this.compareTo(a)>0)?this:a}function bnpBitwiseTo(a,op,r){var i,f,m=Math.min(a.t,this.t);for(i=0;i>=16;r+=16}if((x&255)==0){x>>=8;r+=8}if((x&15)==0){x>>=4;r+=4}if((x&3)==0){x>>=2;r+=2}if((x&1)==0){++r}return r}function bnGetLowestSetBit(){for(var i=0;i=this.t){return(this.s!=0)}return((this.data[j]&(1<<(n%this.DB)))!=0)}function bnpChangeBit(n,op){var r=BigInteger.ONE.shiftLeft(n);this.bitwiseTo(r,op,r);return r}function bnSetBit(n){return this.changeBit(n,op_or)}function bnClearBit(n){return this.changeBit(n,op_andnot)}function bnFlipBit(n){return this.changeBit(n,op_xor)}function bnpAddTo(a,r){var i=0,c=0,m=Math.min(a.t,this.t);while(i>=this.DB}if(a.t>=this.DB}c+=this.s}else{c+=this.s;while(i>=this.DB}c+=a.s}r.s=(c<0)?-1:0;if(c>0){r.data[i++]=c}else{if(c<-1){r.data[i++]=this.DV+c}}r.t=i;r.clamp()}function bnAdd(a){var r=nbi();this.addTo(a,r);return r}function bnSubtract(a){var r=nbi();this.subTo(a,r);return r}function bnMultiply(a){var r=nbi();this.multiplyTo(a,r);return r}function bnDivide(a){var r=nbi();this.divRemTo(a,r,null);return r}function bnRemainder(a){var r=nbi();this.divRemTo(a,null,r);return r}function bnDivideAndRemainder(a){var q=nbi(),r=nbi();this.divRemTo(a,q,r);return new Array(q,r)}function bnpDMultiply(n){this.data[this.t]=this.am(0,n-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(n,w){if(n==0){return}while(this.t<=w){this.data[this.t++]=0}this.data[w]+=n;while(this.data[w]>=this.DV){this.data[w]-=this.DV;if(++w>=this.t){this.data[this.t++]=0}++this.data[w]}}function NullExp(){}function nNop(x){return x}function nMulTo(x,y,r){x.multiplyTo(y,r)}function nSqrTo(x,r){x.squareTo(r)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(e){return this.exp(e,new NullExp())}function bnpMultiplyLowerTo(a,n,r){var i=Math.min(this.t+a.t,n);r.s=0;r.t=i;while(i>0){r.data[--i]=0}var j;for(j=r.t-this.t;i=0){r.data[i]=0}for(i=Math.max(n-this.t,0);i2*this.m.t){return x.mod(this.m)}else{if(x.compareTo(this.m)<0){return x}else{var r=nbi();x.copyTo(r);this.reduce(r);return r}}}function barrettRevert(x){return x}function barrettReduce(x){x.drShiftTo(this.m.t-1,this.r2);if(x.t>this.m.t+1){x.t=this.m.t+1;x.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(x.compareTo(this.r2)<0){x.dAddOffset(1,this.m.t+1)}x.subTo(this.r2,x);while(x.compareTo(this.m)>=0){x.subTo(this.m,x)}}function barrettSqrTo(x,r){x.squareTo(r);this.reduce(r)}function barrettMulTo(x,y,r){x.multiplyTo(y,r);this.reduce(r)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(e,m){var i=e.bitLength(),k,r=nbv(1),z;if(i<=0){return r}else{if(i<18){k=1}else{if(i<48){k=3}else{if(i<144){k=4}else{if(i<768){k=5}else{k=6}}}}}if(i<8){z=new Classic(m)}else{if(m.isEven()){z=new Barrett(m)}else{z=new Montgomery(m)}}var g=new Array(),n=3,k1=k-1,km=(1<1){var g2=nbi();z.sqrTo(g[1],g2);while(n<=km){g[n]=nbi();z.mulTo(g2,g[n-2],g[n]);n+=2}}var j=e.t-1,w,is1=true,r2=nbi(),t; i=nbits(e.data[j])-1;while(j>=0){if(i>=k1){w=(e.data[j]>>(i-k1))&km}else{w=(e.data[j]&((1<<(i+1))-1))<<(k1-i);if(j>0){w|=e.data[j-1]>>(this.DB+i-k1)}}n=k;while((w&1)==0){w>>=1;--n}if((i-=n)<0){i+=this.DB;--j}if(is1){g[w].copyTo(r);is1=false}else{while(n>1){z.sqrTo(r,r2);z.sqrTo(r2,r);n-=2}if(n>0){z.sqrTo(r,r2)}else{t=r;r=r2;r2=t}z.mulTo(r2,g[w],r)}while(j>=0&&(e.data[j]&(1<0){x.rShiftTo(g,x);y.rShiftTo(g,y)}while(x.signum()>0){if((i=x.getLowestSetBit())>0){x.rShiftTo(i,x)}if((i=y.getLowestSetBit())>0){y.rShiftTo(i,y)}if(x.compareTo(y)>=0){x.subTo(y,x);x.rShiftTo(1,x)}else{y.subTo(x,y);y.rShiftTo(1,y)}}if(g>0){y.lShiftTo(g,y)}return y}function bnpModInt(n){if(n<=0){return 0}var d=this.DV%n,r=(this.s<0)?n-1:0;if(this.t>0){if(d==0){r=this.data[0]%n}else{for(var i=this.t-1;i>=0;--i){r=(d*r+this.data[i])%n}}}return r}function bnModInverse(m){var ac=m.isEven();if((this.isEven()&&ac)||m.signum()==0){return BigInteger.ZERO}var u=m.clone(),v=this.clone();var a=nbv(1),b=nbv(0),c=nbv(0),d=nbv(1);while(u.signum()!=0){while(u.isEven()){u.rShiftTo(1,u);if(ac){if(!a.isEven()||!b.isEven()){a.addTo(this,a);b.subTo(m,b)}a.rShiftTo(1,a)}else{if(!b.isEven()){b.subTo(m,b)}}b.rShiftTo(1,b)}while(v.isEven()){v.rShiftTo(1,v);if(ac){if(!c.isEven()||!d.isEven()){c.addTo(this,c);d.subTo(m,d)}c.rShiftTo(1,c)}else{if(!d.isEven()){d.subTo(m,d)}}d.rShiftTo(1,d)}if(u.compareTo(v)>=0){u.subTo(v,u);if(ac){a.subTo(c,a)}b.subTo(d,b)}else{v.subTo(u,v);if(ac){c.subTo(a,c)}d.subTo(b,d)}}if(v.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(d.compareTo(m)>=0){return d.subtract(m)}if(d.signum()<0){d.addTo(m,d)}else{return d}if(d.signum()<0){return d.add(m)}else{return d}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(t){var i,x=this.abs();if(x.t==1&&x.data[0]<=lowprimes[lowprimes.length-1]){for(i=0;i=0);var y=a.modPow(r,this);if(y.compareTo(BigInteger.ONE)!=0&&y.compareTo(n1)!=0){var j=1;while(j++=0){throw new Error("Encrypted message is invalid.")}var x=op(y,key);return forge.pkcs1.i2osp(x,k)}function _rsaPublicOp(x,key){return x.modPow(key.e,key.n)}function _rsaPrivateOp(x,key){if(!key.p||!key.q){return x.modPow(key.d,key.n)}if(!key.dP){key.dP=key.d.mod(key.p.subtract(BigInteger.ONE))}if(!key.dQ){key.dQ=key.d.mod(key.q.subtract(BigInteger.ONE))}if(!key.qInv){key.qInv=key.q.modInverse(key.p)}var r;do{r=new BigInteger(forge.util.bytesToHex(forge.random.getBytes(key.n.bitLength()/8)),16).mod(key.n)}while(r.equals(BigInteger.ZERO));x=x.multiply(r.modPow(key.e,key.n)).mod(key.n);var xp=x.mod(key.p).modPow(key.dP,key.p);var xq=x.mod(key.q).modPow(key.dQ,key.q);while(xp.compareTo(xq)<0){xp=xp.add(key.p)}var y=xp.subtract(xq).multiply(key.qInv).mod(key.p).multiply(key.q).add(xq);y=y.multiply(r.modInverse(key.n)).mod(key.n);return y}function _bnToBuffer(b){var hex=b.toString(16);if(hex[0]>="8"){hex="00"+hex}return new ByteBuffer(hex,"hex")}var signatureSchemes={};function _getSignatureScheme(scheme){if(scheme===null){scheme="NONE"}if(typeof scheme==="string"){if(!(scheme in signatureSchemes)){throw new Error("Unsupported scheme: "+scheme)}scheme=signatureSchemes[scheme]}else{if(typeof scheme!=="object"){throw new TypeError("scheme must be a string identifying a "+"registered signature scheme or an object that defines the "+"required scheme API.")}}return scheme}signatureSchemes.NONE={encode:function(key,input){if(!(input instanceof ByteBuffer)){throw new TypeError("input must be a ByteBuffer")}return input},verify:function(key,encoded,input){return encoded.getBytes()===input.getBytes()}};signatureSchemes["RSASSA-PKCS1-V1_5"]={encode:function(key,input){if(!(input instanceof forge.md.MessageDigest)){throw new TypeError("input must be a MessageDigest")}return forge.pkcs1.encode_rsassa(key,input)},verify:function(key,encoded,input){var decoded=forge.pkcs1.decode_rsassa(key,encoded);return input.getBytes()===decoded.getBytes()}};signatureSchemes["EME-PKCS1-V1_5"]={encode:function(key,input){if(!(input instanceof ByteBuffer)){throw new TypeError("input must be a ByteBuffer")}return forge.pkcs1.encode_eme_v1_5(key,input,2) },verify:function(key,encoded,input){var decoded=forge.pkcs1.decode_eme_v1_5(key,encoded);return input.getBytes()===decoded.getBytes()}};var encryptionSchemes={};function _getEncryptionScheme(scheme){if(scheme===null){scheme="NONE"}if(typeof scheme==="string"){if(!(scheme in encryptionSchemes)){throw new Error("Unsupported scheme: "+scheme)}scheme=encryptionSchemes[scheme]}else{if(typeof scheme!=="object"){throw new TypeError("scheme must be a string identifying a "+"registered encryption scheme or an object that defines the "+"required scheme API.")}}return scheme}encryptionSchemes["RSAES-PKCS1-V1_5"]={encode:function(key,input,options){return forge.pkcs1.encode_rsaes(key,input,options)},decode:function(key,input,options){return forge.pkcs1.decode_rsaes(key,input,options)}};encryptionSchemes["RSA-OAEP"]=encryptionSchemes["RSAES-OAEP"]={encode:function(key,input,options){return forge.pkcs1.encode_rsa_oaep(key,input,options)},decode:function(key,input,options){return forge.pkcs1.decode_rsa_oaep(key,input,options)}};encryptionSchemes.NONE={encode:function(key,input){return input},decode:function(key,input){return input}};var rsaPublicKeyValidator={name:"RSAPublicKey",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"RSAPublicKey.modulus",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:false,capture:{name:"publicKeyModulus",format:"buffer"}},{name:"RSAPublicKey.exponent",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:false,capture:{name:"publicKeyExponent",format:"buffer"}}]};var publicKeyValidator=forge.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"subjectPublicKeyInfo",format:"asn1"},value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.BITSTRING,constructed:false,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,optional:true,capture:{name:"rsaPublicKey",format:"asn1"}}]}]}}return initModule(forge)})();(function(){function initModule(forge){var pem=forge.pem=forge.pem||{};var ByteBuffer=forge.util.ByteBuffer;pem.encode=function(msg,options){options=options||{};var maxline=options.maxline||64;var rval="";var header;if(msg.procType){header={name:"Proc-Type",values:[String(msg.procType.version),msg.procType.type]};rval+=foldHeader(header)}if(msg.contentDomain){header={name:"Content-Domain",values:[msg.contentDomain]};rval+=foldHeader(header)}if(msg.dekInfo){header={name:"DEK-Info",values:[msg.dekInfo.algorithm]};if(msg.dekInfo.parameters){header.values.push(msg.dekInfo.parameters)}rval+=foldHeader(header)}if(msg.headers){for(var i=0;i65&&candidate!==-1){var insert=rval[candidate];if(insert===","){++candidate;rval=rval.substr(0,candidate)+"\r\n "+rval.substr(candidate)}else{rval=rval.substr(0,candidate)+"\r\n"+insert+rval.substr(candidate+1)}length=(i-candidate-1);candidate=-1;++i}else{if(rval[i]===" "||rval[i]==="\t"||rval[i]===","){candidate=i}}}return rval}function ltrim(str){return str.replace(/^\s+/,"")}}return initModule(forge)})();(function(){function initModule(forge){var ByteBuffer=forge.util.ByteBuffer;var asn1=forge.asn1;var pki=forge.pki=forge.pki||{};var oids=pki.oids;var _shortNames={};_shortNames["CN"]=oids["commonName"];_shortNames["commonName"]="CN";_shortNames["C"]=oids["countryName"];_shortNames["countryName"]="C";_shortNames["L"]=oids["localityName"];_shortNames["localityName"]="L";_shortNames["ST"]=oids["stateOrProvinceName"];_shortNames["stateOrProvinceName"]="ST";_shortNames["O"]=oids["organizationName"];_shortNames["organizationName"]="O";_shortNames["OU"]=oids["organizationalUnitName"];_shortNames["organizationalUnitName"]="OU";_shortNames["E"]=oids["emailAddress"];_shortNames["emailAddress"]="E";var publicKeyValidator=forge.pki.rsa.publicKeyValidator;var x509CertificateValidator={name:"Certificate",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"Certificate.TBSCertificate",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"tbsCertificate",format:"asn1"},value:[{name:"Certificate.TBSCertificate.version",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:0,constructed:true,optional:true,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:false,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:false,capture:{name:"certSerialNumber",format:"hex"}},{name:"Certificate.TBSCertificate.signature",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:asn1.Class.UNIVERSAL,optional:true,capture:{name:"certinfoSignatureParams",format:"asn1"}}]},{name:"Certificate.TBSCertificate.issuer",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"certIssuer",format:"asn1"}},{name:"Certificate.TBSCertificate.validity",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.UTCTIME,constructed:false,optional:true,capture:{name:"certValidity1UTCTime",format:"date"}},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.GENERALIZEDTIME,constructed:false,optional:true,capture:{name:"certValidity2GeneralizedTime",format:"date"}},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.UTCTIME,constructed:false,optional:true,capture:{name:"certValidity3UTCTime",format:"date"}},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.GENERALIZEDTIME,constructed:false,optional:true,capture:{name:"certValidity4GeneralizedTime",format:"date"}}]},{name:"Certificate.TBSCertificate.subject",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"certSubject",format:"asn1"}},publicKeyValidator,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:1,constructed:true,optional:true,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.BITSTRING,constructed:false,capture:{name:"certIssuerUniqueId",format:"buffer"}}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:2,constructed:true,optional:true,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.BITSTRING,constructed:false,capture:{name:"certSubjectUniqueId",format:"buffer"}}]},{name:"Certificate.TBSCertificate.extensions",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:3,constructed:true,capture:{name:"certExtensions",format:"asn1"},optional:true}]},{name:"Certificate.signatureAlgorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:asn1.Class.UNIVERSAL,optional:true,capture:{name:"certSignatureParams",format:"asn1"}}]},{name:"Certificate.signatureValue",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.BITSTRING,constructed:false,capture:{name:"certSignature",format:"buffer"}}]}; var rsassaPssParameterValidator={name:"rsapss",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"rsapss.hashAlgorithm",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:0,constructed:true,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:asn1.Class.UNIVERSAL,type:asn1.Class.SEQUENCE,constructed:true,optional:true,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:1,constructed:true,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:asn1.Class.UNIVERSAL,type:asn1.Class.SEQUENCE,constructed:true,optional:true,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:2,optional:true,value:[{name:"rsapss.saltLength.saltLength",tagClass:asn1.Class.UNIVERSAL,type:asn1.Class.INTEGER,constructed:false,capture:{name:"saltLength",format:"number"}}]},{name:"rsapss.trailerField",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:3,optional:true,value:[{name:"rsapss.trailer.trailer",tagClass:asn1.Class.UNIVERSAL,type:asn1.Class.INTEGER,constructed:false,capture:{name:"trailer",format:"number"}}]}]};var certificationRequestInfoValidator={name:"CertificationRequestInfo",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"certificationRequestInfo",format:"asn1"},value:[{name:"CertificationRequestInfo.integer",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.INTEGER,constructed:false,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"certificationRequestInfoSubject",format:"asn1"}},publicKeyValidator,{name:"CertificationRequestInfo.attributes",tagClass:asn1.Class.CONTEXT_SPECIFIC,type:0,constructed:true,optional:true,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false},{name:"CertificationRequestInfo.attributes.value",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SET,constructed:true}]}]}]};var certificationRequestValidator={name:"CertificationRequest",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,capture:{name:"csr",format:"asn1"},value:[certificationRequestInfoValidator,{name:"CertificationRequest.signatureAlgorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.SEQUENCE,constructed:true,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.OID,constructed:false,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:asn1.Class.UNIVERSAL,optional:true,capture:{name:"csrSignatureParams",format:"asn1"}}]},{name:"CertificationRequest.signature",tagClass:asn1.Class.UNIVERSAL,type:asn1.Type.BITSTRING,constructed:false,capture:{name:"csrSignature",format:"buffer"}}]};pki.RDNAttributesAsArray=function(rdn,md){var rval=[];var set,attr,obj;for(var si=0;si1){b2=ev.value.at(1);b3=ev.value.length()>2?ev.value.at(2):0}e.digitalSignature=(b2&128)===128;e.nonRepudiation=(b2&64)===64;e.keyEncipherment=(b2&32)===32;e.dataEncipherment=(b2&16)===16;e.keyAgreement=(b2&8)===8;e.keyCertSign=(b2&4)===4;e.cRLSign=(b2&2)===2;e.encipherOnly=(b2&1)===1;e.decipherOnly=(b3&128)===128}else{if(e.name==="basicConstraints"){var ev=asn1.fromDer(e.value);if(ev.value.length>0&&ev.value[0].type===asn1.Type.BOOLEAN){e.cA=asn1.derToBoolean(ev.value[0].value)}else{e.cA=false}var value=null;if(ev.value.length>0&&ev.value[0].type===asn1.Type.INTEGER){value=ev.value[0].value}else{if(ev.value.length>1){value=ev.value[1].value}}if(value!==null&&!(value instanceof ByteBuffer)){e.pathLenConstraint=value}}else{if(e.name==="extKeyUsage"){var ev=asn1.fromDer(e.value);for(var vi=0;vi1){b2=ev.value.at(1)}e.client=(b2&128)===128;e.server=(b2&64)===64;e.email=(b2&32)===32;e.objsign=(b2&16)===16;e.reserved=(b2&8)===8;e.sslCA=(b2&4)===4;e.emailCA=(b2&2)===2;e.objCA=(b2&1)===1}else{if(e.name==="subjectAltName"||e.name==="issuerAltName"){e.altNames=[];var gn;var ev=asn1.fromDer(e.value);for(var n=0;n2){throw new Error("Cannot read notBefore/notAfter validity times; more "+"than two times were provided in the certificate.")}if(validity.length<2){throw new Error("Cannot read notBefore/notAfter validity times; they "+"were not provided as either UTCTime or GeneralizedTime.")}cert.validity.notBefore=validity[0];cert.validity.notAfter=validity[1];cert.tbsCertificate=capture.tbsCertificate;if(computeHash){cert.md=null;if(cert.signatureOid in oids){var oid=oids[cert.signatureOid];switch(oid){case"sha1WithRSAEncryption":cert.md=forge.md.sha1.create();break;case"md5WithRSAEncryption":cert.md=forge.md.md5.create();break;case"sha256WithRSAEncryption":cert.md=forge.md.sha256.create();break;case"RSASSA-PSS":cert.md=forge.md.sha256.create();break}}if(cert.md===null){var error=new Error("Could not compute certificate digest. "+"Unknown signature OID.");error.signatureOid=cert.signatureOid;throw error}cert.md.update(asn1.toDer(cert.tbsCertificate))}var imd=forge.md.sha1.create();cert.issuer.getField=function(sn){return _getAttribute(cert.issuer,sn)};cert.issuer.addField=function(attr){_fillMissingFields([attr]);cert.issuer.attributes.push(attr)};cert.issuer.attributes=pki.RDNAttributesAsArray(capture.certIssuer,imd);if(capture.certIssuerUniqueId){cert.issuer.uniqueId=capture.certIssuerUniqueId}cert.issuer.hash=imd.digest().toHex(); var smd=forge.md.sha1.create();cert.subject.getField=function(sn){return _getAttribute(cert.subject,sn)};cert.subject.addField=function(attr){_fillMissingFields([attr]);cert.subject.attributes.push(attr)};cert.subject.attributes=pki.RDNAttributesAsArray(capture.certSubject,smd);if(capture.certSubjectUniqueId){cert.subject.uniqueId=capture.certSubjectUniqueId}cert.subject.hash=smd.digest().toHex();if(capture.certExtensions){cert.extensions=_parseExtensions(capture.certExtensions)}else{cert.extensions=[]}cert.publicKey=pki.publicKeyFromAsn1(capture.subjectPublicKeyInfo);return cert};function _dnToAsn1(obj){var rval=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[]);var attr,set;var attrs=obj.attributes;for(var i=0;i0){tbs.value.push(_extensionsToAsn1(cert.extensions))}return tbs};pki.distinguishedNameToAsn1=function(dn){return _dnToAsn1(dn)};pki.certificateToAsn1=function(cert){var tbsCertificate=cert.tbsCertificate||pki.getTBSCertificate(cert);return asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[tbsCertificate,asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,false,cert.signatureOid),_signatureParametersToAsn1(cert.signatureOid,cert.signatureParameters)]),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.BITSTRING,false,new ByteBuffer().putByte(0).putBytes(cert.signature.bytes()))])};pki.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"}}return initModule(forge)})();(function(){function initModule(forge){var _crypto=null;var prng=forge.prng=forge.prng||{};prng.create=function(plugin){var ctx={plugin:plugin,key:null,seed:null,time:null,reseeds:0,generated:0};var md=plugin.md;var pools=new Array(32);for(var i=0;i<32;++i){pools[i]=md.create()}ctx.pools=pools;ctx.pool=0;ctx.generate=function(count,callback){return ctx.generateSync(count)};ctx.generateSync=function(count){var cipher=ctx.plugin.cipher;var increment=ctx.plugin.increment;var formatKey=ctx.plugin.formatKey;var formatSeed=ctx.plugin.formatSeed;ctx.key=null;var b=forge.util.createBuffer();while(b.length()1048575){ctx.key=null}if(ctx.key===null){_reseedSync()}var bytes=cipher(ctx.key,ctx.seed);ctx.generated+=bytes.length;b.putBytes(bytes);ctx.key=formatKey(cipher(ctx.key,increment(ctx.seed)));ctx.seed=formatSeed(cipher(ctx.key,ctx.seed))}return b.getBytes(count)};function _reseed(callback){if(ctx.pools[0].messageLength>=32){_seed();return callback()}var needed=(32-ctx.pools[0].messageLength)<<5;ctx.seedFile(needed,function(err,bytes){if(err){return callback(err)}ctx.collect(bytes);_seed();callback()})}function _reseedSync(){if(ctx.pools[0].messageLength>=32){return _seed()}var needed=(32-ctx.pools[0].messageLength)<<5;ctx.collect(ctx.seedFileSync(needed));_seed()}function _seed(){var md=ctx.plugin.md.create();md.update(ctx.pools[0].digest());ctx.pools[0].start();var k=1;for(var i=1;i<32;++i){k=(k===31)?2147483648:(k<<2);if(k%ctx.reseeds===0){md.update(ctx.pools[i].digest());ctx.pools[i].start()}}var keyBytes=md.digest();md.start();md.update(keyBytes);var seedBytes=md.digest().getBytes();ctx.key=ctx.plugin.formatKey(keyBytes);ctx.seed=ctx.plugin.formatSeed(seedBytes);ctx.reseeds=(ctx.reseeds===4294967295)?0:ctx.reseeds+1;ctx.generated=0}function defaultSeedFile(needed){var getRandomValues=null;if(typeof window!=="undefined"){var _crypto=window.crypto||window.msCrypto;if(_crypto&&_crypto.getRandomValues){getRandomValues=function(arr){return _crypto.getRandomValues(arr)}}}var b=forge.util.createBuffer();if(getRandomValues){while(b.length()>16);lo+=(hi&32767)<<16;lo+=hi>>15;lo=(lo&2147483647)+(lo>>31);seed=lo&4294967295;for(var i=0;i<3;++i){next=seed>>>(i<<3);next^=Math.floor(Math.random()*256);b.putByte(String.fromCharCode(next&255))}}}return b.getBytes(needed)}ctx.seedFile=function(needed,callback){try{callback(null,defaultSeedFile(needed))}catch(e){callback(e)}};ctx.seedFileSync=defaultSeedFile;ctx.collect=function(bytes){var count=bytes.length;for(var i=0;i>x)&255)}ctx.collect(bytes)};return ctx}}return initModule(forge)})();(function(){function initModule(forge){if(forge.random&&forge.random.getBytes){return}(function(jQuery){var prng_aes={};var _prng_aes_output=new Array(4);var _prng_aes_buffer=forge.util.createBuffer();prng_aes.formatKey=function(key){var tmp=forge.util.createBuffer(key);key=new Array(4);key[0]=tmp.getInt32();key[1]=tmp.getInt32(); key[2]=tmp.getInt32();key[3]=tmp.getInt32();return forge.aes._expandKey(key,false)};prng_aes.formatSeed=function(seed){var tmp=forge.util.createBuffer(seed);seed=new Array(4);seed[0]=tmp.getInt32();seed[1]=tmp.getInt32();seed[2]=tmp.getInt32();seed[3]=tmp.getInt32();return seed};prng_aes.cipher=function(key,seed){forge.aes._updateBlock(key,seed,_prng_aes_output,false);_prng_aes_buffer.putInt32(_prng_aes_output[0]);_prng_aes_buffer.putInt32(_prng_aes_output[1]);_prng_aes_buffer.putInt32(_prng_aes_output[2]);_prng_aes_buffer.putInt32(_prng_aes_output[3]);return _prng_aes_buffer.getBytes()};prng_aes.increment=function(seed){++seed[3];return seed};prng_aes.md=forge.md.sha1;function spawnPrng(){var ctx=forge.prng.create(prng_aes);ctx.getBytes=function(count,callback){return ctx.generate(count,callback)};ctx.getBytesSync=function(count){return ctx.generate(count)};return ctx}var _ctx=spawnPrng();var _nodejs=(typeof process!=="undefined"&&process.versions&&process.versions.node);var getRandomValues=null;if(typeof window!=="undefined"){var _crypto=window.crypto||window.msCrypto;if(_crypto&&_crypto.getRandomValues){getRandomValues=function(arr){return _crypto.getRandomValues(arr)}}}if(!forge.random){forge.random=_ctx}else{for(var key in _ctx){forge.random[key]=_ctx[key]}}forge.random.createInstance=spawnPrng})(typeof(jQuery)!=="undefined"?jQuery:null)}return initModule(forge)})();(function(){function initModule(forge){var pkcs1=forge.pkcs1=forge.pkcs1||{};var asn1=forge.asn1;var oids=forge.pki.oids;var BigInteger=forge.jsbn.BigInteger;var ByteBuffer=forge.util.ByteBuffer;pkcs1.i2osp=function(x,len){var xhex=x.toString(16);var zeros=len-Math.ceil(xhex.length/2);return new ByteBuffer().fillWithByte(0,zeros).putBytes(forge.util.hexToBytes(xhex))};pkcs1.os2ip=function(b){return new BigInteger(b.toString("hex"),16)};pkcs1.encode_rsaes=function(key,message){return pkcs1.encode_eme_v1_5(key,message,2)};pkcs1.decode_rsaes=function(key,em){return pkcs1.decode_eme_v1_5(key,em)};pkcs1.encode_rsassa=function(key,message){var em=pkcs1.encode_emsa_v1_5(message);return pkcs1.encode_eme_v1_5(key,em,1)};pkcs1.decode_rsassa=function(key,em){var m=pkcs1.decode_eme_v1_5(key,em);return pkcs1.decode_emsa_v1_5(m)};pkcs1.encode_emsa_v1_5=function(md){var oid;if(md.algorithm in oids){oid=oids[md.algorithm]}else{throw new Error("Unknown message digest algorithm: "+md.algorithm)}var digestInfo=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[]);var digestAlgorithm=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[]);digestAlgorithm.value.push(asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,false,oid));digestAlgorithm.value.push(asn1.create(asn1.Class.UNIVERSAL,asn1.Type.NULL,false,null));var digest=asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,false,md.digest());digestInfo.value.push(digestAlgorithm);digestInfo.value.push(digest);return asn1.toDer(digestInfo)};pkcs1.decode_emsa_v1_5=function(em){if(!(em instanceof ByteBuffer)){throw new TypeError("em must be a ByteBuffer")}var obj=asn1.fromDer(em);return obj.value[1].value};pkcs1.encode_eme_v1_5=function(key,m,blockType){if(!(m instanceof ByteBuffer)){throw new TypeError("m must be a ByteBuffer")}m=m.bytes();if(blockType!==0&&blockType!==1&&blockType!==2){throw new Error("blockType must be 0, 1, or 2.")}var eb=new ByteBuffer();var k=Math.ceil(key.n.bitLength()/8);if(m.length>(k-11)){var error=new Error("Message is too long for EME-PKCS1-v1_5 padding.");error.length=m.length;error.max=k-11;throw error}eb.putByte(0);eb.putByte(blockType);var padNum=k-3-m.length;var padByte;if(blockType===0||blockType===1){padByte=(blockType===0?0:255);for(var i=0;i0){var numZeros=0;var padBytes=forge.random.getBytes(padNum);for(var i=0;i=0&&bt<=2)||(bt===0&&typeof(ml)==="undefined")){throw new Error("Encryption block is invalid.")}var padNum=0;if(bt===0){padNum=k-3-ml;for(var i=0;i1){if(eb.getByte()!==255){--eb.read;break}++padNum}}else{if(bt===2){padNum=0;while(eb.length()>1){if(eb.getByte()===0){--eb.read;break}++padNum}}}}var zero=eb.getByte();if(zero!==0||padNum!==(k-3-eb.length())){throw new Error("Encryption block is invalid.")}return new ByteBuffer().putBuffer(eb)};pkcs1.encode_rsa_oaep=function(key,message,options){if(!(message instanceof ByteBuffer)){throw new TypeError("message must be a ByteBuffer")}message=message.bytes();var label;var seed;var md;var mgf1Md;if(typeof options==="string"){label=options;seed=arguments[3]||undefined;md=arguments[4]||undefined}else{if(options){label=options.label||undefined; seed=options.seed||undefined;md=options.md||undefined;if(options.mgf1&&options.mgf1.md){mgf1Md=options.mgf1.md}}}if(!md){md=forge.md.sha1.create()}else{md.start()}if(!mgf1Md){mgf1Md=md}var keyLength=Math.ceil(key.n.bitLength()/8);var maxLength=keyLength-2*md.digestLength-2;if(message.length>maxLength){var error=new Error("RSAES-OAEP input message length is too long; message length="+message.length+", max length="+maxLength);error.length=message.length;error.maxLength=maxLength;throw error}if(!label){label=""}md.update(label,"binary");var lHash=md.digest();var PS="";var PS_length=maxLength-message.length;for(var i=0;i>24)&255,(i>>16)&255,(i>>8)&255,i&255);hash.start();hash.update(seed+c,"binary");t+=hash.digest().getBytes()}return t.substring(0,maskLength)}}return initModule(forge)})();(function(){function initModule(forge){var asn1=forge.asn1;var p7=forge.pkcs7=forge.pkcs7||{};var ByteBuffer=forge.util.ByteBuffer;p7.messageToPem=function(msg){var pemObj={type:"PKCS7",body:asn1.toDer(msg.toAsn1())};return forge.pem.encode(pemObj)};var _recipientInfoFromAsn1=function(obj){var capture={};var errors=[];if(!asn1.validate(obj,p7.asn1.recipientInfoValidator,capture,errors)){var error=new Error("Cannot read PKCS#7 message. "+"ASN.1 object is not an PKCS#7 EnvelopedData.");error.errors=errors;throw error}var param=capture.encParameter.value;if(param instanceof ByteBuffer){param=param.copy()}return{version:capture.version,issuer:forge.pki.RDNAttributesAsArray(capture.issuer),serialNumber:capture.serial,encryptedContent:{algorithm:capture.encAlgorithm,parameter:param,content:capture.encKey}}};var _recipientInfoToAsn1=function(obj){return asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.INTEGER,false,obj.version),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[forge.pki.distinguishedNameToAsn1({attributes:obj.issuer}),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.INTEGER,false,new ByteBuffer(obj.serialNumber,"hex"))]),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.SEQUENCE,true,[asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OID,false,obj.encryptedContent.algorithm),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.NULL,false,null)]),asn1.create(asn1.Class.UNIVERSAL,asn1.Type.OCTETSTRING,false,new ByteBuffer(obj.encryptedContent.content,"binary"))])};var _recipientInfosFromAsn1=function(objArr){var ret=[]; for(var i=0;i>>5]|=a[c]<<24-d%32}return b};xtx.wordsToBytes=function(a){var b=[],c=0;for(;c>>5]>>>24-c%32&255)}return b};xtx.digestData=function(strInData,encoding){var strRealData;if(encoding=="hex"&&strInData.length%2!=0){return""}if(encoding=="raw"){strRealData=xtx.encodeGBK(strInData)}var md=forge.md.sha1.create();md.update(strRealData,encoding);return md.digest().toString("base64")};xtx.sha1=function(m,hash){var w=[];var H0=hash[0],H1=hash[1],H2=hash[2],H3=hash[3],H4=hash[4];for(var i=0;i>>31)}var t=((H0<<5)|(H0>>>27))+H4+(w[j]>>>0)+(j<20?(H1&H2|~H1&H3)+1518500249:j<40?(H1^H2^H3)+1859775393:j<60?(H1&H2|H1&H3|H2&H3)-1894007588:(H1^H2^H3)-899497514);H4=H3;H3=H2;H2=(H1<<30)|(H1>>>2);H1=H0;H0=t}H0=(H0+a)|0;H1=(H1+b)|0;H2=(H2+c)|0;H3=(H3+d)|0;H4=(H4+e)|0}return[H0,H1,H2,H3,H4]};xtx.hash=[1732584193,-271733879,-1732584194,271733878,-1009589776];xtx.sha1ArrayBuffer=function(a){var uint8_array,message,block,nBitsTotal,output,nBitsLeft,nBitsTotalH,nBitsTotalL,res;uint8_array=new Uint8Array(a);message=xtx.bytesToWords(uint8_array);nBitsTotal=a.byteLength*8;nBitsLeft=a.byteLength*8;nBitsTotalH=Math.floor(nBitsTotal/4294967296);nBitsTotalL=nBitsTotal&4294967295;message[nBitsLeft>>>5]|=128<<(24-nBitsLeft%32);message[((nBitsLeft+64>>>9)<<4)+14]=nBitsTotalH;message[((nBitsLeft+64>>>9)<<4)+15]=nBitsTotalL;res=xtx.hash;res=xtx.sha1(message,res);return xtx.bytesToBase64(xtx.wordsToBytes(res))};xtx.bytesToHex=function(a){for(var b=[],c=0;c>>4).toString(16)),b.push((a[c]&15).toString(16))}return b.join("")};xtx.bytesToBase64=function(a){for(var b=[],c=0;c>>6*(3-e)&63)):b.push("=")}}return b.join("")};xtx.onReady=null;xtx.digestFile=function(file){var reader=new FileReader();reader.onload=function(rResult){var digestData=xtx.sha1ArrayBuffer(rResult.target.result);if(typeof xtx.onReady=="function"){xtx.onReady(digestData)}};reader.readAsArrayBuffer(file);return};xtx.encryptMessage=function(strCert,strInData,encoding){var strRealData;if(encoding=="hex"&&strInData.length%2!=0){return""}if(encoding=="raw"){strRealData=xtx.encodeGBK(strInData)}var p7=forge.pkcs7.createEnvelopedData();var cert=forge.pki.certificateFromPem(strCert);p7.addRecipient(cert);p7.content=forge.util.createBuffer(strRealData,encoding);p7.encrypt();return forge.pkcs7.messageToPem(p7)};xtx.tmpData=null;xtx.tmpCert=null;xtx.digestAndEncryptData=function(strCert,strUserInfo,file){xtx.tmpData=strUserInfo;var reader=new FileReader();reader.onload=function(rResult){var digestData=xtx.sha1ArrayBuffer(rResult.target.result);var strEncryptData=xtx.tmpData+"|"+digestData;var strEnvlope=xtx.encryptMessage(xtx.tmpCert,strEncryptData,"raw");xtx.tmpData=null;xtx.tmpCert=null;if(typeof xtx.onReady=="function"){xtx.onReady(strEnvlope)}alert(digestData)};xtx.tmpData=strUserInfo;xtx.tmpCert=strCert;reader.readAsArrayBuffer(file);return};xtx.parseCertSubjectDN=function(strCert){var certObj=forge.pki.certificateFromPem(strCert);var len=certObj.subject.attributes.length;var userDN;var i;for(i=0;i