From a907dfa7c9b6df0e7660e51b0670f9acc50f2e74 Mon Sep 17 00:00:00 2001 From: Michal Kolodziej Date: Sat, 27 Apr 2013 16:46:19 +0200 Subject: [PATCH] Fixed time. --- resources/openpgp.js | 27 +- resources/openpgp.min.js | 598 +++++++++++++++++++-------------------- src/packet/literal.js | 20 +- src/packet/time.js | 7 +- 4 files changed, 319 insertions(+), 333 deletions(-) diff --git a/resources/openpgp.js b/resources/openpgp.js index bbbf376c..c012b67e 100644 --- a/resources/openpgp.js +++ b/resources/openpgp.js @@ -9594,14 +9594,13 @@ function openpgp_packet_literal() { var format = bytes[0]; - this.filename = util.decode_utf8(bytes.substr(2, bytes - .charCodeAt(1))); + var filename_len = bytes.charCodeAt(1); + this.filename = util.decode_utf8(bytes.substr(2, filename_len)); - this.date = new Date(parseInt(bytes.substr(2 - + bytes.charCodeAt(1), 4)) * 1000); + this.date = openpgp_packet_time_read(bytes.substr(2 + + filename_len, 4)); - var data = bytes.substring(6 - + bytes.charCodeAt(1)); + var data = bytes.substring(6 + filename_len); this.set_data_bytes(data, format); } @@ -9621,14 +9620,7 @@ function openpgp_packet_literal() { result += this.format; result += String.fromCharCode(filename.length); result += filename; - result += String - .fromCharCode((Math.round(this.date.getTime() / 1000) >> 24) & 0xFF); - result += String - .fromCharCode((Math.round(this.date.getTime() / 1000) >> 16) & 0xFF); - result += String - .fromCharCode((Math.round(this.date.getTime() / 1000) >> 8) & 0xFF); - result += String - .fromCharCode(Math.round(this.date.getTime() / 1000) & 0xFF); + result += openpgp_packet_time_write(this.date); result += data; return result; } @@ -12514,7 +12506,8 @@ function openpgp_packet_number_read(bytes) { var n = 0; for(var i = 0; i < bytes.length; i++) { - n += bytes[i].charCodeAt() * 8 * (bytes.length - i - 1); + n <<= 8; + n += bytes[i].charCodeAt() } return n; @@ -12523,7 +12516,7 @@ function openpgp_packet_number_read(bytes) { function openpgp_packet_number_write(n, bytes) { var b = ''; for(var i = 0; i < bytes; i++) { - b += String.fromCharCode((n >> 8 * (bytes.length - i - 1)) ^ 0xFF); + b += String.fromCharCode((n >> (8 * (bytes- i - 1))) & 0xFF); } return b; @@ -12539,7 +12532,7 @@ function openpgp_packet_time_read(bytes) { } function openpgp_packet_time_write(time) { - var numeric = Math.round(this.time.getTime() / 1000); + var numeric = Math.round(time.getTime() / 1000); return openpgp_packet_number_write(numeric, 4); } diff --git a/resources/openpgp.min.js b/resources/openpgp.min.js index 829b389b..713d1169 100644 --- a/resources/openpgp.min.js +++ b/resources/openpgp.min.js @@ -1,131 +1,131 @@ -function DSA(){this.select_hash_algorithm=function(a){var b=openpgp.config.config.prefer_hash_algorithm;switch(Math.round(a.bitLength()/8)){case 20:return 2!=b&&11b?2:b;case 28:return 11b?11:b;case 32:return 10b?8:b;default:return util.print_debug("DSA select hash algorithm: returning null for an unknown length of q"),null}};this.sign=function(a,b,c,d,e,f){a=util.getLeftNBits(openpgp_crypto_hashData(a,b),e.bitLength());a=new BigInteger(util.hexstrdump(a),16);b=openpgp_crypto_getRandomBigIntegerInRange(BigInteger.ONE.add(BigInteger.ONE), -e.subtract(BigInteger.ONE));c=c.modPow(b,d).mod(e);e=b.modInverse(e).multiply(a.add(f.multiply(c))).mod(e);f=[];f[0]=c.toMPI();f[1]=e.toMPI();return f};this.verify=function(a,b,c,d,e,f,g,h){a=util.getLeftNBits(openpgp_crypto_hashData(a,d),f.bitLength());a=new BigInteger(util.hexstrdump(a),16);if(0this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))} -function bnSigNum(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1}function bnpToRadix(a){null==a&&(a=10);if(0==this.signum()||2>a||36j?"-"==a.charAt(h)&&0==this.signum()&&(e=!0):(g=b*g+j,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0))}0a)this.fromInt(1);else{this.fromNumber(a,c);this.testBit(a-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);for(this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(BigInteger.ONE.shiftLeft(a-1),this)}else{var c=[],d=a&7;c.length=(a>>3)+1;b.nextBytes(c);c[0]=0>c)!=(this.s&this.DM)>>c)b[e++]=d|this.s<c?(d=(this[a]&(1<>(c+=this.DB-8)):(d=this[a]>>(c-=8)&255,0>=c&&(c+=this.DB,--a)),0this.compareTo(a)?this:a}function bnMax(a){return 0a?this.rShiftTo(-a,b):this.lShiftTo(a,b);return b}function bnShiftRight(a){var b=nbi();0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b);return b} -function lbit(a){if(0==a)return-1;var b=0;0==(a&65535)&&(a>>=16,b+=16);0==(a&255)&&(a>>=8,b+=8);0==(a&15)&&(a>>=4,b+=4);0==(a&3)&&(a>>=2,b+=2);0==(a&1)&&++b;return b}function bnGetLowestSetBit(){for(var a=0;athis.s?this.t*this.DB:-1}function cbit(a){for(var b=0;0!=a;)a&=a-1,++b;return b}function bnBitCount(){for(var a=0,b=this.s&this.DM,c=0;c=this.t?0!=this.s:0!=(this[b]&1<>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d+=a.s}b.s=0>d?-1:0;0d&&(b[c++]=this.DV+d);b.t=c;b.clamp()}function bnAdd(a){var b=nbi();this.addTo(a,b);return b}function bnSubtract(a){var b=nbi();this.subTo(a,b);return b} -function bnMultiply(a){var b=nbi();this.multiplyTo(a,b);return b}function bnSquare(){var a=nbi();this.squareTo(a);return a}function bnDivide(a){var b=nbi();this.divRemTo(a,b,null);return b}function bnRemainder(a){var b=nbi();this.divRemTo(a,null,b);return b}function bnDivideAndRemainder(a){var b=nbi(),c=nbi();this.divRemTo(a,b,c);return[b,c]}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()} -function bnpDAddOffset(a,b){if(0!=a){for(;this.t<=b;)this[this.t++]=0;for(this[b]+=a;this[b]>=this.DV;)this[b]-=this.DV,++b>=this.t&&(this[this.t++]=0),++this[b]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,b,c){a.multiplyTo(b,c)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp)} -function bnpMultiplyLowerTo(a,b,c){var d=Math.min(this.t+a.t,b);c.s=0;for(c.t=d;0a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var b=nbi();a.copyTo(b);this.reduce(b);return b}function barrettRevert(a){return a} -function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1)a.t=this.m.t+1,a.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}Barrett.prototype.convert=barrettConvert; +function DSA(){this.select_hash_algorithm=function(b){var a=openpgp.config.config.prefer_hash_algorithm;switch(Math.round(b.bitLength()/8)){case 20:return 2!=a&&11a?2:a;case 28:return 11a?11:a;case 32:return 10a?8:a;default:return util.print_debug("DSA select hash algorithm: returning null for an unknown length of q"),null}};this.sign=function(b,a,c,d,e,f){b=util.getLeftNBits(openpgp_crypto_hashData(b,a),e.bitLength());b=new BigInteger(util.hexstrdump(b),16);a=openpgp_crypto_getRandomBigIntegerInRange(BigInteger.ONE.add(BigInteger.ONE), +e.subtract(BigInteger.ONE));c=c.modPow(a,d).mod(e);e=a.modInverse(e).multiply(b.add(f.multiply(c))).mod(e);f=[];f[0]=c.toMPI();f[1]=e.toMPI();return f};this.verify=function(b,a,c,d,e,f,g,h){b=util.getLeftNBits(openpgp_crypto_hashData(b,d),f.bitLength());b=new BigInteger(util.hexstrdump(b),16);if(0this.s){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function bnShortValue(){return 0==this.t?this.s:this[0]<<16>>16}function bnpChunkSize(b){return Math.floor(Math.LN2*this.DB/Math.log(b))} +function bnSigNum(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this[0]?0:1}function bnpToRadix(b){null==b&&(b=10);if(0==this.signum()||2>b||36j?"-"==b.charAt(h)&&0==this.signum()&&(e=!0):(g=a*g+j,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0))}0b)this.fromInt(1);else{this.fromNumber(b,c);this.testBit(b-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(b-1),op_or,this);for(this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(a);)this.dAddOffset(2,0),this.bitLength()>b&&this.subTo(BigInteger.ONE.shiftLeft(b-1),this)}else{var c=[],d=b&7;c.length=(b>>3)+1;a.nextBytes(c);c[0]=0>c)!=(this.s&this.DM)>>c)a[e++]=d|this.s<c?(d=(this[b]&(1<>(c+=this.DB-8)):(d=this[b]>>(c-=8)&255,0>=c&&(c+=this.DB,--b)),0this.compareTo(b)?this:b}function bnMax(b){return 0b?this.rShiftTo(-b,a):this.lShiftTo(b,a);return a}function bnShiftRight(b){var a=nbi();0>b?this.lShiftTo(-b,a):this.rShiftTo(b,a);return a} +function lbit(b){if(0==b)return-1;var a=0;0==(b&65535)&&(b>>=16,a+=16);0==(b&255)&&(b>>=8,a+=8);0==(b&15)&&(b>>=4,a+=4);0==(b&3)&&(b>>=2,a+=2);0==(b&1)&&++a;return a}function bnGetLowestSetBit(){for(var b=0;bthis.s?this.t*this.DB:-1}function cbit(b){for(var a=0;0!=b;)b&=b-1,++a;return a}function bnBitCount(){for(var b=0,a=this.s&this.DM,c=0;c=this.t?0!=this.s:0!=(this[a]&1<>=this.DB;if(b.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d+=b.s}a.s=0>d?-1:0;0d&&(a[c++]=this.DV+d);a.t=c;a.clamp()}function bnAdd(b){var a=nbi();this.addTo(b,a);return a}function bnSubtract(b){var a=nbi();this.subTo(b,a);return a} +function bnMultiply(b){var a=nbi();this.multiplyTo(b,a);return a}function bnSquare(){var b=nbi();this.squareTo(b);return b}function bnDivide(b){var a=nbi();this.divRemTo(b,a,null);return a}function bnRemainder(b){var a=nbi();this.divRemTo(b,null,a);return a}function bnDivideAndRemainder(b){var a=nbi(),c=nbi();this.divRemTo(b,a,c);return[a,c]}function bnpDMultiply(b){this[this.t]=this.am(0,b-1,this,0,0,this.t);++this.t;this.clamp()} +function bnpDAddOffset(b,a){if(0!=b){for(;this.t<=a;)this[this.t++]=0;for(this[a]+=b;this[a]>=this.DV;)this[a]-=this.DV,++a>=this.t&&(this[this.t++]=0),++this[a]}}function NullExp(){}function nNop(b){return b}function nMulTo(b,a,c){b.multiplyTo(a,c)}function nSqrTo(b,a){b.squareTo(a)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(b){return this.exp(b,new NullExp)} +function bnpMultiplyLowerTo(b,a,c){var d=Math.min(this.t+b.t,a);c.s=0;for(c.t=d;0b.s||b.t>2*this.m.t)return b.mod(this.m);if(0>b.compareTo(this.m))return b;var a=nbi();b.copyTo(a);this.reduce(a);return a}function barrettRevert(b){return b} +function barrettReduce(b){b.drShiftTo(this.m.t-1,this.r2);if(b.t>this.m.t+1)b.t=this.m.t+1,b.clamp();this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>b.compareTo(this.r2);)b.dAddOffset(1,this.m.t+1);for(b.subTo(this.r2,b);0<=b.compareTo(this.m);)b.subTo(this.m,b)}function barrettSqrTo(b,a){b.squareTo(a);this.reduce(a)}function barrettMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}Barrett.prototype.convert=barrettConvert; Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo; -function bnModPow(a,b){var c=a.bitLength(),d,e=nbv(1),f;if(0>=c)return e;d=18>c?1:48>c?3:144>c?4:768>c?5:6;f=8>c?new Classic(b):b.isEven()?new Barrett(b):new Montgomery(b);var g=[],h=3,j=d-1,k=(1<=j?m=a[l]>>c-j&k:(m=(a[l]&(1<>this.DB+c-j));for(h=d;0==(m&1);)m>>=1,--h;if(0>(c-=h))c+=this.DB,--l;if(r)g[m].copyTo(e), -r=!1;else{for(;1--c&&(c=this.DB-1,--l)}return f.revert(e)} -function bnGCD(a){var b=0>this.s?this.negate():this.clone(),a=0>a.s?a.negate():a.clone();if(0>b.compareTo(a))var c=b,b=a,a=c;var c=b.getLowestSetBit(),d=a.getLowestSetBit();if(0>d)return b;c=a)return 0;var b=this.DV%a,c=0>this.s?a-1:0;if(0h.signum())h.addTo(a,h);else return h;return 0>h.signum()?h.add(a):h} +function bnModPow(b,a){var c=b.bitLength(),d,e=nbv(1),f;if(0>=c)return e;d=18>c?1:48>c?3:144>c?4:768>c?5:6;f=8>c?new Classic(a):a.isEven()?new Barrett(a):new Montgomery(a);var g=[],h=3,j=d-1,k=(1<=j?m=b[l]>>c-j&k:(m=(b[l]&(1<>this.DB+c-j));for(h=d;0==(m&1);)m>>=1,--h;if(0>(c-=h))c+=this.DB,--l;if(r)g[m].copyTo(e), +r=!1;else{for(;1--c&&(c=this.DB-1,--l)}return f.revert(e)} +function bnGCD(b){var a=0>this.s?this.negate():this.clone(),b=0>b.s?b.negate():b.clone();if(0>a.compareTo(b))var c=a,a=b,b=c;var c=a.getLowestSetBit(),d=b.getLowestSetBit();if(0>d)return a;c=b)return 0;var a=this.DV%b,c=0>this.s?b-1:0;if(0h.signum())h.addTo(b,h);else return h;return 0>h.signum()?h.add(b):h} 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,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727, 733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],lplim=67108864/lowprimes[lowprimes.length-1]; -function bnIsProbablePrime(a){var b,c=this.abs();if(1==c.t&&c[0]<=lowprimes[lowprimes.length-1]){for(b=0;b>>16))a=c,b+=16;if(0!=(c=a>>8))a=c,b+=8;if(0!=(c=a>>4))a=c,b+=4;if(0!=(c=a>>2))a=c,b+=2;0!=a>>1&&(b+=1);return b}function bnToMPI(){var a=this.toByteArray(),b=8*(a.length-1)+nbits(a[0]),c;c=""+String.fromCharCode((b&65280)>>8);c+=String.fromCharCode(b&255);return c+=util.bin2str(a)} -function bnpMillerRabin(a){var b=this.subtract(BigInteger.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c),a=a+1>>1;if(a>lowprimes.length)a=lowprimes.length;for(var e=nbi(),f=0;f>>16))b=c,a+=16;if(0!=(c=b>>8))b=c,a+=8;if(0!=(c=b>>4))b=c,a+=4;if(0!=(c=b>>2))b=c,a+=2;0!=b>>1&&(a+=1);return a}function bnToMPI(){var b=this.toByteArray(),a=8*(b.length-1)+nbits(b[0]),c;c=""+String.fromCharCode((a&65280)>>8);c+=String.fromCharCode(a&255);return c+=util.bin2str(b)} +function bnpMillerRabin(b){var a=this.subtract(BigInteger.ONE),c=a.getLowestSetBit();if(0>=c)return!1;var d=a.shiftRight(c),b=b+1>>1;if(b>lowprimes.length)b=lowprimes.length;for(var e=nbi(),f=0;f>15;0<=--f;){var h=this[a]&32767,j=this[a++]>>15,k=b*h+j*g,h=g*h+((k&32767)<<15)+c[d]+(e&1073741823),e=(h>>>30)+(k>>>15)+b*j+(e>>>30);c[d++]=h&1073741823}return e}function am3(a,b,c,d,e,f){for(var g=b&16383,b=b>>14;0<=--f;){var h=this[a]&16383,j=this[a++]>>14,k=b*h+j*g,h=g*h+((k&16383)<<14)+c[d]+e,e=(h>>28)+(k>>14)+b*j;c[d++]=h&268435455}return e} +var dbits,canary=244837814094590,j_lm=15715070==(canary&16777215);function BigInteger(b,a,c){null!=b&&("number"==typeof b?this.fromNumber(b,a,c):null==a&&"string"!=typeof b?this.fromString(b,256):this.fromString(b,a))}function nbi(){return new BigInteger(null)}function am1(b,a,c,d,e,f){for(;0<=--f;){var g=a*this[b++]+c[d]+e,e=Math.floor(g/67108864);c[d++]=g&67108863}return e} +function am2(b,a,c,d,e,f){for(var g=a&32767,a=a>>15;0<=--f;){var h=this[b]&32767,j=this[b++]>>15,k=a*h+j*g,h=g*h+((k&32767)<<15)+c[d]+(e&1073741823),e=(h>>>30)+(k>>>15)+a*j+(e>>>30);c[d++]=h&1073741823}return e}function am3(b,a,c,d,e,f){for(var g=a&16383,a=a>>14;0<=--f;){var h=this[b]&16383,j=this[b++]>>14,k=a*h+j*g,h=g*h+((k&16383)<<14)+c[d]+e,e=(h>>28)+(k>>14)+a*j;c[d++]=h&268435455}return e} j_lm&&"Microsoft Internet Explorer"==navigator.appName?(BigInteger.prototype.am=am2,dbits=30):j_lm&&"Netscape"!=navigator.appName?(BigInteger.prototype.am=am1,dbits=26):(BigInteger.prototype.am=am3,dbits=28);BigInteger.prototype.DB=dbits;BigInteger.prototype.DM=(1<=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;function int2char(a){return BI_RM.charAt(a)}function intAt(a,b){var c=BI_RC[a.charCodeAt(b)];return null==c?-1:c}function bnpCopyTo(a){for(var b=this.t-1;0<=b;--b)a[b]=this[b];a.t=this.t;a.s=this.s}function bnpFromInt(a){this.t=1;this.s=0>a?-1:0;0a?this[0]=a+DV:this.t=0}function nbv(a){var b=nbi();b.fromInt(a);return b} -function bnpFromString(a,b){var c;if(16==b)c=4;else if(8==b)c=3;else if(256==b)c=8;else if(2==b)c=1;else if(32==b)c=5;else if(4==b)c=2;else{this.fromRadix(a,b);return}this.s=this.t=0;for(var d=a.length,e=!1,f=0;0<=--d;){var g=8==c?a[d]&255:intAt(a,d);0>g?"-"==a.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB))}if(8==c&&0!=(a[0]&128))this.s=-1,0this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<>g))d=!0,e=int2char(c);for(;0<=f;)g>(g+=this.DB-a)):(c=this[f]>>(g-=a)&b,0>=g&&(g+=this.DB,--f)),0this.s?this.negate():this}function bnCompareTo(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t,b=c-a.t;if(0!=b)return b;for(;0<=--c;)if(0!=(b=this[c]-a[c]))return b;return 0}function nbits(a){var b=1,c;if(0!=(c=a>>>16))a=c,b+=16;if(0!=(c=a>>8))a=c,b+=8;if(0!=(c=a>>4))a=c,b+=4;if(0!=(c=a>>2))a=c,b+=2;0!=a>>1&&(b+=1);return b} -function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(a,b){var c;for(c=this.t-1;0<=c;--c)b[c+a]=this[c];for(c=a-1;0<=c;--c)b[c]=0;b.t=this.t+a;b.s=this.s}function bnpDRShiftTo(a,b){for(var c=a;c>d|g,g=(this[h]&e)<=this.t)b.t=0;else{var d=a%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;0>=this.DB;if(a.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=a.s}b.s=0>d?-1:0;-1>d?b[c++]=this.DV+d:0=b.DV)a[c+b.t]-=b.DV,a[c+b.t+1]=1}0=d.t)){var e=this.abs();if(e.t>this.F2:0),k=this.FV/j,j=(1<g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(a){var b=nbi();this.abs().divRemTo(a,null,b);0>this.s&&0a.s||0<=a.compareTo(this.m)?a.mod(this.m):a}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo; -function bnpInvDigit(){if(1>this.t)return 0;var a=this[0];if(0==(a&1))return 0;var b=a&3,b=b*(2-(a&15)*b)&15,b=b*(2-(a&255)*b)&255,b=b*(2-((a&65535)*b&65535))&65535,b=b*(2-a*b%this.DV)%this.DV;return 0>15;this.um=(1<a.s&&0>15)*this.mpl&this.um)<<15)&a.DM,c=b+this.m.t;for(a[c]+=this.m.am(0,d,a,b,0,this.m.t);a[c]>=a.DV;)a[c]-=a.DV,a[++c]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,b,c){a.multiplyTo(b,c);this.reduce(c)}Montgomery.prototype.convert=montConvert; -Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return 0==(0a)return BigInteger.ONE;var c=nbi(),d=nbi(),e=b.convert(this),f=nbits(a)-1;for(e.copyTo(c);0<=--f;)if(b.sqrTo(c,d),0<(a&1<a||b.isEven()?new Classic(b):new Montgomery(b);return this.exp(a,c)}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; +rr=48;for(vv=0;9>=vv;++vv)BI_RC[rr++]=vv;rr=97;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;rr=65;for(vv=10;36>vv;++vv)BI_RC[rr++]=vv;function int2char(b){return BI_RM.charAt(b)}function intAt(b,a){var c=BI_RC[b.charCodeAt(a)];return null==c?-1:c}function bnpCopyTo(b){for(var a=this.t-1;0<=a;--a)b[a]=this[a];b.t=this.t;b.s=this.s}function bnpFromInt(b){this.t=1;this.s=0>b?-1:0;0b?this[0]=b+DV:this.t=0}function nbv(b){var a=nbi();a.fromInt(b);return a} +function bnpFromString(b,a){var c;if(16==a)c=4;else if(8==a)c=3;else if(256==a)c=8;else if(2==a)c=1;else if(32==a)c=5;else if(4==a)c=2;else{this.fromRadix(b,a);return}this.s=this.t=0;for(var d=b.length,e=!1,f=0;0<=--d;){var g=8==c?b[d]&255:intAt(b,d);0>g?"-"==b.charAt(d)&&(e=!0):(e=!1,0==f?this[this.t++]=g:f+c>this.DB?(this[this.t-1]|=(g&(1<>this.DB-f):this[this.t-1]|=g<=this.DB&&(f-=this.DB))}if(8==c&&0!=(b[0]&128))this.s=-1,0this.s)return"-"+this.negate().toString(b);if(16==b)b=4;else if(8==b)b=3;else if(2==b)b=1;else if(32==b)b=5;else if(4==b)b=2;else return this.toRadix(b);var a=(1<>g))d=!0,e=int2char(c);for(;0<=f;)g>(g+=this.DB-b)):(c=this[f]>>(g-=b)&a,0>=g&&(g+=this.DB,--f)),0this.s?this.negate():this}function bnCompareTo(b){var a=this.s-b.s;if(0!=a)return a;var c=this.t,a=c-b.t;if(0!=a)return a;for(;0<=--c;)if(0!=(a=this[c]-b[c]))return a;return 0}function nbits(b){var a=1,c;if(0!=(c=b>>>16))b=c,a+=16;if(0!=(c=b>>8))b=c,a+=8;if(0!=(c=b>>4))b=c,a+=4;if(0!=(c=b>>2))b=c,a+=2;0!=b>>1&&(a+=1);return a} +function bnBitLength(){return 0>=this.t?0:this.DB*(this.t-1)+nbits(this[this.t-1]^this.s&this.DM)}function bnpDLShiftTo(b,a){var c;for(c=this.t-1;0<=c;--c)a[c+b]=this[c];for(c=b-1;0<=c;--c)a[c]=0;a.t=this.t+b;a.s=this.s}function bnpDRShiftTo(b,a){for(var c=b;c>d|g,g=(this[h]&e)<=this.t)a.t=0;else{var d=b%this.DB,e=this.DB-d,f=(1<>d;for(var g=c+1;g>d;0>=this.DB;if(b.t>=this.DB;d+=this.s}else{for(d+=this.s;c>=this.DB;d-=b.s}a.s=0>d?-1:0;-1>d?a[c++]=this.DV+d:0=a.DV)b[c+a.t]-=a.DV,b[c+a.t+1]=1}0=d.t)){var e=this.abs();if(e.t>this.F2:0),k=this.FV/j,j=(1<g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(b){var a=nbi();this.abs().divRemTo(b,null,a);0>this.s&&0b.s||0<=b.compareTo(this.m)?b.mod(this.m):b}function cRevert(b){return b}function cReduce(b){b.divRemTo(this.m,null,b)}function cMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}function cSqrTo(b,a){b.squareTo(a);this.reduce(a)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo; +function bnpInvDigit(){if(1>this.t)return 0;var b=this[0];if(0==(b&1))return 0;var a=b&3,a=a*(2-(b&15)*a)&15,a=a*(2-(b&255)*a)&255,a=a*(2-((b&65535)*a&65535))&65535,a=a*(2-b*a%this.DV)%this.DV;return 0>15;this.um=(1<b.s&&0>15)*this.mpl&this.um)<<15)&b.DM,c=a+this.m.t;for(b[c]+=this.m.am(0,d,b,a,0,this.m.t);b[c]>=b.DV;)b[c]-=b.DV,b[++c]++}b.clamp();b.drShiftTo(this.m.t,b);0<=b.compareTo(this.m)&&b.subTo(this.m,b)}function montSqrTo(b,a){b.squareTo(a);this.reduce(a)}function montMulTo(b,a,c){b.multiplyTo(a,c);this.reduce(c)}Montgomery.prototype.convert=montConvert; +Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return 0==(0b)return BigInteger.ONE;var c=nbi(),d=nbi(),e=a.convert(this),f=nbits(b)-1;for(e.copyTo(c);0<=--f;)if(a.sqrTo(c,d),0<(b&1<b||a.isEven()?new Classic(a):new Montgomery(a);return this.exp(b,c)}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 SecureRandom(){this.nextBytes=function(a){for(var b=0;b>1;d.e=parseInt(c,16);for(d.ee=new BigInteger(c,16);;){for(;!(d.p=new BigInteger(b-f,1,e),0==d.p.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.p.isProbablePrime(10)););for(;!(d.q=new BigInteger(f,1,e),0==d.q.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.q.isProbablePrime(10));); -if(0>=d.p.compareTo(d.q)){var g=d.p;d.p=d.q;d.q=g}var g=d.p.subtract(BigInteger.ONE),h=d.q.subtract(BigInteger.ONE),j=g.multiply(h);if(0==j.gcd(d.ee).compareTo(BigInteger.ONE)){d.n=d.p.multiply(d.q);d.d=d.ee.modInverse(j);d.dmp1=d.d.mod(g);d.dmq1=d.d.mod(h);d.u=d.p.modInverse(d.q);break}}return d};this.keyObject=a}function MD5(a){a=md5(a);return util.hex2bin(a)} -function md5cycle(a,b){var c=a[0],d=a[1],e=a[2],f=a[3],c=ff(c,d,e,f,b[0],7,-680876936),f=ff(f,c,d,e,b[1],12,-389564586),e=ff(e,f,c,d,b[2],17,606105819),d=ff(d,e,f,c,b[3],22,-1044525330),c=ff(c,d,e,f,b[4],7,-176418897),f=ff(f,c,d,e,b[5],12,1200080426),e=ff(e,f,c,d,b[6],17,-1473231341),d=ff(d,e,f,c,b[7],22,-45705983),c=ff(c,d,e,f,b[8],7,1770035416),f=ff(f,c,d,e,b[9],12,-1958414417),e=ff(e,f,c,d,b[10],17,-42063),d=ff(d,e,f,c,b[11],22,-1990404162),c=ff(c,d,e,f,b[12],7,1804603682),f=ff(f,c,d,e,b[13],12, --40341101),e=ff(e,f,c,d,b[14],17,-1502002290),d=ff(d,e,f,c,b[15],22,1236535329),c=gg(c,d,e,f,b[1],5,-165796510),f=gg(f,c,d,e,b[6],9,-1069501632),e=gg(e,f,c,d,b[11],14,643717713),d=gg(d,e,f,c,b[0],20,-373897302),c=gg(c,d,e,f,b[5],5,-701558691),f=gg(f,c,d,e,b[10],9,38016083),e=gg(e,f,c,d,b[15],14,-660478335),d=gg(d,e,f,c,b[4],20,-405537848),c=gg(c,d,e,f,b[9],5,568446438),f=gg(f,c,d,e,b[14],9,-1019803690),e=gg(e,f,c,d,b[3],14,-187363961),d=gg(d,e,f,c,b[8],20,1163531501),c=gg(c,d,e,f,b[13],5,-1444681467), -f=gg(f,c,d,e,b[2],9,-51403784),e=gg(e,f,c,d,b[7],14,1735328473),d=gg(d,e,f,c,b[12],20,-1926607734),c=hh(c,d,e,f,b[5],4,-378558),f=hh(f,c,d,e,b[8],11,-2022574463),e=hh(e,f,c,d,b[11],16,1839030562),d=hh(d,e,f,c,b[14],23,-35309556),c=hh(c,d,e,f,b[1],4,-1530992060),f=hh(f,c,d,e,b[4],11,1272893353),e=hh(e,f,c,d,b[7],16,-155497632),d=hh(d,e,f,c,b[10],23,-1094730640),c=hh(c,d,e,f,b[13],4,681279174),f=hh(f,c,d,e,b[0],11,-358537222),e=hh(e,f,c,d,b[3],16,-722521979),d=hh(d,e,f,c,b[6],23,76029189),c=hh(c,d, -e,f,b[9],4,-640364487),f=hh(f,c,d,e,b[12],11,-421815835),e=hh(e,f,c,d,b[15],16,530742520),d=hh(d,e,f,c,b[2],23,-995338651),c=ii(c,d,e,f,b[0],6,-198630844),f=ii(f,c,d,e,b[7],10,1126891415),e=ii(e,f,c,d,b[14],15,-1416354905),d=ii(d,e,f,c,b[5],21,-57434055),c=ii(c,d,e,f,b[12],6,1700485571),f=ii(f,c,d,e,b[3],10,-1894986606),e=ii(e,f,c,d,b[10],15,-1051523),d=ii(d,e,f,c,b[1],21,-2054922799),c=ii(c,d,e,f,b[8],6,1873313359),f=ii(f,c,d,e,b[15],10,-30611744),e=ii(e,f,c,d,b[6],15,-1560198380),d=ii(d,e,f,c,b[13], -21,1309151649),c=ii(c,d,e,f,b[4],6,-145523070),f=ii(f,c,d,e,b[11],10,-1120210379),e=ii(e,f,c,d,b[2],15,718787259),d=ii(d,e,f,c,b[9],21,-343485551);a[0]=add32(c,a[0]);a[1]=add32(d,a[1]);a[2]=add32(e,a[2]);a[3]=add32(f,a[3])}function cmn(a,b,c,d,e,f){b=add32(add32(b,a),add32(d,f));return add32(b<>>32-e,c)}function ff(a,b,c,d,e,f,g){return cmn(b&c|~b&d,a,b,e,f,g)}function gg(a,b,c,d,e,f,g){return cmn(b&d|c&~d,a,b,e,f,g)}function hh(a,b,c,d,e,f,g){return cmn(b^c^d,a,b,e,f,g)} -function ii(a,b,c,d,e,f,g){return cmn(c^(b|~d),a,b,e,f,g)}function md51(a){txt="";var b=a.length,c=[1732584193,-271733879,-1732584194,271733878],d;for(d=64;d<=a.length;d+=64)md5cycle(c,md5blk(a.substring(d-64,d)));var a=a.substring(d-64),e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(d=0;d>2]|=a.charCodeAt(d)<<(d%4<<3);e[d>>2]|=128<<(d%4<<3);if(55d;d++)e[d]=0}e[14]=8*b;md5cycle(c,e);return c} -function md5blk(a){var b=[],c;for(c=0;64>c;c+=4)b[c>>2]=a.charCodeAt(c)+(a.charCodeAt(c+1)<<8)+(a.charCodeAt(c+2)<<16)+(a.charCodeAt(c+3)<<24);return b}var hex_chr="0123456789abcdef".split("");function rhex(a){for(var b="",c=0;4>c;c++)b+=hex_chr[a>>8*c+4&15]+hex_chr[a>>8*c&15];return b}function hex(a){for(var b=0;b>16)+(b>>16)+(c>>16)<<16|c&65535});var RMDsize=160,X=[];function ROL(a,b){return new Number(a<>>32-b)}function F(a,b,c){return new Number(a^b^c)}function G(a,b,c){return new Number(a&b|~a&c)}function H(a,b,c){return new Number((a|~b)^c)}function I(a,b,c){return new Number(a&c|b&~c)}function J(a,b,c){return new Number(a^(b|~c))} -function mixOneRound(a,b,c,d,e,f,g,h){switch(h){case 0:a+=F(b,c,d)+f+0;break;case 1:a+=G(b,c,d)+f+1518500249;break;case 2:a+=H(b,c,d)+f+1859775393;break;case 3:a+=I(b,c,d)+f+2400959708;break;case 4:a+=J(b,c,d)+f+2840853838;break;case 5:a+=J(b,c,d)+f+1352829926;break;case 6:a+=I(b,c,d)+f+1548603684;break;case 7:a+=H(b,c,d)+f+1836072691;break;case 8:a+=G(b,c,d)+f+2053994217;break;case 9:a+=F(b,c,d)+f+0;break;default:document.write("Bogus round number")}a=ROL(a,g)+e;c=ROL(c,10);h=[];h[0]=a&4294967295; -h[1]=b&4294967295;h[2]=c&4294967295;h[3]=d&4294967295;h[4]=e&4294967295;h[5]=f;h[6]=g;return h}function MDinit(a){a[0]=1732584193;a[1]=4023233417;a[2]=2562383102;a[3]=271733878;a[4]=3285377520} +BigInteger.ZERO=nbv(0);BigInteger.ONE=nbv(1);function SecureRandom(){this.nextBytes=function(b){for(var a=0;a>1;d.e=parseInt(c,16);for(d.ee=new BigInteger(c,16);;){for(;!(d.p=new BigInteger(a-f,1,e),0==d.p.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.p.isProbablePrime(10)););for(;!(d.q=new BigInteger(f,1,e),0==d.q.subtract(BigInteger.ONE).gcd(d.ee).compareTo(BigInteger.ONE)&&d.q.isProbablePrime(10));); +if(0>=d.p.compareTo(d.q)){var g=d.p;d.p=d.q;d.q=g}var g=d.p.subtract(BigInteger.ONE),h=d.q.subtract(BigInteger.ONE),j=g.multiply(h);if(0==j.gcd(d.ee).compareTo(BigInteger.ONE)){d.n=d.p.multiply(d.q);d.d=d.ee.modInverse(j);d.dmp1=d.d.mod(g);d.dmq1=d.d.mod(h);d.u=d.p.modInverse(d.q);break}}return d};this.keyObject=b}function MD5(b){b=md5(b);return util.hex2bin(b)} +function md5cycle(b,a){var c=b[0],d=b[1],e=b[2],f=b[3],c=ff(c,d,e,f,a[0],7,-680876936),f=ff(f,c,d,e,a[1],12,-389564586),e=ff(e,f,c,d,a[2],17,606105819),d=ff(d,e,f,c,a[3],22,-1044525330),c=ff(c,d,e,f,a[4],7,-176418897),f=ff(f,c,d,e,a[5],12,1200080426),e=ff(e,f,c,d,a[6],17,-1473231341),d=ff(d,e,f,c,a[7],22,-45705983),c=ff(c,d,e,f,a[8],7,1770035416),f=ff(f,c,d,e,a[9],12,-1958414417),e=ff(e,f,c,d,a[10],17,-42063),d=ff(d,e,f,c,a[11],22,-1990404162),c=ff(c,d,e,f,a[12],7,1804603682),f=ff(f,c,d,e,a[13],12, +-40341101),e=ff(e,f,c,d,a[14],17,-1502002290),d=ff(d,e,f,c,a[15],22,1236535329),c=gg(c,d,e,f,a[1],5,-165796510),f=gg(f,c,d,e,a[6],9,-1069501632),e=gg(e,f,c,d,a[11],14,643717713),d=gg(d,e,f,c,a[0],20,-373897302),c=gg(c,d,e,f,a[5],5,-701558691),f=gg(f,c,d,e,a[10],9,38016083),e=gg(e,f,c,d,a[15],14,-660478335),d=gg(d,e,f,c,a[4],20,-405537848),c=gg(c,d,e,f,a[9],5,568446438),f=gg(f,c,d,e,a[14],9,-1019803690),e=gg(e,f,c,d,a[3],14,-187363961),d=gg(d,e,f,c,a[8],20,1163531501),c=gg(c,d,e,f,a[13],5,-1444681467), +f=gg(f,c,d,e,a[2],9,-51403784),e=gg(e,f,c,d,a[7],14,1735328473),d=gg(d,e,f,c,a[12],20,-1926607734),c=hh(c,d,e,f,a[5],4,-378558),f=hh(f,c,d,e,a[8],11,-2022574463),e=hh(e,f,c,d,a[11],16,1839030562),d=hh(d,e,f,c,a[14],23,-35309556),c=hh(c,d,e,f,a[1],4,-1530992060),f=hh(f,c,d,e,a[4],11,1272893353),e=hh(e,f,c,d,a[7],16,-155497632),d=hh(d,e,f,c,a[10],23,-1094730640),c=hh(c,d,e,f,a[13],4,681279174),f=hh(f,c,d,e,a[0],11,-358537222),e=hh(e,f,c,d,a[3],16,-722521979),d=hh(d,e,f,c,a[6],23,76029189),c=hh(c,d, +e,f,a[9],4,-640364487),f=hh(f,c,d,e,a[12],11,-421815835),e=hh(e,f,c,d,a[15],16,530742520),d=hh(d,e,f,c,a[2],23,-995338651),c=ii(c,d,e,f,a[0],6,-198630844),f=ii(f,c,d,e,a[7],10,1126891415),e=ii(e,f,c,d,a[14],15,-1416354905),d=ii(d,e,f,c,a[5],21,-57434055),c=ii(c,d,e,f,a[12],6,1700485571),f=ii(f,c,d,e,a[3],10,-1894986606),e=ii(e,f,c,d,a[10],15,-1051523),d=ii(d,e,f,c,a[1],21,-2054922799),c=ii(c,d,e,f,a[8],6,1873313359),f=ii(f,c,d,e,a[15],10,-30611744),e=ii(e,f,c,d,a[6],15,-1560198380),d=ii(d,e,f,c,a[13], +21,1309151649),c=ii(c,d,e,f,a[4],6,-145523070),f=ii(f,c,d,e,a[11],10,-1120210379),e=ii(e,f,c,d,a[2],15,718787259),d=ii(d,e,f,c,a[9],21,-343485551);b[0]=add32(c,b[0]);b[1]=add32(d,b[1]);b[2]=add32(e,b[2]);b[3]=add32(f,b[3])}function cmn(b,a,c,d,e,f){a=add32(add32(a,b),add32(d,f));return add32(a<>>32-e,c)}function ff(b,a,c,d,e,f,g){return cmn(a&c|~a&d,b,a,e,f,g)}function gg(b,a,c,d,e,f,g){return cmn(a&d|c&~d,b,a,e,f,g)}function hh(b,a,c,d,e,f,g){return cmn(a^c^d,b,a,e,f,g)} +function ii(b,a,c,d,e,f,g){return cmn(c^(a|~d),b,a,e,f,g)}function md51(b){txt="";var a=b.length,c=[1732584193,-271733879,-1732584194,271733878],d;for(d=64;d<=b.length;d+=64)md5cycle(c,md5blk(b.substring(d-64,d)));var b=b.substring(d-64),e=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(d=0;d>2]|=b.charCodeAt(d)<<(d%4<<3);e[d>>2]|=128<<(d%4<<3);if(55d;d++)e[d]=0}e[14]=8*a;md5cycle(c,e);return c} +function md5blk(b){var a=[],c;for(c=0;64>c;c+=4)a[c>>2]=b.charCodeAt(c)+(b.charCodeAt(c+1)<<8)+(b.charCodeAt(c+2)<<16)+(b.charCodeAt(c+3)<<24);return a}var hex_chr="0123456789abcdef".split("");function rhex(b){for(var a="",c=0;4>c;c++)a+=hex_chr[b>>8*c+4&15]+hex_chr[b>>8*c&15];return a}function hex(b){for(var a=0;a>16)+(a>>16)+(c>>16)<<16|c&65535});var RMDsize=160,X=[];function ROL(b,a){return new Number(b<>>32-a)}function F(b,a,c){return new Number(b^a^c)}function G(b,a,c){return new Number(b&a|~b&c)}function H(b,a,c){return new Number((b|~a)^c)}function I(b,a,c){return new Number(b&c|a&~c)}function J(b,a,c){return new Number(b^(a|~c))} +function mixOneRound(b,a,c,d,e,f,g,h){switch(h){case 0:b+=F(a,c,d)+f+0;break;case 1:b+=G(a,c,d)+f+1518500249;break;case 2:b+=H(a,c,d)+f+1859775393;break;case 3:b+=I(a,c,d)+f+2400959708;break;case 4:b+=J(a,c,d)+f+2840853838;break;case 5:b+=J(a,c,d)+f+1352829926;break;case 6:b+=I(a,c,d)+f+1548603684;break;case 7:b+=H(a,c,d)+f+1836072691;break;case 8:b+=G(a,c,d)+f+2053994217;break;case 9:b+=F(a,c,d)+f+0;break;default:document.write("Bogus round number")}b=ROL(b,g)+e;c=ROL(c,10);h=[];h[0]=b&4294967295; +h[1]=a&4294967295;h[2]=c&4294967295;h[3]=d&4294967295;h[4]=e&4294967295;h[5]=f;h[6]=g;return h}function MDinit(b){b[0]=1732584193;b[1]=4023233417;b[2]=2562383102;b[3]=271733878;b[4]=3285377520} var ROLs=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12],[11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5],[11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12],[9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6],[9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11],[9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5],[15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8],[8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]],indexes=[[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15],[7,4,13,1,10,6,15,3,12, 0,9,5,2,14,11,8],[3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12],[1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2],[4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12],[6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2],[15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13],[8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14],[12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]]; -function compress(a,b){blockA=[];blockB=[];for(var c,d=0;5>d;d++)blockA[d]=new Number(a[d]),blockB[d]=new Number(a[d]);for(var e=0,f=0;5>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockA[(e+0)%5],blockA[(e+1)%5],blockA[(e+2)%5],blockA[(e+3)%5],blockA[(e+4)%5],b[indexes[f][d]],ROLs[f][d],f),blockA[(e+0)%5]=c[0],blockA[(e+1)%5]=c[1],blockA[(e+2)%5]=c[2],blockA[(e+3)%5]=c[3],blockA[(e+4)%5]=c[4],e+=4;e=0;for(f=5;10>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockB[(e+0)%5],blockB[(e+1)%5],blockB[(e+2)%5],blockB[(e+ -3)%5],blockB[(e+4)%5],b[indexes[f][d]],ROLs[f][d],f),blockB[(e+0)%5]=c[0],blockB[(e+1)%5]=c[1],blockB[(e+2)%5]=c[2],blockB[(e+3)%5]=c[3],blockB[(e+4)%5]=c[4],e+=4;blockB[3]+=blockA[2]+a[1];a[1]=a[2]+blockA[3]+blockB[4];a[2]=a[3]+blockA[4]+blockB[0];a[3]=a[4]+blockA[0]+blockB[1];a[4]=a[0]+blockA[1]+blockB[2];a[0]=blockB[3]}function zeroX(a){for(var b=0;16>b;b++)a[b]=0} -function MDfinish(a,b,c,d){var e=Array(16);zeroX(e);for(var f=0,g=0;g<(c&63);g++)e[g>>>2]^=(b.charCodeAt(f++)&255)<<8*(g&3);e[c>>>2&15]^=1<<8*(c&3)+7;55<(c&63)&&(compress(a,e),e=Array(16),zeroX(e));e[14]=c<<3;e[15]=c>>>29|d<<3;compress(a,e)}function BYTES_TO_DWORD(a){var b=(a.charCodeAt(3)&255)<<24,b=b|(a.charCodeAt(2)&255)<<16,b=b|(a.charCodeAt(1)&255)<<8;return b|=a.charCodeAt(0)&255} -function RMD(a){var b=Array(RMDsize/32),c=Array(RMDsize/8),d,e;MDinit(b);d=a.length;var f=Array(16);zeroX(f);var g=0;for(e=d;63h;h++)f[h]=BYTES_TO_DWORD(a.substr(g,4)),g+=4;compress(b,f)}MDfinish(b,a.substr(g),d,0);for(h=0;h>>2]&255,c[h+1]=b[h>>>2]>>>8&255,c[h+2]=b[h>>>2]>>>16&255,c[h+3]=b[h>>>2]>>>24&255;return c}function RMDstring(a){for(var a=RMD(a),b="",c=0;c>5]|=(b.charCodeAt(d/8)&255)<<24-d%32;return a},c=function(b){var a=[],c=b.length,d,e;for(d=0;d>3]|=e<<24-4*(d%8)}return a},d=function(b){var a="",c=4*b.length,d,e;for(d=0;d>2]>>8*(3-d%4),a+="0123456789abcdef".charAt(e>>4&15)+"0123456789abcdef".charAt(e&15);return a},e=function(b){var a= -"",c=4*b.length,d,e,f;for(d=0;d>2]>>8*(3-d%4)&255)<<16|(b[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|b[d+2>>2]>>8*(3-(d+2)%4)&255;for(e=0;4>e;e+=1)a=8*d+6*e<=32*b.length?a+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>6*(3-e)&63):a+""}return a},f=function(b){for(var a="",c=0;c<32*b.length;c+=8)a+=String.fromCharCode(b[c>>5]>>>24-c%32&255);return a},g=function(b,a){return b<>>32-a},h=function(b,a){return b>>>a|b<<32-a},j=function(b,c){return 32>=c?new a(b.highOrder>>> -c|b.lowOrder<<32-c,b.lowOrder>>>c|b.highOrder<<32-c):new a(b.lowOrder>>>c|b.highOrder<<32-c,b.highOrder>>>c|b.lowOrder<<32-c)},k=function(b,c){return 32>=c?new a(b.highOrder>>>c,b.lowOrder>>>c|b.highOrder<<32-c):new a(0,b.highOrder<<32-c)},l=function(b,a,c){return b&a^~b&c},m=function(b,c,d){return new a(b.highOrder&c.highOrder^~b.highOrder&d.highOrder,b.lowOrder&c.lowOrder^~b.lowOrder&d.lowOrder)},r=function(b,a,c){return b&a^b&c^a&c},p=function(b,c,d){return new a(b.highOrder&c.highOrder^b.highOrder& -d.highOrder^c.highOrder&d.highOrder,b.lowOrder&c.lowOrder^b.lowOrder&d.lowOrder^c.lowOrder&d.lowOrder)},o=function(b){return h(b,2)^h(b,13)^h(b,22)},y=function(b){var c=j(b,28),d=j(b,34),b=j(b,39);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},x=function(b){return h(b,6)^h(b,11)^h(b,25)},v=function(b){var c=j(b,14),d=j(b,18),b=j(b,41);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},u=function(b){return h(b,7)^h(b,18)^b>>>3}, -t=function(b){var c=j(b,1),d=j(b,8),b=k(b,7);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},E=function(b){return h(b,17)^h(b,19)^b>>>10},Q=function(b){var c=j(b,19),d=j(b,61),b=k(b,6);return new a(c.highOrder^d.highOrder^b.highOrder,c.lowOrder^d.lowOrder^b.lowOrder)},D=function(b,a){var c=(b&65535)+(a&65535);return((b>>>16)+(a>>>16)+(c>>>16)&65535)<<16|c&65535},M=function(b,a,c,d){var e=(b&65535)+(a&65535)+(c&65535)+(d&65535);return((b>>>16)+(a>>>16)+(c>>>16)+ -(d>>>16)+(e>>>16)&65535)<<16|e&65535},K=function(b,a,c,d,e){var f=(b&65535)+(a&65535)+(c&65535)+(d&65535)+(e&65535);return((b>>>16)+(a>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16)&65535)<<16|f&65535},w=function(b,c){var d,e,f;d=(b.lowOrder&65535)+(c.lowOrder&65535);e=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d>>>16);f=(e&65535)<<16|d&65535;d=(b.highOrder&65535)+(c.highOrder&65535)+(e>>>16);e=(b.highOrder>>>16)+(c.highOrder>>>16)+(d>>>16);return new a((e&65535)<<16|d&65535,f)},z=function(b,c,d,e){var f,g, -h;f=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder&65535);g=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f>>>16);h=(g&65535)<<16|f&65535;f=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(g>>>16);g=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f>>>16);return new a((g&65535)<<16|f&65535,h)},T=function(b,c,d,e,f){var g,h,j;g=(b.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder& -65535)+(f.lowOrder&65535);h=(b.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f.lowOrder>>>16)+(g>>>16);j=(h&65535)<<16|g&65535;g=(b.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(f.highOrder&65535)+(h>>>16);h=(b.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f.highOrder>>>16)+(g>>>16);return new a((h&65535)<<16|g&65535,j)},A=function(b,a){var c=[],d,e,f,h,j,k,l,m,o,s=[1732584193,4023233417,2562383102,271733878,3285377520], +function compress(b,a){blockA=[];blockB=[];for(var c,d=0;5>d;d++)blockA[d]=new Number(b[d]),blockB[d]=new Number(b[d]);for(var e=0,f=0;5>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockA[(e+0)%5],blockA[(e+1)%5],blockA[(e+2)%5],blockA[(e+3)%5],blockA[(e+4)%5],a[indexes[f][d]],ROLs[f][d],f),blockA[(e+0)%5]=c[0],blockA[(e+1)%5]=c[1],blockA[(e+2)%5]=c[2],blockA[(e+3)%5]=c[3],blockA[(e+4)%5]=c[4],e+=4;e=0;for(f=5;10>f;f++)for(d=0;16>d;d++)c=mixOneRound(blockB[(e+0)%5],blockB[(e+1)%5],blockB[(e+2)%5],blockB[(e+ +3)%5],blockB[(e+4)%5],a[indexes[f][d]],ROLs[f][d],f),blockB[(e+0)%5]=c[0],blockB[(e+1)%5]=c[1],blockB[(e+2)%5]=c[2],blockB[(e+3)%5]=c[3],blockB[(e+4)%5]=c[4],e+=4;blockB[3]+=blockA[2]+b[1];b[1]=b[2]+blockA[3]+blockB[4];b[2]=b[3]+blockA[4]+blockB[0];b[3]=b[4]+blockA[0]+blockB[1];b[4]=b[0]+blockA[1]+blockB[2];b[0]=blockB[3]}function zeroX(b){for(var a=0;16>a;a++)b[a]=0} +function MDfinish(b,a,c,d){var e=Array(16);zeroX(e);for(var f=0,g=0;g<(c&63);g++)e[g>>>2]^=(a.charCodeAt(f++)&255)<<8*(g&3);e[c>>>2&15]^=1<<8*(c&3)+7;55<(c&63)&&(compress(b,e),e=Array(16),zeroX(e));e[14]=c<<3;e[15]=c>>>29|d<<3;compress(b,e)}function BYTES_TO_DWORD(b){var a=(b.charCodeAt(3)&255)<<24,a=a|(b.charCodeAt(2)&255)<<16,a=a|(b.charCodeAt(1)&255)<<8;return a|=b.charCodeAt(0)&255} +function RMD(b){var a=Array(RMDsize/32),c=Array(RMDsize/8),d,e;MDinit(a);d=b.length;var f=Array(16);zeroX(f);var g=0;for(e=d;63h;h++)f[h]=BYTES_TO_DWORD(b.substr(g,4)),g+=4;compress(a,f)}MDfinish(a,b.substr(g),d,0);for(h=0;h>>2]&255,c[h+1]=a[h>>>2]>>>8&255,c[h+2]=a[h>>>2]>>>16&255,c[h+3]=a[h>>>2]>>>24&255;return c}function RMDstring(b){for(var b=RMD(b),a="",c=0;c>5]|=(a.charCodeAt(d/8)&255)<<24-d%32;return b},c=function(a){var b=[],c=a.length,d,e;for(d=0;d>3]|=e<<24-4*(d%8)}return b},d=function(a){var b="",c=4*a.length,d,e;for(d=0;d>2]>>8*(3-d%4),b+="0123456789abcdef".charAt(e>>4&15)+"0123456789abcdef".charAt(e&15);return b},e=function(a){var b= +"",c=4*a.length,d,e,f;for(d=0;d>2]>>8*(3-d%4)&255)<<16|(a[d+1>>2]>>8*(3-(d+1)%4)&255)<<8|a[d+2>>2]>>8*(3-(d+2)%4)&255;for(e=0;4>e;e+=1)b=8*d+6*e<=32*a.length?b+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(f>>6*(3-e)&63):b+""}return b},f=function(a){for(var b="",c=0;c<32*a.length;c+=8)b+=String.fromCharCode(a[c>>5]>>>24-c%32&255);return b},g=function(a,b){return a<>>32-b},h=function(a,b){return a>>>b|a<<32-b},j=function(a,c){return 32>=c?new b(a.highOrder>>> +c|a.lowOrder<<32-c,a.lowOrder>>>c|a.highOrder<<32-c):new b(a.lowOrder>>>c|a.highOrder<<32-c,a.highOrder>>>c|a.lowOrder<<32-c)},k=function(a,c){return 32>=c?new b(a.highOrder>>>c,a.lowOrder>>>c|a.highOrder<<32-c):new b(0,a.highOrder<<32-c)},l=function(a,b,c){return a&b^~a&c},m=function(a,c,d){return new b(a.highOrder&c.highOrder^~a.highOrder&d.highOrder,a.lowOrder&c.lowOrder^~a.lowOrder&d.lowOrder)},r=function(a,b,c){return a&b^a&c^b&c},p=function(a,c,d){return new b(a.highOrder&c.highOrder^a.highOrder& +d.highOrder^c.highOrder&d.highOrder,a.lowOrder&c.lowOrder^a.lowOrder&d.lowOrder^c.lowOrder&d.lowOrder)},o=function(a){return h(a,2)^h(a,13)^h(a,22)},y=function(a){var c=j(a,28),d=j(a,34),a=j(a,39);return new b(c.highOrder^d.highOrder^a.highOrder,c.lowOrder^d.lowOrder^a.lowOrder)},x=function(a){return h(a,6)^h(a,11)^h(a,25)},v=function(a){var c=j(a,14),d=j(a,18),a=j(a,41);return new b(c.highOrder^d.highOrder^a.highOrder,c.lowOrder^d.lowOrder^a.lowOrder)},u=function(a){return h(a,7)^h(a,18)^a>>>3}, +t=function(a){var c=j(a,1),d=j(a,8),a=k(a,7);return new b(c.highOrder^d.highOrder^a.highOrder,c.lowOrder^d.lowOrder^a.lowOrder)},E=function(a){return h(a,17)^h(a,19)^a>>>10},Q=function(a){var c=j(a,19),d=j(a,61),a=k(a,6);return new b(c.highOrder^d.highOrder^a.highOrder,c.lowOrder^d.lowOrder^a.lowOrder)},D=function(a,b){var c=(a&65535)+(b&65535);return((a>>>16)+(b>>>16)+(c>>>16)&65535)<<16|c&65535},M=function(a,b,c,d){var e=(a&65535)+(b&65535)+(c&65535)+(d&65535);return((a>>>16)+(b>>>16)+(c>>>16)+ +(d>>>16)+(e>>>16)&65535)<<16|e&65535},K=function(a,b,c,d,e){var f=(a&65535)+(b&65535)+(c&65535)+(d&65535)+(e&65535);return((a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16)&65535)<<16|f&65535},w=function(a,c){var d,e,f;d=(a.lowOrder&65535)+(c.lowOrder&65535);e=(a.lowOrder>>>16)+(c.lowOrder>>>16)+(d>>>16);f=(e&65535)<<16|d&65535;d=(a.highOrder&65535)+(c.highOrder&65535)+(e>>>16);e=(a.highOrder>>>16)+(c.highOrder>>>16)+(d>>>16);return new b((e&65535)<<16|d&65535,f)},z=function(a,c,d,e){var f,g, +h;f=(a.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder&65535);g=(a.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f>>>16);h=(g&65535)<<16|f&65535;f=(a.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(g>>>16);g=(a.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f>>>16);return new b((g&65535)<<16|f&65535,h)},T=function(a,c,d,e,f){var g,h,j;g=(a.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder& +65535)+(f.lowOrder&65535);h=(a.lowOrder>>>16)+(c.lowOrder>>>16)+(d.lowOrder>>>16)+(e.lowOrder>>>16)+(f.lowOrder>>>16)+(g>>>16);j=(h&65535)<<16|g&65535;g=(a.highOrder&65535)+(c.highOrder&65535)+(d.highOrder&65535)+(e.highOrder&65535)+(f.highOrder&65535)+(h>>>16);h=(a.highOrder>>>16)+(c.highOrder>>>16)+(d.highOrder>>>16)+(e.highOrder>>>16)+(f.highOrder>>>16)+(g>>>16);return new b((h&65535)<<16|g&65535,j)},A=function(a,b){var c=[],d,e,f,h,j,k,l,m,o,s=[1732584193,4023233417,2562383102,271733878,3285377520], p=[1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708, -2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782];b[a>>5]|=128<<24-a%32;b[(a+65>>9<<4)+15]=a;o=b.length;for(l=0;lm;m+=1)c[m]= -16>m?b[m+l]:g(c[m-3]^c[m-8]^c[m-14]^c[m-16],1),k=20>m?K(g(d,5),e&f^~e&h,j,p[m],c[m]):40>m?K(g(d,5),e^f^h,j,p[m],c[m]):60>m?K(g(d,5),r(e,f,h),j,p[m],c[m]):K(g(d,5),e^f^h,j,p[m],c[m]),j=h,h=f,f=g(e,30),e=d,d=k;s[0]=D(d,s[0]);s[1]=D(e,s[1]);s[2]=D(f,s[2]);s[3]=D(h,s[3]);s[4]=D(j,s[4])}return s},B=function(b,c,d){var e,f,g,h,j,k,A,B,C,s,ca,Y,L,da,ba,O,ea,fa,ga,ha,ia,ja,ka,la,q,ma,Z=[],ra;if("SHA-224"===d||"SHA-256"===d)ca=64,e=(c+65>>9<<4)+15,da=16,ba=1,q=Number,O=D,ea=M,fa=K,ga=u,ha=E,ia=o,ja=x,la=r, +2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782];a[b>>5]|=128<<24-b%32;a[(b+65>>9<<4)+15]=b;o=a.length;for(l=0;lm;m+=1)c[m]= +16>m?a[m+l]:g(c[m-3]^c[m-8]^c[m-14]^c[m-16],1),k=20>m?K(g(d,5),e&f^~e&h,j,p[m],c[m]):40>m?K(g(d,5),e^f^h,j,p[m],c[m]):60>m?K(g(d,5),r(e,f,h),j,p[m],c[m]):K(g(d,5),e^f^h,j,p[m],c[m]),j=h,h=f,f=g(e,30),e=d,d=k;s[0]=D(d,s[0]);s[1]=D(e,s[1]);s[2]=D(f,s[2]);s[3]=D(h,s[3]);s[4]=D(j,s[4])}return s},B=function(a,c,d){var e,f,g,h,j,k,A,B,C,s,ca,Y,L,da,ba,O,ea,fa,ga,ha,ia,ja,ka,la,q,ma,Z=[],ra;if("SHA-224"===d||"SHA-256"===d)ca=64,e=(c+65>>9<<4)+15,da=16,ba=1,q=Number,O=D,ea=M,fa=K,ga=u,ha=E,ia=o,ja=x,la=r, ka=l,ma=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804, -4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s="SHA-224"===d?[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]:[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];else if("SHA-384"===d||"SHA-512"===d)ca=80,e=(c+128>>10<<5)+31,da=32,ba=2,q=a,O=w,ea=z,fa=T,ga=t,ha=Q,ia=y,ja=v,la= +4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s="SHA-224"===d?[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]:[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225];else if("SHA-384"===d||"SHA-512"===d)ca=80,e=(c+128>>10<<5)+31,da=32,ba=2,q=b,O=w,ea=z,fa=T,ga=t,ha=Q,ia=y,ja=v,la= p,ka=m,ma=[new q(1116352408,3609767458),new q(1899447441,602891725),new q(3049323471,3964484399),new q(3921009573,2173295548),new q(961987163,4081628472),new q(1508970993,3053834265),new q(2453635748,2937671579),new q(2870763221,3664609560),new q(3624381080,2734883394),new q(310598401,1164996542),new q(607225278,1323610764),new q(1426881987,3590304994),new q(1925078388,4068182383),new q(2162078206,991336113),new q(2614888103,633803317),new q(3248222580,3479774868),new q(3835390401,2666613458),new q(4022224774, 944711139),new q(264347078,2341262773),new q(604807628,2007800933),new q(770255983,1495990901),new q(1249150122,1856431235),new q(1555081692,3175218132),new q(1996064986,2198950837),new q(2554220882,3999719339),new q(2821834349,766784016),new q(2952996808,2566594879),new q(3210313671,3203337956),new q(3336571891,1034457026),new q(3584528711,2466948901),new q(113926993,3758326383),new q(338241895,168717936),new q(666307205,1188179964),new q(773529912,1546045734),new q(1294757372,1522805485),new q(1396182291, 2643833823),new q(1695183700,2343527390),new q(1986661051,1014477480),new q(2177026350,1206759142),new q(2456956037,344077627),new q(2730485921,1290863460),new q(2820302411,3158454273),new q(3259730800,3505952657),new q(3345764771,106217008),new q(3516065817,3606008344),new q(3600352804,1432725776),new q(4094571909,1467031594),new q(275423344,851169720),new q(430227734,3100823752),new q(506948616,1363258195),new q(659060556,3750685593),new q(883997877,3785050280),new q(958139571,3318307427),new q(1322822218, 3812723403),new q(1537002063,2003034995),new q(1747873779,3602036899),new q(1955562222,1575990012),new q(2024104815,1125592928),new q(2227730452,2716904306),new q(2361852424,442776044),new q(2428436474,593698344),new q(2756734187,3733110249),new q(3204031479,2999351573),new q(3329325298,3815920427),new q(3391569614,3928383900),new q(3515267271,566280711),new q(3940187606,3454069534),new q(4118630271,4000239992),new q(116418474,1914138554),new q(174292421,2731055270),new q(289380356,3203993006),new q(460393269, 320620315),new q(685471733,587496836),new q(852142971,1086792851),new q(1017036298,365543100),new q(1126000580,2618297676),new q(1288033470,3409855158),new q(1501505948,4234509866),new q(1607167915,987167468),new q(1816402316,1246189591)],s="SHA-384"===d?[new q(3418070365,3238371032),new q(1654270250,914150663),new q(2438529370,812702999),new q(355462360,4144912697),new q(1731405415,4290775857),new q(41048885895,1750603025),new q(3675008525,1694076839),new q(1203062813,3204075428)]:[new q(1779033703, -4089235720),new q(3144134277,2227873595),new q(1013904242,4271175723),new q(2773480762,1595750129),new q(1359893119,2917565137),new q(2600822924,725511199),new q(528734635,4215389547),new q(1541459225,327033209)];b[c>>5]|=128<<24-c%32;b[e]=c;ra=b.length;for(Y=0;YL?new q(b[L*ba+Y],b[L*ba+Y+1]):ea(ha(Z[L-2]),Z[L-7],ga(Z[L-15]),Z[L-16]),B=fa(A,ja(h),ka(h,j,k),ma[L],Z[L]),C=O(ia(c),la(c,e,f)),A=k,k=j,j=h,h=O(g, +4089235720),new q(3144134277,2227873595),new q(1013904242,4271175723),new q(2773480762,1595750129),new q(1359893119,2917565137),new q(2600822924,725511199),new q(528734635,4215389547),new q(1541459225,327033209)];a[c>>5]|=128<<24-c%32;a[e]=c;ra=a.length;for(Y=0;YL?new q(a[L*ba+Y],a[L*ba+Y+1]):ea(ha(Z[L-2]),Z[L-7],ga(Z[L-15]),Z[L-16]),B=fa(A,ja(h),ka(h,j,k),ma[L],Z[L]),C=O(ia(c),la(c,e,f)),A=k,k=j,j=h,h=O(g, B),g=f,f=e,e=c,c=O(B,C);s[0]=O(c,s[0]);s[1]=O(e,s[1]);s[2]=O(f,s[2]);s[3]=O(g,s[3]);s[4]=O(h,s[4]);s[5]=O(j,s[5]);s[6]=O(k,s[6]);s[7]=O(A,s[7])}switch(d){case "SHA-224":return[s[0],s[1],s[2],s[3],s[4],s[5],s[6]];case "SHA-256":return s;case "SHA-384":return[s[0].highOrder,s[0].lowOrder,s[1].highOrder,s[1].lowOrder,s[2].highOrder,s[2].lowOrder,s[3].highOrder,s[3].lowOrder,s[4].highOrder,s[4].lowOrder,s[5].highOrder,s[5].lowOrder];case "SHA-512":return[s[0].highOrder,s[0].lowOrder,s[1].highOrder,s[1].lowOrder, -s[2].highOrder,s[2].lowOrder,s[3].highOrder,s[3].lowOrder,s[4].highOrder,s[4].lowOrder,s[5].highOrder,s[5].lowOrder,s[6].highOrder,s[6].lowOrder,s[7].highOrder,s[7].lowOrder];default:return[]}},C=function(a,d){this.strToHash=this.strBinLen=this.sha512=this.sha384=this.sha256=this.sha224=this.sha1=null;if("HEX"===d){if(0!==a.length%2)return"TEXT MUST BE IN BYTE INCREMENTS";this.strBinLen=4*a.length;this.strToHash=c(a)}else if("ASCII"===d||"undefined"===typeof d)this.strBinLen=8*a.length,this.strToHash= -b(a);else return"UNKNOWN TEXT INPUT TYPE"};C.prototype={getHash:function(b,a){var c=null,g=this.strToHash.slice();switch(a){case "HEX":c=d;break;case "B64":c=e;break;case "ASCII":c=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(b){case "SHA-1":if(null===this.sha1)this.sha1=A(g,this.strBinLen);return c(this.sha1);case "SHA-224":if(null===this.sha224)this.sha224=B(g,this.strBinLen,b);return c(this.sha224);case "SHA-256":if(null===this.sha256)this.sha256=B(g,this.strBinLen,b);return c(this.sha256); -case "SHA-384":if(null===this.sha384)this.sha384=B(g,this.strBinLen,b);return c(this.sha384);case "SHA-512":if(null===this.sha512)this.sha512=B(g,this.strBinLen,b);return c(this.sha512);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(a,g,h,j){var k,l,m,o,p;l=[];var t=[];switch(j){case "HEX":j=d;break;case "B64":j=e;break;case "ASCII":j=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(h){case "SHA-1":k=64;p=160;break;case "SHA-224":k=64;p=224;break;case "SHA-256":k=64;p=256;break;case "SHA-384":k= -128;p=384;break;case "SHA-512":k=128;p=512;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===g){if(0!==a.length%2)return"KEY MUST BE IN BYTE INCREMENTS";g=c(a);o=4*a.length}else if("ASCII"===g)g=b(a),o=8*a.length;else return"UNKNOWN KEY INPUT TYPE";a=8*k;m=k/4-1;ko/8&&(g[m]&=4294967040);for(k=0;k<=m;k+=1)l[k]=g[k]^909522486,t[k]=g[k]^1549556828;"SHA-1"===h?(l=A(l.concat(this.strToHash),a+this.strBinLen),l=A(t.concat(l),a+p)):(l=B(l.concat(this.strToHash), -a+this.strBinLen,h),l=B(t.concat(l),a+p,h));return j(l)}};return C}();function str_sha1(a){return(new jsSHA(a,"ASCII")).getHash("SHA-1","ASCII")}function str_sha224(a){return(new jsSHA(a,"ASCII")).getHash("SHA-224","ASCII")}function str_sha256(a){return(new jsSHA(a,"ASCII")).getHash("SHA-256","ASCII")}function str_sha384(a){return(new jsSHA(a,"ASCII")).getHash("SHA-384","ASCII")}function str_sha512(a){return(new jsSHA(a,"ASCII")).getHash("SHA-512","ASCII")} -function openpgp_cfb_encrypt(a,b,c,d,e,f){var g=Array(d),h=Array(d),a=a+a.charAt(d-2)+a.charAt(d-1);util.print_debug("prefixrandom:"+util.hexstrdump(a));for(var j="",k=0;kb*g;){for(var e=a(f,c),f=d.substring(g*b,g*b+b),k=0;kb*g;){for(var j=a(f,c),f=d.substring(g*b+0,g*b+b+0),e=0;ea?4:16==a?1:17==a?1:0}function openpgp_crypto_getPrefixRandom(a){switch(a){case 2:case 3:case 4:return openpgp_crypto_getRandomBytes(8);case 7:case 8:case 9:case 10:return openpgp_crypto_getRandomBytes(16);default:return null}} -function openpgp_crypto_MDCSystemBytes(a,b,c){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nencrypteddata:",c);switch(a){case 0:return c;case 2:return openpgp_cfb_mdc(desede,8,b,c,openpgp_cfb);case 3:return openpgp_cfb_mdc(cast5_encrypt,8,b,c);case 4:return openpgp_cfb_mdc(BFencrypt,8,b,c);case 7:case 8:case 9:return openpgp_cfb_mdc(AESencrypt,16,keyExpansion(b),c);case 10:return openpgp_cfb_mdc(TFencrypt,16,b,c);case 1:util.print_error(""+(1==a?"IDEA Algorithm not implemented": -"Twofish Algorithm not implemented"))}return null}function openpgp_crypto_generateSessionKey(a){return openpgp_crypto_getRandomBytes(openpgp_crypto_getKeyLength(a))}function openpgp_crypto_getKeyLength(a){switch(a){case 2:case 8:return 24;case 3:case 4:case 7:return 16;case 9:case 10:return 32}return null}function openpgp_crypto_getBlockLength(a){switch(a){case 1:case 2:case 3:return 8;case 4:case 7:case 8:case 9:return 16;case 10:return 32;default:return 0}} -function openpgp_crypto_verifySignature(a,b,c,d,e){var f=openpgp_crypto_hashData(b,e);switch(a){case 1:case 2:case 3:e=new RSA;a=d[0].toBigInteger();d=d[1].toBigInteger();c=c[0].toBigInteger();d=e.verify(c,d,a);b=openpgp_encoding_emsa_pkcs1_decode(b,d.toMPI().substring(2));return-1==b?(util.print_error("PKCS1 padding in message or key incorrect. Aborting..."),!1):b==f;case 16:return util.print_error("signing with Elgamal is not defined in the OpenPGP standard."),null;case 17:var a=new DSA,f=c[0].toBigInteger(), -c=c[1].toBigInteger(),g=d[0].toBigInteger(),h=d[1].toBigInteger(),j=d[2].toBigInteger(),d=d[3].toBigInteger(),d=a.verify(b,f,c,e,g,h,j,d);return 0==d.compareTo(f);default:return null}} -function openpgp_crypto_signData(a,b,c,d,e){switch(b){case 1:case 2:case 3:var b=new RSA,d=d[0].toBigInteger(),f=c[0].toBigInteger(),a=openpgp_encoding_emsa_pkcs1_encode(a,e,c[0].mpiByteLength);util.print_debug("signing using RSA");return b.sign(a,d,f).toMPI();case 17:b=new DSA;util.print_debug("DSA Sign: q size in Bytes:"+c[1].getByteLength());var f=c[0].toBigInteger(),g=c[1].toBigInteger(),h=c[2].toBigInteger();c[3].toBigInteger();c=d[0].toBigInteger();a=b.sign(a,e,h,f,g,c);util.print_debug("signing using DSA\n result:"+ -util.hexstrdump(a[0])+"|"+util.hexstrdump(a[1]));return a[0]+a[1];case 16:return util.print_debug("signing with Elgamal is not defined in the OpenPGP standard."),null;default:return null}}function openpgp_crypto_hashData(a,b){var c=null;switch(a){case 1:c=MD5(b);break;case 2:c=str_sha1(b);break;case 3:c=RMDstring(b);break;case 8:c=str_sha256(b);break;case 9:c=str_sha384(b);break;case 10:c=str_sha512(b);break;case 11:c=str_sha224(b)}return c} -function openpgp_crypto_getHashByteLength(a){switch(a){case 1:return 16;case 2:case 3:return 20;case 8:return 32;case 9:return 48;case 10:return 64;case 11:return 28}return null}function openpgp_crypto_getRandomBytes(a){for(var b="",c=0;cb-a;)window.crypto.getRandomValues(c);return a+Math.abs(c[0]&Math.pow(2,d)-1)}function openpgp_crypto_getSecureRandomOctet(){var a=new Uint32Array(1);window.crypto.getRandomValues(a);return a[0]&255} -function openpgp_crypto_getRandomBigInteger(a){if(0>a)return null;var b=openpgp_crypto_getRandomBytes(Math.floor((a+7)/8));0=b.compareTo(a))){for(var c=b.subtract(a),d=openpgp_crypto_getRandomBigInteger(c.bitLength());d>c;)d=openpgp_crypto_getRandomBigInteger(c.bitLength());return a.add(d)}} -function openpgp_crypto_testRSA(a){debugger;var b=new RSA,c=new openpgp_type_mpi;c.create(openpgp_encoding_eme_pkcs1_encode("ABABABAB",128));c=b.encrypt(c.toBigInteger(),a.ee,a.n);b.decrypt(c,a.d,a.p,a.q,a.u)} -function openpgp_crypto_generateKeyPair(a,b,c,d,e){var f,g,h=new Date,h=h.getTime()/1E3,h=String.fromCharCode(Math.floor(h/16777216%256))+String.fromCharCode(Math.floor(h/65536%256))+String.fromCharCode(Math.floor(h/256%256))+String.fromCharCode(Math.floor(h%256));switch(a){case 1:b=(new RSA).generate(b,"10001");f=(new openpgp_packet_keymaterial).write_private_key(a,b,c,d,e,h);g=(new openpgp_packet_keymaterial).write_public_key(a,b,h);break;default:util.print_error("Unknown keytype "+a)}return{privateKey:f, +s[2].highOrder,s[2].lowOrder,s[3].highOrder,s[3].lowOrder,s[4].highOrder,s[4].lowOrder,s[5].highOrder,s[5].lowOrder,s[6].highOrder,s[6].lowOrder,s[7].highOrder,s[7].lowOrder];default:return[]}},C=function(b,d){this.strToHash=this.strBinLen=this.sha512=this.sha384=this.sha256=this.sha224=this.sha1=null;if("HEX"===d){if(0!==b.length%2)return"TEXT MUST BE IN BYTE INCREMENTS";this.strBinLen=4*b.length;this.strToHash=c(b)}else if("ASCII"===d||"undefined"===typeof d)this.strBinLen=8*b.length,this.strToHash= +a(b);else return"UNKNOWN TEXT INPUT TYPE"};C.prototype={getHash:function(a,b){var c=null,g=this.strToHash.slice();switch(b){case "HEX":c=d;break;case "B64":c=e;break;case "ASCII":c=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(a){case "SHA-1":if(null===this.sha1)this.sha1=A(g,this.strBinLen);return c(this.sha1);case "SHA-224":if(null===this.sha224)this.sha224=B(g,this.strBinLen,a);return c(this.sha224);case "SHA-256":if(null===this.sha256)this.sha256=B(g,this.strBinLen,a);return c(this.sha256); +case "SHA-384":if(null===this.sha384)this.sha384=B(g,this.strBinLen,a);return c(this.sha384);case "SHA-512":if(null===this.sha512)this.sha512=B(g,this.strBinLen,a);return c(this.sha512);default:return"HASH NOT RECOGNIZED"}},getHMAC:function(b,g,h,j){var k,l,m,o,p;l=[];var t=[];switch(j){case "HEX":j=d;break;case "B64":j=e;break;case "ASCII":j=f;break;default:return"FORMAT NOT RECOGNIZED"}switch(h){case "SHA-1":k=64;p=160;break;case "SHA-224":k=64;p=224;break;case "SHA-256":k=64;p=256;break;case "SHA-384":k= +128;p=384;break;case "SHA-512":k=128;p=512;break;default:return"HASH NOT RECOGNIZED"}if("HEX"===g){if(0!==b.length%2)return"KEY MUST BE IN BYTE INCREMENTS";g=c(b);o=4*b.length}else if("ASCII"===g)g=a(b),o=8*b.length;else return"UNKNOWN KEY INPUT TYPE";b=8*k;m=k/4-1;ko/8&&(g[m]&=4294967040);for(k=0;k<=m;k+=1)l[k]=g[k]^909522486,t[k]=g[k]^1549556828;"SHA-1"===h?(l=A(l.concat(this.strToHash),b+this.strBinLen),l=A(t.concat(l),b+p)):(l=B(l.concat(this.strToHash), +b+this.strBinLen,h),l=B(t.concat(l),b+p,h));return j(l)}};return C}();function str_sha1(b){return(new jsSHA(b,"ASCII")).getHash("SHA-1","ASCII")}function str_sha224(b){return(new jsSHA(b,"ASCII")).getHash("SHA-224","ASCII")}function str_sha256(b){return(new jsSHA(b,"ASCII")).getHash("SHA-256","ASCII")}function str_sha384(b){return(new jsSHA(b,"ASCII")).getHash("SHA-384","ASCII")}function str_sha512(b){return(new jsSHA(b,"ASCII")).getHash("SHA-512","ASCII")} +function openpgp_cfb_encrypt(b,a,c,d,e,f){var g=Array(d),h=Array(d),b=b+b.charAt(d-2)+b.charAt(d-1);util.print_debug("prefixrandom:"+util.hexstrdump(b));for(var j="",k=0;ka*g;){for(var e=b(f,c),f=d.substring(g*a,g*a+a),k=0;ka*g;){for(var j=b(f,c),f=d.substring(g*a+0,g*a+a+0),e=0;eb?4:16==b?1:17==b?1:0}function openpgp_crypto_getPrefixRandom(b){switch(b){case 2:case 3:case 4:return openpgp_crypto_getRandomBytes(8);case 7:case 8:case 9:case 10:return openpgp_crypto_getRandomBytes(16);default:return null}} +function openpgp_crypto_MDCSystemBytes(b,a,c){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nencrypteddata:",c);switch(b){case 0:return c;case 2:return openpgp_cfb_mdc(desede,8,a,c,openpgp_cfb);case 3:return openpgp_cfb_mdc(cast5_encrypt,8,a,c);case 4:return openpgp_cfb_mdc(BFencrypt,8,a,c);case 7:case 8:case 9:return openpgp_cfb_mdc(AESencrypt,16,keyExpansion(a),c);case 10:return openpgp_cfb_mdc(TFencrypt,16,a,c);case 1:util.print_error(""+(1==b?"IDEA Algorithm not implemented": +"Twofish Algorithm not implemented"))}return null}function openpgp_crypto_generateSessionKey(b){return openpgp_crypto_getRandomBytes(openpgp_crypto_getKeyLength(b))}function openpgp_crypto_getKeyLength(b){switch(b){case 2:case 8:return 24;case 3:case 4:case 7:return 16;case 9:case 10:return 32}return null}function openpgp_crypto_getBlockLength(b){switch(b){case 1:case 2:case 3:return 8;case 4:case 7:case 8:case 9:return 16;case 10:return 32;default:return 0}} +function openpgp_crypto_verifySignature(b,a,c,d,e){var f=openpgp_crypto_hashData(a,e);switch(b){case 1:case 2:case 3:e=new RSA;b=d[0].toBigInteger();d=d[1].toBigInteger();c=c[0].toBigInteger();d=e.verify(c,d,b);a=openpgp_encoding_emsa_pkcs1_decode(a,d.toMPI().substring(2));return-1==a?(util.print_error("PKCS1 padding in message or key incorrect. Aborting..."),!1):a==f;case 16:return util.print_error("signing with Elgamal is not defined in the OpenPGP standard."),null;case 17:var b=new DSA,f=c[0].toBigInteger(), +c=c[1].toBigInteger(),g=d[0].toBigInteger(),h=d[1].toBigInteger(),j=d[2].toBigInteger(),d=d[3].toBigInteger(),d=b.verify(a,f,c,e,g,h,j,d);return 0==d.compareTo(f);default:return null}} +function openpgp_crypto_signData(b,a,c,d,e){switch(a){case 1:case 2:case 3:var a=new RSA,d=d[0].toBigInteger(),f=c[0].toBigInteger(),b=openpgp_encoding_emsa_pkcs1_encode(b,e,c[0].mpiByteLength);util.print_debug("signing using RSA");return a.sign(b,d,f).toMPI();case 17:a=new DSA;util.print_debug("DSA Sign: q size in Bytes:"+c[1].getByteLength());var f=c[0].toBigInteger(),g=c[1].toBigInteger(),h=c[2].toBigInteger();c[3].toBigInteger();c=d[0].toBigInteger();b=a.sign(b,e,h,f,g,c);util.print_debug("signing using DSA\n result:"+ +util.hexstrdump(b[0])+"|"+util.hexstrdump(b[1]));return b[0]+b[1];case 16:return util.print_debug("signing with Elgamal is not defined in the OpenPGP standard."),null;default:return null}}function openpgp_crypto_hashData(b,a){var c=null;switch(b){case 1:c=MD5(a);break;case 2:c=str_sha1(a);break;case 3:c=RMDstring(a);break;case 8:c=str_sha256(a);break;case 9:c=str_sha384(a);break;case 10:c=str_sha512(a);break;case 11:c=str_sha224(a)}return c} +function openpgp_crypto_getHashByteLength(b){switch(b){case 1:return 16;case 2:case 3:return 20;case 8:return 32;case 9:return 48;case 10:return 64;case 11:return 28}return null}function openpgp_crypto_getRandomBytes(b){for(var a="",c=0;ca-b;)window.crypto.getRandomValues(c);return b+Math.abs(c[0]&Math.pow(2,d)-1)}function openpgp_crypto_getSecureRandomOctet(){var b=new Uint32Array(1);window.crypto.getRandomValues(b);return b[0]&255} +function openpgp_crypto_getRandomBigInteger(b){if(0>b)return null;var a=openpgp_crypto_getRandomBytes(Math.floor((b+7)/8));0=a.compareTo(b))){for(var c=a.subtract(b),d=openpgp_crypto_getRandomBigInteger(c.bitLength());d>c;)d=openpgp_crypto_getRandomBigInteger(c.bitLength());return b.add(d)}} +function openpgp_crypto_testRSA(b){debugger;var a=new RSA,c=new openpgp_type_mpi;c.create(openpgp_encoding_eme_pkcs1_encode("ABABABAB",128));c=a.encrypt(c.toBigInteger(),b.ee,b.n);a.decrypt(c,b.d,b.p,b.q,b.u)} +function openpgp_crypto_generateKeyPair(b,a,c,d,e){var f,g,h=new Date,h=h.getTime()/1E3,h=String.fromCharCode(Math.floor(h/16777216%256))+String.fromCharCode(Math.floor(h/65536%256))+String.fromCharCode(Math.floor(h/256%256))+String.fromCharCode(Math.floor(h%256));switch(b){case 1:a=(new RSA).generate(a,"10001");f=(new openpgp_packet_keymaterial).write_private_key(b,a,c,d,e,h);g=(new openpgp_packet_keymaterial).write_public_key(b,a,h);break;default:util.print_error("Unknown keytype "+b)}return{privateKey:f, publicKey:g}} -function openpgp_crypto_symmetricEncrypt(a,b,c,d,e){switch(b){case 0:return d;case 2:return openpgp_cfb_encrypt(a,desede,d,8,c,e).substring(0,d.length+10);case 3:return openpgp_cfb_encrypt(a,cast5_encrypt,d,8,c,e).substring(0,d.length+10);case 4:return openpgp_cfb_encrypt(a,BFencrypt,d,8,c,e).substring(0,d.length+10);case 7:case 8:case 9:return openpgp_cfb_encrypt(a,AESencrypt,d,16,keyExpansion(c),e).substring(0,d.length+18);case 10:return openpgp_cfb_encrypt(a,TFencrypt,d,16,c,e).substring(0,d.length+ +function openpgp_crypto_symmetricEncrypt(b,a,c,d,e){switch(a){case 0:return d;case 2:return openpgp_cfb_encrypt(b,desede,d,8,c,e).substring(0,d.length+10);case 3:return openpgp_cfb_encrypt(b,cast5_encrypt,d,8,c,e).substring(0,d.length+10);case 4:return openpgp_cfb_encrypt(b,BFencrypt,d,8,c,e).substring(0,d.length+10);case 7:case 8:case 9:return openpgp_cfb_encrypt(b,AESencrypt,d,16,keyExpansion(c),e).substring(0,d.length+18);case 10:return openpgp_cfb_encrypt(b,TFencrypt,d,16,c,e).substring(0,d.length+ 18);case 1:return util.print_error("IDEA Algorithm not implemented"),null;default:return null}} -function openpgp_crypto_symmetricDecrypt(a,b,c,d){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+a+"\nencrypteddata:",c);var e=0;d||(e=2);switch(a){case 0:return c;case 2:return openpgp_cfb_decrypt(desede,8,b,c,d).substring(e,c.length+e-10);case 3:return openpgp_cfb_decrypt(cast5_encrypt,8,b,c,d).substring(e,c.length+e-10);case 4:return openpgp_cfb_decrypt(BFencrypt,8,b,c,d).substring(e,c.length+e-10);case 7:case 8:case 9:return openpgp_cfb_decrypt(AESencrypt,16,keyExpansion(b), -c,d).substring(e,c.length+e-18);case 10:return openpgp_cfb_decrypt(TFencrypt,16,b,c,d).substring(e,c.length+e-18);case 1:util.print_error(""+(1==a?"IDEA Algorithm not implemented":"Twofish Algorithm not implemented"))}return null} +function openpgp_crypto_symmetricDecrypt(b,a,c,d){util.print_debug_hexstr_dump("openpgp_crypto_symmetricDecrypt:\nalgo:"+b+"\nencrypteddata:",c);var e=0;d||(e=2);switch(b){case 0:return c;case 2:return openpgp_cfb_decrypt(desede,8,a,c,d).substring(e,c.length+e-10);case 3:return openpgp_cfb_decrypt(cast5_encrypt,8,a,c,d).substring(e,c.length+e-10);case 4:return openpgp_cfb_decrypt(BFencrypt,8,a,c,d).substring(e,c.length+e-10);case 7:case 8:case 9:return openpgp_cfb_decrypt(AESencrypt,16,keyExpansion(a), +c,d).substring(e,c.length+e-18);case 10:return openpgp_cfb_decrypt(TFencrypt,16,a,c,d).substring(e,c.length+e-18);case 1:util.print_error(""+(1==b?"IDEA Algorithm not implemented":"Twofish Algorithm not implemented"))}return null} var Rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],S=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80, 60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65, 153,45,15,176,84,187,22],T1=[2774754246,2222750968,2574743534,2373680118,234025727,3177933782,2976870366,1422247313,1345335392,50397442,2842126286,2099981142,436141799,1658312629,3870010189,2591454956,1170918031,2642575903,1086966153,2273148410,368769775,3948501426,3376891790,200339707,3970805057,1742001331,4255294047,3937382213,3214711843,4154762323,2524082916,1539358875,3266819957,486407649,2928907069,1780885068,1513502316,1094664062,49805301,1338821763,1546925160,4104496465,887481809,150073849, @@ -149,12 +149,12 @@ var Rcon=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53, 3711886307,1584475951,328696964,2801095507,3110654417,0,3240947181,1080041504,3810524412,2043195825,3069008731,3569248874,2370227147,1742323390,1917532473,2497595978,2564049996,2968016984,2236272591,3144405200,3307925487,1340451498,3977706491,2261074755,2597801293,1716859699,294946181,2328839493,3910203897,67502594,4269899647,2700103760,2017737788,632987551,1273211048,2733855057,1576969123,2160083008,92966799,1068339858,566009245,1883781176,4043634165,1675607228,2009183926,2943736538,1113792801,540020752, 3843751935,4245615603,3211645650,2169294285,403966988,641012499,3274697964,3202441055,899848087,2295088196,775493399,2472002756,1441965991,4236410494,2051489085,3366741092,3135724893,841685273,3868554099,3231735904,429425025,2664517455,2743065820,1147544098,1417554474,1001099408,193169544,2362066502,3341414126,1809037496,675025940,2809781982,3168951902,371002123,2910247899,3678134496,1683370546,1951283770,337512970,2463844681,201983494,1215046692,3101973596,2673722050,3178157011,1139780780,3299238498, 967348625,832869781,3543655652,4069226873,3576883175,2336475336,1851340599,3669454189,25988493,2976175573,2631028302,1239460265,3635702892,2902087254,4077384948,3475368682,3400492389,4102978170,1206496942,270010376,1876277946,4035475576,1248797989,1550986798,941890588,1475454630,1942467764,2538718918,3408128232,2709315037,3902567540,1042358047,2531085131,1641856445,226921355,260409994,3767562352,2084716094,1908716981,3433719398,2430093384,100991747,4144101110,470945294,3265487201,1784624437,2935576407, -1775286713,395413126,2572730817,975641885,666476190,3644383713,3943954680,733190296,573772049,3535497577,2842745305,126455438,866620564,766942107,1008868894,361924487,3374377449,2269761230,2868860245,1350051880,2776293343,59739276,1509466529,159418761,437718285,1708834751,3610371814,2227585602,3501746280,2193834305,699439513,1517759789,504434447,2076946608,2835108948,1842789307,742004246];function B0(a){return a&255}function B1(a){return a>>8&255}function B2(a){return a>>16&255} -function B3(a){return a>>24&255}function F1(a,b,c,d){return B1(T1[a&255])|B1(T1[b>>8&255])<<8|B1(T1[c>>16&255])<<16|B1(T1[d>>>24])<<24}function packBytes(a){var b,c,d=a.length,e=Array(d/4);if(a&&!(d%4)){for(b=0,c=0;cc;d++,c++)f[a][c]=j[d];4==c&&(a++,c=0)}for(;ac;d++,c++)f[a][c]=j[d];4==c&&(a++,c=0)}}this.rounds=e;this.rk=f;return this} -function AESencrypt(a,b){var c,d,e,f,g,h=packBytes(a),j=b.rounds,k=h[0],l=h[1],m=h[2];g=h[3];for(c=0;c>8&255]^T3[f>>16&255]^T4[g>>>24],l=T1[e&255]^T2[f>>8&255]^T3[g>>16&255]^T4[d>>>24],m=T1[f&255]^T2[g>>8&255]^T3[d>>16&255]^T4[e>>>24],g=T1[g&255]^T2[d>>8&255]^T3[e>>16&255]^T4[f>>>24];c=j-1;d=k^b.rk[c][0];e=l^b.rk[c][1];f=m^b.rk[c][2];g^=b.rk[c][3];h[0]=F1(d,e,f,g)^b.rk[j][0];h[1]=F1(e,f,g,d)^b.rk[j][1];h[2]=F1(f, -g,d,e)^b.rk[j][2];h[3]=F1(g,d,e,f)^b.rk[j][3];return unpackBytes(h)}function Blowfish(){}Blowfish.prototype.BLOCKSIZE=8; +1775286713,395413126,2572730817,975641885,666476190,3644383713,3943954680,733190296,573772049,3535497577,2842745305,126455438,866620564,766942107,1008868894,361924487,3374377449,2269761230,2868860245,1350051880,2776293343,59739276,1509466529,159418761,437718285,1708834751,3610371814,2227585602,3501746280,2193834305,699439513,1517759789,504434447,2076946608,2835108948,1842789307,742004246];function B0(b){return b&255}function B1(b){return b>>8&255}function B2(b){return b>>16&255} +function B3(b){return b>>24&255}function F1(b,a,c,d){return B1(T1[b&255])|B1(T1[a>>8&255])<<8|B1(T1[c>>16&255])<<16|B1(T1[d>>>24])<<24}function packBytes(b){var a,c,d=b.length,e=Array(d/4);if(b&&!(d%4)){for(a=0,c=0;cc;d++,c++)f[b][c]=j[d];4==c&&(b++,c=0)}for(;bc;d++,c++)f[b][c]=j[d];4==c&&(b++,c=0)}}this.rounds=e;this.rk=f;return this} +function AESencrypt(b,a){var c,d,e,f,g,h=packBytes(b),j=a.rounds,k=h[0],l=h[1],m=h[2];g=h[3];for(c=0;c>8&255]^T3[f>>16&255]^T4[g>>>24],l=T1[e&255]^T2[f>>8&255]^T3[g>>16&255]^T4[d>>>24],m=T1[f&255]^T2[g>>8&255]^T3[d>>16&255]^T4[e>>>24],g=T1[g&255]^T2[d>>8&255]^T3[e>>16&255]^T4[f>>>24];c=j-1;d=k^a.rk[c][0];e=l^a.rk[c][1];f=m^a.rk[c][2];g^=a.rk[c][3];h[0]=F1(d,e,f,g)^a.rk[j][0];h[1]=F1(e,f,g,d)^a.rk[j][1];h[2]=F1(f, +g,d,e)^a.rk[j][2];h[3]=F1(g,d,e,f)^a.rk[j][3];return unpackBytes(h)}function Blowfish(){}Blowfish.prototype.BLOCKSIZE=8; Blowfish.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,3101798381,1780907670,3128725573,4046225305,614570311,3012652279,134345442,2240740374,1667834072,1901547113,2757295779,4103290238,227898511,1921955416,1904987480,2182433518,2069144605,3260701109,2620446009,720527379,3318853667,677414384,3393288472,3101374703,2390351024,1614419982,1822297739,2954791486,3608508353,3174124327,2024746970,1432378464,3864339955,2857741204,1464375394,1676153920,1439316330,715854006,3033291828,289532110, 2706671279,2087905683,3018724369,1668267050,732546397,1947742710,3462151702,2609353502,2950085171,1814351708,2050118529,680887927,999245976,1800124847,3300911131,1713906067,1641548236,4213287313,1216130144,1575780402,4018429277,3917837745,3693486850,3949271944,596196993,3549867205,258830323,2213823033,772490370,2760122372,1774776394,2652871518,566650946,4142492826,1728879713,2882767088,1783734482,3629395816,2517608232,2874225571,1861159788,326777828,3124490320,2130389656,2716951837,967770486,1724537150, 2185432712,2364442137,1164943284,2105845187,998989502,3765401048,2244026483,1075463327,1455516326,1322494562,910128902,469688178,1117454909,936433444,3490320968,3675253459,1240580251,122909385,2157517691,634681816,4142456567,3825094682,3061402683,2540495037,79693498,3249098678,1084186820,1583128258,426386531,1761308591,1047286709,322548459,995290223,1845252383,2603652396,3431023940,2942221577,3202600964,3727903485,1712269319,422464435,3234572375,1170764815,3523960633,3117677531,1434042557,442511882, @@ -177,20 +177,20 @@ Blowfish.prototype.SBOXES=[[3509652390,2564797868,805139163,3491422135,310179838 3718408830,978976581,1043663428,3165965781,1927990952,4200891579,2372276910,3208408903,3533431907,1412390302,2931980059,4132332400,1947078029,3881505623,4168226417,2941484381,1077988104,1320477388,886195818,18198404,3786409E3,2509781533,112762804,3463356488,1866414978,891333506,18488651,661792760,1628790961,3885187036,3141171499,876946877,2693282273,1372485963,791857591,2686433993,3759982718,3167212022,3472953795,2716379847,445679433,3561995674,3504004811,3574258232,54117162,3331405415,2381918588, 3769707343,4154350007,1140177722,4074052095,668550556,3214352940,367459370,261225585,2610173221,4209349473,3468074219,3265815641,314222801,3066103646,3808782860,282218597,3406013506,3773591054,379116347,1285071038,846784868,2669647154,3771962079,3550491691,2305946142,453669953,1268987020,3317592352,3279303384,3744833421,2610507566,3859509063,266596637,3847019092,517658769,3462560207,3443424879,370717030,4247526661,2224018117,4143653529,4112773975,2788324899,2477274417,1456262402,2901442914,1517677493, 1846949527,2295493580,3734397586,2176403920,1280348187,1908823572,3871786941,846861322,1172426758,3287448474,3383383037,1655181056,3139813346,901632758,1897031941,2986607138,3066810236,3447102507,1393639104,373351379,950779232,625454576,3124240540,4148612726,2007998917,544563296,2244738638,2330496472,2058025392,1291430526,424198748,50039436,29584100,3605783033,2429876329,2791104160,1057563949,3255363231,3075367218,3463963227,1469046755,985887462]]; -Blowfish.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731];Blowfish.prototype.NN=16;Blowfish.prototype._clean=function(a){0>a&&(a=(a&2147483647)+2147483648);return a};Blowfish.prototype._F=function(a){var b,c,d;d=a&255;a>>>=8;c=a&255;a>>>=8;b=a&255;a=this.sboxes[0][a>>>8&255]+this.sboxes[1][b];a^=this.sboxes[2][c];return a+=this.sboxes[3][d]}; -Blowfish.prototype._encrypt_block=function(a){var b=a[0],c=a[1],d;for(d=0;d>>24-8*b&255,a[b+d]=c[1]>>>24-8*b&255;return a}; -Blowfish.prototype._decrypt_block=function(a){var b=a[0],c=a[1],d;for(d=this.NN+1;1e;++e)d=d<<8|a[c]&255,++c>=a.length&&(c=0);this.parray[b]=this.PARRAY[b]^d}this.sboxes=[];for(b=0;4>b;++b){this.sboxes[b]=[];for(c=0;256>c;++c)this.sboxes[b][c]=this.SBOXES[b][c]}a=[0,0];for(b=0;bb;++b)for(c=0;256>c;c+=2)this._encrypt_block(a),this.sboxes[b][c+0]=a[0],this.sboxes[b][c+1]=a[1]}; -function BFencrypt(a,b){var c=new Blowfish;c.init(util.str2bin(b));return c.encrypt_block(a)}function cast5_encrypt(a,b){var c=new openpgp_symenc_cast5;c.setKey(util.str2bin(b));return c.encrypt(a)} -function openpgp_symenc_cast5(){function a(b,a,c){b=a+b;c=b<>>32-c;return(f[0][c>>>24]^f[1][c>>>16&255])-f[2][c>>>8&255]+f[3][c&255]}function b(b,a,c){b^=a;c=b<>>32-c;return f[0][c>>>24]-f[1][c>>>16&255]+f[2][c>>>8&255]^f[3][c&255]}function c(b,a,c){b=a-b;c=b<>>32-c;return(f[0][c>>>24]+f[1][c>>>16&255]^f[2][c>>>8&255])-f[3][c&255]}this.BlockSize=8;this.KeySize=16;this.setKey=function(b){this.masking=Array(16);this.rotate=Array(16);this.reset();if(b.length==this.KeySize)this.keySchedule(b); -else return util.print_error("cast5.js: CAST-128: keys must be 16 bytes"),!1;return!0};this.reset=function(){for(var b=0;16>b;b++)this.masking[b]=0,this.rotate[b]=0};this.getBlockSize=function(){return BlockSize};this.encrypt=function(d){for(var e=Array(d.length),f=0;f>>24&255;e[f+1]=l>>>16&255;e[f+2]=l>>>8&255;e[f+3]=l&255;e[f+4]=k>>>24&255;e[f+5]=k>>>16&255;e[f+6]=k>>>8&255;e[f+7]=k&255}return e};this.decrypt=function(d){for(var e=Array(d.length),f=0;f>>24&255;e[f+1]=l>>>16&255;e[f+2]=l>>>8&255;e[f+3]=l&255;e[f+4]=k>>>24&255;e[f+5]=k>>16&255;e[f+6]=k>>8&255;e[f+7]=k&255}return e};var d=Array(4);d[0]=Array(4);d[0][0]=[4,0,13,15,12,14,8];d[0][1]=[5,2,16,18,17,19,10];d[0][2]=[6,3,23,22,21,20,9];d[0][3]=[7,1,26,25,27,24,11];d[1]=Array(4);d[1][0]=[0, +Blowfish.prototype.PARRAY=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479,2450970073,2306472731];Blowfish.prototype.NN=16;Blowfish.prototype._clean=function(b){0>b&&(b=(b&2147483647)+2147483648);return b};Blowfish.prototype._F=function(b){var a,c,d;d=b&255;b>>>=8;c=b&255;b>>>=8;a=b&255;b=this.sboxes[0][b>>>8&255]+this.sboxes[1][a];b^=this.sboxes[2][c];return b+=this.sboxes[3][d]}; +Blowfish.prototype._encrypt_block=function(b){var a=b[0],c=b[1],d;for(d=0;d>>24-8*a&255,b[a+d]=c[1]>>>24-8*a&255;return b}; +Blowfish.prototype._decrypt_block=function(b){var a=b[0],c=b[1],d;for(d=this.NN+1;1e;++e)d=d<<8|b[c]&255,++c>=b.length&&(c=0);this.parray[a]=this.PARRAY[a]^d}this.sboxes=[];for(a=0;4>a;++a){this.sboxes[a]=[];for(c=0;256>c;++c)this.sboxes[a][c]=this.SBOXES[a][c]}b=[0,0];for(a=0;aa;++a)for(c=0;256>c;c+=2)this._encrypt_block(b),this.sboxes[a][c+0]=b[0],this.sboxes[a][c+1]=b[1]}; +function BFencrypt(b,a){var c=new Blowfish;c.init(util.str2bin(a));return c.encrypt_block(b)}function cast5_encrypt(b,a){var c=new openpgp_symenc_cast5;c.setKey(util.str2bin(a));return c.encrypt(b)} +function openpgp_symenc_cast5(){function b(a,b,c){a=b+a;c=a<>>32-c;return(f[0][c>>>24]^f[1][c>>>16&255])-f[2][c>>>8&255]+f[3][c&255]}function a(a,b,c){a^=b;c=a<>>32-c;return f[0][c>>>24]-f[1][c>>>16&255]+f[2][c>>>8&255]^f[3][c&255]}function c(a,b,c){a=b-a;c=a<>>32-c;return(f[0][c>>>24]+f[1][c>>>16&255]^f[2][c>>>8&255])-f[3][c&255]}this.BlockSize=8;this.KeySize=16;this.setKey=function(a){this.masking=Array(16);this.rotate=Array(16);this.reset();if(a.length==this.KeySize)this.keySchedule(a); +else return util.print_error("cast5.js: CAST-128: keys must be 16 bytes"),!1;return!0};this.reset=function(){for(var a=0;16>a;a++)this.masking[a]=0,this.rotate[a]=0};this.getBlockSize=function(){return BlockSize};this.encrypt=function(d){for(var e=Array(d.length),f=0;f>>24&255;e[f+1]=l>>>16&255;e[f+2]=l>>>8&255;e[f+3]=l&255;e[f+4]=k>>>24&255;e[f+5]=k>>>16&255;e[f+6]=k>>>8&255;e[f+7]=k&255}return e};this.decrypt=function(d){for(var e=Array(d.length),f=0;f>>24&255;e[f+1]=l>>>16&255;e[f+2]=l>>>8&255;e[f+3]=l&255;e[f+4]=k>>>24&255;e[f+5]=k>>16&255;e[f+6]=k>>8&255;e[f+7]=k&255}return e};var d=Array(4);d[0]=Array(4);d[0][0]=[4,0,13,15,12,14,8];d[0][1]=[5,2,16,18,17,19,10];d[0][2]=[6,3,23,22,21,20,9];d[0][3]=[7,1,26,25,27,24,11];d[1]=Array(4);d[1][0]=[0, 6,21,23,20,22,16];d[1][1]=[1,4,0,2,1,3,18];d[1][2]=[2,5,7,6,5,4,17];d[1][3]=[3,7,10,9,11,8,19];d[2]=Array(4);d[2][0]=[4,0,13,15,12,14,8];d[2][1]=[5,2,16,18,17,19,10];d[2][2]=[6,3,23,22,21,20,9];d[2][3]=[7,1,26,25,27,24,11];d[3]=Array(4);d[3][0]=[0,6,21,23,20,22,16];d[3][1]=[1,4,0,2,1,3,18];d[3][2]=[2,5,7,6,5,4,17];d[3][3]=[3,7,10,9,11,8,19];var e=Array(4);e[0]=Array(4);e[0][0]=[24,25,23,22,18];e[0][1]=[26,27,21,20,22];e[0][2]=[28,29,19,18,25];e[0][3]=[30,31,17,16,28];e[1]=Array(4);e[1][0]=[3,2,12, -13,8];e[1][1]=[1,0,14,15,13];e[1][2]=[7,6,8,9,3];e[1][3]=[5,4,10,11,7];e[2]=Array(4);e[2][0]=[19,18,28,29,25];e[2][1]=[17,16,30,31,28];e[2][2]=[23,22,24,25,18];e[2][3]=[21,20,26,27,22];e[3]=Array(4);e[3][0]=[8,9,7,6,3];e[3][1]=[10,11,5,4,7];e[3][2]=[12,13,3,2,8];e[3][3]=[14,15,1,0,13];this.keySchedule=function(b){for(var a=Array(8),c=Array(32),k=0;4>k;k++){var l=4*k;a[k]=b[l]<<24|b[l+1]<<16|b[l+2]<<8|b[l+3]}for(var b=[6,7,4,5],m=k=0;2>m;m++)for(var r=0;4>r;r++){for(l=0;4>l;l++){var p=d[r][l],o=a[p[1]], -o=o^f[4][a[p[2]>>>2]>>>24-8*(p[2]&3)&255],o=o^f[5][a[p[3]>>>2]>>>24-8*(p[3]&3)&255],o=o^f[6][a[p[4]>>>2]>>>24-8*(p[4]&3)&255],o=o^f[7][a[p[5]>>>2]>>>24-8*(p[5]&3)&255],o=o^f[b[l]][a[p[6]>>>2]>>>24-8*(p[6]&3)&255];a[p[0]]=o}for(l=0;4>l;l++)p=e[r][l],o=f[4][a[p[0]>>>2]>>>24-8*(p[0]&3)&255],o^=f[5][a[p[1]>>>2]>>>24-8*(p[1]&3)&255],o^=f[6][a[p[2]>>>2]>>>24-8*(p[2]&3)&255],o^=f[7][a[p[3]>>>2]>>>24-8*(p[3]&3)&255],o^=f[4+l][a[p[4]>>>2]>>>24-8*(p[4]&3)&255],c[k]=o,k++}for(k=0;16>k;k++)this.masking[k]=c[k], +13,8];e[1][1]=[1,0,14,15,13];e[1][2]=[7,6,8,9,3];e[1][3]=[5,4,10,11,7];e[2]=Array(4);e[2][0]=[19,18,28,29,25];e[2][1]=[17,16,30,31,28];e[2][2]=[23,22,24,25,18];e[2][3]=[21,20,26,27,22];e[3]=Array(4);e[3][0]=[8,9,7,6,3];e[3][1]=[10,11,5,4,7];e[3][2]=[12,13,3,2,8];e[3][3]=[14,15,1,0,13];this.keySchedule=function(a){for(var b=Array(8),c=Array(32),k=0;4>k;k++){var l=4*k;b[k]=a[l]<<24|a[l+1]<<16|a[l+2]<<8|a[l+3]}for(var a=[6,7,4,5],m=k=0;2>m;m++)for(var r=0;4>r;r++){for(l=0;4>l;l++){var p=d[r][l],o=b[p[1]], +o=o^f[4][b[p[2]>>>2]>>>24-8*(p[2]&3)&255],o=o^f[5][b[p[3]>>>2]>>>24-8*(p[3]&3)&255],o=o^f[6][b[p[4]>>>2]>>>24-8*(p[4]&3)&255],o=o^f[7][b[p[5]>>>2]>>>24-8*(p[5]&3)&255],o=o^f[a[l]][b[p[6]>>>2]>>>24-8*(p[6]&3)&255];b[p[0]]=o}for(l=0;4>l;l++)p=e[r][l],o=f[4][b[p[0]>>>2]>>>24-8*(p[0]&3)&255],o^=f[5][b[p[1]>>>2]>>>24-8*(p[1]&3)&255],o^=f[6][b[p[2]>>>2]>>>24-8*(p[2]&3)&255],o^=f[7][b[p[3]>>>2]>>>24-8*(p[3]&3)&255],o^=f[4+l][b[p[4]>>>2]>>>24-8*(p[4]&3)&255],c[k]=o,k++}for(k=0;16>k;k++)this.masking[k]=c[k], this.rotate[k]=c[16+k]&31};var f=Array(8);f[0]=[821772500,2678128395,1810681135,1059425402,505495343,2617265619,1610868032,3483355465,3218386727,2294005173,3791863952,2563806837,1852023008,365126098,3269944861,584384398,677919599,3229601881,4280515016,2002735330,1136869587,3744433750,2289869850,2731719981,2714362070,879511577,1639411079,575934255,717107937,2857637483,576097850,2731753936,1725645E3,2810460463,5111599,767152862,2543075244,1251459544,1383482551,3052681127,3089939183,3612463449,1878520045, 1510570527,2189125840,2431448366,582008916,3163445557,1265446783,1354458274,3529918736,3202711853,3073581712,3912963487,3029263377,1275016285,4249207360,2905708351,3304509486,1442611557,3585198765,2712415662,2731849581,3248163920,2283946226,208555832,2766454743,1331405426,1447828783,3315356441,3108627284,2957404670,2981538698,3339933917,1669711173,286233437,1465092821,1782121619,3862771680,710211251,980974943,1651941557,430374111,2051154026,704238805,4128970897,3144820574,2857402727,948965521,3333752299, 2227686284,718756367,2269778983,2731643755,718440111,2857816721,3616097120,1113355533,2478022182,410092745,1811985197,1944238868,2696854588,1415722873,1682284203,1060277122,1998114690,1503841958,82706478,2315155686,1068173648,845149890,2167947013,1768146376,1993038550,3566826697,3390574031,940016341,3355073782,2328040721,904371731,1205506512,4094660742,2816623006,825647681,85914773,2857843460,1249926541,1417871568,3287612,3211054559,3126306446,1975924523,1353700161,2814456437,2438597621,1800716203, @@ -235,213 +235,213 @@ f[2]=[2381300288,637164959,3952098751,3893414151,1197506559,916448331,2350892612 2689246273,1022871705,2464987878,3714515309,353796843,2822958815,4256850100,4052777845,551748367,618185374,3778635579,4020649912,1904685140,3069366075,2670879810,3407193292,2954511620,4058283405,2219449317,3135758300,1120655984,3447565834,1474845562,3577699062,550456716,3466908712,2043752612,881257467,869518812,2005220179,938474677,3305539448,3850417126,1315485940,3318264702,226533026,965733244,321539988,1136104718,804158748,573969341,3708209826,937399083,3290727049,2901666755,1461057207,4013193437, 4066861423,3242773476,2421326174,1581322155,3028952165,786071460,3900391652,3918438532,1485433313,4023619836,3708277595,3678951060,953673138,1467089153,1930354364,1533292819,2492563023,1346121658,1685000834,1965281866,3765933717,4190206607,2052792609,3515332758,690371149,3125873887,2180283551,2903598061,3933952357,436236910,289419410,14314871,1242357089,2904507907,1616633776,2666382180,585885352,3471299210,2699507360,1432659641,277164553,3354103607,770115018,2303809295,3741942315,3177781868,2853364978, 2269453327,3774259834,987383833,1290892879,225909803,1741533526,890078084,1496906255,1111072499,916028167,243534141,1252605537,2204162171,531204876,290011180,3916834213,102027703,237315147,209093447,1486785922,220223953,2758195998,4175039106,82940208,3127791296,2569425252,518464269,1353887104,3941492737,2377294467,3935040926]} -function desede(a,b){var c=b.substring(0,8),d=b.substring(8,16),e=b.substring(16,24);return util.str2bin(des(des_createKeys(e),des(des_createKeys(d),des(des_createKeys(c),util.bin2str(a),!0,0,null,null),!1,0,null,null),!0,0,null,null))} -function des(a,b,c,d,e,f){var g=[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],h=[-2146402272,-2147450880, +function desede(b,a){var c=a.substring(0,8),d=a.substring(8,16),e=a.substring(16,24);return util.str2bin(des(des_createKeys(e),des(des_createKeys(d),des(des_createKeys(c),util.bin2str(b),!0,0,null,null),!1,0,null,null),!0,0,null,null))} +function des(b,a,c,d,e,f){var g=[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],h=[-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],j=[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],k=[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],l=[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],m=[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],r=[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],p=[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],o=0,y,x,v,u,t,E,Q,D,M,K,w,z,T=b.length,A=0,B=32==a.length? -3:9;E=3==B?c?[0,32,2]:[30,-2,-2]:c?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2];2==f?b+=" ":1==f?(f=8-T%8,b+=String.fromCharCode(f,f,f,f,f,f,f,f),8==f&&(T+=8)):f||(b+="\x00\x00\x00\x00\x00\x00\x00\x00");tempresult=result="";1==d&&(Q=e.charCodeAt(o++)<<24|e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++),M=e.charCodeAt(o++)<<24|e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++),o=0);for(;o>>4^t)&252645135;t^=f;u^=f<<4;f=(u>>>16^t)&65535;t^=f;u^=f<<16;f=(t>>>2^u)&858993459;u^=f;t^=f<<2;f=(t>>>8^u)&16711935;u^=f;t^=f<<8;f=(u>>>1^t)&1431655765;t^=f;u^=f<<1;u=u<<1|u>>>31;t=t<<1|t>>>31;for(y=0;y>>4|t<<28)^a[e+1],f=u,u=t,t=f^(h[x>>>24&63]|k[x>>>16&63]|m[x>>>8&63]|p[x&63]|g[v>>>24&63]|j[v>>>16&63]|l[v>>> +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],o=0,y,x,v,u,t,E,Q,D,M,K,w,z,T=a.length,A=0,B=32==b.length? +3:9;E=3==B?c?[0,32,2]:[30,-2,-2]:c?[0,32,2,62,30,-2,64,96,2]:[94,62,-2,32,64,2,30,-2,-2];2==f?a+=" ":1==f?(f=8-T%8,a+=String.fromCharCode(f,f,f,f,f,f,f,f),8==f&&(T+=8)):f||(a+="\x00\x00\x00\x00\x00\x00\x00\x00");tempresult=result="";1==d&&(Q=e.charCodeAt(o++)<<24|e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++),M=e.charCodeAt(o++)<<24|e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++),o=0);for(;o>>4^t)&252645135;t^=f;u^=f<<4;f=(u>>>16^t)&65535;t^=f;u^=f<<16;f=(t>>>2^u)&858993459;u^=f;t^=f<<2;f=(t>>>8^u)&16711935;u^=f;t^=f<<8;f=(u>>>1^t)&1431655765;t^=f;u^=f<<1;u=u<<1|u>>>31;t=t<<1|t>>>31;for(y=0;y>>4|t<<28)^b[e+1],f=u,u=t,t=f^(h[x>>>24&63]|k[x>>>16&63]|m[x>>>8&63]|p[x&63]|g[v>>>24&63]|j[v>>>16&63]|l[v>>> 8&63]|r[v&63]);f=u;u=t;t=f}u=u>>>1|u<<31;t=t>>>1|t<<31;f=(u>>>1^t)&1431655765;t^=f;u^=f<<1;f=(t>>>8^u)&16711935;u^=f;t^=f<<8;f=(t>>>2^u)&858993459;u^=f;t^=f<<2;f=(u>>>16^t)&65535;t^=f;u^=f<<16;f=(u>>>4^t)&252645135;t^=f;u^=f<<4;1==d&&(c?(Q=u,M=t):(u^=D,t^=K));tempresult+=String.fromCharCode(u>>>24,u>>>16&255,u>>>8&255,u&255,t>>>24,t>>>16&255,t>>>8&255,t&255);A+=8;512==A&&(result+=tempresult,tempresult="",A=0)}result+=tempresult;return result=result.replace(/\0*$/g,"")} -function des_createKeys(a){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, +function des_createKeys(b){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];for(var b=8>>4^right)&252645135; +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];for(var a=8>>4^right)&252645135; right^=j;left^=j<<4;j=(right>>>-16^left)&65535;left^=j;right^=j<<-16;j=(left>>>2^right)&858993459;right^=j;left^=j<<2;j=(right>>>-16^left)&65535;left^=j;right^=j<<-16;j=(left>>>1^right)&1431655765;right^=j;left^=j<<1;j=(right>>>8^left)&16711935;left^=j;right^=j<<8;j=(left>>>1^right)&1431655765;right^=j;left^=j<<1;j=left<<8|right>>>20&240;left=right<<24|right<<8&16711680|right>>>8&65280|right>>>24&240;right=j;for(i=0;i>>26,right=right<<2|right>>>26):(left=left<< 1|left>>>27,right=right<<1|right>>>27),left&=-15,right&=-15,e=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],f=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],j=(f>>>16^e)&65535,c[h++]=e^j,c[h++]=f^j<<16}return c} -function TFencrypt(a,b){var c=[].concat(a),d=createTwofish();d.open(util.str2bin(b),0);c=d.encrypt(c,0);d.close();return c}var MAXINT=4294967295;function rotb(a,b){return(a<>>8-b)&255}function rotw(a,b){return(a<>>32-b)&MAXINT}function getW(a,b){return a[b]|a[b+1]<<8|a[b+2]<<16|a[b+3]<<24}function setW(a,b,c){a.splice(b,4,c&255,c>>>8&255,c>>>16&255,c>>>24&255)}function setWInv(a,b,c){a.splice(b,4,c>>>24&255,c>>>16&255,c>>>8&255,c&255)}function getB(a,b){return a>>>8*b&255} -function getNrBits(a){for(var b=0;0>>=1;return b}function getMask(a){return(1<d;d++)e=c>>>24,c=c<<8&MAXINT|b>>>24,b=b<<8&MAXINT,f=e<<1,e&128&&(f^=333),c^=e^f<<16,f^=e>>>1,e&1&&(f^=166),c^=f<<24|f<<8;return c}function d(b,a){var c,e,f;c=a>>4;e=a&15;f=t[b][c^ -e];c=E[b][M[e]^K[c]];return D[b][M[c]^K[f]]<<4|Q[b][f^c]}function e(b,a){var c=getB(b,0),d=getB(b,1),f=getB(b,2),g=getB(b,3);switch(x){case 4:c=w[1][c]^getB(a[3],0),d=w[0][d]^getB(a[3],1),f=w[0][f]^getB(a[3],2),g=w[1][g]^getB(a[3],3);case 3:c=w[1][c]^getB(a[2],0),d=w[1][d]^getB(a[2],1),f=w[0][f]^getB(a[2],2),g=w[0][g]^getB(a[2],3);case 2:c=w[0][w[0][c]^getB(a[1],0)]^getB(a[0],0),d=w[0][w[1][d]^getB(a[1],1)]^getB(a[0],1),f=w[1][w[0][f]^getB(a[1],2)]^getB(a[0],2),g=w[1][w[1][g]^getB(a[1],3)]^getB(a[0], -3)}return z[0][c]^z[1][d]^z[2][f]^z[3][g]}c=b;var m,r,p,o;p=[];o=[];var y=[],x,v=[],u,t=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],E=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],Q=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],D=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],M=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],K=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14, -7],w=[[],[]],z=[[],[],[],[]];c=c.slice(0,32);for(b=c.length;16!=b&&24!=b&&32!=b;)c[b++]=0;for(b=0;b>2]=getW(c,b);for(b=0;256>b;b++)w[0][b]=d(0,b),w[1][b]=d(1,b);for(b=0;256>b;b++)m=w[1][b],r=m^m>>2^[0,90,180,238][m&3],u=m^m>>1^m>>2^[0,238,180,90][m&3],z[0][b]=m+(r<<8)+(u<<16)+(u<<24),z[2][b]=r+(u<<8)+(m<<16)+(u<<24),m=w[0][b],r=m^m>>2^[0,90,180,238][m&3],u=m^m>>1^m>>2^[0,238,180,90][m&3],z[1][b]=u+(u<<8)+(r<<16)+(m<<24),z[3][b]=r+(m<<8)+(u<<16)+(r<<24);x=y.length/2;for(b=0;bb;b+=2)m=16843009*b,r=m+16843009,m=e(m,p),r=rotw(e(r,o),8),f[b]=m+r&MAXINT,f[b+1]=rotw(m+2*r,9);for(b=0;256>b;b++)switch(m=r=p=o=b,x){case 4:m=w[1][m]^getB(v[3],0),r=w[0][r]^getB(v[3],1),p=w[0][p]^getB(v[3],2),o=w[1][o]^getB(v[3],3);case 3:m=w[1][m]^getB(v[2],0),r=w[1][r]^getB(v[2],1),p=w[0][p]^getB(v[2],2),o=w[0][o]^getB(v[2],3);case 2:g[0][b]=z[0][w[0][w[0][m]^getB(v[1],0)]^getB(v[0],0)],g[1][b]=z[1][w[0][w[1][r]^getB(v[1],1)]^getB(v[0], -1)],g[2][b]=z[2][w[1][w[0][p]^getB(v[1],2)]^getB(v[0],2)],g[3][b]=z[3][w[1][w[1][o]^getB(v[1],3)]^getB(v[0],3)]}},close:function(){f=[];g=[[],[],[],[]]},encrypt:function(c,g){d=c;e=g;for(var k=[getW(d,e)^f[0],getW(d,e+4)^f[1],getW(d,e+8)^f[2],getW(d,e+12)^f[3]],l=0;8>l;l++){var m=l,r=k,p=a(r[0]),o=b(r[1]);r[2]=rotw(r[2]^p+o+f[4*m+8]&MAXINT,31);r[3]=rotw(r[3],1)^p+2*o+f[4*m+9]&MAXINT;p=a(r[2]);o=b(r[3]);r[0]=rotw(r[0]^p+o+f[4*m+10]&MAXINT,31);r[1]=rotw(r[1],1)^p+2*o+f[4*m+11]&MAXINT}setW(d,e,k[2]^ -f[4]);setW(d,e+4,k[3]^f[5]);setW(d,e+8,k[0]^f[6]);setW(d,e+12,k[1]^f[7]);e+=16;return d},decrypt:function(c,g){d=c;e=g;for(var k=[getW(d,e)^f[4],getW(d,e+4)^f[5],getW(d,e+8)^f[6],getW(d,e+12)^f[7]],l=7;0<=l;l--){var m=l,r=k,p=a(r[0]),o=b(r[1]);r[2]=rotw(r[2],1)^p+o+f[4*m+10]&MAXINT;r[3]=rotw(r[3]^p+2*o+f[4*m+11]&MAXINT,31);p=a(r[2]);o=b(r[3]);r[0]=rotw(r[0],1)^p+o+f[4*m+8]&MAXINT;r[1]=rotw(r[1]^p+2*o+f[4*m+9]&MAXINT,31)}setW(d,e,k[2]^f[0]);setW(d,e+4,k[3]^f[1]);setW(d,e+8,k[0]^f[2]);setW(d,e+12,k[1]^ -f[3]);e+=16},finalize:function(){return d}}}JXG={exists:function(a){return function(b){return!(b===a||null===b)}}()};JXG.decompress=function(a){return unescape((new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(a))).unzip()[0][0])};JXG.Util={}; -JXG.Util.Unzip=function(a){function b(){$+=8;return B>=1;0==C&&(C=b(),a=C&1,C=C>>1|128);return a}function d(b){for(var a=0,d=b;d--;)a=a<<1|c();b&&(a=D[a]>>8-b);return a}function e(b){Q++;u[t++]=b;p.push(String.fromCharCode(b));32768==t&&(t=0)}function f(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1}function g(){for(;;){if(W[N]>=qa)return-1;if(pa[W[N]]==N)return W[N]++;W[N]++}}function h(){var b=V[U],a;o&&document.write("
len:"+N+" treepos:"+ -U);if(17==N)return-1;U++;N++;a=g();o&&document.write("
IsPat "+a);if(0<=a)b.b0=a,o&&document.write("
b0 "+b.b0);else if(b.b0=32768,o&&document.write("
b0 "+b.b0),h())return-1;a=g();if(0<=a)b.b1=a,o&&document.write("
b1 "+b.b1),b.jump=null;else if(b.b1=32768,o&&document.write("
b1 "+b.b1),b.jump=V[U],b.jumppos=U,h())return-1;N--;return 0}function j(b,a,c,d){o&&document.write("currentTree "+b+" numval "+a+" lengths "+c+" show "+d);V=b;U=0;pa=c;qa=a;for(b=0;17>b;b++)W[b]=0;N=0;if(h())return o&& -alert("invalid huffman tree\n"),-1;if(o){document.write("
Tree: "+V.length);for(b=0;32>b;b++)document.write("Places["+b+"].b0="+V[b].b0+"
"),document.write("Places["+b+"].b1="+V[b].b1+"
")}return 0}function k(b){for(var a,d,e=0,f=b[e];;)if(a=c(),o&&document.write("b="+a),a){if(!(f.b1&32768))return o&&document.write("ret1"),f.b1;f=f.jump;a=b.length;for(d=0;d>1,23>>8-a)&255}function rotw(b,a){return(b<>>32-a)&MAXINT}function getW(b,a){return b[a]|b[a+1]<<8|b[a+2]<<16|b[a+3]<<24}function setW(b,a,c){b.splice(a,4,c&255,c>>>8&255,c>>>16&255,c>>>24&255)}function setWInv(b,a,c){b.splice(a,4,c>>>24&255,c>>>16&255,c>>>8&255,c&255)}function getB(b,a){return b>>>8*a&255} +function getNrBits(b){for(var a=0;0>>=1;return a}function getMask(b){return(1<d;d++)e=c>>>24,c=c<<8&MAXINT|a>>>24,a=a<<8&MAXINT,f=e<<1,e&128&&(f^=333),c^=e^f<<16,f^=e>>>1,e&1&&(f^=166),c^=f<<24|f<<8;return c}function d(a,b){var c,e,f;c=b>>4;e=b&15;f=t[a][c^ +e];c=E[a][M[e]^K[c]];return D[a][M[c]^K[f]]<<4|Q[a][f^c]}function e(a,b){var c=getB(a,0),d=getB(a,1),f=getB(a,2),g=getB(a,3);switch(x){case 4:c=w[1][c]^getB(b[3],0),d=w[0][d]^getB(b[3],1),f=w[0][f]^getB(b[3],2),g=w[1][g]^getB(b[3],3);case 3:c=w[1][c]^getB(b[2],0),d=w[1][d]^getB(b[2],1),f=w[0][f]^getB(b[2],2),g=w[0][g]^getB(b[2],3);case 2:c=w[0][w[0][c]^getB(b[1],0)]^getB(b[0],0),d=w[0][w[1][d]^getB(b[1],1)]^getB(b[0],1),f=w[1][w[0][f]^getB(b[1],2)]^getB(b[0],2),g=w[1][w[1][g]^getB(b[1],3)]^getB(b[0], +3)}return z[0][c]^z[1][d]^z[2][f]^z[3][g]}c=a;var m,r,p,o;p=[];o=[];var y=[],x,v=[],u,t=[[8,1,7,13,6,15,3,2,0,11,5,9,14,12,10,4],[2,8,11,13,15,7,6,14,3,1,9,4,0,10,12,5]],E=[[14,12,11,8,1,2,3,5,15,4,10,6,7,0,9,13],[1,14,2,11,4,12,3,7,6,13,10,5,15,9,0,8]],Q=[[11,10,5,14,6,13,9,0,12,8,15,3,2,4,7,1],[4,12,7,5,1,6,9,10,0,14,13,8,2,11,3,15]],D=[[13,7,15,4,1,2,6,14,9,11,3,0,8,5,12,10],[11,9,5,1,12,3,13,14,6,4,7,15,2,0,8,10]],M=[0,8,1,9,2,10,3,11,4,12,5,13,6,14,7,15],K=[0,9,2,11,4,13,6,15,8,1,10,3,12,5,14, +7],w=[[],[]],z=[[],[],[],[]];c=c.slice(0,32);for(a=c.length;16!=a&&24!=a&&32!=a;)c[a++]=0;for(a=0;a>2]=getW(c,a);for(a=0;256>a;a++)w[0][a]=d(0,a),w[1][a]=d(1,a);for(a=0;256>a;a++)m=w[1][a],r=m^m>>2^[0,90,180,238][m&3],u=m^m>>1^m>>2^[0,238,180,90][m&3],z[0][a]=m+(r<<8)+(u<<16)+(u<<24),z[2][a]=r+(u<<8)+(m<<16)+(u<<24),m=w[0][a],r=m^m>>2^[0,90,180,238][m&3],u=m^m>>1^m>>2^[0,238,180,90][m&3],z[1][a]=u+(u<<8)+(r<<16)+(m<<24),z[3][a]=r+(m<<8)+(u<<16)+(r<<24);x=y.length/2;for(a=0;aa;a+=2)m=16843009*a,r=m+16843009,m=e(m,p),r=rotw(e(r,o),8),f[a]=m+r&MAXINT,f[a+1]=rotw(m+2*r,9);for(a=0;256>a;a++)switch(m=r=p=o=a,x){case 4:m=w[1][m]^getB(v[3],0),r=w[0][r]^getB(v[3],1),p=w[0][p]^getB(v[3],2),o=w[1][o]^getB(v[3],3);case 3:m=w[1][m]^getB(v[2],0),r=w[1][r]^getB(v[2],1),p=w[0][p]^getB(v[2],2),o=w[0][o]^getB(v[2],3);case 2:g[0][a]=z[0][w[0][w[0][m]^getB(v[1],0)]^getB(v[0],0)],g[1][a]=z[1][w[0][w[1][r]^getB(v[1],1)]^getB(v[0], +1)],g[2][a]=z[2][w[1][w[0][p]^getB(v[1],2)]^getB(v[0],2)],g[3][a]=z[3][w[1][w[1][o]^getB(v[1],3)]^getB(v[0],3)]}},close:function(){f=[];g=[[],[],[],[]]},encrypt:function(c,g){d=c;e=g;for(var k=[getW(d,e)^f[0],getW(d,e+4)^f[1],getW(d,e+8)^f[2],getW(d,e+12)^f[3]],l=0;8>l;l++){var m=l,r=k,p=b(r[0]),o=a(r[1]);r[2]=rotw(r[2]^p+o+f[4*m+8]&MAXINT,31);r[3]=rotw(r[3],1)^p+2*o+f[4*m+9]&MAXINT;p=b(r[2]);o=a(r[3]);r[0]=rotw(r[0]^p+o+f[4*m+10]&MAXINT,31);r[1]=rotw(r[1],1)^p+2*o+f[4*m+11]&MAXINT}setW(d,e,k[2]^ +f[4]);setW(d,e+4,k[3]^f[5]);setW(d,e+8,k[0]^f[6]);setW(d,e+12,k[1]^f[7]);e+=16;return d},decrypt:function(c,g){d=c;e=g;for(var k=[getW(d,e)^f[4],getW(d,e+4)^f[5],getW(d,e+8)^f[6],getW(d,e+12)^f[7]],l=7;0<=l;l--){var m=l,r=k,p=b(r[0]),o=a(r[1]);r[2]=rotw(r[2],1)^p+o+f[4*m+10]&MAXINT;r[3]=rotw(r[3]^p+2*o+f[4*m+11]&MAXINT,31);p=b(r[2]);o=a(r[3]);r[0]=rotw(r[0],1)^p+o+f[4*m+8]&MAXINT;r[1]=rotw(r[1]^p+2*o+f[4*m+9]&MAXINT,31)}setW(d,e,k[2]^f[0]);setW(d,e+4,k[3]^f[1]);setW(d,e+8,k[0]^f[2]);setW(d,e+12,k[1]^ +f[3]);e+=16},finalize:function(){return d}}}JXG={exists:function(b){return function(a){return!(a===b||null===a)}}()};JXG.decompress=function(b){return unescape((new JXG.Util.Unzip(JXG.Util.Base64.decodeAsArray(b))).unzip()[0][0])};JXG.Util={}; +JXG.Util.Unzip=function(b){function a(){$+=8;return B>=1;0==C&&(C=a(),b=C&1,C=C>>1|128);return b}function d(a){for(var b=0,d=a;d--;)b=b<<1|c();a&&(b=D[b]>>8-a);return b}function e(a){Q++;u[t++]=a;p.push(String.fromCharCode(a));32768==t&&(t=0)}function f(){this.b1=this.b0=0;this.jump=null;this.jumppos=-1}function g(){for(;;){if(W[N]>=qa)return-1;if(pa[W[N]]==N)return W[N]++;W[N]++}}function h(){var a=V[U],b;o&&document.write("
len:"+N+" treepos:"+ +U);if(17==N)return-1;U++;N++;b=g();o&&document.write("
IsPat "+b);if(0<=b)a.b0=b,o&&document.write("
b0 "+a.b0);else if(a.b0=32768,o&&document.write("
b0 "+a.b0),h())return-1;b=g();if(0<=b)a.b1=b,o&&document.write("
b1 "+a.b1),a.jump=null;else if(a.b1=32768,o&&document.write("
b1 "+a.b1),a.jump=V[U],a.jumppos=U,h())return-1;N--;return 0}function j(a,b,c,d){o&&document.write("currentTree "+a+" numval "+b+" lengths "+c+" show "+d);V=a;U=0;pa=c;qa=b;for(a=0;17>a;a++)W[a]=0;N=0;if(h())return o&& +alert("invalid huffman tree\n"),-1;if(o){document.write("
Tree: "+V.length);for(a=0;32>a;a++)document.write("Places["+a+"].b0="+V[a].b0+"
"),document.write("Places["+a+"].b1="+V[a].b1+"
")}return 0}function k(a){for(var b,d,e=0,f=a[e];;)if(b=c(),o&&document.write("b="+b),b){if(!(f.b1&32768))return o&&document.write("ret1"),f.b1;f=f.jump;b=a.length;for(d=0;d>1,23h)e(h);else if(256==h)break;else{var p;h-=257;m=d(K[h])+M[h];h=D[d(5)]>>3;8h;h++)r[h]=0;for(h=0;hdistanceTree");for(h=0;h"+P[h].b0+" "+P[h].b1+" "+P[h].jump+" "+P[h].jumppos)}m=g+p;l=0;var v= -1;for(o&&document.write("
n="+m+" bits: "+$+"
");l"+v+" i:"+l+" decode: "+h+" bits "+$+"
"),16>h)r[l++]=h;else if(16==h){var x;h=3+d(2);if(l+h>m)return t=0,1;for(x=l?r[l-1]:0;h--;)r[l++]=x}else{h=17==h?3+d(3):11+d(7);if(l+h>m)return t=0,1;for(;h--;)r[l++]=0}m=aa.length;for(l=0;lliteralTree"); -a:for(;;)if(h=k(aa),256<=h){h-=256;if(0==h)break;h--;m=d(K[h])+M[h];h=k(P);8t-p)break a;g=u[t-p&32767];e(g)}}else e(h)}}while(!a);t=0;C=1;return 0}function m(){o&&alert("NEXTFILE");p=[];var a=[];E=!1;a[0]=b();a[1]=b();o&&alert("type: "+a[0]+" "+a[1]);120==a[0]&&218==a[1]&&(o&&alert("GEONExT-GZIP"),l(),o&&alert(p.join("")),v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="geonext.gxt",x++);120==a[0]&&156==a[1]&&(o&&alert("ZLIB"),l(),o&&alert(p.join("")), -v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="ZLIB",x++);31==a[0]&&139==a[1]&&(o&&alert("GZIP"),r(),o&&alert(p.join("")),v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="file",x++);if(80==a[0]&&75==a[1]&&(E=!0,a[2]=b(),a[3]=b(),3==a[2]&&4==a[3])){a[0]=b();a[1]=b();o&&alert("ZIP-Version: "+a[1]+" "+a[0]/10+"."+a[0]%10);y=b();y|=b()<<8;o&&alert("gpflags: "+y);a=b();a|=b()<<8;o&&alert("method: "+a);b();b();b();b();var c=b(),c=c|b()<<8,c=c|b()<<16,c=c|b()<<24,d=b(),d=d|b()<<8,d=d|b()<<16,d=d|b()<<24,e=b(),e=e|b()<< -8,e=e|b()<<16,e=e|b()<<24;o&&alert("local CRC: "+c+"\nlocal Size: "+e+"\nlocal CompSize: "+d);c=b();c|=b()<<8;d=b();d|=b()<<8;o&&alert("filelen "+c);f=0;for(R=[];c--;)e=b(),"/"==e|":"==e?f=0:ft-p)break a;g=u[t-p&32767];e(g)}}else e(h)}}while(!b);t=0;C=1;return 0}function m(){o&&alert("NEXTFILE");p=[];var b=[];E=!1;b[0]=a();b[1]=a();o&&alert("type: "+b[0]+" "+b[1]);120==b[0]&&218==b[1]&&(o&&alert("GEONExT-GZIP"),l(),o&&alert(p.join("")),v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="geonext.gxt",x++);120==b[0]&&156==b[1]&&(o&&alert("ZLIB"),l(),o&&alert(p.join("")), +v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="ZLIB",x++);31==b[0]&&139==b[1]&&(o&&alert("GZIP"),r(),o&&alert(p.join("")),v[x]=Array(2),v[x][0]=p.join(""),v[x][1]="file",x++);if(80==b[0]&&75==b[1]&&(E=!0,b[2]=a(),b[3]=a(),3==b[2]&&4==b[3])){b[0]=a();b[1]=a();o&&alert("ZIP-Version: "+b[1]+" "+b[0]/10+"."+b[0]%10);y=a();y|=a()<<8;o&&alert("gpflags: "+y);b=a();b|=a()<<8;o&&alert("method: "+b);a();a();a();a();var c=a(),c=c|a()<<8,c=c|a()<<16,c=c|a()<<24,d=a(),d=d|a()<<8,d=d|a()<<16,d=d|a()<<24,e=a(),e=e|a()<< +8,e=e|a()<<16,e=e|a()<<24;o&&alert("local CRC: "+c+"\nlocal Size: "+e+"\nlocal CompSize: "+d);c=a();c|=a()<<8;d=a();d|=a()<<8;o&&alert("filelen "+c);f=0;for(R=[];c--;)e=a(),"/"==e|":"==e?f=0:f>2,c=(c&3)<<4|d>>4,g=(d&15)<<2|e>>6,h=e&63,isNaN(d)?g=h=64:isNaN(e)&&(h=64),b.push([this._keyStr.charAt(f),this._keyStr.charAt(c),this._keyStr.charAt(g),this._keyStr.charAt(h)].join(""));return b.join("")},decode:function(a,b){for(var c=[],d,e,f,g,h, -j=0,a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");j>4,e=(e&15)<<4|g>>2,f=(g&3)<<6|h,c.push(String.fromCharCode(d)),64!=g&&c.push(String.fromCharCode(e)),64!=h&&c.push(String.fromCharCode(f));c=c.join("");b&&(c=JXG.Util.Base64._utf8_decode(c));return c},_utf8_encode:function(a){for(var a=a.replace(/\r\n/g,"\n"),b="",c=0;cd?b+=String.fromCharCode(d):(127d?b+=String.fromCharCode(d>>6|192):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128)),b+=String.fromCharCode(d&63|128))}return b},_utf8_decode:function(a){for(var b=[],c=0,d=0,e=0,f=0;cd?(b.push(String.fromCharCode(d)),c++):191d?(e=a.charCodeAt(c+1),b.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b.push(String.fromCharCode((d&15)<<12| -(e&63)<<6|f&63)),c+=3);return b.join("")},_destrip:function(a,b){var c=[],d,e,f=[];null==b&&(b=76);a.replace(/ /g,"");d=a.length/b;for(e=0;e>2,c=(c&3)<<4|d>>4,g=(d&15)<<2|e>>6,h=e&63,isNaN(d)?g=h=64:isNaN(e)&&(h=64),a.push([this._keyStr.charAt(f),this._keyStr.charAt(c),this._keyStr.charAt(g),this._keyStr.charAt(h)].join(""));return a.join("")},decode:function(b,a){for(var c=[],d,e,f,g,h, +j=0,b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");j>4,e=(e&15)<<4|g>>2,f=(g&3)<<6|h,c.push(String.fromCharCode(d)),64!=g&&c.push(String.fromCharCode(e)),64!=h&&c.push(String.fromCharCode(f));c=c.join("");a&&(c=JXG.Util.Base64._utf8_decode(c));return c},_utf8_encode:function(b){for(var b=b.replace(/\r\n/g,"\n"),a="",c=0;cd?a+=String.fromCharCode(d):(127d?a+=String.fromCharCode(d>>6|192):(a+=String.fromCharCode(d>>12|224),a+=String.fromCharCode(d>>6&63|128)),a+=String.fromCharCode(d&63|128))}return a},_utf8_decode:function(b){for(var a=[],c=0,d=0,e=0,f=0;cd?(a.push(String.fromCharCode(d)),c++):191d?(e=b.charCodeAt(c+1),a.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=b.charCodeAt(c+1),f=b.charCodeAt(c+2),a.push(String.fromCharCode((d&15)<<12| +(e&63)<<6|f&63)),c+=3);return a.join("")},_destrip:function(b,a){var c=[],d,e,f=[];null==a&&(a=76);b.replace(/ /g,"");d=b.length/a;for(e=0;ed?(b.push(String.fromCharCode(d)),c++):191d?(e=a.charCodeAt(c+1),b.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=a.charCodeAt(c+1),f=a.charCodeAt(c+2),b.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return b.join("")}; -JXG.Util.genUUID=function(){for(var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?b[e]="-":14==e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19==e?d&3|8:d]);return b.join("")}; -function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20130427";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var a=JSON.parse(window.localStorage.getItem("config"));null==a?(this.config=this.default_config,this.write()):this.config=a};this.write=function(){window.localStorage.setItem("config", -JSON.stringify(this.config))}}var b64s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s2r(a){var b,c,d,e="",f=0,g=0,h=a.length;for(d=0;d>2&63),b=(c&3)<<4):1==g?(e+=b64s.charAt(b|c>>4&15),b=(c&15)<<2):2==g&&(e+=b64s.charAt(b|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0>6-e&255)),e=e+2&7,f=b<>16)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255);return openpgp_encoding_base64_encode(a)}function verifyCheckSum(a,b){var c=getCheckSum(a);return c[0]==b[0]&&c[1]==b[1]&&c[2]==b[2]} +JXG.Util.utf8Decode=function(b){var a=[],c=0,d=0,e=0,f;if(!JXG.exists(b))return"";for(;cd?(a.push(String.fromCharCode(d)),c++):191d?(e=b.charCodeAt(c+1),a.push(String.fromCharCode((d&31)<<6|e&63)),c+=2):(e=b.charCodeAt(c+1),f=b.charCodeAt(c+2),a.push(String.fromCharCode((d&15)<<12|(e&63)<<6|f&63)),c+=3);return a.join("")}; +JXG.Util.genUUID=function(){for(var b="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),a=Array(36),c=0,d,e=0;36>e;e++)8==e||13==e||18==e||23==e?a[e]="-":14==e?a[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,a[e]=b[19==e?d&3|8:d]);return a.join("")}; +function openpgp_config(){this.config=null;this.default_config={prefer_hash_algorithm:8,encryption_cipher:9,compression:1,show_version:!0,show_comment:!0,integrity_protect:!0,composition_behavior:0,keyserver:"keyserver.linux.it"};this.versionstring="OpenPGP.js v.1.20130427";this.commentstring="http://openpgpjs.org";this.debug=!1;this.read=function(){var b=JSON.parse(window.localStorage.getItem("config"));null==b?(this.config=this.default_config,this.write()):this.config=b};this.write=function(){window.localStorage.setItem("config", +JSON.stringify(this.config))}}var b64s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function s2r(b){var a,c,d,e="",f=0,g=0,h=b.length;for(d=0;d>2&63),a=(c&3)<<4):1==g?(e+=b64s.charAt(a|c>>4&15),a=(c&15)<<2):2==g&&(e+=b64s.charAt(a|c>>6&3),f+=1,0==f%60&&(e+="\n"),e+=b64s.charAt(c&63)),f+=1,0==f%60&&(e+="\n"),g+=1,3==g&&(g=0);0>6-e&255)),e=e+2&7,f=a<>16)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255);return openpgp_encoding_base64_encode(b)}function verifyCheckSum(b,a){var c=getCheckSum(b);return c[0]==a[0]&&c[1]==a[1]&&c[2]==a[2]} var crc_table=[0,8801531,25875725,17603062,60024545,51751450,35206124,44007191,128024889,120049090,103502900,112007375,70412248,78916387,95990485,88014382,264588937,256049778,240098180,248108927,207005800,215016595,232553829,224014750,140824496,149062475,166599357,157832774,200747345,191980970,176028764,184266919,520933865,529177874,512099556,503334943,480196360,471432179,487973381,496217854,414011600,405478443,422020573,430033190,457094705,465107658,448029500,439496647,281648992,273666971,289622637, 298124950,324696449,333198714,315665548,307683447,392699481,401494690,383961940,375687087,352057528,343782467,359738805,368533838,1041867730,1050668841,1066628831,1058355748,1032471859,1024199112,1006669886,1015471301,968368875,960392720,942864358,951368477,975946762,984451313,1000411399,992435708,836562267,828023200,810956886,818967725,844041146,852051777,868605623,860066380,914189410,922427545,938981743,930215316,904825475,896059E3,878993294,887231349,555053627,563297984,547333942,538569677,579245274, 570480673,588005847,596249900,649392898,640860153,658384399,666397428,623318499,631331096,615366894,606833685,785398962,777416777,794487231,802989380,759421523,767923880,751374174,743392165,695319947,704115056,687564934,679289981,719477610,711202705,728272487,737067676,2083735460,2092239711,2109313705,2101337682,2141233477,2133257662,2116711496,2125215923,2073216669,2064943718,2048398224,2057199467,2013339772,2022141063,2039215473,2030942602,1945504045,1936737750,1920785440,1929023707,1885728716, 1893966647,1911503553,1902736954,1951893524,1959904495,1977441561,1968902626,2009362165,2000822798,1984871416,1992881923,1665111629,1673124534,1656046400,1647513531,1621913772,1613380695,1629922721,1637935450,1688082292,1679317903,1695859321,1704103554,1728967061,1737211246,1720132760,1711368291,1828378820,1820103743,1836060105,1844855090,1869168165,1877963486,1860430632,1852155859,1801148925,1809650950,1792118E3,1784135691,1757986588,1750004711,1765960209,1774462698,1110107254,1118611597,1134571899, 1126595968,1102643863,1094667884,1077139354,1085643617,1166763343,1158490548,1140961346,1149762745,1176011694,1184812885,1200772771,1192499800,1307552511,1298785796,1281720306,1289958153,1316768798,1325007077,1341561107,1332794856,1246636998,1254647613,1271201483,1262662192,1239272743,1230733788,1213667370,1221678289,1562785183,1570797924,1554833554,1546300521,1588974462,1580441477,1597965939,1605978760,1518843046,1510078557,1527603627,1535847760,1494504007,1502748348,1486784330,1478020017,1390639894, 1382365165,1399434779,1408230112,1366334967,1375129868,1358579962,1350304769,1430452783,1438955220,1422405410,1414423513,1456544974,1448562741,1465633219,1474135352]; -function createcrc24(a){for(var b=11994318,c=0;16>16^a.charCodeAt(c))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+1))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+2))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+3))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+4))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+5))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+6))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+7))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+8))&255],b=b<<8^crc_table[(b>> -16^a.charCodeAt(c+9))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+10))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+11))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+12))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+13))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+14))&255],b=b<<8^crc_table[(b>>16^a.charCodeAt(c+15))&255],c+=16;for(var d=c;d>16^a.charCodeAt(c++))&255];return b&16777215}function openpgp_encoding_base64_encode(a){return s2r(a)} -function openpgp_encoding_base64_decode(a){return r2s(a)}function openpgp_encoding_eme_pkcs1_encode(a,b){if(a.length>b-11)return-1;var c;c=""+String.fromCharCode(0);c+=String.fromCharCode(2);for(var d=0;da.length||0!=a.charCodeAt(0)||2!=a.charCodeAt(1))return-1;for(var c=2;0!=a.charCodeAt(c)&&a.length>c;)c++;return a.substring(c+1,a.length)}hash_headers=[,[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20]];hash_headers[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]; +function createcrc24(b){for(var a=11994318,c=0;16>16^b.charCodeAt(c))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+1))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+2))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+3))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+4))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+5))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+6))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+7))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+8))&255],a=a<<8^crc_table[(a>> +16^b.charCodeAt(c+9))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+10))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+11))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+12))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+13))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+14))&255],a=a<<8^crc_table[(a>>16^b.charCodeAt(c+15))&255],c+=16;for(var d=c;d>16^b.charCodeAt(c++))&255];return a&16777215}function openpgp_encoding_base64_encode(b){return s2r(b)} +function openpgp_encoding_base64_decode(b){return r2s(b)}function openpgp_encoding_eme_pkcs1_encode(b,a){if(b.length>a-11)return-1;var c;c=""+String.fromCharCode(0);c+=String.fromCharCode(2);for(var d=0;db.length||0!=b.charCodeAt(0)||2!=b.charCodeAt(1))return-1;for(var c=2;0!=b.charCodeAt(c)&&b.length>c;)c++;return b.substring(c+1,b.length)}hash_headers=[,[48,32,48,12,6,8,42,134,72,134,247,13,2,5,5,0,4,16],[48,33,48,9,6,5,43,14,3,2,26,5,0,4,20],[48,33,48,9,6,5,43,36,3,2,1,5,0,4,20]];hash_headers[8]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,1,5,0,4,32]; hash_headers[9]=[48,65,48,13,6,9,96,134,72,1,101,3,4,2,2,5,0,4,48];hash_headers[10]=[48,81,48,13,6,9,96,134,72,1,101,3,4,2,3,5,0,4,64];hash_headers[11]=[48,49,48,13,6,9,96,134,72,1,101,3,4,2,4,5,0,4,28]; -function openpgp_encoding_emsa_pkcs1_encode(a,b,c){var d;d=""+String.fromCharCode(0);d+=String.fromCharCode(1);for(var e=0;ej.signatureType||3==j.tagType||4==j.tagType||8==j.tagType||9==j.tagType||10==j.tagType||11==j.tagType||18==j.tagType||19==j.tagType)if(e[e.length]=new openpgp_msg_message,e[f].messagePacket=j,e[f].type=b.type,9==j.tagType||1==j.tagType||3==j.tagType||18==j.tagType)if(9==j.tagType){util.print_error("unexpected openpgp packet"); -break}else if(1==j.tagType){util.print_debug("session key found:\n "+j.toString());var k=!0;e[f].sessionKeys=[];for(var l=0;k;)e[f].sessionKeys[l]=j,g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,j=openpgp_packet.read_packet(a,g,h),1!=j.tagType&&3!=j.tagType&&(k=!1),l++;18==j.tagType||9==j.tagType?(util.print_debug("encrypted data found:\n "+j.toString()),e[f].encryptedData=j,g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,f++):util.print_debug("something is wrong: "+ +function openpgp_encoding_emsa_pkcs1_encode(b,a,c){var d;d=""+String.fromCharCode(0);d+=String.fromCharCode(1);for(var e=0;ej.signatureType||3==j.tagType||4==j.tagType||8==j.tagType||9==j.tagType||10==j.tagType||11==j.tagType||18==j.tagType||19==j.tagType)if(e[e.length]=new openpgp_msg_message,e[f].messagePacket=j,e[f].type=a.type,9==j.tagType||1==j.tagType||3==j.tagType||18==j.tagType)if(9==j.tagType){util.print_error("unexpected openpgp packet"); +break}else if(1==j.tagType){util.print_debug("session key found:\n "+j.toString());var k=!0;e[f].sessionKeys=[];for(var l=0;k;)e[f].sessionKeys[l]=j,g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,j=openpgp_packet.read_packet(b,g,h),1!=j.tagType&&3!=j.tagType&&(k=!1),l++;18==j.tagType||9==j.tagType?(util.print_debug("encrypted data found:\n "+j.toString()),e[f].encryptedData=j,g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,f++):util.print_debug("something is wrong: "+ j.tagType)}else{if(18==j.tagType){util.print_debug("symmetric encrypted data");break}}else 2==j.tagType&&3>j.signatureType?(g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,e[f].text=d,e[f].signature=j,f++):4==j.tagType?(g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength):8==j.tagType?(g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,j=j.decompress(),e=e.concat(openpgp.read_messages_dearmored({text:j,openpgp:j}))):10==j.tagType?(e.length=0,g+=j.packetLength+ -j.headerLength,h-=j.packetLength+j.headerLength):11==j.tagType?(g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength,d=j.data,e[f].data=j.data,f++):19==j.tagType&&(g+=j.packetLength+j.headerLength,h-=j.packetLength+j.headerLength);else return util.print_error("no message found!"),null}return e}this.tostring="";this.generate_key_pair=function(b,a,d,e){var f=(new openpgp_packet_userid).write_packet(d),a=openpgp_crypto_generateKeyPair(b,a,e,openpgp.config.config.prefer_hash_algorithm,3), -b=a.privateKey,g=(new openpgp_packet_keymaterial).read_priv_key(b.string,3,b.string.length);g.decryptSecretMPIs(e)||util.print_error("Issue creating key. Unable to read resulting private key");e=new openpgp_msg_privatekey;e.privateKeyPacket=g;e.getPreferredSignatureHashAlgorithm=function(){return openpgp.config.config.prefer_hash_algorithm};g=e.privateKeyPacket.publicKey.data;g=String.fromCharCode(153)+String.fromCharCode(g.length>>8&255)+String.fromCharCode(g.length&255)+g+String.fromCharCode(180)+ -String.fromCharCode(d.length>>24)+String.fromCharCode(d.length>>16&255)+String.fromCharCode(d.length>>8&255)+String.fromCharCode(d.length&255)+d;d=new openpgp_packet_signature;d=d.write_message_signature(16,g,e);a=openpgp_encoding_armor(4,a.publicKey.string+f+d.openpgp);f=openpgp_encoding_armor(5,b.string+f+d.openpgp);return{privateKey:e,privateKeyArmored:f,publicKeyArmored:a}};this.write_signed_message=function(b,a){var d=(new openpgp_packet_signature).write_message_signature(1,a.replace(/\r\n/g, -"\n").replace(/\n/,"\r\n"),b),d={text:a.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"),openpgp:d.openpgp,hash:d.hash};return openpgp_encoding_armor(2,d,null,null)};this.write_signed_and_encrypted_message=function(b,a,d){var e="",f=(new openpgp_packet_literaldata).write_packet(d.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));util.print_debug_hexstr_dump("literal_packet: |"+f+"|\n",f);for(var g=0;g>8&255)+String.fromCharCode(g.length&255)+g+String.fromCharCode(180)+ +String.fromCharCode(d.length>>24)+String.fromCharCode(d.length>>16&255)+String.fromCharCode(d.length>>8&255)+String.fromCharCode(d.length&255)+d;d=new openpgp_packet_signature;d=d.write_message_signature(16,g,e);b=openpgp_encoding_armor(4,b.publicKey.string+f+d.openpgp);f=openpgp_encoding_armor(5,a.string+f+d.openpgp);return{privateKey:e,privateKeyArmored:f,publicKeyArmored:b}};this.write_signed_message=function(a,b){var d=(new openpgp_packet_signature).write_message_signature(1,b.replace(/\r\n/g, +"\n").replace(/\n/,"\r\n"),a),d={text:b.replace(/\r\n/g,"\n").replace(/\n/,"\r\n"),openpgp:d.openpgp,hash:d.hash};return openpgp_encoding_armor(2,d,null,null)};this.write_signed_and_encrypted_message=function(a,b,d){var e="",f=(new openpgp_packet_literaldata).write_packet(d.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));util.print_debug_hexstr_dump("literal_packet: |"+f+"|\n",f);for(var g=0;g")[0]: -a.trim(),d=d.toLowerCase();if(!util.emailRegEx.test(d))return b;for(a=0;a")[0]:a.trim(),d=d.toLowerCase();if(!util.emailRegEx.test(d))return b;for(a=0;a -a;){var e=openpgp_packet.read_packet(b,a,b.length-a);if(null==e){util.print_error("openpgp.msg.messge decrypt:\n[pub/priv_key]parsing ends here @:"+a+" l:"+d);break}else switch(e.tagType){case 2:if(32==e.signatureType)this.revocationSignatures[this.revocationSignatures.length]=e;else if(15e.signatureType){if(null==this.certificationsignatures)this.certificationSignatures=[];this.certificationSignatures[this.certificationSignatures.length]=e}else util.print_error("openpgp.msg.messge decrypt:\nunknown signature type directly on key "+ -e.signatureType+" @"+a);a+=e.packetLength+e.headerLength;break;case 7:this.subKeys[this.subKeys.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;case 17:this.userAttributes[this.userAttributes.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;case 13:this.userIds[this.userIds.length]=e;a+=e.packetLength+e.headerLength;a+=e.read_nodes(this.privateKeyPacket,b,a,b.length-a);break;default:return this.position= -c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength,this.len=a-c}}this.position=c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength;return this.len=a-c};this.decryptSecretMPIs=function(a){return this.privateKeyPacket.decryptSecretMPIs(a)};this.getSubKeyIds=function(){if(4==this.privateKeyPacket.publicKey.version)var a=[];for(var b=0;b")[0]: +b.trim(),d=d.toLowerCase();if(!util.emailRegEx.test(d))return a;for(b=0;b")[0]:b.trim(),d=d.toLowerCase();if(!util.emailRegEx.test(d))return a;for(b=0;b +b;){var e=openpgp_packet.read_packet(a,b,a.length-b);if(null==e){util.print_error("openpgp.msg.messge decrypt:\n[pub/priv_key]parsing ends here @:"+b+" l:"+d);break}else switch(e.tagType){case 2:if(32==e.signatureType)this.revocationSignatures[this.revocationSignatures.length]=e;else if(15e.signatureType){if(null==this.certificationsignatures)this.certificationSignatures=[];this.certificationSignatures[this.certificationSignatures.length]=e}else util.print_error("openpgp.msg.messge decrypt:\nunknown signature type directly on key "+ +e.signatureType+" @"+b);b+=e.packetLength+e.headerLength;break;case 7:this.subKeys[this.subKeys.length]=e;b+=e.packetLength+e.headerLength;b+=e.read_nodes(this.privateKeyPacket,a,b,a.length-b);break;case 17:this.userAttributes[this.userAttributes.length]=e;b+=e.packetLength+e.headerLength;b+=e.read_nodes(this.privateKeyPacket,a,b,a.length-b);break;case 13:this.userIds[this.userIds.length]=e;b+=e.packetLength+e.headerLength;b+=e.read_nodes(this.privateKeyPacket,a,b,a.length-b);break;default:return this.position= +c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength,this.len=b-c}}this.position=c-this.privateKeyPacket.packetLength-this.privateKeyPacket.headerLength;return this.len=b-c};this.decryptSecretMPIs=function(b){return this.privateKeyPacket.decryptSecretMPIs(b)};this.getSubKeyIds=function(){if(4==this.privateKeyPacket.publicKey.version)var b=[];for(var a=0;a>24&255);c+=String.fromCharCode(Math.round(this.date.getTime()/1E3)>>16&255);c+=String.fromCharCode(Math.round(this.date.getTime()/1E3)>>8&255);c+=String.fromCharCode(Math.round(this.date.getTime()/ -1E3)&255);return c+b};this.toString=function(){return"5.9. Literal Data Packet (Tag 11)\n length: "+this.packetLength+"\n format: "+this.format+"\n filename:"+this.filename+"\n date: "+this.date+"\n data: |"+this.data+"|\n rdata: |"+this.real_data+"|\n"}}openpgp_packet_literal.format={binary:"b",text:"t",utf8:"u"};function openpgp_packet_marker(){this.tag=10;this.read=function(a){return 80==a[0].charCodeAt()&&71==a[1].charCodeAt()&&80==a[2].charCodeAt()?!0:!1}} +function openpgp_packet_literal(){this.tag=11;this.format=openpgp_packet_literal.format.utf8;this.data="";this.date=new Date;this.set_data=function(b,a){this.format=a;this.data=b};this.set_data_bytes=function(b,a){this.format=a;a==openpgp_packet_literal.format.utf8&&(b=util.decode_utf8(b));this.data=b};this.get_data_bytes=function(){return this.format==openpgp_packet_literal.format.utf8?util.encode_utf8(this.data):this.data};this.read=function(b){var a=b[0],c=b.charCodeAt(1);this.filename=util.decode_utf8(b.substr(2, +c));this.date=openpgp_packet_time_read(b.substr(2+c,4));this.set_data_bytes(b.substring(6+c),a)};this.write=function(){var b=util.encode_utf8("msg.txt"),a=this.get_data_bytes(),c;c=""+this.format;c+=String.fromCharCode(b.length);c=c+b+openpgp_packet_time_write(this.date);return c+a};this.toString=function(){return"5.9. Literal Data Packet (Tag 11)\n length: "+this.packetLength+"\n format: "+this.format+"\n filename:"+this.filename+"\n date: "+this.date+"\n data: |"+this.data+"|\n rdata: |"+ +this.real_data+"|\n"}}openpgp_packet_literal.format={binary:"b",text:"t",utf8:"u"};function openpgp_packet_marker(){this.tag=10;this.read=function(b){return 80==b[0].charCodeAt()&&71==b[1].charCodeAt()&&80==b[2].charCodeAt()?!0:!1}} function openpgp_packet_onepasssignature(){this.tagType=4;this.flags=this.signingKeyId=this.publicKeyAlgorithm=this.hashAlgorithm=this.type=this.version=null;this.read_packet=read_packet;this.toString=function(){return"5.4. One-Pass Signature Packets (Tag 4)\n length: "+this.packetLength+"\n type: "+this.type+"\n keyID: "+this.signingKeyId.toString()+"\n hashA: "+this.hashAlgorithm+"\n pubKeyA:"+this.publicKeyAlgorithm+"\n flags: "+this.flags+"\n version:"+this.version+ "\n"};this.write_packet=write_packet} -function openpgp_packet_signature(){function a(b,a){var d;d=""+openpgp_packet.encode_length(a.length+1);d+=String.fromCharCode(b);return d+a}this.tagType=2;this.embeddedSignature=this.signatureTargetHash=this.signatureTargetHashAlgorithm=this.signatureTargetPublicKeyAlgorithm=this.reasonForRevocationString=this.reasonForRevocationFlag=this.signersUserId=this.keyFlags=this.policyURI=this.isPrimaryUserID=this.preferredKeyServer=this.keyServerPreferences=this.preferredCompressionAlgorithms=this.preferredHashAlgorithms= +function openpgp_packet_signature(){function b(a,b){var d;d=""+openpgp_packet.encode_length(b.length+1);d+=String.fromCharCode(a);return d+b}this.tagType=2;this.embeddedSignature=this.signatureTargetHash=this.signatureTargetHashAlgorithm=this.signatureTargetPublicKeyAlgorithm=this.reasonForRevocationString=this.reasonForRevocationFlag=this.signersUserId=this.keyFlags=this.policyURI=this.isPrimaryUserID=this.preferredKeyServer=this.keyServerPreferences=this.preferredCompressionAlgorithms=this.preferredHashAlgorithms= this.notationValue=this.notationName=this.notationFlags=this.issuerKeyId=this.revocationKeyFingerprint=this.revocationKeyAlgorithm=this.revocationKeyClass=this.preferredSymmetricAlgorithms=this.keyNeverExpires=this.keyExpirationTime=this.revocable=this.regular_expression=this.trustAmount=this.trustLevel=this.exportable=this.hashAlgorithm=this.publicKeyAlgorithm=this.MPIs=this.signedHashValue=this.signatureNeverExpires=this.signatureExpirationTime=this.signatureData=this.keyId=this.creationTime=this.signatureType= -null;this.verified=!1;this._raw_read_signature_sub_packet=function(b,a,d){0>d&&util.print_debug("openpgp.packet.signature.js\n_raw_read_signature_sub_packet length < 0 @:"+a);var e=a,f=0;192>b[e].charCodeAt()?f=b[e++].charCodeAt():192<=b[e].charCodeAt()&&224>b[e].charCodeAt()?f=(b[e++].charCodeAt()-192<<8)+b[e++].charCodeAt()+192:223b[e].charCodeAt()?f=1<<(b[e++].charCodeAt()&31):255>b[e].charCodeAt()&&(e++,f=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<< -8|b[e++].charCodeAt());var g=b[e++].charCodeAt()&127;switch(g){case 2:this.creationTime=new Date(1E3*(b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt()));break;case 3:this.signatureExpirationTime=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.signatureNeverExpires=0==this.signature_expiration_time;break;case 4:this.exportable=1==b[e++].charCodeAt();break;case 5:this.trustLevel=b[e++].charCodeAt();this.trustAmount= -b[e++].charCodeAt();break;case 6:this.regular_expression=new String;for(g=0;gg;g++)this.revocationKeyFingerprint=b[e++].charCodeAt();break;case 16:this.issuerKeyId=b.substring(e,e+8);e+=8;break;case 20:this.notationFlags=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt();d=b[e++].charCodeAt()<<8|b[e++].charCodeAt();f=b[e++].charCodeAt()<<8|b[e++].charCodeAt();this.notationName="";for(g=0;g>24&255)+String.fromCharCode(b>>16&255)+String.fromCharCode(b>>8&255)+String.fromCharCode(b&255)),h=a(16,d.getKeyId()),g=g+String.fromCharCode(b.length+h.length>>8&255),g=g+String.fromCharCode(b.length+h.length&255),g=g+b+h,b=""+String.fromCharCode(4),b=b+String.fromCharCode(255),b=b+String.fromCharCode(g.length>>24),b=b+String.fromCharCode(g.length>>16&255),b=b+String.fromCharCode(g.length>>8&255),b=b+String.fromCharCode(g.length&255),h=String.fromCharCode(0), -h=h+String.fromCharCode(0),j=openpgp_crypto_hashData(f,c+g+b);util.print_debug("DSA Signature is calculated with:|"+c+g+b+"|\n"+util.hexstrdump(c+g+b)+"\n hash:"+util.hexstrdump(j));h+=j.charAt(0);h+=j.charAt(1);h+=openpgp_crypto_signData(f,d.privateKeyPacket.publicKey.publicKeyAlgorithm,e.MPIs,d.privateKeyPacket.secMPIs,c+g+b);return{openpgp:openpgp_packet.write_packet_header(2,(g+h).length)+g+h,hash:util.get_hashAlgorithmString(f)}};this.verify=function(b,a){var d;d=""+String.fromCharCode(this.version); -d+=String.fromCharCode(255);d+=String.fromCharCode(this.signatureData.length>>24);d+=String.fromCharCode(this.signatureData.length>>16&255);d+=String.fromCharCode(this.signatureData.length>>8&255);d+=String.fromCharCode(this.signatureData.length&255);switch(this.signatureType){case 0:if(4==this.version)this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,b+this.signatureData+d);break;case 1:if(4==this.version){this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm, -this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,b+this.signatureData+d);break}break;case 2:if(3==this.version){this.verified=!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.obj.publicKeyPacket.MPIs,this.signatureData+d);break;case 16:case 17:case 18:case 19:case 48:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.MPIs,b+this.signatureData+d);break;case 24:if(3==this.version){this.verified= -!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.MPIs,b+this.signatureData+d);break;case 25:case 31:case 32:case 40:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,a.MPIs,b+this.signatureData+d);break;default:util.print_error("openpgp.packet.signature.js\nsignature verification for type"+this.signatureType+" not implemented")}return this.verified};this.read_packet=function(b,a,d){this.data= -b.substring(a,a+d);if(0>d)return util.print_debug("openpgp.packet.signature.js\nopenpgp_packet_signature read_packet length < 0 @:"+a),null;var e=a;this.packetLength=d;this.version=b[e++].charCodeAt();switch(this.version){case 3:5!=b[e++].charCodeAt()&&util.print_debug("openpgp.packet.signature.js\ninvalid One-octet length of following hashed material. MUST be 5. @:"+(e-1));this.signatureType=b[e++].charCodeAt();this.creationTime=new Date(1E3*(b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<< -8|b[e++].charCodeAt()));this.signatureData=b.substring(a,e);this.keyId=b.substring(e,e+8);e+=8;this.publicKeyAlgorithm=b[e++].charCodeAt();this.hashAlgorithm=b[e++].charCodeAt();this.signedHashValue=b[e++].charCodeAt()<<8|b[e++].charCodeAt();d=0;0this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;fthis.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;fd&&util.print_debug("openpgp.packet.signature.js\n_raw_read_signature_sub_packet length < 0 @:"+b);var e=b,f=0;192>a[e].charCodeAt()?f=a[e++].charCodeAt():192<=a[e].charCodeAt()&&224>a[e].charCodeAt()?f=(a[e++].charCodeAt()-192<<8)+a[e++].charCodeAt()+192:223a[e].charCodeAt()?f=1<<(a[e++].charCodeAt()&31):255>a[e].charCodeAt()&&(e++,f=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<< +8|a[e++].charCodeAt());var g=a[e++].charCodeAt()&127;switch(g){case 2:this.creationTime=new Date(1E3*(a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt()));break;case 3:this.signatureExpirationTime=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt();this.signatureNeverExpires=0==this.signature_expiration_time;break;case 4:this.exportable=1==a[e++].charCodeAt();break;case 5:this.trustLevel=a[e++].charCodeAt();this.trustAmount= +a[e++].charCodeAt();break;case 6:this.regular_expression=new String;for(g=0;gg;g++)this.revocationKeyFingerprint=a[e++].charCodeAt();break;case 16:this.issuerKeyId=a.substring(e,e+8);e+=8;break;case 20:this.notationFlags=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt();d=a[e++].charCodeAt()<<8|a[e++].charCodeAt();f=a[e++].charCodeAt()<<8|a[e++].charCodeAt();this.notationName="";for(g=0;g>24&255)+String.fromCharCode(a>>16&255)+String.fromCharCode(a>>8&255)+String.fromCharCode(a&255)),h=b(16,d.getKeyId()),g=g+String.fromCharCode(a.length+h.length>>8&255),g=g+String.fromCharCode(a.length+h.length&255),g=g+a+h,a=""+String.fromCharCode(4),a=a+String.fromCharCode(255),a=a+String.fromCharCode(g.length>>24),a=a+String.fromCharCode(g.length>>16&255),a=a+String.fromCharCode(g.length>>8&255),a=a+String.fromCharCode(g.length&255),h=String.fromCharCode(0), +h=h+String.fromCharCode(0),j=openpgp_crypto_hashData(f,c+g+a);util.print_debug("DSA Signature is calculated with:|"+c+g+a+"|\n"+util.hexstrdump(c+g+a)+"\n hash:"+util.hexstrdump(j));h+=j.charAt(0);h+=j.charAt(1);h+=openpgp_crypto_signData(f,d.privateKeyPacket.publicKey.publicKeyAlgorithm,e.MPIs,d.privateKeyPacket.secMPIs,c+g+a);return{openpgp:openpgp_packet.write_packet_header(2,(g+h).length)+g+h,hash:util.get_hashAlgorithmString(f)}};this.verify=function(a,b){var d;d=""+String.fromCharCode(this.version); +d+=String.fromCharCode(255);d+=String.fromCharCode(this.signatureData.length>>24);d+=String.fromCharCode(this.signatureData.length>>16&255);d+=String.fromCharCode(this.signatureData.length>>8&255);d+=String.fromCharCode(this.signatureData.length&255);switch(this.signatureType){case 0:if(4==this.version)this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData+d);break;case 1:if(4==this.version){this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm, +this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData+d);break}break;case 2:if(3==this.version){this.verified=!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,this.signatureData+d);break;case 16:case 17:case 18:case 19:case 48:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 24:if(3==this.version){this.verified= +!1;break}this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;case 25:case 31:case 32:case 40:this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.MPIs,a+this.signatureData+d);break;default:util.print_error("openpgp.packet.signature.js\nsignature verification for type"+this.signatureType+" not implemented")}return this.verified};this.read_packet=function(a,b,d){this.data= +a.substring(b,b+d);if(0>d)return util.print_debug("openpgp.packet.signature.js\nopenpgp_packet_signature read_packet length < 0 @:"+b),null;var e=b;this.packetLength=d;this.version=a[e++].charCodeAt();switch(this.version){case 3:5!=a[e++].charCodeAt()&&util.print_debug("openpgp.packet.signature.js\ninvalid One-octet length of following hashed material. MUST be 5. @:"+(e-1));this.signatureType=a[e++].charCodeAt();this.creationTime=new Date(1E3*(a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<< +8|a[e++].charCodeAt()));this.signatureData=a.substring(b,e);this.keyId=a.substring(e,e+8);e+=8;this.publicKeyAlgorithm=a[e++].charCodeAt();this.hashAlgorithm=a[e++].charCodeAt();this.signedHashValue=a[e++].charCodeAt()<<8|a[e++].charCodeAt();d=0;0this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;fthis.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;fa[b].charCodeAt()?(packet_length=a[b++].charCodeAt(),c=1):192<=a[b].charCodeAt()&&224>a[b].charCodeAt()?(packet_length=(a[b++].charCodeAt()-192<<8)+a[b++].charCodeAt()+192,c=2):223a[b].charCodeAt()?(packet_length=1<<(a[b++].charCodeAt()& -31),c=1):(c=5,b++,packet_length=a[b++].charCodeAt()<<24|a[b++].charCodeAt()<<16|a[b++].charCodeAt()<<8|a[b++].charCodeAt());a[b++].charCodeAt();packet_length--;c++;this.userattributes[0]=[];this.userattributes[0]=a.substring(b,b+0);b+=packet_length;total_len+=c+0}return this};this.read_packet=read_packet;this.read_nodes=function(a,b,c,d){this.parentNode=a;for(var e=c,f=d;b.length!=e;){var g=openpgp_packet.read_packet(b,e,f);if(null==g){util.print_error("openpgp.packet.userattribute.js\n[user_attr] parsing ends here @:"+ -e+" l:"+f);break}else switch(g.tagType){case 2:15g.signatureType?this.certificationSignatures[this.certificationSignatures.length]=g:32==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);e+=g.packetLength+g.headerLength;f=d-(e-c);break;default:return this.data=b,this.position=c-a.packetLength,this.len=e-c}}this.data=b;this.position=c-a.packetLength;return this.len=e-c};this.toString=function(){for(var a="5.12. User Attribute Packet (Tag 17)\n AttributePackets: (count = "+ -this.userattributes.length+")\n",b=0;bb?a+=String.fromCharCode(b):191b?(a+=String.fromCharCode((b-192>>8)+192),a+=String.fromCharCode(b-192&255)):(a+=String.fromCharCode(255),a+=String.fromCharCode(b>>24&255),a+=String.fromCharCode(b>>16&255),a+=String.fromCharCode(b>>8&255),a+=String.fromCharCode(b&255));return a}this.encode_length=a;this.write_old_packet_header=function(b,a){var d="";256>a?(d+=String.fromCharCode(128|b<<2),d+=String.fromCharCode(a)):(65536>a?(d+=String.fromCharCode(b<< -2|129),d+=String.fromCharCode(a>>8)):(d+=String.fromCharCode(b<<2|130),d+=String.fromCharCode(a>>24&255),d+=String.fromCharCode(a>>16&255),d+=String.fromCharCode(a>>8&255)),d+=String.fromCharCode(a&255));return d};this.write_packet_header=function(b,c){var d;d=""+String.fromCharCode(192|b);return d+=a(c)};this.read_packet=function(b,a,d){if(null==b||b.length<=a||2>b.substring(a).length||0==(b[a].charCodeAt()&128))return util.print_error("Error during parsing. This message / key is probably not containing a valid OpenPGP format."), -null;var e=-1,f=-1,f=0;0!=(b[a].charCodeAt()&64)&&(f=1);var g;f?e=b[a].charCodeAt()&63:(e=(b[a].charCodeAt()&63)>>2,g=b[a].charCodeAt()&3);a++;var h=null,j=-1;if(f)if(192>b[a].charCodeAt())d=b[a++].charCodeAt(),util.print_debug("1 byte length:"+d);else if(192<=b[a].charCodeAt()&&224>b[a].charCodeAt())d=(b[a++].charCodeAt()-192<<8)+b[a++].charCodeAt()+192,util.print_debug("2 byte length:"+d);else if(223b[a].charCodeAt()){d=1<<(b[a++].charCodeAt()&31);util.print_debug("4 byte length:"+ -d);j=a+d;for(h=b.substring(a,a+d);;)if(192>b[j].charCodeAt()){g=b[j++].charCodeAt();d+=g;h+=b.substring(j,j+g);j+=g;break}else if(192<=b[j].charCodeAt()&&224>b[j].charCodeAt()){g=(b[j++].charCodeAt()-192<<8)+b[j++].charCodeAt()+192;d+=g;h+=b.substring(j,j+g);j+=g;break}else if(223b[j].charCodeAt())g=1<<(b[j++].charCodeAt()&31),d+=g,h+=b.substring(j,j+g),j+=g;else{j++;g=b[j++].charCodeAt()<<24|b[j++].charCodeAt()<<16|b[j++].charCodeAt()<<8|b[j++].charCodeAt();h+=b.substring(j, -j+g);d+=g;j+=g;break}}else a++,d=b[a++].charCodeAt()<<24|b[a++].charCodeAt()<<16|b[a++].charCodeAt()<<8|b[a++].charCodeAt();else switch(g){case 0:d=b[a++].charCodeAt();break;case 1:d=b[a++].charCodeAt()<<8|b[a++].charCodeAt();break;case 2:d=b[a++].charCodeAt()<<24|b[a++].charCodeAt()<<16|b[a++].charCodeAt()<<8|b[a++].charCodeAt();break}-1==j&&(j=d);null==h&&(h=b.substring(a,a+j));var b={},k;for(k in this.type)b[this.type[k]]=k;k="openpgp_packet_"+b[e];b=window[k];if(void 0==b)throw k;k=new b;k.read(h); -return{packet:k,offset:a+j}};this.type={reserved:0,public_key_encrypted_session_key:1,signature:2,sym_encrypted_session_key:3,one_pass_signature:4,secret_key:5,public_key:6,secret_subkey:7,compressed:8,symmetrically_encrypted:9,marker:10,literal:11,trust:12,userid:13,public_subkey:14,user_attribute:17,sym_encrypted_integrity_protected:18,modification_detection_code:19}}var openpgp_packet=new _openpgp_packet; -function openpgp_packetlist(){this.length=0;this.read=function(a){for(var b=0;ba.length)return util.print_error("openpgp.packet.encryptedsessionkey.js\ninvalid length"),null;this.version=a[0].charCodeAt();this.public_key_id.read_packet(a,1);this.public_key_algorithm=a[9].charCodeAt(); -var b=10;switch(this.public_key_algorithm){case openpgp.publickey.rsa_encrypt:case openpgp.publickey.rsa_encrypt_sign:this.encrypted=[];this.encrypted[0]=new openpgp_type_mpi;this.encrypted[0].read(a.substr(b));break;case openpgp.publickey.elgamal:this.encrypted=[];this.encrypted[0]=new openpgp_type_mpi;b+=this.encrypted[0].read(a.substr(b));this.encrypted[1]=new openpgp_type_mpi;this.encrypted[1].read(a.substr(b));break;default:util.print_error("openpgp.packet.encryptedsessionkey.js\nunknown public key packet algorithm type "+ -this.public_key_algorithm)}};this.write=function(){for(var a=String.fromCharCode(this.version),a=a+this.public_key_id.bytes,a=a+String.fromCharCode(this.public_key_algorithm),b=0;b>8&255),b=b+String.fromCharCode(c&255),c=new openpgp_type_mpi;c.fromBytes(openpgp_encoding_eme_pkcs1_encode(b, -a[0].byteLength()));this.encrypted=openpgp_crypto_asymetricEncrypt(this.public_key_algorithm,a,c)};this.decrypt=function(a,b){var c=openpgp_crypto_asymetricDecrypt(this.public_key_algorithm,a,b,this.encrypted).toBytes(),d=(c.charCodeAt(c.length-2)<<8)+c.charCodeAt(c.length-1),c=openpgp_encoding_eme_pkcs1_decode(c,a[0].byteLength()),e=c.substring(1,c.length-2);d!=util.calc_checksum(e)?util.print_error("Checksum mismatch"):(this.symmetric_key=e,this.symmetric_algorithm=c.charCodeAt(0))};this.toString= -function(){for(var a="5.1. Public-Key Encrypted Session Key Packets (Tag 1)\n KeyId: "+this.keyId.toString()+"\n length: "+this.packetLength+"\n version:"+this.version+"\n pubAlgUs:"+this.publicKeyAlgorithmUsed+"\n",b=0;bthis.algorithm?2:16==this.algorithm?3:17==this.algorithm?4:0;this.mpi=[];for(var a=a.substr(6),c=0,d=0;da.length&&util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);return c+6}util.print_error("Unknown packet version")}};this.write=function(){var a=String.fromCharCode(4),a=a+openpgp_packet_time_write(this.created),a=a+String.fromCharCode(this.algorithm),b;for(b in this.mpi)a+=this.mpi[b].write();return a}}function openpgp_packet_public_subkey(){openpgp_packet_public_key.call(this);this.tag=14} -function openpgp_packet_secret_key(){this.tag=5;this.public_key=new openpgp_packet_public_key;this.mpi=[];this.symmetric_algorithm=openpgp.symmetric.plaintext;this.iv=this.encrypted=this.s2k=null;this.read=function(a){var b=this.public_key.read(a),a=a.substr(b),c=a[0].charCodeAt(),b=1;if(255==c||254==c)this.symmetric_algorithm=a[b++].charCodeAt(),this.s2k=new openpgp_type_s2k,b+=this.s2k.read(a.substr(b));if(0!=c&&255!=c&&254!=c)this.symmetric_algorithm=c;if(0!=c&&1001!=this.s2k.type)this.iv=a.substr(b, -openpgp_crypto_getBlockLength(this.symmetric_algorithm)),b+=this.iv.length;if(0!=c&&1001==this.s2k.type)this.encrypted=this.mpi=null;else if(0!=c)this.encrypted=a.substr(b);else{c=openpgp_crypto_getPrivateMpiCount(this.public_key.algorithm);this.mpi=[];for(var d=0;dthis.publicKey.publicKeyAlgorithm){var c=0;this.mpi=[];this.mpi[0]=new openpgp_type_mpi;this.mpi[0].read(a,0,b);c+=this.mpi[0].packetLength;this.mpi[1]=new openpgp_type_mpi;this.mpi[1].read(a,c,b-c);c+=this.mpi[1].packetLength;this.mpi[2]=new openpgp_type_mpi;this.mpi[2].read(a,c,b-c);c+=this.mpi[2].packetLength;this.mpi[3]=new openpgp_type_mpi;this.mpi[3].read(a,c,b-c); -c+=this.mpi[3].packetLength}else if(16==this.publicKey.publicKeyAlgorithm)this.mpi=[],this.mpi[0]=new openpgp_type_mpi,this.mpi[0].read(a,0,a);else if(17==this.publicKey.publicKeyAlgorithm)this.mpi=[],this.mpi[0]=new openpgp_type_mpi,this.mpi[0].read(a,0,b);return!0}}}function openpgp_packet_secret_subkey(){openpgp_packet_secret_key.call(this);this.tag=7}function openpgp_packet_signature(){this.tag=2;this.write=function(){};this.read=function(){}} -function openpgp_packet_sym_encrypted_integrity_protected(){this.tag=18;this.version=1;this.encrypted=null;this.modification=!1;this.packets=new openpgp_packetlist;this.read=function(a){this.version=a[0].charCodeAt();if(1!=this.version)return util.print_error("openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: "+this.version+"hex:"+util.hexstrdump(a)),null;this.encrypted=a.substr(1)};this.write=function(){return String.fromCharCode(this.version)+ -this.encrypted};this.encrypt=function(a,b){var c=this.packets.write(),d=openpgp_crypto_getPrefixRandom(a),e=d+d.charAt(d.length-2)+d.charAt(d.length-1),c=c+String.fromCharCode(211),c=c+String.fromCharCode(20);util.print_debug_hexstr_dump("data to be hashed:",e+c);c+=str_sha1(e+c);util.print_debug_hexstr_dump("hash:",c.substring(c.length-20,c.length));this.encrypted=openpgp_crypto_symmetricEncrypt(d,a,b,c,!1).substring(0,e.length+c.length)};this.decrypt=function(a,b){var c=openpgp_crypto_symmetricDecrypt(a, -b,this.encrypted,!1);this.hash=str_sha1(openpgp_crypto_MDCSystemBytes(a,b,this.encrypted)+c.substring(0,c.length-20));util.print_debug_hexstr_dump("calc hash = ",this.hash);this.hash!=c.substr(c.length-20,20)?(this.packets=new openpgp_packetlist,util.print_error("Decryption stopped: discovered a modification of encrypted data.")):this.packets.read(c.substr(0,c.length-22))};this.toString=function(){var a="";openpgp.config.debug&&(a=" data: Bytes ["+util.hexstrdump(this.encrypted)+"]");return"5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18)\n\n version: "+ -this.version+"\n"+a}} -function openpgp_packet_sym_encrypted_session_key(){this.tag=3;this.private_algorithm=null;this.algorithm=openpgp.symmetric.aes256;this.encrypted=null;this.s2k=new openpgp_type_s2k;this.read=function(a){this.version=a[0].charCodeAt();var b=a[1].charCodeAt(),c=this.s2k.read(a.substr(2))+2;cb[a].charCodeAt()?(packet_length=b[a++].charCodeAt(),c=1):192<=b[a].charCodeAt()&&224>b[a].charCodeAt()?(packet_length=(b[a++].charCodeAt()-192<<8)+b[a++].charCodeAt()+192,c=2):223b[a].charCodeAt()?(packet_length=1<<(b[a++].charCodeAt()& +31),c=1):(c=5,a++,packet_length=b[a++].charCodeAt()<<24|b[a++].charCodeAt()<<16|b[a++].charCodeAt()<<8|b[a++].charCodeAt());b[a++].charCodeAt();packet_length--;c++;this.userattributes[0]=[];this.userattributes[0]=b.substring(a,a+0);a+=packet_length;total_len+=c+0}return this};this.read_packet=read_packet;this.read_nodes=function(b,a,c,d){this.parentNode=b;for(var e=c,f=d;a.length!=e;){var g=openpgp_packet.read_packet(a,e,f);if(null==g){util.print_error("openpgp.packet.userattribute.js\n[user_attr] parsing ends here @:"+ +e+" l:"+f);break}else switch(g.tagType){case 2:15g.signatureType?this.certificationSignatures[this.certificationSignatures.length]=g:32==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);e+=g.packetLength+g.headerLength;f=d-(e-c);break;default:return this.data=a,this.position=c-b.packetLength,this.len=e-c}}this.data=a;this.position=c-b.packetLength;return this.len=e-c};this.toString=function(){for(var b="5.12. User Attribute Packet (Tag 17)\n AttributePackets: (count = "+ +this.userattributes.length+")\n",a=0;aa?b+=String.fromCharCode(a):191a?(b+=String.fromCharCode((a-192>>8)+192),b+=String.fromCharCode(a-192&255)):(b+=String.fromCharCode(255),b+=String.fromCharCode(a>>24&255),b+=String.fromCharCode(a>>16&255),b+=String.fromCharCode(a>>8&255),b+=String.fromCharCode(a&255));return b}this.encode_length=b;this.write_old_packet_header=function(a,b){var d="";256>b?(d+=String.fromCharCode(128|a<<2),d+=String.fromCharCode(b)):(65536>b?(d+=String.fromCharCode(a<< +2|129),d+=String.fromCharCode(b>>8)):(d+=String.fromCharCode(a<<2|130),d+=String.fromCharCode(b>>24&255),d+=String.fromCharCode(b>>16&255),d+=String.fromCharCode(b>>8&255)),d+=String.fromCharCode(b&255));return d};this.write_packet_header=function(a,c){var d;d=""+String.fromCharCode(192|a);return d+=b(c)};this.read_packet=function(a,b,d){if(null==a||a.length<=b||2>a.substring(b).length||0==(a[b].charCodeAt()&128))return util.print_error("Error during parsing. This message / key is probably not containing a valid OpenPGP format."), +null;var e=-1,f=-1,f=0;0!=(a[b].charCodeAt()&64)&&(f=1);var g;f?e=a[b].charCodeAt()&63:(e=(a[b].charCodeAt()&63)>>2,g=a[b].charCodeAt()&3);b++;var h=null,j=-1;if(f)if(192>a[b].charCodeAt())d=a[b++].charCodeAt(),util.print_debug("1 byte length:"+d);else if(192<=a[b].charCodeAt()&&224>a[b].charCodeAt())d=(a[b++].charCodeAt()-192<<8)+a[b++].charCodeAt()+192,util.print_debug("2 byte length:"+d);else if(223a[b].charCodeAt()){d=1<<(a[b++].charCodeAt()&31);util.print_debug("4 byte length:"+ +d);j=b+d;for(h=a.substring(b,b+d);;)if(192>a[j].charCodeAt()){g=a[j++].charCodeAt();d+=g;h+=a.substring(j,j+g);j+=g;break}else if(192<=a[j].charCodeAt()&&224>a[j].charCodeAt()){g=(a[j++].charCodeAt()-192<<8)+a[j++].charCodeAt()+192;d+=g;h+=a.substring(j,j+g);j+=g;break}else if(223a[j].charCodeAt())g=1<<(a[j++].charCodeAt()&31),d+=g,h+=a.substring(j,j+g),j+=g;else{j++;g=a[j++].charCodeAt()<<24|a[j++].charCodeAt()<<16|a[j++].charCodeAt()<<8|a[j++].charCodeAt();h+=a.substring(j, +j+g);d+=g;j+=g;break}}else b++,d=a[b++].charCodeAt()<<24|a[b++].charCodeAt()<<16|a[b++].charCodeAt()<<8|a[b++].charCodeAt();else switch(g){case 0:d=a[b++].charCodeAt();break;case 1:d=a[b++].charCodeAt()<<8|a[b++].charCodeAt();break;case 2:d=a[b++].charCodeAt()<<24|a[b++].charCodeAt()<<16|a[b++].charCodeAt()<<8|a[b++].charCodeAt();break}-1==j&&(j=d);null==h&&(h=a.substring(b,b+j));var a={},k;for(k in this.type)a[this.type[k]]=k;k="openpgp_packet_"+a[e];a=window[k];if(void 0==a)throw k;k=new a;k.read(h); +return{packet:k,offset:b+j}};this.type={reserved:0,public_key_encrypted_session_key:1,signature:2,sym_encrypted_session_key:3,one_pass_signature:4,secret_key:5,public_key:6,secret_subkey:7,compressed:8,symmetrically_encrypted:9,marker:10,literal:11,trust:12,userid:13,public_subkey:14,user_attribute:17,sym_encrypted_integrity_protected:18,modification_detection_code:19}}var openpgp_packet=new _openpgp_packet; +function openpgp_packetlist(){this.length=0;this.read=function(b){for(var a=0;ab.length)return util.print_error("openpgp.packet.encryptedsessionkey.js\ninvalid length"),null;this.version=b[0].charCodeAt();this.public_key_id.read_packet(b,1);this.public_key_algorithm=b[9].charCodeAt(); +var a=10;switch(this.public_key_algorithm){case openpgp.publickey.rsa_encrypt:case openpgp.publickey.rsa_encrypt_sign:this.encrypted=[];this.encrypted[0]=new openpgp_type_mpi;this.encrypted[0].read(b.substr(a));break;case openpgp.publickey.elgamal:this.encrypted=[];this.encrypted[0]=new openpgp_type_mpi;a+=this.encrypted[0].read(b.substr(a));this.encrypted[1]=new openpgp_type_mpi;this.encrypted[1].read(b.substr(a));break;default:util.print_error("openpgp.packet.encryptedsessionkey.js\nunknown public key packet algorithm type "+ +this.public_key_algorithm)}};this.write=function(){for(var b=String.fromCharCode(this.version),b=b+this.public_key_id.bytes,b=b+String.fromCharCode(this.public_key_algorithm),a=0;a>8&255),a=a+String.fromCharCode(c&255),c=new openpgp_type_mpi;c.fromBytes(openpgp_encoding_eme_pkcs1_encode(a, +b[0].byteLength()));this.encrypted=openpgp_crypto_asymetricEncrypt(this.public_key_algorithm,b,c)};this.decrypt=function(b,a){var c=openpgp_crypto_asymetricDecrypt(this.public_key_algorithm,b,a,this.encrypted).toBytes(),d=(c.charCodeAt(c.length-2)<<8)+c.charCodeAt(c.length-1),c=openpgp_encoding_eme_pkcs1_decode(c,b[0].byteLength()),e=c.substring(1,c.length-2);d!=util.calc_checksum(e)?util.print_error("Checksum mismatch"):(this.symmetric_key=e,this.symmetric_algorithm=c.charCodeAt(0))};this.toString= +function(){for(var b="5.1. Public-Key Encrypted Session Key Packets (Tag 1)\n KeyId: "+this.keyId.toString()+"\n length: "+this.packetLength+"\n version:"+this.version+"\n pubAlgUs:"+this.publicKeyAlgorithmUsed+"\n",a=0;athis.algorithm?2:16==this.algorithm?3:17==this.algorithm?4:0;this.mpi=[];for(var b=b.substr(6),c=0,d=0;db.length&&util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);return c+6}util.print_error("Unknown packet version")}};this.write=function(){var b=String.fromCharCode(4),b=b+openpgp_packet_time_write(this.created),b=b+String.fromCharCode(this.algorithm),a;for(a in this.mpi)b+=this.mpi[a].write();return b}}function openpgp_packet_public_subkey(){openpgp_packet_public_key.call(this);this.tag=14} +function openpgp_packet_secret_key(){this.tag=5;this.public_key=new openpgp_packet_public_key;this.mpi=[];this.symmetric_algorithm=openpgp.symmetric.plaintext;this.iv=this.encrypted=this.s2k=null;this.read=function(b){var a=this.public_key.read(b),b=b.substr(a),c=b[0].charCodeAt(),a=1;if(255==c||254==c)this.symmetric_algorithm=b[a++].charCodeAt(),this.s2k=new openpgp_type_s2k,a+=this.s2k.read(b.substr(a));if(0!=c&&255!=c&&254!=c)this.symmetric_algorithm=c;if(0!=c&&1001!=this.s2k.type)this.iv=b.substr(a, +openpgp_crypto_getBlockLength(this.symmetric_algorithm)),a+=this.iv.length;if(0!=c&&1001==this.s2k.type)this.encrypted=this.mpi=null;else if(0!=c)this.encrypted=b.substr(a);else{c=openpgp_crypto_getPrivateMpiCount(this.public_key.algorithm);this.mpi=[];for(var d=0;dthis.publicKey.publicKeyAlgorithm){var c=0;this.mpi=[];this.mpi[0]=new openpgp_type_mpi;this.mpi[0].read(b,0,a);c+=this.mpi[0].packetLength;this.mpi[1]=new openpgp_type_mpi;this.mpi[1].read(b,c,a-c);c+=this.mpi[1].packetLength;this.mpi[2]=new openpgp_type_mpi;this.mpi[2].read(b,c,a-c);c+=this.mpi[2].packetLength;this.mpi[3]=new openpgp_type_mpi;this.mpi[3].read(b,c,a-c); +c+=this.mpi[3].packetLength}else if(16==this.publicKey.publicKeyAlgorithm)this.mpi=[],this.mpi[0]=new openpgp_type_mpi,this.mpi[0].read(b,0,b);else if(17==this.publicKey.publicKeyAlgorithm)this.mpi=[],this.mpi[0]=new openpgp_type_mpi,this.mpi[0].read(b,0,a);return!0}}}function openpgp_packet_secret_subkey(){openpgp_packet_secret_key.call(this);this.tag=7}function openpgp_packet_signature(){this.tag=2;this.write=function(){};this.read=function(){}} +function openpgp_packet_sym_encrypted_integrity_protected(){this.tag=18;this.version=1;this.encrypted=null;this.modification=!1;this.packets=new openpgp_packetlist;this.read=function(b){this.version=b[0].charCodeAt();if(1!=this.version)return util.print_error("openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: "+this.version+"hex:"+util.hexstrdump(b)),null;this.encrypted=b.substr(1)};this.write=function(){return String.fromCharCode(this.version)+ +this.encrypted};this.encrypt=function(b,a){var c=this.packets.write(),d=openpgp_crypto_getPrefixRandom(b),e=d+d.charAt(d.length-2)+d.charAt(d.length-1),c=c+String.fromCharCode(211),c=c+String.fromCharCode(20);util.print_debug_hexstr_dump("data to be hashed:",e+c);c+=str_sha1(e+c);util.print_debug_hexstr_dump("hash:",c.substring(c.length-20,c.length));this.encrypted=openpgp_crypto_symmetricEncrypt(d,b,a,c,!1).substring(0,e.length+c.length)};this.decrypt=function(b,a){var c=openpgp_crypto_symmetricDecrypt(b, +a,this.encrypted,!1);this.hash=str_sha1(openpgp_crypto_MDCSystemBytes(b,a,this.encrypted)+c.substring(0,c.length-20));util.print_debug_hexstr_dump("calc hash = ",this.hash);this.hash!=c.substr(c.length-20,20)?(this.packets=new openpgp_packetlist,util.print_error("Decryption stopped: discovered a modification of encrypted data.")):this.packets.read(c.substr(0,c.length-22))};this.toString=function(){var b="";openpgp.config.debug&&(b=" data: Bytes ["+util.hexstrdump(this.encrypted)+"]");return"5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18)\n\n version: "+ +this.version+"\n"+b}} +function openpgp_packet_sym_encrypted_session_key(){this.tag=3;this.private_algorithm=null;this.algorithm=openpgp.symmetric.aes256;this.encrypted=null;this.s2k=new openpgp_type_s2k;this.read=function(b){this.version=b[0].charCodeAt();var a=b[1].charCodeAt(),c=this.s2k.read(b.substr(2))+2;c>8*(b.length-d-1)^255);return c}function openpgp_packet_time_read(a){var a=openpgp_packet_number_read(a),b=new Date;b.setTime(1E3*a);return b} -function openpgp_packet_time_write(){var a=Math.round(this.time.getTime()/1E3);return openpgp_packet_number_write(a,4)}function openpgp_packet_userid(){this.userid="";this.tag=13;this.read=function(a){this.userid=util.decode_utf8(a)};this.write=function(){return util.encode_utf8(this.userid)}} -function openpgp_type_mpi(){this.data=null;this.read=function(a){var b=a[0].charCodeAt()<<8|a[1].charCodeAt(),b=Math.ceil(b/8);this.fromBytes(a.substr(2,b));return 2+b};this.fromBytes=function(a){this.data=new BigInteger(util.hexstrdump(a),16)};this.toBytes=function(){return this.write().substr(2)};this.byteLength=function(){return this.toBytes().length};this.write=function(){return this.data.toMPI()};this.toBigInteger=function(){return this.data.clone()};this.fromBigInteger=function(a){this.data= -a.clone()};this.toString=function(){var a=" MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x",a=a+util.hexstrdump(this.MPI);return a+"\n"}}function openpgp_type_keyid(){for(var a="",b=0;8>b;b++)a+=String.fromCharCode(0);this.read_packet=function(a,b){this.bytes=a.substring(b,b+8);return this};this.toString=function(){return util.hexstrdump(this.bytes)}} -function openpgp_type_s2k(){this.read=function(a,b){var c=b;this.type=a[c++].charCodeAt();switch(this.type){case 0:this.hashAlgorithm=a[c++].charCodeAt();this.s2kLength=1;break;case 1:this.hashAlgorithm=a[c++].charCodeAt();this.saltValue=a.substring(c,c+8);c+=8;this.s2kLength=9;break;case 3:this.hashAlgorithm=a[c++].charCodeAt();this.saltValue=a.substring(c,c+8);c+=8;this.EXPBIAS=6;var d=a[c++].charCodeAt();this.count=16+(d&15)<<(d>>4)+this.EXPBIAS;this.s2kLength=10;break;case 101:"GNU"==a.substring(c+ -1,c+4)?(this.hashAlgorithm=a[c++].charCodeAt(),c+=3,d=1E3+a[c++].charCodeAt(),1001==d?(this.type=d,this.s2kLength=5):util.print_error("unknown s2k gnu protection mode! "+this.type)):util.print_error("unknown s2k type! "+this.type);break;default:util.print_error("unknown s2k type! "+this.type)}this.packetLength=c-b;return this};this.write=function(a,b,c,d,e){this.type=a;if(3==this.type)this.saltValue=d,this.hashAlgorithm=b,this.count=16+(e&15)<<(e>>4)+6,this.s2kLength=10;return this.produce_key(c)}; -this.produce_key=function(a,b){var a=util.encode_utf8(a),c;if(0==this.type)c=openpgp_crypto_hashData(this.hashAlgorithm,a);else if(1==this.type)c=openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+a);else if(3==this.type){c=[];for(c[0]=this.saltValue+a;c.length*(this.saltValue+a).lengththis.count&&(c=c.substr(0,this.count));c=b&&(24==b||32==b)?openpgp_crypto_hashData(this.hashAlgorithm,c)+openpgp_crypto_hashData(this.hashAlgorithm, -String.fromCharCode(0)+c):openpgp_crypto_hashData(this.hashAlgorithm,c)}else return null;return c.substr(0,b)}} -function openpgp_type_s2k(){this.algorithm=openpgp.hash.sha256;this.type=openpgp_type_s2k.type.iterated;this.c=10;this.salt=openpgp_crypto_getRandomBytes(8);this.get_count=function(){return 16+(this.c&15)<<(this.c>>4)+6};this.read=function(a){var b=0;this.type=a[b++].charCodeAt();this.algorithm=a[b++].charCodeAt();var c=openpgp_type_s2k.type;switch(this.type){case c.simple:break;case c.salted:this.salt=a.substr(b,8);b+=8;break;case c.iterated:this.salt=a.substr(b,8);b+=8;this.c=a[b++].charCodeAt(); -break;case c.gnu:"GNU"==a.substr(b,3)?(b+=3,a=1E3+a[b++].charCodeAt(),1001==a?this.type=a:util.print_error("unknown s2k gnu protection mode! "+this.type)):util.print_error("unknown s2k type! "+this.type);break;default:util.print_error("unknown s2k type! "+this.type)}return b};this.write=function(){var a=String.fromCharCode(this.type),a=a+String.fromCharCode(this.algorithm),b=openpgp_type_s2k.type;switch(this.type){case b.salted:a+=this.salt;break;case b.iterated:a+=this.salt,a+=String.fromCharCode(this.c)}return a}; -this.produce_key=function(a,b){for(var a=util.encode_utf8(a),c="",d="";c.length<=b;){var e;a:{e=d;var f=openpgp_type_s2k.type;switch(this.type){case f.simple:e=openpgp_crypto_hashData(this.algorithm,e+a);break a;case f.salted:e=openpgp_crypto_hashData(this.algorithm,e+this.salt+a);break a;case f.iterated:var f=[],g=this.get_count();for(data=this.salt+a;f.length*data.lengthg&&(f=f.substr(0,g));e=openpgp_crypto_hashData(this.algorithm,e+f);break a}e=void 0}c+= -e;d+=String.fromCharCode(0)}return c.substr(0,b)}}openpgp_type_s2k.type={simple:0,salted:1,iterated:3,gnu:101}; -var Util=function(){this.emailRegEx=/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;this.debug=!1;this.hexdump=function(a){for(var b=[],e=a.length,f=0,g,h=0;fg.length;)g="0"+g;b.push(" "+g);h++;0==h%32&&b.push("\n ")}return b.join("")};this.hexstrdump=function(a){if(null==a)return"";for(var b=[],e=a.length,f=0,g;f -g.length;)g="0"+g;b.push(""+g)}return b.join("")};this.hex2bin=function(a){for(var b="",e=0;eg.length;)g="0"+g;b.push(""+g)}return b.join("")};this.encode_utf8=function(a){return unescape(encodeURIComponent(a))};this.decode_utf8=function(a){return decodeURIComponent(escape(a))};var a=function(a,b){for(var e=0;e>8*(a-d-1)&255);return c}function openpgp_packet_time_read(b){var b=openpgp_packet_number_read(b),a=new Date;a.setTime(1E3*b);return a} +function openpgp_packet_time_write(b){b=Math.round(b.getTime()/1E3);return openpgp_packet_number_write(b,4)}function openpgp_packet_userid(){this.userid="";this.tag=13;this.read=function(b){this.userid=util.decode_utf8(b)};this.write=function(){return util.encode_utf8(this.userid)}} +function openpgp_type_mpi(){this.data=null;this.read=function(b){var a=b[0].charCodeAt()<<8|b[1].charCodeAt(),a=Math.ceil(a/8);this.fromBytes(b.substr(2,a));return 2+a};this.fromBytes=function(b){this.data=new BigInteger(util.hexstrdump(b),16)};this.toBytes=function(){return this.write().substr(2)};this.byteLength=function(){return this.toBytes().length};this.write=function(){return this.data.toMPI()};this.toBigInteger=function(){return this.data.clone()};this.fromBigInteger=function(b){this.data= +b.clone()};this.toString=function(){var b=" MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x",b=b+util.hexstrdump(this.MPI);return b+"\n"}}function openpgp_type_keyid(){for(var b="",a=0;8>a;a++)b+=String.fromCharCode(0);this.read_packet=function(b,a){this.bytes=b.substring(a,a+8);return this};this.toString=function(){return util.hexstrdump(this.bytes)}} +function openpgp_type_s2k(){this.read=function(b,a){var c=a;this.type=b[c++].charCodeAt();switch(this.type){case 0:this.hashAlgorithm=b[c++].charCodeAt();this.s2kLength=1;break;case 1:this.hashAlgorithm=b[c++].charCodeAt();this.saltValue=b.substring(c,c+8);c+=8;this.s2kLength=9;break;case 3:this.hashAlgorithm=b[c++].charCodeAt();this.saltValue=b.substring(c,c+8);c+=8;this.EXPBIAS=6;var d=b[c++].charCodeAt();this.count=16+(d&15)<<(d>>4)+this.EXPBIAS;this.s2kLength=10;break;case 101:"GNU"==b.substring(c+ +1,c+4)?(this.hashAlgorithm=b[c++].charCodeAt(),c+=3,d=1E3+b[c++].charCodeAt(),1001==d?(this.type=d,this.s2kLength=5):util.print_error("unknown s2k gnu protection mode! "+this.type)):util.print_error("unknown s2k type! "+this.type);break;default:util.print_error("unknown s2k type! "+this.type)}this.packetLength=c-a;return this};this.write=function(b,a,c,d,e){this.type=b;if(3==this.type)this.saltValue=d,this.hashAlgorithm=a,this.count=16+(e&15)<<(e>>4)+6,this.s2kLength=10;return this.produce_key(c)}; +this.produce_key=function(b,a){var b=util.encode_utf8(b),c;if(0==this.type)c=openpgp_crypto_hashData(this.hashAlgorithm,b);else if(1==this.type)c=openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+b);else if(3==this.type){c=[];for(c[0]=this.saltValue+b;c.length*(this.saltValue+b).lengththis.count&&(c=c.substr(0,this.count));c=a&&(24==a||32==a)?openpgp_crypto_hashData(this.hashAlgorithm,c)+openpgp_crypto_hashData(this.hashAlgorithm, +String.fromCharCode(0)+c):openpgp_crypto_hashData(this.hashAlgorithm,c)}else return null;return c.substr(0,a)}} +function openpgp_type_s2k(){this.algorithm=openpgp.hash.sha256;this.type=openpgp_type_s2k.type.iterated;this.c=10;this.salt=openpgp_crypto_getRandomBytes(8);this.get_count=function(){return 16+(this.c&15)<<(this.c>>4)+6};this.read=function(b){var a=0;this.type=b[a++].charCodeAt();this.algorithm=b[a++].charCodeAt();var c=openpgp_type_s2k.type;switch(this.type){case c.simple:break;case c.salted:this.salt=b.substr(a,8);a+=8;break;case c.iterated:this.salt=b.substr(a,8);a+=8;this.c=b[a++].charCodeAt(); +break;case c.gnu:"GNU"==b.substr(a,3)?(a+=3,b=1E3+b[a++].charCodeAt(),1001==b?this.type=b:util.print_error("unknown s2k gnu protection mode! "+this.type)):util.print_error("unknown s2k type! "+this.type);break;default:util.print_error("unknown s2k type! "+this.type)}return a};this.write=function(){var b=String.fromCharCode(this.type),b=b+String.fromCharCode(this.algorithm),a=openpgp_type_s2k.type;switch(this.type){case a.salted:b+=this.salt;break;case a.iterated:b+=this.salt,b+=String.fromCharCode(this.c)}return b}; +this.produce_key=function(b,a){for(var b=util.encode_utf8(b),c="",d="";c.length<=a;){var e;a:{e=d;var f=openpgp_type_s2k.type;switch(this.type){case f.simple:e=openpgp_crypto_hashData(this.algorithm,e+b);break a;case f.salted:e=openpgp_crypto_hashData(this.algorithm,e+this.salt+b);break a;case f.iterated:var f=[],g=this.get_count();for(data=this.salt+b;f.length*data.lengthg&&(f=f.substr(0,g));e=openpgp_crypto_hashData(this.algorithm,e+f);break a}e=void 0}c+= +e;d+=String.fromCharCode(0)}return c.substr(0,a)}}openpgp_type_s2k.type={simple:0,salted:1,iterated:3,gnu:101}; +var Util=function(){this.emailRegEx=/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;this.debug=!1;this.hexdump=function(b){for(var a=[],e=b.length,f=0,g,h=0;fg.length;)g="0"+g;a.push(" "+g);h++;0==h%32&&a.push("\n ")}return a.join("")};this.hexstrdump=function(b){if(null==b)return"";for(var a=[],e=b.length,f=0,g;f +g.length;)g="0"+g;a.push(""+g)}return a.join("")};this.hex2bin=function(b){for(var a="",e=0;eg.length;)g="0"+g;a.push(""+g)}return a.join("")};this.encode_utf8=function(b){return unescape(encodeURIComponent(b))};this.decode_utf8=function(b){return decodeURIComponent(escape(b))};var b=function(b,a){for(var e=0;e>=b%8,0> 24) & 0xFF); - result += String - .fromCharCode((Math.round(this.date.getTime() / 1000) >> 16) & 0xFF); - result += String - .fromCharCode((Math.round(this.date.getTime() / 1000) >> 8) & 0xFF); - result += String - .fromCharCode(Math.round(this.date.getTime() / 1000) & 0xFF); + result += openpgp_packet_time_write(this.date); result += data; return result; } diff --git a/src/packet/time.js b/src/packet/time.js index 97afb9bd..ff6aecbb 100644 --- a/src/packet/time.js +++ b/src/packet/time.js @@ -5,7 +5,8 @@ function openpgp_packet_number_read(bytes) { var n = 0; for(var i = 0; i < bytes.length; i++) { - n += bytes[i].charCodeAt() * 8 * (bytes.length - i - 1); + n <<= 8; + n += bytes[i].charCodeAt() } return n; @@ -14,7 +15,7 @@ function openpgp_packet_number_read(bytes) { function openpgp_packet_number_write(n, bytes) { var b = ''; for(var i = 0; i < bytes; i++) { - b += String.fromCharCode((n >> 8 * (bytes.length - i - 1)) ^ 0xFF); + b += String.fromCharCode((n >> (8 * (bytes- i - 1))) & 0xFF); } return b; @@ -30,7 +31,7 @@ function openpgp_packet_time_read(bytes) { } function openpgp_packet_time_write(time) { - var numeric = Math.round(this.time.getTime() / 1000); + var numeric = Math.round(time.getTime() / 1000); return openpgp_packet_number_write(numeric, 4); }