Fix signing with version 3 keys
This commit is contained in:
parent
1f4911450b
commit
84f6483cba
1635
resources/openpgp.js
1635
resources/openpgp.js
File diff suppressed because it is too large
Load Diff
216
resources/openpgp.min.js
vendored
216
resources/openpgp.min.js
vendored
|
@ -2,29 +2,7 @@ function DSA(){this.select_hash_algorithm=function(b){var a=openpgp.config.confi
|
|||
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(0<BigInteger.ZERO.compareTo(a)||0<a.compareTo(f)||0<BigInteger.ZERO.compareTo(c)||0<c.compareTo(f))return util.print_error("invalid DSA Signature"),null;c=c.modInverse(f);b=b.multiply(c).mod(f);a=a.multiply(c).mod(f);
|
||||
return g.modPow(b,e).multiply(h.modPow(a,e)).mod(e).mod(f)}}
|
||||
function Elgamal(){this.encrypt=function(b,a,c,d){var e=BigInteger.ONE.add(BigInteger.ONE),f=c.subtract(e),e=openpgp_crypto_getRandomBigIntegerInRange(e,f),e=e.mod(f).add(BigInteger.ONE),f=[];f[0]=a.modPow(e,c);f[1]=d.modPow(e,c).multiply(b).mod(c).toMPI();f[0]=f[0].toMPI();return f};this.decrypt=function(b,a,c,d){util.print_debug("Elgamal Decrypt:\nc1:"+util.hexstrdump(b.toMPI())+"\nc2:"+util.hexstrdump(a.toMPI())+"\np:"+util.hexstrdump(c.toMPI())+"\nx:"+util.hexstrdump(d.toMPI()));return b.modPow(d,
|
||||
c).modInverse(c).multiply(a).mod(c)}}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<<dbits)-1;BigInteger.prototype.DV=1<<dbits;var BI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP);BigInteger.prototype.F1=BI_FP-dbits;BigInteger.prototype.F2=2*dbits-BI_FP;var BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=[],rr,vv;
|
||||
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;0<b?this[0]=b:-1>b?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)-1)<<f,this[this.t++]=g>>this.DB-f):this[this.t-1]|=g<<f,f+=c,f>=this.DB&&(f-=this.DB))}if(8==c&&0!=(b[0]&128))this.s=-1,0<f&&(this[this.t-1]|=(1<<
|
||||
this.DB-f)-1<<f);this.clamp();e&&BigInteger.ZERO.subTo(this,this)}function bnpClamp(){for(var b=this.s&this.DM;0<this.t&&this[this.t-1]==b;)--this.t}
|
||||
function bnToString(b){if(0>this.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<<b)-1,c,d=!1,e="",f=this.t,g=this.DB-f*this.DB%b;if(0<f--){if(g<this.DB&&0<(c=this[f]>>g))d=!0,e=int2char(c);for(;0<=f;)g<b?(c=(this[f]&(1<<g)-1)<<b-g,c|=this[--f]>>(g+=this.DB-b)):(c=this[f]>>(g-=b)&a,0>=g&&(g+=this.DB,--f)),0<c&&(d=!0),d&&(e+=int2char(c))}return d?e:"0"}
|
||||
function bnNegate(){var b=nbi();BigInteger.ZERO.subTo(this,b);return b}function bnAbs(){return 0>this.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<this.t;++c)a[c-b]=this[c];a.t=Math.max(this.t-b,0);a.s=this.s}
|
||||
function bnpLShiftTo(b,a){var c=b%this.DB,d=this.DB-c,e=(1<<d)-1,f=Math.floor(b/this.DB),g=this.s<<c&this.DM,h;for(h=this.t-1;0<=h;--h)a[h+f+1]=this[h]>>d|g,g=(this[h]&e)<<c;for(h=f-1;0<=h;--h)a[h]=0;a[f]=g;a.t=this.t+f+1;a.s=this.s;a.clamp()}
|
||||
function bnpRShiftTo(b,a){a.s=this.s;var c=Math.floor(b/this.DB);if(c>=this.t)a.t=0;else{var d=b%this.DB,e=this.DB-d,f=(1<<d)-1;a[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)a[g-c-1]|=(this[g]&f)<<e,a[g-c]=this[g]>>d;0<d&&(a[this.t-c-1]|=(this.s&f)<<e);a.t=this.t-c;a.clamp()}}
|
||||
function bnpSubTo(b,a){for(var c=0,d=0,e=Math.min(b.t,this.t);c<e;)d+=this[c]-b[c],a[c++]=d&this.DM,d>>=this.DB;if(b.t<this.t){for(d-=b.s;c<this.t;)d+=this[c],a[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<b.t;)d-=b[c],a[c++]=d&this.DM,d>>=this.DB;d-=b.s}a.s=0>d?-1:0;-1>d?a[c++]=this.DV+d:0<d&&(a[c++]=d);a.t=c;a.clamp()}
|
||||
function bnpMultiplyTo(b,a){var c=this.abs(),d=b.abs(),e=c.t;for(a.t=e+d.t;0<=--e;)a[e]=0;for(e=0;e<d.t;++e)a[e+c.t]=c.am(0,d[e],a,e,0,c.t);a.s=0;a.clamp();this.s!=b.s&&BigInteger.ZERO.subTo(a,a)}function bnpSquareTo(b){for(var a=this.abs(),c=b.t=2*a.t;0<=--c;)b[c]=0;for(c=0;c<a.t-1;++c){var d=a.am(c,a[c],b,2*c,0,1);if((b[c+a.t]+=a.am(c+1,2*a[c],b,2*c+1,d,a.t-c-1))>=a.DV)b[c+a.t]-=a.DV,b[c+a.t+1]=1}0<b.t&&(b[b.t-1]+=a.am(c,a[c],b,2*c,0,1));b.s=0;b.clamp()}
|
||||
function bnpDivRemTo(b,a,c){var d=b.abs();if(!(0>=d.t)){var e=this.abs();if(e.t<d.t)null!=a&&a.fromInt(0),null!=c&&this.copyTo(c);else{null==c&&(c=nbi());var f=nbi(),g=this.s,b=b.s,h=this.DB-nbits(d[d.t-1]);0<h?(d.lShiftTo(h,f),e.lShiftTo(h,c)):(d.copyTo(f),e.copyTo(c));d=f.t;e=f[d-1];if(0!=e){var j=e*(1<<this.F1)+(1<d?f[d-2]>>this.F2:0),k=this.FV/j,j=(1<<this.F1)/j,l=1<<this.F2,m=c.t,r=m-d,p=null==a?nbi():a;f.dlShiftTo(r,p);0<=c.compareTo(p)&&(c[c.t++]=1,c.subTo(p,c));BigInteger.ONE.dlShiftTo(d,
|
||||
p);for(p.subTo(f,f);f.t<d;)f[f.t++]=0;for(;0<=--r;){var o=c[--m]==e?this.DM:Math.floor(c[m]*k+(c[m-1]+l)*j);if((c[m]+=f.am(0,o,c,r,0,d))<o){f.dlShiftTo(r,p);for(c.subTo(p,c);c[m]<--o;)c.subTo(p,c)}}null!=a&&(c.drShiftTo(d,a),g!=b&&BigInteger.ZERO.subTo(a,a));c.t=d;c.clamp();0<h&&c.rShiftTo(h,c);0>g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(b){var a=nbi();this.abs().divRemTo(b,null,a);0>this.s&&0<a.compareTo(BigInteger.ZERO)&&b.subTo(a,a);return a}function Classic(b){this.m=b}
|
||||
function cConvert(b){return 0>b.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<a?this.DV-a:-a}function Montgomery(b){this.m=b;this.mp=b.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<b.DB-15)-1;this.mt2=2*b.t}
|
||||
function montConvert(b){var a=nbi();b.abs().dlShiftTo(this.m.t,a);a.divRemTo(this.m,null,a);0>b.s&&0<a.compareTo(BigInteger.ZERO)&&this.m.subTo(a,a);return a}function montRevert(b){var a=nbi();b.copyTo(a);this.reduce(a);return a}
|
||||
function montReduce(b){for(;b.t<=this.mt2;)b[b.t++]=0;for(var a=0;a<this.m.t;++a){var c=b[a]&32767,d=c*this.mpl+((c*this.mph+(b[a]>>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==(0<this.t?this[0]&1:this.s)}function bnpExp(b,a){if(4294967295<b||1>b)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<<f))a.mulTo(d,e,c);else var g=c,c=d,d=g;return a.revert(c)}
|
||||
function bnModPowInt(b,a){var c;c=256>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 bnClone(){var b=nbi();this.copyTo(b);return b}function bnIntValue(){if(0>this.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)<<this.DB|this[0]}function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>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))}
|
||||
c).modInverse(c).multiply(a).mod(c)}}function bnClone(){var b=nbi();this.copyTo(b);return b}function bnIntValue(){if(0>this.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)<<this.DB|this[0]}function bnByteValue(){return 0==this.t?this.s:this[0]<<24>>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||36<b)return"0";var a=this.chunkSize(b),a=Math.pow(b,a),c=nbv(a),d=nbi(),e=nbi(),f="";for(this.divRemTo(c,d,e);0<d.signum();)f=(a+e.intValue()).toString(b).substr(1)+f,d.divRemTo(c,d,e);return e.intValue().toString(b)+f}
|
||||
function bnpFromRadix(b,a){this.fromInt(0);null==a&&(a=10);for(var c=this.chunkSize(a),d=Math.pow(a,c),e=!1,f=0,g=0,h=0;h<b.length;++h){var j=intAt(b,h);0>j?"-"==b.charAt(h)&&0==this.signum()&&(e=!0):(g=a*g+j,++f>=c&&(this.dMultiply(d),this.dAddOffset(g,0),g=f=0))}0<f&&(this.dMultiply(Math.pow(a,f)),this.dAddOffset(g,0));e&&BigInteger.ZERO.subTo(this,this)}
|
||||
function bnpFromNumber(b,a,c){if("number"==typeof a)if(2>b)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<d?c[0]&(1<<d)-1:0;this.fromString(c,256)}}
|
||||
|
@ -55,7 +33,29 @@ BigInteger.prototype.chunkSize=bnpChunkSize;BigInteger.prototype.toRadix=bnpToRa
|
|||
BigInteger.prototype.modInt=bnpModInt;BigInteger.prototype.millerRabin=bnpMillerRabin;BigInteger.prototype.clone=bnClone;BigInteger.prototype.intValue=bnIntValue;BigInteger.prototype.byteValue=bnByteValue;BigInteger.prototype.shortValue=bnShortValue;BigInteger.prototype.signum=bnSigNum;BigInteger.prototype.toByteArray=bnToByteArray;BigInteger.prototype.equals=bnEquals;BigInteger.prototype.min=bnMin;BigInteger.prototype.max=bnMax;BigInteger.prototype.and=bnAnd;BigInteger.prototype.or=bnOr;
|
||||
BigInteger.prototype.xor=bnXor;BigInteger.prototype.andNot=bnAndNot;BigInteger.prototype.not=bnNot;BigInteger.prototype.shiftLeft=bnShiftLeft;BigInteger.prototype.shiftRight=bnShiftRight;BigInteger.prototype.getLowestSetBit=bnGetLowestSetBit;BigInteger.prototype.bitCount=bnBitCount;BigInteger.prototype.testBit=bnTestBit;BigInteger.prototype.setBit=bnSetBit;BigInteger.prototype.clearBit=bnClearBit;BigInteger.prototype.flipBit=bnFlipBit;BigInteger.prototype.add=bnAdd;BigInteger.prototype.subtract=bnSubtract;
|
||||
BigInteger.prototype.multiply=bnMultiply;BigInteger.prototype.divide=bnDivide;BigInteger.prototype.remainder=bnRemainder;BigInteger.prototype.divideAndRemainder=bnDivideAndRemainder;BigInteger.prototype.modPow=bnModPow;BigInteger.prototype.modInverse=bnModInverse;BigInteger.prototype.pow=bnPow;BigInteger.prototype.gcd=bnGCD;BigInteger.prototype.isProbablePrime=bnIsProbablePrime;BigInteger.prototype.toMPI=bnToMPI;BigInteger.prototype.square=bnSquare;
|
||||
function SecureRandom(){this.nextBytes=function(b){for(var a=0;a<b.length;a++)b[a]=openpgp_crypto_getSecureRandomOctet()}}
|
||||
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<<dbits)-1;BigInteger.prototype.DV=1<<dbits;var BI_FP=52;BigInteger.prototype.FV=Math.pow(2,BI_FP);BigInteger.prototype.F1=BI_FP-dbits;BigInteger.prototype.F2=2*dbits-BI_FP;var BI_RM="0123456789abcdefghijklmnopqrstuvwxyz",BI_RC=[],rr,vv;
|
||||
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;0<b?this[0]=b:-1>b?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)-1)<<f,this[this.t++]=g>>this.DB-f):this[this.t-1]|=g<<f,f+=c,f>=this.DB&&(f-=this.DB))}if(8==c&&0!=(b[0]&128))this.s=-1,0<f&&(this[this.t-1]|=(1<<
|
||||
this.DB-f)-1<<f);this.clamp();e&&BigInteger.ZERO.subTo(this,this)}function bnpClamp(){for(var b=this.s&this.DM;0<this.t&&this[this.t-1]==b;)--this.t}
|
||||
function bnToString(b){if(0>this.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<<b)-1,c,d=!1,e="",f=this.t,g=this.DB-f*this.DB%b;if(0<f--){if(g<this.DB&&0<(c=this[f]>>g))d=!0,e=int2char(c);for(;0<=f;)g<b?(c=(this[f]&(1<<g)-1)<<b-g,c|=this[--f]>>(g+=this.DB-b)):(c=this[f]>>(g-=b)&a,0>=g&&(g+=this.DB,--f)),0<c&&(d=!0),d&&(e+=int2char(c))}return d?e:"0"}
|
||||
function bnNegate(){var b=nbi();BigInteger.ZERO.subTo(this,b);return b}function bnAbs(){return 0>this.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<this.t;++c)a[c-b]=this[c];a.t=Math.max(this.t-b,0);a.s=this.s}
|
||||
function bnpLShiftTo(b,a){var c=b%this.DB,d=this.DB-c,e=(1<<d)-1,f=Math.floor(b/this.DB),g=this.s<<c&this.DM,h;for(h=this.t-1;0<=h;--h)a[h+f+1]=this[h]>>d|g,g=(this[h]&e)<<c;for(h=f-1;0<=h;--h)a[h]=0;a[f]=g;a.t=this.t+f+1;a.s=this.s;a.clamp()}
|
||||
function bnpRShiftTo(b,a){a.s=this.s;var c=Math.floor(b/this.DB);if(c>=this.t)a.t=0;else{var d=b%this.DB,e=this.DB-d,f=(1<<d)-1;a[0]=this[c]>>d;for(var g=c+1;g<this.t;++g)a[g-c-1]|=(this[g]&f)<<e,a[g-c]=this[g]>>d;0<d&&(a[this.t-c-1]|=(this.s&f)<<e);a.t=this.t-c;a.clamp()}}
|
||||
function bnpSubTo(b,a){for(var c=0,d=0,e=Math.min(b.t,this.t);c<e;)d+=this[c]-b[c],a[c++]=d&this.DM,d>>=this.DB;if(b.t<this.t){for(d-=b.s;c<this.t;)d+=this[c],a[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<b.t;)d-=b[c],a[c++]=d&this.DM,d>>=this.DB;d-=b.s}a.s=0>d?-1:0;-1>d?a[c++]=this.DV+d:0<d&&(a[c++]=d);a.t=c;a.clamp()}
|
||||
function bnpMultiplyTo(b,a){var c=this.abs(),d=b.abs(),e=c.t;for(a.t=e+d.t;0<=--e;)a[e]=0;for(e=0;e<d.t;++e)a[e+c.t]=c.am(0,d[e],a,e,0,c.t);a.s=0;a.clamp();this.s!=b.s&&BigInteger.ZERO.subTo(a,a)}function bnpSquareTo(b){for(var a=this.abs(),c=b.t=2*a.t;0<=--c;)b[c]=0;for(c=0;c<a.t-1;++c){var d=a.am(c,a[c],b,2*c,0,1);if((b[c+a.t]+=a.am(c+1,2*a[c],b,2*c+1,d,a.t-c-1))>=a.DV)b[c+a.t]-=a.DV,b[c+a.t+1]=1}0<b.t&&(b[b.t-1]+=a.am(c,a[c],b,2*c,0,1));b.s=0;b.clamp()}
|
||||
function bnpDivRemTo(b,a,c){var d=b.abs();if(!(0>=d.t)){var e=this.abs();if(e.t<d.t)null!=a&&a.fromInt(0),null!=c&&this.copyTo(c);else{null==c&&(c=nbi());var f=nbi(),g=this.s,b=b.s,h=this.DB-nbits(d[d.t-1]);0<h?(d.lShiftTo(h,f),e.lShiftTo(h,c)):(d.copyTo(f),e.copyTo(c));d=f.t;e=f[d-1];if(0!=e){var j=e*(1<<this.F1)+(1<d?f[d-2]>>this.F2:0),k=this.FV/j,j=(1<<this.F1)/j,l=1<<this.F2,m=c.t,r=m-d,p=null==a?nbi():a;f.dlShiftTo(r,p);0<=c.compareTo(p)&&(c[c.t++]=1,c.subTo(p,c));BigInteger.ONE.dlShiftTo(d,
|
||||
p);for(p.subTo(f,f);f.t<d;)f[f.t++]=0;for(;0<=--r;){var o=c[--m]==e?this.DM:Math.floor(c[m]*k+(c[m-1]+l)*j);if((c[m]+=f.am(0,o,c,r,0,d))<o){f.dlShiftTo(r,p);for(c.subTo(p,c);c[m]<--o;)c.subTo(p,c)}}null!=a&&(c.drShiftTo(d,a),g!=b&&BigInteger.ZERO.subTo(a,a));c.t=d;c.clamp();0<h&&c.rShiftTo(h,c);0>g&&BigInteger.ZERO.subTo(c,c)}}}}function bnMod(b){var a=nbi();this.abs().divRemTo(b,null,a);0>this.s&&0<a.compareTo(BigInteger.ZERO)&&b.subTo(a,a);return a}function Classic(b){this.m=b}
|
||||
function cConvert(b){return 0>b.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<a?this.DV-a:-a}function Montgomery(b){this.m=b;this.mp=b.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<b.DB-15)-1;this.mt2=2*b.t}
|
||||
function montConvert(b){var a=nbi();b.abs().dlShiftTo(this.m.t,a);a.divRemTo(this.m,null,a);0>b.s&&0<a.compareTo(BigInteger.ZERO)&&this.m.subTo(a,a);return a}function montRevert(b){var a=nbi();b.copyTo(a);this.reduce(a);return a}
|
||||
function montReduce(b){for(;b.t<=this.mt2;)b[b.t++]=0;for(var a=0;a<this.m.t;++a){var c=b[a]&32767,d=c*this.mpl+((c*this.mph+(b[a]>>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==(0<this.t?this[0]&1:this.s)}function bnpExp(b,a){if(4294967295<b||1>b)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<<f))a.mulTo(d,e,c);else var g=c,c=d,d=g;return a.revert(c)}
|
||||
function bnModPowInt(b,a){var c;c=256>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(b){for(var a=0;a<b.length;a++)b[a]=openpgp_crypto_getSecureRandomOctet()}}
|
||||
function RSA(){function b(){this.n=null;this.e=0;this.u=this.dmq1=this.dmp1=this.q=this.p=this.d=this.ee=null}this.encrypt=function(a,b,d){return a.modPowInt(b,d)};this.decrypt=function(a,b,d,e,f){var g=a.mod(d).modPow(b.mod(d.subtract(BigInteger.ONE)),d),a=a.mod(e).modPow(b.mod(e.subtract(BigInteger.ONE)),e);util.print_debug("rsa.js decrypt\nxpn:"+util.hexstrdump(g.toMPI())+"\nxqn:"+util.hexstrdump(a.toMPI()));b=a.subtract(g);0==b[0]?(b=g.subtract(a),b=b.multiply(f).mod(e),b=e.subtract(b)):b=b.multiply(f).mod(e);
|
||||
return b.multiply(d).add(g)};this.verify=function(a,b,d){return a.modPowInt(b,d)};this.sign=function(a,b,d){return a.modPow(b,d)};this.generate=function(a,c){var d=new b,e=new SecureRandom,f=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)}
|
||||
|
@ -85,15 +85,15 @@ h;f=(a.lowOrder&65535)+(c.lowOrder&65535)+(d.lowOrder&65535)+(e.lowOrder&65535);
|
|||
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)},K=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];a[b>>5]|=128<<24-b%32;a[(b+65>>9<<4)+15]=b;o=a.length;for(l=0;l<o;l+=16){d=s[0];e=s[1];f=s[2];h=s[3];j=s[4];for(m=0;80>m;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?E(g(d,5),e&f^~e&h,j,p[m],c[m]):40>m?E(g(d,5),e^f^h,j,p[m],c[m]):60>m?E(g(d,5),r(e,f,h),j,p[m],c[m]):E(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]=C(d,s[0]);s[1]=C(e,s[1]);s[2]=C(f,s[2]);s[3]=C(h,s[3]);s[4]=C(j,s[4])}return s},D=function(a,c,d){var e,f,g,h,j,k,K,B,D,s,da,Y,L,ea,ca,N,fa,ga,ha,ia,ja,ka,la,ma,q,na,Z=[],sa;if("SHA-224"===d||"SHA-256"===d)da=64,e=(c+65>>9<<4)+15,ea=16,ca=1,q=Number,N=C,fa=Q,ga=E,ha=A,ia=u,ja=o,ka=v,ma=r,
|
||||
la=l,na=[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)da=80,e=(c+128>>10<<5)+31,ea=32,ca=2,q=b,N=x,fa=z,ga=V,ha=t,ia=P,ja=y,ka=w,ma=
|
||||
p,la=m,na=[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,
|
||||
16>m?a[m+l]:g(c[m-3]^c[m-8]^c[m-14]^c[m-16],1),k=20>m?E(g(d,5),e&f^~e&h,j,p[m],c[m]):40>m?E(g(d,5),e^f^h,j,p[m],c[m]):60>m?E(g(d,5),r(e,f,h),j,p[m],c[m]):E(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]=C(d,s[0]);s[1]=C(e,s[1]);s[2]=C(f,s[2]);s[3]=C(h,s[3]);s[4]=C(j,s[4])}return s},D=function(a,c,d){var e,f,g,h,j,k,K,B,D,s,ea,Y,L,fa,ca,N,ga,ha,ia,ja,ka,la,ma,na,q,oa,Z=[],sa;if("SHA-224"===d||"SHA-256"===d)ea=64,e=(c+65>>9<<4)+15,fa=16,ca=1,q=Number,N=C,ga=Q,ha=E,ia=A,ja=u,ka=o,la=v,na=r,
|
||||
ma=l,oa=[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)ea=80,e=(c+128>>10<<5)+31,fa=32,ca=2,q=b,N=x,ga=z,ha=V,ia=t,ja=P,ka=y,la=w,na=
|
||||
p,ma=m,oa=[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)];a[c>>5]|=128<<24-c%32;a[e]=c;sa=a.length;for(Y=0;Y<sa;Y+=ea){c=s[0];e=s[1];f=s[2];g=s[3];h=s[4];j=s[5];k=s[6];K=s[7];for(L=0;L<da;L+=1)Z[L]=16>L?new q(a[L*ca+Y],a[L*ca+Y+1]):fa(ia(Z[L-2]),Z[L-7],ha(Z[L-15]),Z[L-16]),B=ga(K,ka(h),la(h,j,k),na[L],Z[L]),D=N(ja(c),ma(c,e,f)),K=k,k=j,j=h,h=N(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;sa=a.length;for(Y=0;Y<sa;Y+=fa){c=s[0];e=s[1];f=s[2];g=s[3];h=s[4];j=s[5];k=s[6];K=s[7];for(L=0;L<ea;L+=1)Z[L]=16>L?new q(a[L*ca+Y],a[L*ca+Y+1]):ga(ja(Z[L-2]),Z[L-7],ia(Z[L-15]),Z[L-16]),B=ha(K,la(h),ma(h,j,k),oa[L],Z[L]),D=N(ka(c),na(c,e,f)),K=k,k=j,j=h,h=N(g,
|
||||
B),g=f,f=e,e=c,c=N(B,D);s[0]=N(c,s[0]);s[1]=N(e,s[1]);s[2]=N(f,s[2]);s[3]=N(g,s[3]);s[4]=N(h,s[4]);s[5]=N(j,s[5]);s[6]=N(k,s[6]);s[7]=N(K,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[]}},B=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"};B.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=K(g,this.strBinLen);return c(this.sha1);case "SHA-224":if(null===this.sha224)this.sha224=D(g,this.strBinLen,a);return c(this.sha224);case "SHA-256":if(null===this.sha256)this.sha256=D(g,this.strBinLen,a);return c(this.sha256);
|
||||
|
@ -119,7 +119,7 @@ util.hexstrdump(b[0])+"|"+util.hexstrdump(b[1]));return b[0]+b[1];case 16:return
|
|||
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;c<b;c++)a+=String.fromCharCode(openpgp_crypto_getSecureRandomOctet());return a}function openpgp_crypto_getPseudoRandom(b,a){return Math.round(Math.random()*(a-b))+b}
|
||||
function openpgp_crypto_getSecureRandom(b,a){var c=new Uint32Array(1);window.crypto.getRandomValues(c);for(var d=(a-b).toString(2).length;(c[0]&Math.pow(2,d)-1)>a-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<b%8&&(a=String.fromCharCode(Math.pow(2,b%8)-1&a.charCodeAt(0))+a.substring(1));return(new openpgp_type_mpi).create(a).toBigInteger()}function openpgp_crypto_getRandomBigIntegerInRange(b,a){if(!(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_testRSA(b){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(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+
|
||||
|
@ -266,18 +266,18 @@ 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;r
|
|||
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(){aa+=8;return D<K.length?K[D++]:-1}function c(){var b;aa++;b=B&1;B>>=1;0==B&&(B=a(),b=B&1,B=B>>1|128);return b}function d(a){for(var b=0,d=a;d--;)b=b<<1|c();a&&(b=C[b]>>8-a);return b}function e(a){P++;A[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[M]>=ra)return-1;if(qa[W[M]]==M)return W[M]++;W[M]++}}function h(){var a=U[T],b;o&&document.write("<br>len:"+M+" treepos:"+
|
||||
T);if(17==M)return-1;T++;M++;b=g();o&&document.write("<br>IsPat "+b);if(0<=b)a.b0=b,o&&document.write("<br>b0 "+a.b0);else if(a.b0=32768,o&&document.write("<br>b0 "+a.b0),h())return-1;b=g();if(0<=b)a.b1=b,o&&document.write("<br>b1 "+a.b1),a.jump=null;else if(a.b1=32768,o&&document.write("<br>b1 "+a.b1),a.jump=U[T],a.jumppos=T,h())return-1;M--;return 0}function j(a,b,c,d){o&&document.write("currentTree "+a+" numval "+b+" lengths "+c+" show "+d);U=a;T=0;qa=c;ra=b;for(a=0;17>a;a++)W[a]=0;M=0;if(h())return o&&
|
||||
alert("invalid huffman tree\n"),-1;if(o){document.write("<br>Tree: "+U.length);for(a=0;32>a;a++)document.write("Places["+a+"].b0="+U[a].b0+"<br>"),document.write("Places["+a+"].b1="+U[a].b1+"<br>")}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<b;d++)if(a[d]===f){e=d;break}}else{if(!(f.b0&32768))return o&&document.write("ret2"),f.b0;e++;f=a[e]}o&&document.write("ret3");return-1}
|
||||
function l(){var b,g,h,l,m;do{b=c();h=d(2);switch(h){case 0:o&&alert("Stored\n");break;case 1:o&&alert("Fixed Huffman codes\n");break;case 2:o&&alert("Dynamic Huffman codes\n");break;case 3:o&&alert("Reserved block type!!\n");break;default:o&&alert("Unexpected value %d!\n",h)}if(0==h){B=1;h=a();h|=a()<<8;g=a();g|=a()<<8;for((h^~g)&65535&&document.write("BlockLen checksum mismatch\n");h--;)g=a(),e(g)}else if(1==h)for(;;)if(h=C[d(7)]>>1,23<h?(h=h<<1|c(),199<h?(h-=128,h=h<<1|c()):(h-=48,143<h&&(h+=136))):
|
||||
h+=256,256>h)e(h);else if(256==h)break;else{var p;h-=257;m=d(E[h])+Q[h];h=C[d(5)]>>3;8<z[h]?(p=d(8),p|=d(z[h]-8)<<8):p=d(z[h]);p+=x[h];for(h=0;h<m;h++)g=A[t-p&32767],e(g)}else if(2==h){var r=Array(320);g=257+d(5);p=1+d(5);l=4+d(4);for(h=0;19>h;h++)r[h]=0;for(h=0;h<l;h++)r[V[h]]=d(3);m=O.length;for(l=0;l<m;l++)O[l]=new f;if(j(O,19,r,0))return t=0,1;if(o){document.write("<br>distanceTree");for(h=0;h<O.length;h++)document.write("<br>"+O[h].b0+" "+O[h].b1+" "+O[h].jump+" "+O[h].jumppos)}m=g+p;l=0;var u=
|
||||
-1;for(o&&document.write("<br>n="+m+" bits: "+aa+"<br>");l<m;)if(u++,h=k(O),o&&document.write("<br>"+u+" i:"+l+" decode: "+h+" bits "+aa+"<br>"),16>h)r[l++]=h;else if(16==h){var v;h=3+d(2);if(l+h>m)return t=0,1;for(v=l?r[l-1]:0;h--;)r[l++]=v}else{h=17==h?3+d(3):11+d(7);if(l+h>m)return t=0,1;for(;h--;)r[l++]=0}m=ba.length;for(l=0;l<m;l++)ba[l]=new f;if(j(ba,g,r,0))return t=0,1;m=ba.length;for(l=0;l<m;l++)O[l]=new f;h=[];for(l=g;l<r.length;l++)h[l-g]=r[l];if(j(O,p,h,0))return t=0,1;o&&document.write("<br>literalTree");
|
||||
a:for(;;)if(h=k(ba),256<=h){h-=256;if(0==h)break;h--;m=d(E[h])+Q[h];h=k(O);8<z[h]?(p=d(8),p|=d(z[h]-8)<<8):p=d(z[h]);for(p+=x[h];m--;){if(0>t-p)break a;g=A[t-p&32767];e(g)}}else e(h)}}while(!b);t=0;B=1;return 0}function m(){o&&alert("NEXTFILE");p=[];var b=[];u=!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("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]="geonext.gxt",v++);120==b[0]&&156==b[1]&&(o&&alert("ZLIB"),l(),o&&alert(p.join("")),
|
||||
w[v]=Array(2),w[v][0]=p.join(""),w[v][1]="ZLIB",v++);31==b[0]&&139==b[1]&&(o&&alert("GZIP"),r(),o&&alert(p.join("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]="file",v++);if(80==b[0]&&75==b[1]&&(u=!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<oa-1&&(R[f++]=String.fromCharCode(e));o&&alert("nameBuf: "+R);pa||(pa=R);for(var f=0;f<d;)a(),f++;P=0;8==b&&(l(),o&&alert(p.join("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]=R.join(""),v++);r()}}function r(){var b=[],c;y&8&&(b[0]=a(),b[1]=a(),b[2]=a(),b[3]=a(),80==b[0]&&75==b[1]&&7==b[2]&&8==b[3]&&(a(),a(),
|
||||
a(),a()),a(),a(),a(),a(),a(),a(),a(),a(),o&&alert("CRC:"));u&&m();b[0]=a();if(8!=b[0])return o&&alert("Unknown compression method!"),0;y=a();o&&y&-32&&alert("Unknown flags set!");a();a();a();a();a();a();if(y&4){b[0]=a();b[2]=a();M=b[0]+256*b[1];o&&alert("Extra field size: "+M);for(b=0;b<M;b++)a()}if(y&8){b=0;for(R=[];c=a();){if("7"==c||":"==c)b=0;b<oa-1&&(R[b++]=c)}o&&alert("original file name: "+R)}if(y&16)for(;a(););y&2&&(a(),a());l();a();a();a();a();a();a();a();a();u&&m()}var p=[],o=!1,y,v=0,w=
|
||||
[],A=Array(32768),t=0,u=!1,P,C=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,
|
||||
33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255],Q=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,
|
||||
67,83,99,115,131,163,195,227,258,0,0],E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],x=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K=b,D=0,B=1,aa=0,oa=256,R=[],pa,ba=Array(288),O=Array(32),T=0,U=null,M=0,W=Array(17);W[0]=0;var qa,ra;JXG.Util.Unzip.prototype.unzipFile=function(a){var b;this.unzip();
|
||||
for(b=0;b<w.length;b++)if(w[b][1]==a)return w[b][0]};JXG.Util.Unzip.prototype.deflate=function(){p=[];u=!1;l();o&&alert(p.join(""));w[v]=Array(2);w[v][0]=p.join("");w[v][1]="DEFLATE";v++;return w};JXG.Util.Unzip.prototype.unzip=function(){o&&alert(K);m();return w}};
|
||||
alert("invalid huffman tree\n"),-1;if(o){document.write("<br>Tree: "+U.length);for(a=0;32>a;a++)document.write("Places["+a+"].b0="+U[a].b0+"<br>"),document.write("Places["+a+"].b1="+U[a].b1+"<br>")}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<b;d++)if(a[d]===f){e=d;break}}else{if(!(f.b0&32768))return o&&document.write("ret2"),f.b0;e++;f=a[e]}}function l(){var b,g,h,l,m;do{b=
|
||||
c();h=d(2);switch(h){case 0:o&&alert("Stored\n");break;case 1:o&&alert("Fixed Huffman codes\n");break;case 2:o&&alert("Dynamic Huffman codes\n");break;case 3:o&&alert("Reserved block type!!\n");break;default:o&&alert("Unexpected value %d!\n",h)}if(0==h){B=1;h=a();h|=a()<<8;g=a();g|=a()<<8;for((h^~g)&65535&&document.write("BlockLen checksum mismatch\n");h--;)g=a(),e(g)}else if(1==h)for(;;)if(h=C[d(7)]>>1,23<h?(h=h<<1|c(),199<h?(h-=128,h=h<<1|c()):(h-=48,143<h&&(h+=136))):h+=256,256>h)e(h);else if(256==
|
||||
h)break;else{var p;h-=257;m=d(E[h])+Q[h];h=C[d(5)]>>3;8<z[h]?(p=d(8),p|=d(z[h]-8)<<8):p=d(z[h]);p+=x[h];for(h=0;h<m;h++)g=A[t-p&32767],e(g)}else if(2==h){var r=Array(320);g=257+d(5);p=1+d(5);l=4+d(4);for(h=0;19>h;h++)r[h]=0;for(h=0;h<l;h++)r[V[h]]=d(3);m=O.length;for(l=0;l<m;l++)O[l]=new f;if(j(O,19,r,0))return t=0,1;if(o){document.write("<br>distanceTree");for(h=0;h<O.length;h++)document.write("<br>"+O[h].b0+" "+O[h].b1+" "+O[h].jump+" "+O[h].jumppos)}m=g+p;l=0;var u=-1;for(o&&document.write("<br>n="+
|
||||
m+" bits: "+aa+"<br>");l<m;)if(u++,h=k(O),o&&document.write("<br>"+u+" i:"+l+" decode: "+h+" bits "+aa+"<br>"),16>h)r[l++]=h;else if(16==h){var v;h=3+d(2);if(l+h>m)return t=0,1;for(v=l?r[l-1]:0;h--;)r[l++]=v}else{h=17==h?3+d(3):11+d(7);if(l+h>m)return t=0,1;for(;h--;)r[l++]=0}m=ba.length;for(l=0;l<m;l++)ba[l]=new f;if(j(ba,g,r,0))return t=0,1;m=ba.length;for(l=0;l<m;l++)O[l]=new f;h=[];for(l=g;l<r.length;l++)h[l-g]=r[l];if(j(O,p,h,0))return t=0,1;o&&document.write("<br>literalTree");a:for(;;)if(h=
|
||||
k(ba),256<=h){h-=256;if(0==h)break;h--;m=d(E[h])+Q[h];h=k(O);8<z[h]?(p=d(8),p|=d(z[h]-8)<<8):p=d(z[h]);for(p+=x[h];m--;){if(0>t-p)break a;g=A[t-p&32767];e(g)}}else e(h)}}while(!b);t=0;B=1;return 0}function m(){o&&alert("NEXTFILE");p=[];var b=[];u=!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("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]="geonext.gxt",v++);120==b[0]&&156==b[1]&&(o&&alert("ZLIB"),l(),o&&alert(p.join("")),w[v]=
|
||||
Array(2),w[v][0]=p.join(""),w[v][1]="ZLIB",v++);31==b[0]&&139==b[1]&&(o&&alert("GZIP"),r(),o&&alert(p.join("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]="file",v++);if(80==b[0]&&75==b[1]&&(u=!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);g=0;for(R=[];c--;){var f=a();"/"==f|":"==f?g=0:g<pa-1&&(R[g++]=String.fromCharCode(f))}o&&alert("nameBuf: "+R);da||(da=R);for(var g=0;g<d;)a(),g++;P=0;0==e&&"/"==fileOut.charAt(da.length-1)&&o&&alert("skipdir");8==b&&(l(),o&&alert(p.join("")),w[v]=Array(2),w[v][0]=p.join(""),w[v][1]=R.join(""),v++);r()}}function r(){var b=[],c;y&8&&(b[0]=a(),b[1]=a(),b[2]=
|
||||
a(),b[3]=a(),80==b[0]&&75==b[1]&&7==b[2]&&8==b[3]&&(a(),a(),a(),a()),a(),a(),a(),a(),a(),a(),a(),a(),o&&alert("CRC:"));u&&m();b[0]=a();if(8!=b[0])return o&&alert("Unknown compression method!"),0;y=a();o&&y&-32&&alert("Unknown flags set!");a();a();a();a();a();a();if(y&4){b[0]=a();b[2]=a();M=b[0]+256*b[1];o&&alert("Extra field size: "+M);for(b=0;b<M;b++)a()}if(y&8){b=0;for(R=[];c=a();){if("7"==c||":"==c)b=0;b<pa-1&&(R[b++]=c)}o&&alert("original file name: "+R)}if(y&16)for(;a(););y&2&&(a(),a());l();
|
||||
a();a();a();a();a();a();a();a();u&&m()}var p=[],o=!1,y,v=0,w=[],A=Array(32768),t=0,u=!1,P,C=[0,128,64,192,32,160,96,224,16,144,80,208,48,176,112,240,8,136,72,200,40,168,104,232,24,152,88,216,56,184,120,248,4,132,68,196,36,164,100,228,20,148,84,212,52,180,116,244,12,140,76,204,44,172,108,236,28,156,92,220,60,188,124,252,2,130,66,194,34,162,98,226,18,146,82,210,50,178,114,242,10,138,74,202,42,170,106,234,26,154,90,218,58,186,122,250,6,134,70,198,38,166,102,230,22,150,86,214,54,182,118,246,14,142,78,
|
||||
206,46,174,110,238,30,158,94,222,62,190,126,254,1,129,65,193,33,161,97,225,17,145,81,209,49,177,113,241,9,137,73,201,41,169,105,233,25,153,89,217,57,185,121,249,5,133,69,197,37,165,101,229,21,149,85,213,53,181,117,245,13,141,77,205,45,173,109,237,29,157,93,221,61,189,125,253,3,131,67,195,35,163,99,227,19,147,83,211,51,179,115,243,11,139,75,203,43,171,107,235,27,155,91,219,59,187,123,251,7,135,71,199,39,167,103,231,23,151,87,215,55,183,119,247,15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,
|
||||
255],Q=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],E=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,99,99],x=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],z=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],V=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],K=b,D=0,B=1,aa=0,pa=256,R=[],da,ba=Array(288),O=Array(32),T=0,U=null,M=0,W=Array(17);W[0]=0;var qa,
|
||||
ra;JXG.Util.Unzip.prototype.unzipFile=function(a){var b;this.unzip();for(b=0;b<w.length;b++)if(w[b][1]==a)return w[b][0]};JXG.Util.Unzip.prototype.deflate=function(){p=[];u=!1;l();o&&alert(p.join(""));w[v]=Array(2);w[v][0]=p.join("");w[v][1]="DEFLATE";v++;return w};JXG.Util.Unzip.prototype.unzip=function(){o&&alert(K);m();return w}};
|
||||
JXG.Util.Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(b){for(var a=[],c,d,e,f,g,h,j=0,b=JXG.Util.Base64._utf8_encode(b);j<b.length;)c=b.charCodeAt(j++),d=b.charCodeAt(j++),e=b.charCodeAt(j++),f=c>>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<b.length;)d=this._keyStr.indexOf(b.charAt(j++)),e=this._keyStr.indexOf(b.charAt(j++)),g=this._keyStr.indexOf(b.charAt(j++)),h=this._keyStr.indexOf(b.charAt(j++)),d=d<<2|e>>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;c<b.length;c++){var d=
|
||||
b.charCodeAt(c);128>d?a+=String.fromCharCode(d):(127<d&&2048>d?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;c<b.length;)d=b.charCodeAt(c),128>d?(a.push(String.fromCharCode(d)),c++):191<d&&224>d?(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|
|
||||
|
@ -286,13 +286,14 @@ JXG.Util.asciiCharCodeAt=function(b,a){var c=b.charCodeAt(a);if(255<c)switch(c){
|
|||
151;break;case 732:c=152;break;case 8482:c=153;break;case 353:c=154;break;case 8250:c=155;break;case 339:c=156;break;case 382:c=158;break;case 376:c=159}return c};
|
||||
JXG.Util.utf8Decode=function(b){var a=[],c=0,d=0,e=0,f;if(!JXG.exists(b))return"";for(;c<b.length;)d=b.charCodeAt(c),128>d?(a.push(String.fromCharCode(d)),c++):191<d&&224>d?(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.20131009";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",
|
||||
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.20131130";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<h;d++)c=b.charCodeAt(d),0==g?(e+=b64s.charAt(c>>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<g&&(e+=b64s.charAt(a),f+=1,0==f%60&&(e+="\n"),e+="=",f+=1);1==g&&(0==f%60&&(e+="\n"),e+="=");"\n"===e.charAt(e.length-1)&&(e=e.slice(0,-1));return e}
|
||||
function r2s(b){var a,c,d="",e=0,f=0,g=b.length;for(c=0;c<g;c++)a=b64s.indexOf(b.charAt(c)),0<=a&&(e&&(d+=String.fromCharCode(f|a>>6-e&255)),e=e+2&7,f=a<<e&255);return d}
|
||||
function openpgp_encoding_deArmor(b){var b=b.replace(/\r/g,""),b=b.replace(/\n\s+\n/,"\n\n"),a=openpgp_encoding_get_type(b);if(2!=a){b=b.split("-----");b[2].split("\n\n");var c=b[2].split("\n\n")[1].split("\n="),d=c[0].replace(/\n- /g,"\n"),b=1==c.length?b[2].replace(/[\n=]/g,""):c[1].split("\n")[0],a={openpgp:openpgp_encoding_base64_decode(d),type:a};if(verifyCheckSum(a.openpgp,b))return a;util.print_error("Ascii armor integrity check on message failed: '"+b+"' should be '"+getCheckSum(a));return!1}b=
|
||||
b.split("-----");a={text:b[2].replace(/\n- /g,"\n").split("\n\n")[1],openpgp:openpgp_encoding_base64_decode(b[4].split("\n\n")[1].split("\n=")[0]),type:a};if(verifyCheckSum(a.openpgp,b[4].split("\n\n")[1].split("\n=")[1]))return a;util.print_error("Ascii armor integrity check on message failed");return!1}
|
||||
function openpgp_encoding_get_type(b){b=b.split("-----");if(b[1].match(/BEGIN PGP MESSAGE, PART \d+\/\d+/))return 0;if(b[1].match(/BEGIN PGP MESSAGE, PART \d+/))return 1;if(b[1].match(/BEGIN PGP SIGNED MESSAGE/))return 2;if(b[1].match(/BEGIN PGP MESSAGE/))return 3;if(b[1].match(/BEGIN PGP PUBLIC KEY BLOCK/))return 4;if(b[1].match(/BEGIN PGP PRIVATE KEY BLOCK/))return 5}
|
||||
function openpgp_encoding_deArmor(b){var a=/^-----[^-]+-----$\n/m,b=b.replace(/\r/g,""),c=openpgp_encoding_get_type(b),d=b.split(a),e=1;b.search(a)!=d[0].length&&(e=0);if(2!=c){b=openpgp_encoding_split_headers(d[e]);d=openpgp_encoding_split_checksum(b.body);c={openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed: '"+d.checksum+"' should be '"+getCheckSum(c)+"'");return!1}b=openpgp_encoding_split_headers(d[e]);
|
||||
d=openpgp_encoding_split_headers(d[e+1]);d=openpgp_encoding_split_checksum(d.body);c={text:b.body.replace(/\n$/,"").replace(/\n/g,"\r\n"),openpgp:openpgp_encoding_base64_decode(d.body),type:c};if(verifyCheckSum(c.openpgp,d.checksum))return c;util.print_error("Ascii armor integrity check on message failed");return!1}function openpgp_encoding_split_headers(b){var a="",c=b,d=/^[\t ]*\n/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+d[0].length));return{headers:a,body:c}}
|
||||
function openpgp_encoding_split_checksum(b){var a=b,c="",d=/^=/m.exec(b);null!=d&&(a=b.slice(0,d.index),c=b.slice(d.index+1));return{body:a,checksum:c}}
|
||||
function openpgp_encoding_get_type(b){b=b.match(/^-----([^-]+)-----$\n/m);if(b[1].match(/BEGIN PGP MESSAGE, PART \d+\/\d+/))return 0;if(b[1].match(/BEGIN PGP MESSAGE, PART \d+/))return 1;if(b[1].match(/BEGIN PGP SIGNED MESSAGE/))return 2;if(b[1].match(/BEGIN PGP MESSAGE/))return 3;if(b[1].match(/BEGIN PGP PUBLIC KEY BLOCK/))return 4;if(b[1].match(/BEGIN PGP PRIVATE KEY BLOCK/))return 5}
|
||||
function openpgp_encoding_armor_addheader(){var b="";openpgp.config.config.show_version&&(b+="Version: "+openpgp.config.versionstring+"\r\n");openpgp.config.config.show_comment&&(b+="Comment: "+openpgp.config.commentstring+"\r\n");return b+"\r\n"}
|
||||
function openpgp_encoding_armor(b,a,c,d){var e="";switch(b){case 0:e=e+("-----BEGIN PGP MESSAGE, PART "+c+"/"+d+"-----\r\n")+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a);e+="\r\n="+getCheckSum(a)+"\r\n";e+="-----END PGP MESSAGE, PART "+c+"/"+d+"-----\r\n";break;case 1:e=e+("-----BEGIN PGP MESSAGE, PART "+c+"-----\r\n")+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a);e+="\r\n="+getCheckSum(a)+"\r\n";e+="-----END PGP MESSAGE, PART "+c+"-----\r\n";break;
|
||||
case 2:e+="\r\n-----BEGIN PGP SIGNED MESSAGE-----\r\nHash: "+a.hash+"\r\n\r\n";e+=a.text.replace(/\n-/g,"\n- -");e=e+"\r\n-----BEGIN PGP SIGNATURE-----\r\n"+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a.openpgp);e+="\r\n="+getCheckSum(a.openpgp)+"\r\n";e+="-----END PGP SIGNATURE-----\r\n";break;case 3:e=e+"-----BEGIN PGP MESSAGE-----\r\n"+openpgp_encoding_armor_addheader();e+=openpgp_encoding_base64_encode(a);e+="\r\n="+getCheckSum(a)+"\r\n";e+="-----END PGP MESSAGE-----\r\n";
|
||||
|
@ -321,8 +322,8 @@ b.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"),a),d={text:b.replace(/\r\n/g,"\n")
|
|||
a,!1);util.print_debug_hexstr_dump("onepasssigstr: |"+h+"|\n",h);var j=(new openpgp_packet_signature).write_message_signature(1,d.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"),a);util.print_debug_hexstr_dump("datasignature: |"+j.openpgp+"|\n",j.openpgp);e=0==g?h+f+j.openpgp:h+e+j.openpgp}util.print_debug_hexstr_dump("signed packet: |"+e+"|\n",e);a=openpgp_crypto_generateSessionKey(openpgp.config.config.encryption_cipher);d="";for(g=0;g<b.length;g++){f=b[g].getEncryptionKey();if(null==f)return util.print_error("no encryption key found! Key is for signing only."),
|
||||
null;d+=(new openpgp_packet_encryptedsessionkey).write_pub_key_packet(f.getKeyId(),f.MPIs,f.publicKeyAlgorithm,openpgp.config.config.encryption_cipher,a)}d=openpgp.config.config.integrity_protect?d+(new openpgp_packet_encryptedintegrityprotecteddata).write_packet(openpgp.config.config.encryption_cipher,a,e):d+(new openpgp_packet_encrypteddata).write_packet(openpgp.config.config.encryption_cipher,a,e);return openpgp_encoding_armor(3,d,null,null)};this.write_encrypted_message=function(a,b){var d="",
|
||||
d=(new openpgp_packet_literaldata).write_packet(b.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"));util.print_debug_hexstr_dump("literal_packet: |"+d+"|\n",d);for(var e=openpgp_crypto_generateSessionKey(openpgp.config.config.encryption_cipher),f="",g=0;g<a.length;g++){var h=a[g].getEncryptionKey();if(null==h)return util.print_error("no encryption key found! Key is for signing only."),null;f+=(new openpgp_packet_encryptedsessionkey).write_pub_key_packet(h.getKeyId(),h.MPIs,h.publicKeyAlgorithm,openpgp.config.config.encryption_cipher,
|
||||
e)}f=openpgp.config.config.integrity_protect?f+(new openpgp_packet_encryptedintegrityprotecteddata).write_packet(openpgp.config.config.encryption_cipher,e,d):f+(new openpgp_packet_encrypteddata).write_packet(openpgp.config.config.encryption_cipher,e,d);return openpgp_encoding_armor(3,f,null,null)};this.read_message=function(a){var c;try{c=openpgp_encoding_deArmor(a.replace(/\r/g,""))}catch(d){return util.print_error("no message found!"),null}return b(c)};this.read_messages_dearmored=b;this.read_publicKey=
|
||||
function(a){for(var b=0,d=[],e=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,f=a.length;b!=a.length;){var g=openpgp_packet.read_packet(a,b,f);if(153==a[b].charCodeAt()||6==g.tagType)d[e]=new openpgp_msg_publickey,d[e].header=a.substring(b,b+3),153==a[b].charCodeAt()?(b++,f=a[b++].charCodeAt()<<8|a[b++].charCodeAt(),d[e].publicKeyPacket=new openpgp_packet_keymaterial,d[e].publicKeyPacket.header=d[e].header,d[e].publicKeyPacket.read_tag6(a,b,f),b+=d[e].publicKeyPacket.packetLength,b+=d[e].read_nodes(d[e].publicKeyPacket,
|
||||
e)}f=openpgp.config.config.integrity_protect?f+(new openpgp_packet_encryptedintegrityprotecteddata).write_packet(openpgp.config.config.encryption_cipher,e,d):f+(new openpgp_packet_encrypteddata).write_packet(openpgp.config.config.encryption_cipher,e,d);return openpgp_encoding_armor(3,f,null,null)};this.read_message=function(a){var c;try{c=openpgp_encoding_deArmor(a)}catch(d){return util.print_error("no message found!"),null}return b(c)};this.read_messages_dearmored=b;this.read_publicKey=function(a){for(var b=
|
||||
0,d=[],e=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,f=a.length;b!=a.length;){var g=openpgp_packet.read_packet(a,b,f);if(153==a.charCodeAt(b)||6==g.tagType)d[e]=new openpgp_msg_publickey,d[e].header=a.substring(b,b+3),153==a.charCodeAt(b)?(b++,f=a.charCodeAt(b++)<<8|a.charCodeAt(b++),d[e].publicKeyPacket=new openpgp_packet_keymaterial,d[e].publicKeyPacket.header=d[e].header,d[e].publicKeyPacket.read_tag6(a,b,f),b+=d[e].publicKeyPacket.packetLength,b+=d[e].read_nodes(d[e].publicKeyPacket,
|
||||
a,b,a.length-b)):(d[e]=new openpgp_msg_publickey,d[e].publicKeyPacket=g,b+=g.headerLength+g.packetLength,b+=d[e].read_nodes(g,a,b,a.length-b));else return util.print_error("no public key found!"),null;d[e].data=a.substring(0,b);e++}return d};this.read_privateKey=function(a){for(var b=[],d=0,e=0,a=openpgp_encoding_deArmor(a.replace(/\r/g,"")).openpgp,f=a.length;e!=a.length;){var g=openpgp_packet.read_packet(a,e,f);if(5==g.tagType)b[b.length]=new openpgp_msg_privatekey,e+=g.headerLength+g.packetLength,
|
||||
e+=b[d].read_nodes(g,a,e,f);else return util.print_error("no block packet found!"),null;b[d].data=a.substring(0,e);d++}return b};this.init=function(){this.config=new openpgp_config;this.config.read();this.keyring=new openpgp_keyring;this.keyring.init()}}var openpgp=new _openpgp;
|
||||
function openpgp_keyring(){this.init=function(){var b=JSON.parse(window.localStorage.getItem("privatekeys")),a=JSON.parse(window.localStorage.getItem("publickeys"));if(null==b||0==b.length)b=[];if(null==a||0==a.length)a=[];this.publicKeys=[];this.privateKeys=[];for(var c=0,d=0;d<b.length;d++){var e=openpgp.read_privateKey(b[d]);this.privateKeys[c]={armored:b[d],obj:e[0],keyId:e[0].getKeyId()};c++}for(d=c=0;d<a.length;d++)e=openpgp.read_publicKey(a[d]),null!=e[0]&&(this.publicKeys[c]={armored:a[d],
|
||||
|
@ -334,8 +335,8 @@ keyId:a[c].getKeyId()};return!0};this.importPrivateKey=function(b,a){var c=openp
|
|||
this.privateKeys.splice(b,1);this.store();return b}}
|
||||
function openpgp_msg_message(){this.text="";this.type=this.messagePacket=null;this.decrypt=function(b,a){return this.decryptAndVerifySignature(b,a).text};this.decryptAndVerifySignature=function(b,a,c){if(null==b||null==a||""==a)return null;a=a.decrypt(this,b.keymaterial);if(null==a)return null;b=[];util.print_debug_hexstr_dump("openpgp.msg.messge decrypt:\n",a);var a=openpgp.read_messages_dearmored({text:a,openpgp:a}),d;for(d in a){if(a[d].data)this.text=a[d].data;a[d].signature&&b.push(a[d].verifySignature(c))}return{text:this.text,
|
||||
validSignatures:b}};this.verifySignature=function(b){var a=!1;if(2==this.signature.tagType){if(!b||0==b.length)if(4==this.signature.version)b=openpgp.keyring.getPublicKeysForKeyId(this.signature.issuerKeyId);else if(3==this.signature.version)b=openpgp.keyring.getPublicKeysForKeyId(this.signature.keyId);else return util.print_error("unknown signature type on message!"),!1;if(0==b.length)util.print_warning("Unable to verify signature of issuer: "+util.hexstrdump(this.signature.issuerKeyId)+". Public key not found in keyring.");
|
||||
else for(var c=0;c<b.length;c++)this.signature.verify(this.text.replace(/\r\n/g,"\n").replace(/\n/g,"\r\n"),b[c])?(util.print_info("Found Good Signature from "+b[c].obj.userIds[0].text+" (0x"+util.hexstrdump(b[c].obj.getKeyId()).substring(8)+")"),a=!0):util.print_error("Signature verification failed: Bad Signature from "+b[c].obj.userIds[0].text+" (0x"+util.hexstrdump(b[0].obj.getKeyId()).substring(8)+")")}return a};this.toString=function(){var b="Session Keys:\n";if(null!=this.sessionKeys)for(var a=
|
||||
0;a<this.sessionKeys.length;a++)b+=this.sessionKeys[a].toString();b+="\n\n EncryptedData:\n";null!=this.encryptedData&&(b+=this.encryptedData.toString());b+="\n\n Signature:\n";null!=this.signature&&(b+=this.signature.toString());b+="\n\n Text:\n";null!=this.signature&&(b+=this.text);return b}}
|
||||
else for(var c=0;c<b.length;c++)if(this.signature.verify(this.text,b[c])){util.print_info("Found Good Signature from "+b[c].obj.userIds[0].text+" (0x"+util.hexstrdump(b[c].obj.getKeyId()).substring(8)+")");a=!0;break}else util.print_error("Signature verification failed: Bad Signature from "+b[c].obj.userIds[0].text+" (0x"+util.hexstrdump(b[0].obj.getKeyId()).substring(8)+")")}return a};this.toString=function(){var b="Session Keys:\n";if(null!=this.sessionKeys)for(var a=0;a<this.sessionKeys.length;a++)b+=
|
||||
this.sessionKeys[a].toString();b+="\n\n EncryptedData:\n";null!=this.encryptedData&&(b+=this.encryptedData.toString());b+="\n\n Signature:\n";null!=this.signature&&(b+=this.signature.toString());b+="\n\n Text:\n";null!=this.signature&&(b+=this.text);return b}}
|
||||
function openpgp_msg_privatekey(){this.subKeys=[];this.privateKeyPacket=null;this.userIds=[];this.userAttributes=[];this.revocationSignatures=[];this.subKeys=[];this.extractPublicKey=function(){for(var b=this.privateKeyPacket.publicKey.header+this.privateKeyPacket.publicKey.data,a=0;a<this.userIds.length;a++){if(0===this.userIds[a].certificationSignatures.length)return util.print_error("extractPublicKey - missing certification signatures"),null;for(var c=new openpgp_packet_userid,b=b+c.write_packet(this.userIds[a].text),
|
||||
c=0;c<this.userIds[a].certificationSignatures.length;c++)var d=this.userIds[a].certificationSignatures[c],b=b+(openpgp_packet.write_packet_header(2,d.data.length)+d.data)}for(a=0;a<this.subKeys.length;a++)if(c=this.subKeys[a].publicKey,b+=openpgp_packet.write_old_packet_header(14,c.data.length)+c.data,c=this.subKeys[a].subKeySignature,null!==c)b+=openpgp_packet.write_packet_header(2,c.data.length)+c.data;else return util.print_error("extractPublicKey - missing subkey signature"),null;return openpgp_encoding_armor(4,
|
||||
b)};this.getSigningKey=function(){if((17==this.privateKeyPacket.publicKey.publicKeyAlgorithm||2!=this.privateKeyPacket.publicKey.publicKeyAlgorithm)&&3==this.privateKeyPacket.publicKey.verifyKey())return this.privateKeyPacket;if(4==this.privateKeyPacket.publicKey.version)for(var b=0;b<this.privateKeyPacket.subKeys.length;b++)if((17==this.privateKeyPacket.subKeys[b].publicKey.publicKeyAlgorithm||2!=this.privateKeyPacket.subKeys[b].publicKey.publicKeyAlgorithm)&&3==this.privateKeyPacket.subKeys[b].publicKey.verifyKey())return this.privateKeyPacket.subKeys[b];
|
||||
|
@ -361,39 +362,38 @@ this.write_packet=function(b,a){this.decompressedData=a;if(null==b)this.type=1;v
|
|||
function openpgp_packet_encrypteddata(){this.tagType=9;this.decryptedData=this.encryptedData=this.packetLength=null;this.decrypt_sym=function(b,a){this.decryptedData=openpgp_crypto_symmetricDecrypt(b,a,this.encryptedData,!0);util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\ndata: "+util.hexstrdump(this.decryptedData));return this.decryptedData};this.toString=function(){return"5.7. Symmetrically Encrypted Data Packet (Tag 9)\n length: "+this.packetLength+"\n Used symmetric algorithm: "+
|
||||
this.algorithmType+"\n encrypted data: Bytes ["+util.hexstrdump(this.encryptedData)+"]\n"};this.read_packet=function(b,a,c){this.packetLength=c;this.encryptedData=b.substring(a,a+c);return this};this.write_packet=function(b,a,c){b=""+openpgp_crypto_symmetricEncrypt(openpgp_crypto_getPrefixRandom(b),b,a,c,!0);return b=openpgp_packet.write_packet_header(9,b.length)+b}}
|
||||
function openpgp_packet_encryptedintegrityprotecteddata(){this.tagType=18;this.hash=this.decrytpedData=this.encryptedData=this.packetLength=this.version=null;this.write_packet=function(b,a,c){var 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));b=openpgp_crypto_symmetricEncrypt(d,
|
||||
b,a,c,!1).substring(0,e.length+c.length);a=openpgp_packet.write_packet_header(18,b.length+1)+String.fromCharCode(1);this.encryptedData=b;return a+b};this.read_packet=function(b,a,c){this.packetLength=c;this.version=b[a].charCodeAt();if(1!=this.version)return util.print_error("openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: "+this.version+" , @ "+a+"hex:"+util.hexstrdump(b)),null;this.encryptedData=b.substring(a+1,a+1+c);util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\n"+
|
||||
b,a,c,!1).substring(0,e.length+c.length);a=openpgp_packet.write_packet_header(18,b.length+1)+String.fromCharCode(1);this.encryptedData=b;return a+b};this.read_packet=function(b,a,c){this.packetLength=c;this.version=b.charCodeAt(a);if(1!=this.version)return util.print_error("openpgp.packet.encryptedintegrityprotecteddata.js\nunknown encrypted integrity protected data packet version: "+this.version+" , @ "+a+"hex:"+util.hexstrdump(b)),null;this.encryptedData=b.substring(a+1,a+1+c);util.print_debug("openpgp.packet.encryptedintegrityprotecteddata.js\n"+
|
||||
this.toString());return this};this.toString=function(){var b="";openpgp.config.debug&&(b=" data: Bytes ["+util.hexstrdump(this.encryptedData)+"]");return"5.13. Sym. Encrypted Integrity Protected Data Packet (Tag 18)\n length: "+this.packetLength+"\n version: "+this.version+"\n"+b};this.decrypt=function(b,a){this.decryptedData=openpgp_crypto_symmetricDecrypt(b,a,this.encryptedData,!1);this.hash=str_sha1(openpgp_crypto_MDCSystemBytes(b,a,this.encryptedData)+this.decryptedData.substring(0,
|
||||
this.decryptedData.length-20));util.print_debug_hexstr_dump("calc hash = ",this.hash);if(this.hash==this.decryptedData.substring(this.decryptedData.length-20,this.decryptedData.length))return this.decryptedData;util.print_error("Decryption stopped: discovered a modification of encrypted data.");return null}}
|
||||
function openpgp_packet_encryptedsessionkey(){this.read_pub_key_packet=function(b,a,c){this.tagType=1;this.packetLength=c;var d=a;if(10>c)return util.print_error("openpgp.packet.encryptedsessionkey.js\ninvalid length"),null;this.version=b[d++].charCodeAt();this.keyId=new openpgp_type_keyid;this.keyId.read_packet(b,d);d+=8;this.publicKeyAlgorithmUsed=b[d++].charCodeAt();switch(this.publicKeyAlgorithmUsed){case 1:case 2:this.MPIs=[];this.MPIs[0]=new openpgp_type_mpi;this.MPIs[0].read(b,d,d-a);break;
|
||||
case 16:this.MPIs=[];this.MPIs[0]=new openpgp_type_mpi;this.MPIs[0].read(b,d,d-a);d+=this.MPIs[0].packetLength;this.MPIs[1]=new openpgp_type_mpi;this.MPIs[1].read(b,d,d-a);break;default:util.print_error("openpgp.packet.encryptedsessionkey.js\nunknown public key packet algorithm type "+this.publicKeyAlgorithmType)}return this};this.read_symmetric_key_packet=function(b,a,c){this.tagType=3;var d=a;this.version=b[d++];this.symmetricKeyAlgorithmUsed=b[d++];this.s2k=new openpgp_type_s2k;this.s2k.read(b,
|
||||
d);if(s2k.s2kLength+d<c){this.encryptedSessionKey=[];for(a=d-a;a<c;a++)this.encryptedSessionKey[a]=b[d++]}return this};this.write_pub_key_packet=function(b,a,c,d,e){for(var f=String.fromCharCode(3),d=String.fromCharCode(d),d=d+e,e=util.calc_checksum(e),d=d+String.fromCharCode(e>>8&255),d=d+String.fromCharCode(e&255),f=f+b+String.fromCharCode(c),b=new openpgp_type_mpi,a=openpgp_crypto_asymetricEncrypt(c,a,b.create(openpgp_encoding_eme_pkcs1_encode(d,a[0].mpiByteLength))),c=0;c<a.length;c++)f+=a[c];
|
||||
return f=openpgp_packet.write_packet_header(1,f.length)+f};this.toString=function(){if(1==this.tagType){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;a<this.MPIs.length;a++)b+=this.MPIs[a].toString();return b}return"5.3 Symmetric-Key Encrypted Session Key Packets (Tag 3)\n KeyId: "+this.keyId.toString()+"\n length: "+
|
||||
this.packetLength+"\n version:"+this.version+"\n symKeyA:"+this.symmetricKeyAlgorithmUsed+"\n s2k: "+this.s2k+"\n"};this.decrypt=function(b,a){if(1==this.tagType){var c=openpgp_crypto_asymetricDecrypt(this.publicKeyAlgorithmUsed,a.publicKey.MPIs,a.secMPIs,this.MPIs).toMPI();c.charCodeAt(c.length-2);c.charCodeAt(c.length-1);var d=openpgp_encoding_eme_pkcs1_decode(c.substring(2,c.length-2),a.publicKey.MPIs[0].getByteLength()),c=d.substring(1),d=d.charCodeAt(0);return 18==b.encryptedData.tagType?
|
||||
b.encryptedData.decrypt(d,c):b.encryptedData.decrypt_sym(d,c)}if(3==this.tagType)return util.print_error("Symmetric encrypted sessionkey is not supported!"),null}}
|
||||
function openpgp_packet_encryptedsessionkey(){this.read_pub_key_packet=function(b,a,c){this.tagType=1;this.packetLength=c;var d=a;if(10>c)return util.print_error("openpgp.packet.encryptedsessionkey.js\ninvalid length"),null;this.version=b.charCodeAt(d++);this.keyId=new openpgp_type_keyid;this.keyId.read_packet(b,d);d+=8;this.publicKeyAlgorithmUsed=b.charCodeAt(d++);switch(this.publicKeyAlgorithmUsed){case 1:case 2:this.MPIs=[];this.MPIs[0]=new openpgp_type_mpi;this.MPIs[0].read(b,d,d-a);break;case 16:this.MPIs=
|
||||
[];this.MPIs[0]=new openpgp_type_mpi;this.MPIs[0].read(b,d,d-a);d+=this.MPIs[0].packetLength;this.MPIs[1]=new openpgp_type_mpi;this.MPIs[1].read(b,d,d-a);break;default:util.print_error("openpgp.packet.encryptedsessionkey.js\nunknown public key packet algorithm type "+this.publicKeyAlgorithmType)}return this};this.read_symmetric_key_packet=function(b,a,c){this.tagType=3;var d=a;this.version=b[d++];this.symmetricKeyAlgorithmUsed=b[d++];this.s2k=new openpgp_type_s2k;this.s2k.read(b,d);if(s2k.s2kLength+
|
||||
d<c){this.encryptedSessionKey=[];for(a=d-a;a<c;a++)this.encryptedSessionKey[a]=b[d++]}return this};this.write_pub_key_packet=function(b,a,c,d,e){for(var f=String.fromCharCode(3),d=String.fromCharCode(d),d=d+e,e=util.calc_checksum(e),d=d+String.fromCharCode(e>>8&255),d=d+String.fromCharCode(e&255),f=f+b+String.fromCharCode(c),b=new openpgp_type_mpi,a=openpgp_crypto_asymetricEncrypt(c,a,b.create(openpgp_encoding_eme_pkcs1_encode(d,a[0].mpiByteLength))),c=0;c<a.length;c++)f+=a[c];return f=openpgp_packet.write_packet_header(1,
|
||||
f.length)+f};this.toString=function(){if(1==this.tagType){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;a<this.MPIs.length;a++)b+=this.MPIs[a].toString();return b}return"5.3 Symmetric-Key Encrypted Session Key Packets (Tag 3)\n KeyId: "+this.keyId.toString()+"\n length: "+this.packetLength+"\n version:"+this.version+
|
||||
"\n symKeyA:"+this.symmetricKeyAlgorithmUsed+"\n s2k: "+this.s2k+"\n"};this.decrypt=function(b,a){if(1==this.tagType){var c=openpgp_crypto_asymetricDecrypt(this.publicKeyAlgorithmUsed,a.publicKey.MPIs,a.secMPIs,this.MPIs).toMPI();c.charCodeAt(c.length-2);c.charCodeAt(c.length-1);var d=openpgp_encoding_eme_pkcs1_decode(c.substring(2,c.length-2),a.publicKey.MPIs[0].getByteLength()),c=d.substring(1),d=d.charCodeAt(0);return 18==b.encryptedData.tagType?b.encryptedData.decrypt(d,c):b.encryptedData.decrypt_sym(d,
|
||||
c)}if(3==this.tagType)return util.print_error("Symmetric encrypted sessionkey is not supported!"),null}}
|
||||
function _openpgp_packet(){function b(a){result="";192>a?result+=String.fromCharCode(a):191<a&&8384>a?(result+=String.fromCharCode((a-192>>8)+192),result+=String.fromCharCode(a-192&255)):(result+=String.fromCharCode(255),result+=String.fromCharCode(a>>24&255),result+=String.fromCharCode(a>>16&255),result+=String.fromCharCode(a>>8&255),result+=String.fromCharCode(a&255));return result}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=b,f=-1,g=-1,g=0;0!=(a[e].charCodeAt()&64)&&(g=1);var h;g?f=a[e].charCodeAt()&63:(f=(a[e].charCodeAt()&63)>>2,h=a[e].charCodeAt()&3);e++;var j=null,k=-1;if(g)if(192>a[e].charCodeAt())packet_length=a[e++].charCodeAt(),util.print_debug("1 byte length:"+packet_length);else if(192<=a[e].charCodeAt()&&224>a[e].charCodeAt())packet_length=(a[e++].charCodeAt()-192<<8)+a[e++].charCodeAt()+192,util.print_debug("2 byte length:"+packet_length);else if(223<a[e].charCodeAt()&&255>a[e].charCodeAt()){packet_length=
|
||||
1<<(a[e++].charCodeAt()&31);util.print_debug("4 byte length:"+packet_length);k=e+packet_length;for(j=a.substring(e,e+packet_length);;)if(192>a[k].charCodeAt()){d=a[k++].charCodeAt();packet_length+=d;j+=a.substring(k,k+d);k+=d;break}else if(192<=a[k].charCodeAt()&&224>a[k].charCodeAt()){d=(a[k++].charCodeAt()-192<<8)+a[k++].charCodeAt()+192;packet_length+=d;j+=a.substring(k,k+d);k+=d;break}else if(223<a[k].charCodeAt()&&255>a[k].charCodeAt())d=1<<(a[k++].charCodeAt()&31),packet_length+=d,j+=a.substring(k,
|
||||
k+d),k+=d;else{k++;d=a[k++].charCodeAt()<<24|a[k++].charCodeAt()<<16|a[k++].charCodeAt()<<8|a[k++].charCodeAt();j+=a.substring(k,k+d);packet_length+=d;k+=d;break}}else e++,packet_length=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt();else switch(h){case 0:packet_length=a[e++].charCodeAt();break;case 1:packet_length=a[e++].charCodeAt()<<8|a[e++].charCodeAt();break;case 2:packet_length=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|
|
||||
a[e++].charCodeAt();break;default:packet_length=d}-1==k&&(k=packet_length);null==j&&(j=a.substring(e,e+k));switch(f){case 0:break;case 1:f=new openpgp_packet_encryptedsessionkey;if(null!=f.read_pub_key_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 2:f=new openpgp_packet_signature;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 3:f=new openpgp_packet_encryptedsessionkey;if(null!=f.read_symmetric_key_packet(j,0,packet_length))return f.headerLength=
|
||||
e-b,f.packetLength=k,f;break;case 4:f=new openpgp_packet_onepasssignature;if(f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 5:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag5(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 6:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag6(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 7:f=new openpgp_packet_keymaterial;
|
||||
if(null!=f.read_tag7(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 8:f=new openpgp_packet_compressed;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 9:f=new openpgp_packet_encrypteddata;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 10:f=new openpgp_packet_marker;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 11:f=new openpgp_packet_literaldata;
|
||||
if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.header=a.substring(b,e),f.packetLength=k,f;break;case 12:break;case 13:f=new openpgp_packet_userid;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 14:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag14(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 17:f=new openpgp_packet_userattribute;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=
|
||||
e-b,f.packetLength=k,f;break;case 18:f=new openpgp_packet_encryptedintegrityprotecteddata;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 19:f=new openpgp_packet_modificationdetectioncode;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;default:return util.print_error("openpgp.packet.js\n[ERROR] openpgp_packet: failed to parse packet @:"+e+"\nchar:'"+util.hexstrdump(a.substring(e))+"'\ninput:"+util.hexstrdump(a)),
|
||||
null}}}var openpgp_packet=new _openpgp_packet;
|
||||
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.charCodeAt(b)&128))return util.print_error("Error during parsing. This message / key is probably not containing a valid OpenPGP format."),
|
||||
null;var e=b,f=-1,g=-1,g=0;0!=(a.charCodeAt(e)&64)&&(g=1);var h;g?f=a.charCodeAt(e)&63:(f=(a.charCodeAt(e)&63)>>2,h=a.charCodeAt(e)&3);e++;var j=null,k=-1;if(g)if(192>a.charCodeAt(e))packet_length=a.charCodeAt(e++),util.print_debug("1 byte length:"+packet_length);else if(192<=a.charCodeAt(e)&&224>a.charCodeAt(e))packet_length=(a.charCodeAt(e++)-192<<8)+a.charCodeAt(e++)+192,util.print_debug("2 byte length:"+packet_length);else if(223<a.charCodeAt(e)&&255>a.charCodeAt(e)){packet_length=1<<(a.charCodeAt(e++)&
|
||||
31);util.print_debug("4 byte length:"+packet_length);k=e+packet_length;for(j=a.substring(e,e+packet_length);;)if(192>a.charCodeAt(k)){d=a.charCodeAt(k++);packet_length+=d;j+=a.substring(k,k+d);k+=d;break}else if(192<=a.charCodeAt(k)&&224>a.charCodeAt(k)){d=(a.charCodeAt(k++)-192<<8)+a.charCodeAt(k++)+192;packet_length+=d;j+=a.substring(k,k+d);k+=d;break}else if(223<a.charCodeAt(k)&&255>a.charCodeAt(k))d=1<<(a.charCodeAt(k++)&31),packet_length+=d,j+=a.substring(k,k+d),k+=d;else{k++;d=a.charCodeAt(k++)<<
|
||||
24|a.charCodeAt(k++)<<16|a.charCodeAt(k++)<<8|a.charCodeAt(k++);j+=a.substring(k,k+d);packet_length+=d;k+=d;break}}else e++,packet_length=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++);else switch(h){case 0:packet_length=a.charCodeAt(e++);break;case 1:packet_length=a.charCodeAt(e++)<<8|a.charCodeAt(e++);break;case 2:packet_length=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++);break;default:packet_length=d}-1==k&&(k=packet_length);
|
||||
null==j&&(j=a.substring(e,e+k));switch(f){case 0:break;case 1:f=new openpgp_packet_encryptedsessionkey;if(null!=f.read_pub_key_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 2:f=new openpgp_packet_signature;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 3:f=new openpgp_packet_encryptedsessionkey;if(null!=f.read_symmetric_key_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 4:f=new openpgp_packet_onepasssignature;
|
||||
if(f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 5:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag5(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 6:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag6(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 7:f=new openpgp_packet_keymaterial;if(null!=f.read_tag7(j,0,packet_length))return f.headerLength=
|
||||
e-b,f.packetLength=k,f;break;case 8:f=new openpgp_packet_compressed;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 9:f=new openpgp_packet_encrypteddata;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 10:f=new openpgp_packet_marker;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 11:f=new openpgp_packet_literaldata;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=
|
||||
e-b,f.header=a.substring(b,e),f.packetLength=k,f;break;case 12:break;case 13:f=new openpgp_packet_userid;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 14:f=new openpgp_packet_keymaterial;f.header=a.substring(b,e);if(null!=f.read_tag14(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 17:f=new openpgp_packet_userattribute;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 18:f=
|
||||
new openpgp_packet_encryptedintegrityprotecteddata;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;case 19:f=new openpgp_packet_modificationdetectioncode;if(null!=f.read_packet(j,0,packet_length))return f.headerLength=e-b,f.packetLength=k,f;break;default:return util.print_error("openpgp.packet.js\n[ERROR] openpgp_packet: failed to parse packet @:"+e+"\nchar:'"+util.hexstrdump(a.substring(e))+"'\ninput:"+util.hexstrdump(a)),null}}}var openpgp_packet=new _openpgp_packet;
|
||||
function openpgp_packet_keymaterial(){this.subKeyRevocationSignature=this.subKeySignature=this.parentNode=this.checksum=this.hasUnencryptedSecretKeyData=this.encryptedMPIData=this.IVLength=this.s2kUsageConventions=this.symmetricEncryptionAlgorithm=this.publicKey=this.secMPIs=this.MPIs=this.expiration=this.version=this.creationTime=this.tagType=this.publicKeyAlgorithm=null;this.read_tag5=function(b,a,c){this.tagType=5;this.read_priv_key(b,a,c);return this};this.read_tag6=function(b,a,c){this.tagType=
|
||||
6;this.packetLength=c;this.read_pub_key(b,a,c);return this};this.read_tag7=function(b,a,c){this.tagType=7;this.packetLength=c;return this.read_priv_key(b,a,c)};this.read_tag14=function(b,a,c){this.subKeySignature=null;this.subKeyRevocationSignature=[];this.tagType=14;this.packetLength=c;this.read_pub_key(b,a,c);return this};this.toString=function(){var b="";switch(this.tagType){case 6:b+="5.5.1.1. Public-Key Packet (Tag 6)\n length: "+this.packetLength+"\n version: "+
|
||||
this.version+"\n creation time: "+this.creationTime+"\n expiration time: "+this.expiration+"\n publicKeyAlgorithm: "+this.publicKeyAlgorithm+"\n";break;case 14:b+="5.5.1.2. Public-Subkey Packet (Tag 14)\n length: "+this.packetLength+"\n version: "+this.version+"\n creation time: "+this.creationTime+"\n expiration time: "+this.expiration+"\n publicKeyAlgorithm: "+this.publicKeyAlgorithm+"\n";break;case 5:b+="5.5.1.3. Secret-Key Packet (Tag 5)\n length: "+
|
||||
this.packetLength+"\n version: "+this.publicKey.version+"\n creation time: "+this.publicKey.creationTime+"\n expiration time: "+this.publicKey.expiration+"\n publicKeyAlgorithm: "+this.publicKey.publicKeyAlgorithm+"\n";break;case 7:b+="5.5.1.4. Secret-Subkey Packet (Tag 7)\n length: "+this.packetLength+"\n version[1]: "+(4==this.version)+"\n creationtime[4]: "+this.creationTime+"\n expiration[2]: "+this.expiration+"\n publicKeyAlgorithm: "+
|
||||
this.publicKeyAlgorithm+"\n";break;default:b+="unknown key material packet\n"}if(null!=this.MPIs)for(var b=b+"Public Key MPIs:\n",a=0;a<this.MPIs.length;a++)b+=this.MPIs[a].toString();if(null!=this.publicKey&&null!=this.publicKey.MPIs){b+="Public Key MPIs:\n";for(a=0;a<this.publicKey.MPIs.length;a++)b+=this.publicKey.MPIs[a].toString()}if(null!=this.secMPIs){b+="Secret Key MPIs:\n";for(a=0;a<this.secMPIs.length;a++)b+=this.secMPIs[a].toString()}null!=this.subKeySignature&&(b+="subKey Signature:\n"+
|
||||
this.subKeySignature.toString());null!=this.subKeyRevocationSignature&&(b+="subKey Revocation Signature:\n"+this.subKeyRevocationSignature.toString());return b};this.read_pub_key=function(b,a){var c=a;this.version=b[c++].charCodeAt();if(3==this.version){this.creationTime=new Date(1E3*(b[c++].charCodeAt()<<24|b[c++].charCodeAt()<<16|b[c++].charCodeAt()<<8|b[c++].charCodeAt()));this.expiration=b[c++].charCodeAt()<<8&b[c++].charCodeAt();this.publicKeyAlgorithm=b[c++].charCodeAt();var d=0;0<this.publicKeyAlgorithm&&
|
||||
4>this.publicKeyAlgorithm?d=2:16==this.publicKeyAlgorithm?d=3:17==this.publicKeyAlgorithm&&(d=4);this.MPIs=[];for(var e=0;e<d;e++)this.MPIs[e]=new openpgp_type_mpi,null!=this.MPIs[e].read(b,c,c-a)&&!this.packetLength<c-a?c+=this.MPIs[e].packetLength:util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);this.packetLength=c-a}else if(4==this.version){this.creationTime=new Date(1E3*(b[c++].charCodeAt()<<24|b[c++].charCodeAt()<<16|b[c++].charCodeAt()<<8|b[c++].charCodeAt()));this.publicKeyAlgorithm=
|
||||
b[c++].charCodeAt();d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=2:16==this.publicKeyAlgorithm?d=3:17==this.publicKeyAlgorithm&&(d=4);this.MPIs=[];for(e=0;e<d;e++)this.MPIs[e]=new openpgp_type_mpi,null!=this.MPIs[e].read(b,c,c-a)&&!this.packetLength<c-a?c+=this.MPIs[e].packetLength:util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);this.packetLength=c-a}else return null;this.data=b.substring(a,c);this.packetdata=b.substring(a,c);return this};this.read_priv_key=
|
||||
function(b,a,c){this.publicKey=new openpgp_packet_keymaterial;if(null==this.publicKey.read_pub_key(b,a,c))return util.print_error("openpgp.packet.keymaterial.js\nFailed reading public key portion of a private key: "+b[a].charCodeAt()+" "+a+" "+c+"\n Aborting here..."),null;this.publicKey.header=openpgp_packet.write_old_packet_header(6,this.publicKey.packetLength);var d=a+this.publicKey.data.length;this.packetLength=c;this.s2kUsageConventions=b[d++].charCodeAt();if(0==this.s2kUsageConventions)this.hasUnencryptedSecretKeyData=
|
||||
!0;if(255==this.s2kUsageConventions||254==this.s2kUsageConventions)this.symmetricEncryptionAlgorithm=b[d++].charCodeAt();if(255==this.s2kUsageConventions||254==this.s2kUsageConventions)this.s2k=new openpgp_type_s2k,this.s2k.read(b,d),d+=this.s2k.s2kLength;this.symkeylength=0;if(0!=this.s2kUsageConventions&&255!=this.s2kUsageConventions&&254!=this.s2kUsageConventions)this.symmetricEncryptionAlgorithm=this.s2kUsageConventions;if(0!=this.s2kUsageConventions&&1001!=this.s2k.type){this.hasIV=!0;switch(this.symmetricEncryptionAlgorithm){case 1:return util.print_error("openpgp.packet.keymaterial.js\nsymmetric encrytryption algorithim: IDEA is not implemented"),
|
||||
this.subKeySignature.toString());null!=this.subKeyRevocationSignature&&(b+="subKey Revocation Signature:\n"+this.subKeyRevocationSignature.toString());return b};this.read_pub_key=function(b,a){var c=a;this.version=b.charCodeAt(c++);if(3==this.version){this.creationTime=new Date(1E3*(b.charCodeAt(c++)<<24|b.charCodeAt(c++)<<16|b.charCodeAt(c++)<<8|b.charCodeAt(c++)));this.expiration=b.charCodeAt(c++)<<8|b.charCodeAt(c++);this.publicKeyAlgorithm=b.charCodeAt(c++);var d=0;0<this.publicKeyAlgorithm&&
|
||||
4>this.publicKeyAlgorithm?d=2:16==this.publicKeyAlgorithm?d=3:17==this.publicKeyAlgorithm&&(d=4);this.MPIs=[];for(var e=0;e<d;e++)this.MPIs[e]=new openpgp_type_mpi,null!=this.MPIs[e].read(b,c,c-a)&&!this.packetLength<c-a?c+=this.MPIs[e].packetLength:util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);this.packetLength=c-a}else if(4==this.version){this.creationTime=new Date(1E3*(b.charCodeAt(c++)<<24|b.charCodeAt(c++)<<16|b.charCodeAt(c++)<<8|b.charCodeAt(c++)));this.publicKeyAlgorithm=
|
||||
b.charCodeAt(c++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=2:16==this.publicKeyAlgorithm?d=3:17==this.publicKeyAlgorithm&&(d=4);this.MPIs=[];for(e=0;e<d;e++)this.MPIs[e]=new openpgp_type_mpi,null!=this.MPIs[e].read(b,c,c-a)&&!this.packetLength<c-a?c+=this.MPIs[e].packetLength:util.print_error("openpgp.packet.keymaterial.js\nerror reading MPI @:"+c);this.packetLength=c-a}else return null;this.data=b.substring(a,c);this.packetdata=b.substring(a,c);return this};this.read_priv_key=function(b,
|
||||
a,c){this.publicKey=new openpgp_packet_keymaterial;if(null==this.publicKey.read_pub_key(b,a,c))return util.print_error("openpgp.packet.keymaterial.js\nFailed reading public key portion of a private key: "+b.charCodeAt(a)+" "+a+" "+c+"\n Aborting here..."),null;this.publicKey.header=openpgp_packet.write_old_packet_header(6,this.publicKey.packetLength);var d=a+this.publicKey.data.length;this.packetLength=c;this.s2kUsageConventions=b.charCodeAt(d++);if(0==this.s2kUsageConventions)this.hasUnencryptedSecretKeyData=
|
||||
!0;if(255==this.s2kUsageConventions||254==this.s2kUsageConventions)this.symmetricEncryptionAlgorithm=b.charCodeAt(d++);if(255==this.s2kUsageConventions||254==this.s2kUsageConventions)this.s2k=new openpgp_type_s2k,this.s2k.read(b,d),d+=this.s2k.s2kLength;this.symkeylength=0;if(0!=this.s2kUsageConventions&&255!=this.s2kUsageConventions&&254!=this.s2kUsageConventions)this.symmetricEncryptionAlgorithm=this.s2kUsageConventions;if(0!=this.s2kUsageConventions&&1001!=this.s2k.type){this.hasIV=!0;switch(this.symmetricEncryptionAlgorithm){case 1:return util.print_error("openpgp.packet.keymaterial.js\nsymmetric encrytryption algorithim: IDEA is not implemented"),
|
||||
null;case 2:case 3:this.IVLength=8;break;case 4:case 7:case 8:case 9:this.IVLength=16;break;case 10:this.IVLength=32;break;default:return util.print_error("openpgp.packet.keymaterial.js\nunknown encryption algorithm for secret key :"+this.symmetricEncryptionAlgorithm),null}d++;this.IV=b.substring(d,d+this.IVLength);d+=this.IVLength}if(0!=this.s2kUsageConventions&&1001==this.s2k.type)this.encryptedMPIData=this.secMPIs=null;else if(this.hasUnencryptedSecretKeyData){if(0<this.publicKey.publicKeyAlgorithm&&
|
||||
4>this.publicKey.publicKeyAlgorithm)this.secMPIs=[],this.secMPIs[0]=new openpgp_type_mpi,this.secMPIs[0].read(b,d,c-2-(d-a)),d+=this.secMPIs[0].packetLength,this.secMPIs[1]=new openpgp_type_mpi,this.secMPIs[1].read(b,d,c-2-(d-a)),d+=this.secMPIs[1].packetLength,this.secMPIs[2]=new openpgp_type_mpi,this.secMPIs[2].read(b,d,c-2-(d-a)),d+=this.secMPIs[2].packetLength,this.secMPIs[3]=new openpgp_type_mpi,this.secMPIs[3].read(b,d,c-2-(d-a)),d+=this.secMPIs[3].packetLength;else if(16==this.publicKey.publicKeyAlgorithm)this.secMPIs=
|
||||
[],this.secMPIs[0]=new openpgp_type_mpi,this.secMPIs[0].read(b,d,c-2-(d-a)),d+=this.secMPIs[0].packetLength;else if(17==this.publicKey.publicKeyAlgorithm)this.secMPIs=[],this.secMPIs[0]=new openpgp_type_mpi,this.secMPIs[0].read(b,d,c-2-(d-a)),d+=this.secMPIs[0].packetLength;this.checksum=[];this.checksum[0]=b[d++].charCodeAt();this.checksum[1]=b[d++].charCodeAt()}else this.encryptedMPIData=b.substring(d,c);return this};this.decryptSecretMPIs=function(b){if(this.hasUnencryptedSecretKeyData)return this.secMPIs;
|
||||
[],this.secMPIs[0]=new openpgp_type_mpi,this.secMPIs[0].read(b,d,c-2-(d-a)),d+=this.secMPIs[0].packetLength;else if(17==this.publicKey.publicKeyAlgorithm)this.secMPIs=[],this.secMPIs[0]=new openpgp_type_mpi,this.secMPIs[0].read(b,d,c-2-(d-a)),d+=this.secMPIs[0].packetLength;this.checksum=[];this.checksum[0]=b.charCodeAt(d++);this.checksum[1]=b.charCodeAt(d++)}else this.encryptedMPIData=b.substring(d,c);return this};this.decryptSecretMPIs=function(b){if(this.hasUnencryptedSecretKeyData)return this.secMPIs;
|
||||
var a=this.s2k.produce_key(b),c="";switch(this.symmetricEncryptionAlgorithm){case 1:return util.print_error("openpgp.packet.keymaterial.js\nsymmetric encryption algorithim: IDEA is not implemented"),!1;case 2:c=normal_cfb_decrypt(function(a,b){return des(b,a,1,null,0)},this.IVLength,a,this.encryptedMPIData,this.IV);break;case 3:c=normal_cfb_decrypt(function(a,b){var c=new openpgp_symenc_cast5;c.setKey(b);return c.encrypt(util.str2bin(a))},this.IVLength,util.str2bin(a.substring(0,16)),this.encryptedMPIData,
|
||||
this.IV);break;case 4:c=normal_cfb_decrypt(function(a,b){return(new Blowfish(b)).encrypt(a)},this.IVLength,a,this.encryptedMPIData,this.IV);break;case 7:case 8:case 9:c=16;8==this.symmetricEncryptionAlgorithm&&(c=24,a=this.s2k.produce_key(b,c));9==this.symmetricEncryptionAlgorithm&&(c=32,a=this.s2k.produce_key(b,c));c=normal_cfb_decrypt(function(a,b){return AESencrypt(util.str2bin(a),b)},this.IVLength,keyExpansion(a.substring(0,c)),this.encryptedMPIData,this.IV);break;case 10:return util.print_error("openpgp.packet.keymaterial.js\nKey material is encrypted with twofish: not implemented"),
|
||||
!1;default:return util.print_error("openpgp.packet.keymaterial.js\nunknown encryption algorithm for secret key :"+this.symmetricEncryptionAlgorithm),!1}if(null==c)return util.print_error("openpgp.packet.keymaterial.js\ncleartextMPIs was null"),!1;b=c.length;if(254==this.s2kUsageConventions&&str_sha1(c.substring(0,c.length-20))==c.substring(c.length-20))b-=20;else if(254!=this.s2kUsageConventions&&util.calc_checksum(c.substring(0,c.length-2))==(c.charCodeAt(c.length-2)<<8|c.charCodeAt(c.length-1)))b-=
|
||||
|
@ -412,42 +412,42 @@ return{string:b+d,header:b,body:d}}}
|
|||
function openpgp_packet_literaldata(){this.tagType=11;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_literaldata.formats.utf8&&(b=util.decode_utf8(b));this.data=b};this.get_data_bytes=function(){return this.format==openpgp_packet_literaldata.formats.utf8?util.encode_utf8(this.data):this.data};this.read_packet=function(b,a,c){this.packetLength=c;c=b[a];this.filename=util.decode_utf8(b.substr(a+2,b.charCodeAt(a+1)));this.date=
|
||||
new Date(1E3*parseInt(b.substr(a+2+b.charCodeAt(a+1),4)));this.set_data_bytes(b.substring(a+6+b.charCodeAt(a+1)),c);return this};this.write_packet=function(b){this.set_data(b,openpgp_packet_literaldata.formats.utf8);this.filename=util.encode_utf8("msg.txt");this.date=new Date;var b=this.get_data_bytes(),a=openpgp_packet.write_packet_header(11,b.length+6+this.filename.length),a=a+this.format,a=a+String.fromCharCode(this.filename.length),a=a+this.filename,a=a+String.fromCharCode(Math.round(this.date.getTime()/
|
||||
1E3)>>24&255),a=a+String.fromCharCode(Math.round(this.date.getTime()/1E3)>>16&255),a=a+String.fromCharCode(Math.round(this.date.getTime()/1E3)>>8&255),a=a+String.fromCharCode(Math.round(this.date.getTime()/1E3)&255);return a+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_literaldata.formats={binary:"b",text:"t",utf8:"u"};function openpgp_packet_marker(){this.tagType=10;this.read_packet=function(b,a){this.packetLength=3;return 80==b[a].charCodeAt()&&71==b[a+1].charCodeAt()&&80==b[a+2].charCodeAt()?this:null};this.toString=function(){return'5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)\n packet reads: "PGP"\n'}}
|
||||
openpgp_packet_literaldata.formats={binary:"b",text:"t",utf8:"u"};function openpgp_packet_marker(){this.tagType=10;this.read_packet=function(b,a){this.packetLength=3;return 80==b.charCodeAt(a)&&71==b.charCodeAt(a+1)&&80==b.charCodeAt(a+2)?this:null};this.toString=function(){return'5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)\n packet reads: "PGP"\n'}}
|
||||
function openpgp_packet_modificationdetectioncode(){this.tagType=19;this.hash=null;this.read_packet=function(b,a,c){this.packetLength=c;if(20!=c)return util.print_error("openpgp.packet.modificationdetectioncode.js\ninvalid length for a modification detection code packet!"+c),null;this.hash=b.substring(a,a+20);return this};this.toString=function(){return"5.14 Modification detection code packet\n bytes ("+this.hash.length+"): ["+util.hexstrdump(this.hash)+"]"}}
|
||||
function openpgp_packet_onepasssignature(){this.tagType=4;this.flags=this.signingKeyId=this.publicKeyAlgorithm=this.hashAlgorithm=this.type=this.version=null;this.read_packet=function(b,a,c){this.packetLength=c;this.version=b.charCodeAt(a++);this.type=b.charCodeAt(a++);this.hashAlgorithm=b.charCodeAt(a++);this.publicKeyAlgorithm=b.charCodeAt(a++);this.signingKeyId=new openpgp_type_keyid;this.signingKeyId.read_packet(b,a);a+=8;this.flags=b.charCodeAt(a++);return this};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=function(b,a,c,d,e){d=""+openpgp_packet.write_packet_header(4,13);d+=String.fromCharCode(3);d+=String.fromCharCode(b);d+=String.fromCharCode(a);d+=String.fromCharCode(c.privateKeyPacket.publicKey.publicKeyAlgorithm);d+=c.getKeyId();return d=e?d+String.fromCharCode(0):
|
||||
d+String.fromCharCode(1)}}
|
||||
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(a,b,d){0>d&&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:223<a[e].charCodeAt()&&255>a[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;g<f-1;g++)this.regular_expression+=a[e++];break;case 7:this.revocable=1==a[e++].charCodeAt();break;case 9:this.keyExpirationTime=a[e++].charCodeAt()<<24|a[e++].charCodeAt()<<16|a[e++].charCodeAt()<<8|a[e++].charCodeAt();this.keyNeverExpires=0==this.keyExpirationTime;break;case 11:this.preferredSymmetricAlgorithms=[];for(g=0;g<f-1;g++)this.preferredSymmetricAlgorithms=a[e++].charCodeAt();break;case 12:this.revocationKeyClass=
|
||||
a[e++].charCodeAt();this.revocationKeyAlgorithm=a[e++].charCodeAt();this.revocationKeyFingerprint=[];for(g=0;20>g;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<d;g++)this.notationName+=a[e++];this.notationValue=
|
||||
"";for(g=0;g<f;g++)this.notationValue+=a[e++];break;case 21:this.preferredHashAlgorithms=[];for(g=0;g<f-1;g++)this.preferredHashAlgorithms=a[e++].charCodeAt();break;case 22:this.preferredCompressionAlgorithms=[];for(g=0;g<f-1;g++)this.preferredCompressionAlgorithms=a[e++].charCodeAt();break;case 23:this.keyServerPreferences=[];for(g=0;g<f-1;g++)this.keyServerPreferences=a[e++].charCodeAt();break;case 24:this.preferredKeyServer=new String;for(g=0;g<f-1;g++)this.preferredKeyServer+=a[e++];break;case 25:this.isPrimaryUserID=
|
||||
0!=a[e++];break;case 26:this.policyURI=new String;for(g=0;g<f-1;g++)this.policyURI+=a[e++];break;case 27:this.keyFlags=[];for(g=0;g<f-1;g++)this.keyFlags=a[e++].charCodeAt();break;case 28:this.signersUserId=new String;for(g=0;g<f-1;g++)this.signersUserId+=a[e++];break;case 29:this.reasonForRevocationFlag=a[e++].charCodeAt();this.reasonForRevocationString=new String;for(g=0;g<f-2;g++)this.reasonForRevocationString+=a[e++];break;case 30:return f+1;case 31:this.signatureTargetPublicKeyAlgorithm=a[e++].charCodeAt();
|
||||
this.signatureTargetHashAlgorithm=a[e++].charCodeAt();f=0;switch(this.signatureTargetHashAlgorithm){case 1:case 2:f=20;break;case 3:case 8:case 9:case 10:case 11:break;default:return util.print_error("openpgp.packet.signature.js\nunknown signature target hash algorithm:"+this.signatureTargetHashAlgorithm),null}this.signatureTargetHash=[];for(g=0;g<f;g++)this.signatureTargetHash[g]=a[e++];case 32:return this.embeddedSignature=new openpgp_packet_signature,this.embeddedSignature.read_packet(a,e,d-(e-
|
||||
b)),e+this.embeddedSignature.packetLength-b;case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:return util.print_error("openpgp.packet.signature.js\nprivate or experimental signature subpacket type "+g+" @:"+e+" subplen:"+f+" len:"+d),f+1;default:return util.print_error("openpgp.packet.signature.js\nunknown signature subpacket type "+g+" @:"+e+" subplen:"+f+" len:"+d),f+1}return e-b};this.getIssuerKey=function(){var a=null;if(4==this.version)a=openpgp.keyring.getPublicKeysForKeyId(this.issuerKeyId);
|
||||
else if(3==this.version)a=openpgp.keyring.getPublicKeysForKeyId(this.keyId);else return null;return 0==a.length?null:a[0]};this.getIssuer=function(){return 4==this.version?this.issuerKeyId:4==this.verions?this.keyId:null};this.write_message_signature=function(a,c,d){var e=d.privateKeyPacket.publicKey,f=d.getPreferredSignatureHashAlgorithm(),g=String.fromCharCode(4),g=g+String.fromCharCode(a),g=g+String.fromCharCode(e.publicKeyAlgorithm),g=g+String.fromCharCode(f),a=Math.round((new Date).getTime()/
|
||||
1E3),a=b(2,""+String.fromCharCode(a>>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;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+
|
||||
e);break;case 4:this.signatureType=a[e++].charCodeAt();this.publicKeyAlgorithm=a[e++].charCodeAt();this.hashAlgorithm=a[e++].charCodeAt();f=(a[e++].charCodeAt()<<8)+a[e++].charCodeAt();for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nhashed missed something: "+e+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signatureData=a.substring(b,e);f=(a[e++].charCodeAt()<<8)+a[e++].charCodeAt();for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nmissed something: "+
|
||||
d+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signedHashValue=a[e++].charCodeAt()<<8|a[e++].charCodeAt();d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;default:util.print_error("openpgp.packet.signature.js\nunknown signature packet version"+
|
||||
this.version)}return this};this.toString=function(){for(var a=3==this.version?"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nFour-octet creation time. :"+this.creationTime+"\nEight-octet Key ID of signer. :"+util.hexidump(this.keyId)+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+
|
||||
this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\n":"5.2. Signature Packet (Tag 2)\nPacket Length: :"+this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+
|
||||
this.signedHashValue+"\nSignature Creation Time :"+this.creationTime+"\nSignature Expiration Time :"+this.signatureExpirationTime+"\nSignature Never Expires :"+this.signatureNeverExpires+"\nExportable Certification :"+this.exportable+"\nTrust Signature level: :"+this.trustLevel+" amount"+this.trustAmount+"\nRegular Expression :"+this.regular_expression+"\nRevocable :"+this.revocable+"\nKey Expiration Time :"+
|
||||
this.keyExpirationTime+" "+this.keyNeverExpires+"\nPreferred Symmetric Algorithms :"+this.preferredSymmetricAlgorithms+"\nRevocation Key\n ( 1 octet of class, :"+this.revocationKeyClass+"\n 1 octet of public-key ID, :"+this.revocationKeyAlgorithm+"\n 20 octets of fingerprint) :"+this.revocationKeyFingerprint+"\nIssuer :"+util.hexstrdump(this.issuerKeyId)+"\nPreferred Hash Algorithms :"+this.preferredHashAlgorithms+"\nPreferred Compression Alg. :"+
|
||||
this.preferredCompressionAlgorithms+"\nKey Server Preferences :"+this.keyServerPreferences+"\nPreferred Key Server :"+this.preferredKeyServer+"\nPrimary User ID :"+this.isPrimaryUserID+"\nPolicy URI :"+this.policyURI+"\nKey Flags :"+this.keyFlags+"\nSigner's User ID :"+this.signersUserId+"\nNotation :"+this.notationName+" = "+this.notationValue+"\nReason for Revocation\n Flag :"+
|
||||
this.reasonForRevocationFlag+"\n Reason :"+this.reasonForRevocationString+"\nMPI:\n",b=0;b<this.MPIs.length;b++)a+=this.MPIs[b].toString();return a}}
|
||||
function openpgp_packet_userattribute(){this.tagType=17;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.read_packet=function(b,a,c){var d=0;this.packetLength=c;this.userattributes=[];for(var e=a;c!=d;){var f=0;192>b[e].charCodeAt()?(packet_length=b[e++].charCodeAt(),f=1):192<=b[e].charCodeAt()&&224>b[e].charCodeAt()?(packet_length=(b[e++].charCodeAt()-192<<8)+b[e++].charCodeAt()+192,f=2):223<b[e].charCodeAt()&&255>b[e].charCodeAt()?
|
||||
(packet_length=1<<(b[e++].charCodeAt()&31),f=1):(f=5,e++,packet_length=b[e++].charCodeAt()<<24|b[e++].charCodeAt()<<16|b[e++].charCodeAt()<<8|b[e++].charCodeAt());b[e++].charCodeAt();packet_length--;f++;this.userattributes[0]=[];this.userattributes[0]=b.substring(e,e+packet_length);e+=packet_length;d+=f+packet_length}this.packetLength=e-a;return this};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 @:"+
|
||||
null;this.verified=!1;this._raw_read_signature_sub_packet=function(a,b,d){0>d&&util.print_debug("openpgp.packet.signature.js\n_raw_read_signature_sub_packet length < 0 @:"+b);var e=b,f=0;192>a.charCodeAt(e)?f=a.charCodeAt(e++):192<=a.charCodeAt(e)&&224>a.charCodeAt(e)?f=(a.charCodeAt(e++)-192<<8)+a.charCodeAt(e++)+192:223<a.charCodeAt(e)&&255>a.charCodeAt(e)?f=1<<(a.charCodeAt(e++)&31):255>a.charCodeAt(e)&&(e++,f=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++));
|
||||
var g=a.charCodeAt(e++)&127;switch(g){case 2:this.creationTime=new Date(1E3*(a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++)));break;case 3:this.signatureExpirationTime=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++);this.signatureNeverExpires=0==this.signature_expiration_time;break;case 4:this.exportable=1==a.charCodeAt(e++);break;case 5:this.trustLevel=a.charCodeAt(e++);this.trustAmount=a.charCodeAt(e++);break;case 6:this.regular_expression=
|
||||
new String;for(g=0;g<f-1;g++)this.regular_expression+=a[e++];break;case 7:this.revocable=1==a.charCodeAt(e++);break;case 9:this.keyExpirationTime=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++);this.keyNeverExpires=0==this.keyExpirationTime;break;case 11:this.preferredSymmetricAlgorithms=[];for(g=0;g<f-1;g++)this.preferredSymmetricAlgorithms=a.charCodeAt(e++);break;case 12:this.revocationKeyClass=a.charCodeAt(e++);this.revocationKeyAlgorithm=a.charCodeAt(e++);this.revocationKeyFingerprint=
|
||||
[];for(g=0;20>g;g++)this.revocationKeyFingerprint=a.charCodeAt(e++);break;case 16:this.issuerKeyId=a.substring(e,e+8);e+=8;break;case 20:this.notationFlags=a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++);d=a.charCodeAt(e++)<<8|a.charCodeAt(e++);f=a.charCodeAt(e++)<<8|a.charCodeAt(e++);this.notationName="";for(g=0;g<d;g++)this.notationName+=a[e++];this.notationValue="";for(g=0;g<f;g++)this.notationValue+=a[e++];break;case 21:this.preferredHashAlgorithms=[];for(g=
|
||||
0;g<f-1;g++)this.preferredHashAlgorithms=a.charCodeAt(e++);break;case 22:this.preferredCompressionAlgorithms=[];for(g=0;g<f-1;g++)this.preferredCompressionAlgorithms=a.charCodeAt(e++);break;case 23:this.keyServerPreferences=[];for(g=0;g<f-1;g++)this.keyServerPreferences=a.charCodeAt(e++);break;case 24:this.preferredKeyServer=new String;for(g=0;g<f-1;g++)this.preferredKeyServer+=a[e++];break;case 25:this.isPrimaryUserID=0!=a[e++];break;case 26:this.policyURI=new String;for(g=0;g<f-1;g++)this.policyURI+=
|
||||
a[e++];break;case 27:this.keyFlags=[];for(g=0;g<f-1;g++)this.keyFlags=a.charCodeAt(e++);break;case 28:this.signersUserId=new String;for(g=0;g<f-1;g++)this.signersUserId+=a[e++];break;case 29:this.reasonForRevocationFlag=a.charCodeAt(e++);this.reasonForRevocationString=new String;for(g=0;g<f-2;g++)this.reasonForRevocationString+=a[e++];break;case 30:return f+1;case 31:this.signatureTargetPublicKeyAlgorithm=a.charCodeAt(e++);this.signatureTargetHashAlgorithm=a.charCodeAt(e++);f=0;switch(this.signatureTargetHashAlgorithm){case 1:case 2:f=
|
||||
20;break;case 3:case 8:case 9:case 10:case 11:break;default:return util.print_error("openpgp.packet.signature.js\nunknown signature target hash algorithm:"+this.signatureTargetHashAlgorithm),null}this.signatureTargetHash=[];for(g=0;g<f;g++)this.signatureTargetHash[g]=a[e++];case 32:return this.embeddedSignature=new openpgp_packet_signature,this.embeddedSignature.read_packet(a,e,d-(e-b)),e+this.embeddedSignature.packetLength-b;case 100:case 101:case 102:case 103:case 104:case 105:case 106:case 107:case 108:case 109:case 110:return util.print_error("openpgp.packet.signature.js\nprivate or experimental signature subpacket type "+
|
||||
g+" @:"+e+" subplen:"+f+" len:"+d),f+1;default:return util.print_error("openpgp.packet.signature.js\nunknown signature subpacket type "+g+" @:"+e+" subplen:"+f+" len:"+d),f+1}return e-b};this.getIssuerKey=function(){var a=null;if(4==this.version)a=openpgp.keyring.getPublicKeysForKeyId(this.issuerKeyId);else if(3==this.version)a=openpgp.keyring.getPublicKeysForKeyId(this.keyId);else return null;return 0==a.length?null:a[0]};this.getIssuer=function(){return 4==this.version?this.issuerKeyId:3==this.version?
|
||||
this.keyId:null};this.write_message_signature=function(a,c,d){var e=d.privateKeyPacket.publicKey,f=d.getPreferredSignatureHashAlgorithm(),g=String.fromCharCode(4),g=g+String.fromCharCode(a),g=g+String.fromCharCode(e.publicKeyAlgorithm),g=g+String.fromCharCode(f),a=Math.round((new Date).getTime()/1E3),a=b(2,""+String.fromCharCode(a>>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:this.verified=4==this.version?openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,a+this.signatureData+d):!1;break;case 1:if(4==this.version){var e=a.replace(/\r\n/g,"\n").replace(/[\t ]+\n/g,"\n").replace(/\n/g,"\r\n");this.verified=openpgp_crypto_verifySignature(this.publicKeyAlgorithm,this.hashAlgorithm,this.MPIs,b.obj.publicKeyPacket.MPIs,e+this.signatureData+d)}else this.verified=!1;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"),this.verified=!1}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.charCodeAt(e++);switch(this.version){case 3:5!=a.charCodeAt(e++)&&util.print_debug("openpgp.packet.signature.js\ninvalid One-octet length of following hashed material. MUST be 5. @:"+(e-1));this.signatureType=a.charCodeAt(e++);this.creationTime=new Date(1E3*(a.charCodeAt(e++)<<24|a.charCodeAt(e++)<<16|a.charCodeAt(e++)<<8|a.charCodeAt(e++)));this.signatureData=a.substring(b,e);this.keyId=a.substring(e,e+8);e+=8;this.publicKeyAlgorithm=a.charCodeAt(e++);
|
||||
this.hashAlgorithm=a.charCodeAt(e++);this.signedHashValue=a.charCodeAt(e++)<<8|a.charCodeAt(e++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(var f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;case 4:this.signatureType=a.charCodeAt(e++);this.publicKeyAlgorithm=a.charCodeAt(e++);this.hashAlgorithm=
|
||||
a.charCodeAt(e++);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nhashed missed something: "+e+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signatureData=a.substring(b,e);f=(a.charCodeAt(e++)<<8)+a.charCodeAt(e++);for(d=0;f!=d;)f<d&&util.print_debug("openpgp.packet.signature.js\nmissed something: "+d+" c:"+f+" l:"+d),d+=this._raw_read_signature_sub_packet(a,e+d,f-d);e+=f;this.signedHashValue=a.charCodeAt(e++)<<
|
||||
8|a.charCodeAt(e++);d=0;0<this.publicKeyAlgorithm&&4>this.publicKeyAlgorithm?d=1:17==this.publicKeyAlgorithm&&(d=2);this.MPIs=[];for(f=0;f<d;f++)this.MPIs[f]=new openpgp_type_mpi,null!=this.MPIs[f].read(a,e,e-b)&&!this.packetLength<e-b?e+=this.MPIs[f].packetLength:util.print_error("signature contains invalid MPI @:"+e);break;default:util.print_error("openpgp.packet.signature.js\nunknown signature packet version"+this.version)}return this};this.toString=function(){for(var a=3==this.version?"5.2. Signature Packet (Tag 2)\nPacket Length: :"+
|
||||
this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nFour-octet creation time. :"+this.creationTime+"\nEight-octet Key ID of signer. :"+util.hexidump(this.keyId)+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\n":"5.2. Signature Packet (Tag 2)\nPacket Length: :"+
|
||||
this.packetLength+"\nPacket version: :"+this.version+"\nOne-octet signature type :"+this.signatureType+"\nOne-octet public-key algorithm. :"+this.publicKeyAlgorithm+"\nOne-octet hash algorithm. :"+this.hashAlgorithm+"\nTwo-octet field holding left\n 16 bits of signed hash value. :"+this.signedHashValue+"\nSignature Creation Time :"+this.creationTime+"\nSignature Expiration Time :"+this.signatureExpirationTime+"\nSignature Never Expires :"+
|
||||
this.signatureNeverExpires+"\nExportable Certification :"+this.exportable+"\nTrust Signature level: :"+this.trustLevel+" amount"+this.trustAmount+"\nRegular Expression :"+this.regular_expression+"\nRevocable :"+this.revocable+"\nKey Expiration Time :"+this.keyExpirationTime+" "+this.keyNeverExpires+"\nPreferred Symmetric Algorithms :"+this.preferredSymmetricAlgorithms+"\nRevocation Key\n ( 1 octet of class, :"+
|
||||
this.revocationKeyClass+"\n 1 octet of public-key ID, :"+this.revocationKeyAlgorithm+"\n 20 octets of fingerprint) :"+this.revocationKeyFingerprint+"\nIssuer :"+util.hexstrdump(this.issuerKeyId)+"\nPreferred Hash Algorithms :"+this.preferredHashAlgorithms+"\nPreferred Compression Alg. :"+this.preferredCompressionAlgorithms+"\nKey Server Preferences :"+this.keyServerPreferences+"\nPreferred Key Server :"+this.preferredKeyServer+
|
||||
"\nPrimary User ID :"+this.isPrimaryUserID+"\nPolicy URI :"+this.policyURI+"\nKey Flags :"+this.keyFlags+"\nSigner's User ID :"+this.signersUserId+"\nNotation :"+this.notationName+" = "+this.notationValue+"\nReason for Revocation\n Flag :"+this.reasonForRevocationFlag+"\n Reason :"+this.reasonForRevocationString+"\nMPI:\n",b=0;b<this.MPIs.length;b++)a+=
|
||||
this.MPIs[b].toString();return a}}
|
||||
function openpgp_packet_userattribute(){this.tagType=17;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.read_packet=function(b,a,c){var d=0;this.packetLength=c;this.userattributes=[];for(var e=a;c!=d;){var f=0;192>b.charCodeAt(e)?(packet_length=b.charCodeAt(e++),f=1):192<=b.charCodeAt(e)&&224>b.charCodeAt(e)?(packet_length=(b.charCodeAt(e++)-192<<8)+b.charCodeAt(e++)+192,f=2):223<b.charCodeAt(e)&&255>b.charCodeAt(e)?
|
||||
(packet_length=1<<(b.charCodeAt(e++)&31),f=1):(f=5,e++,packet_length=b.charCodeAt(e++)<<24|b.charCodeAt(e++)<<16|b.charCodeAt(e++)<<8|b.charCodeAt(e++));b.charCodeAt(e++);packet_length--;f++;this.userattributes[0]=[];this.userattributes[0]=b.substring(e,e+packet_length);e+=packet_length;d+=f+packet_length}this.packetLength=e-a;return this};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:15<g.signatureType&&20>g.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;a<this.userattributes.length;a++)b+=" ("+this.userattributes[a].length+") bytes: ["+util.hexidump(this.userattributes[a])+"]\n";return b}}
|
||||
function openpgp_packet_userid(){this.text="";this.tagType=13;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.set_text=function(b){this.text=b};this.set_text_bytes=function(b){this.text=util.decode_utf8(b)};this.get_text_bytes=function(){return util.encode_utf8(this.text)};this.read_packet=function(b,a,c){this.packetLength=c;for(var d="",e=0;e<c;e++)d+=b[a+e];this.set_text_bytes(d);return this};this.write_packet=function(b){this.set_text(b);
|
||||
function openpgp_packet_userid(){this.text="";this.tagType=13;this.certificationSignatures=[];this.certificationRevocationSignatures=[];this.revocationSignatures=[];this.parentNode=null;this.set_text=function(b){this.text=b};this.set_text_bytes=function(b){this.text=util.decode_utf8(b)};this.get_text_bytes=function(){return util.encode_utf8(this.text)};this.read_packet=function(b,a,c){this.packetLength=c;this.set_text_bytes(b.substr(a,c));return this};this.write_packet=function(b){this.set_text(b);
|
||||
var b=this.get_text_bytes(),a=openpgp_packet.write_packet_header(13,b.length);return a+b};this.read_nodes=function(b,a,c,d){if(6==b.tagType){this.parentNode=b;for(var e=c,f=d;a.length!=e;){var g=openpgp_packet.read_packet(a,e,f-(e-c));if(null==g){util.print_error("[user_id] parsing ends here @:"+e+" l:"+f);break}else switch(e+=g.packetLength+g.headerLength,f=a.length-e,g.tagType){case 2:if(15<g.signatureType&&20>g.signatureType){this.certificationSignatures[this.certificationSignatures.length]=g;
|
||||
break}else if(48==g.signatureType){this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g;break}else if(24==g.signatureType){this.certificationSignatures[this.certificationSignatures.length]=g;break}else util.print_debug("unknown sig t: "+g.signatureType+"@"+(e-(g.packetLength+g.headerLength)));default:return this.data=a,this.position=c-b.packetLength,this.len=e-c-(g.headerLength+g.packetLength)}}this.data=a;this.position=c-b.packetLength;return this.len=e-c-(g.headerLength+
|
||||
g.packetLength)}if(5==b.tagType){this.parentNode=b;for(e=c;a.length!=e;)if(g=openpgp_packet.read_packet(a,e,f-(e-c)),null==g){util.print_error("parsing ends here @:"+e+" l:"+f);break}else switch(e+=g.packetLength+g.headerLength,g.tagType){case 2:15<g.signatureType&&20>g.signatureType?this.certificationSignatures[this.certificationSignatures.length]=g:48==g.signatureType&&(this.certificationRevocationSignatures[this.certificationRevocationSignatures.length]=g);default:return this.data=a,this.position=
|
||||
|
@ -459,14 +459,14 @@ String.fromCharCode(153)+b.header.substring(1)+b.data+String.fromCharCode(180)+S
|
|||
8&255)+String.fromCharCode(a.length&255)+a;result[c]=this.certificationSignatures[c].verify(f,d)?4:0}}else if(3==this.certificationSignatures[c].version)if(null==this.certificationSignatures[c].keyId)result[c]=0;else if(d=openpgp.keyring.getPublicKeysForKeyId(this.certificationSignatures[c].keyId),null==d||0==d.length)result[c]=2;else if(d=publicKey.obj.getSigningKey(),null==d)result[c]=0;else{e=this.hasCertificationRevocationSignature(this.certificationSignatures[c].keyId);if(null!=e&&e.creationTime>
|
||||
this.certificationSignatures[c].creationTime&&(f=String.fromCharCode(153)+this.publicKeyPacket.header.substring(1)+this.publicKeyPacket.data+a,e.verify(f,d))){result[c]=e.keyId==b.getKeyId()?6:3;continue}f=String.fromCharCode(153)+b.header.substring(1)+b.data+a;result[c]=this.certificationSignatures[c].verify(f,d)?4:0}else result[c]=0;return result};this.verify=function(b){b=this.verifyCertificationSignatures(b);return-1!=b.indexOf(6)?2:-1!=b.indexOf(5)?1:0};this.addCertification=function(){};this.revokeCertification=
|
||||
function(){}}function openpgp_type_keyid(){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_mpi(){this.data=this.mpiByteLength=this.mpiBitLength=this.MPI=null;this.read=function(b,a){var c=a;this.mpiBitLength=b[c++].charCodeAt()<<8|b[c++].charCodeAt();this.mpiByteLength=(this.mpiBitLength-this.mpiBitLength%8)/8;0!=this.mpiBitLength%8&&this.mpiByteLength++;this.MPI=b.substring(c,c+this.mpiByteLength);this.data=b.substring(a,a+2+this.mpiByteLength);this.packetLength=this.mpiByteLength+2;return this};this.toBigInteger=function(){return new BigInteger(util.hexstrdump(this.MPI),
|
||||
function openpgp_type_mpi(){this.data=this.mpiByteLength=this.mpiBitLength=this.MPI=null;this.read=function(b,a){var c=a;this.mpiBitLength=b.charCodeAt(c++)<<8|b.charCodeAt(c++);this.mpiByteLength=(this.mpiBitLength-this.mpiBitLength%8)/8;0!=this.mpiBitLength%8&&this.mpiByteLength++;this.MPI=b.substring(c,c+this.mpiByteLength);this.data=b.substring(a,a+2+this.mpiByteLength);this.packetLength=this.mpiByteLength+2;return this};this.toBigInteger=function(){return new BigInteger(util.hexstrdump(this.MPI),
|
||||
16)};this.toString=function(){var b=" MPI("+this.mpiBitLength+"b/"+this.mpiByteLength+"B) : 0x",b=b+util.hexstrdump(this.MPI);return b+"\n"};this.create=function(b){this.MPI=b;var a=8*(b.length-1),c;a:for(var d=b.charCodeAt(0),e=0;9>e;e++)if(0==d>>e){c=e;break a}this.mpiBitLength=a+c;this.mpiByteLength=b.length;return this};this.toBin=function(){var b=String.fromCharCode(this.mpiBitLength>>8&255),b=b+String.fromCharCode(this.mpiBitLength&255);return b+=this.MPI};this.getByteLength=function(){return this.mpiByteLength}}
|
||||
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);this.s2kLength=9;break;case 3:this.hashAlgorithm=b[c++].charCodeAt();this.saltValue=b.substring(c,c+8);c+=8;this.EXPBIAS=6;c=b[c++].charCodeAt();this.count=16+(c&15)<<(c>>4)+this.EXPBIAS;this.s2kLength=10;break;case 101:"GNU"==b.substring(c+1,c+
|
||||
4)?(this.hashAlgorithm=b[c++].charCodeAt(),c+=3,c=1E3+b[c++].charCodeAt(),1001==c?(this.type=c,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)}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){b=util.encode_utf8(b);if(0==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,b);if(1==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+b);if(3==this.type){var c=[];for(c[0]=this.saltValue+b;c.length*(this.saltValue+b).length<this.count;)c.push(this.saltValue+b);c=c.join("");c.length>this.count&&(c=c.substr(0,this.count));return 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)}return null}}
|
||||
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.hexdump=function(a){for(var b=[],e=a.length,f=0,g,h=0;f<e;){for(g=a.charCodeAt(f++).toString(16);2>g.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<e;){for(g=a[f++].charCodeAt().toString(16);2>g.length;)g=
|
||||
"0"+g;b.push(""+g)}return b.join("")};this.hex2bin=function(a){for(var b="",e=0;e<a.length;e+=2)b+=String.fromCharCode(parseInt(a.substr(e,2),16));return b};this.hexidump=function(a){for(var b=[],e=a.length,f=0,g;f<e;){for(g=a[f++].toString(16);2>g.length;)g="0"+g;b.push(""+g)}return b.join("")};this.encode_utf8=function(a){return unescape(encodeURIComponent(a))};this.decode_utf8=function(a){try{return decodeURIComponent(escape(a))}catch(b){return a}};var b=function(a,b){for(var e=0;e<a.length;e++)b[e]=
|
||||
function openpgp_type_s2k(){this.read=function(b,a){var c=a;this.type=b.charCodeAt(c++);switch(this.type){case 0:this.hashAlgorithm=b.charCodeAt(c++);this.s2kLength=1;break;case 1:this.hashAlgorithm=b.charCodeAt(c++);this.saltValue=b.substring(c,c+8);this.s2kLength=9;break;case 3:this.hashAlgorithm=b.charCodeAt(c++);this.saltValue=b.substring(c,c+8);c+=8;this.EXPBIAS=6;c=b.charCodeAt(c++);this.count=16+(c&15)<<(c>>4)+this.EXPBIAS;this.s2kLength=10;break;case 101:"GNU"==b.substring(c+1,c+4)?(this.hashAlgorithm=
|
||||
b.charCodeAt(c++),c+=3,c=1E3+b.charCodeAt(c++),1001==c?(this.type=c,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)}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){b=util.encode_utf8(b);
|
||||
if(0==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,b);if(1==this.type)return openpgp_crypto_hashData(this.hashAlgorithm,this.saltValue+b);if(3==this.type){var c=[];for(c[0]=this.saltValue+b;c.length*(this.saltValue+b).length<this.count;)c.push(this.saltValue+b);c=c.join("");c.length>this.count&&(c=c.substr(0,this.count));return 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)}return null}}
|
||||
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.hexdump=function(a){for(var b=[],e=a.length,f=0,g,h=0;f<e;){for(g=a.charCodeAt(f++).toString(16);2>g.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<e;){for(g=a.charCodeAt(f++).toString(16);2>g.length;)g="0"+
|
||||
g;b.push(""+g)}return b.join("")};this.hex2bin=function(a){for(var b="",e=0;e<a.length;e+=2)b+=String.fromCharCode(parseInt(a.substr(e,2),16));return b};this.hexidump=function(a){for(var b=[],e=a.length,f=0,g;f<e;){for(g=a[f++].toString(16);2>g.length;)g="0"+g;b.push(""+g)}return b.join("")};this.encode_utf8=function(a){return unescape(encodeURIComponent(a))};this.decode_utf8=function(a){try{return decodeURIComponent(escape(a))}catch(b){return a}};var b=function(a,b){for(var e=0;e<a.length;e++)b[e]=
|
||||
a.charCodeAt(e);return b},a=function(a){for(var b=[],e=0;e<a.length;e++)b.push(String.fromCharCode(a[e]));return b.join("")};this.str2bin=function(a){return b(a,Array(a.length))};this.bin2str=a;this.str2Uint8Array=function(a){return b(a,new Uint8Array(new ArrayBuffer(a.length)))};this.Uint8Array2str=a;this.calc_checksum=function(a){for(var b={s:0,add:function(a){this.s=(this.s+a)%65536}},e=0;e<a.length;e++)b.add(a.charCodeAt(e));return b.s};this.print_debug=function(a){openpgp.config.debug&&(a=openpgp_encoding_html_encode(a),
|
||||
showMessages('<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_debug_hexstr_dump=function(a,b){openpgp.config.debug&&(a+=this.hexstrdump(b),a=openpgp_encoding_html_encode(a),showMessages('<tt><p style="background-color: #ffffff; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;">'+a.replace(/\n/g,"<br>")+"</p></tt>"))};this.print_error=
|
||||
function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #FF8888; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>ERROR:</b></span>\t'+a.replace(/\n/g,"<br>")+"</p>")};this.print_info=function(a){a=openpgp_encoding_html_encode(a);showMessages('<p style="font-size: 80%; background-color: #88FF88; margin:0; width: 652px; word-break: break-word; padding: 5px; border-bottom: 1px solid black;"><span style="color: #888;"><b>INFO:</b></span>\t'+
|
||||
|
|
|
@ -708,7 +708,7 @@ function openpgp_packet_signature() {
|
|||
function getIssuer() {
|
||||
if (this.version == 4)
|
||||
return this.issuerKeyId;
|
||||
if (this.verions == 4)
|
||||
if (this.version == 3)
|
||||
return this.keyId;
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user