jsbn.js 18 KB

1
  1. (function(){function B(E){function e(a,b,c){this.data=[];null!=a&&("number"==typeof a?this.fromNumber(a,b,c):null==b&&"string"!=typeof a?this.fromString(a,256):this.fromString(a,b))}function g(){return new e(null)}function J(a,b,c,d,e,f){for(;0<=--f;){var k=b*this.data[a++]+c.data[d]+e;e=Math.floor(k/67108864);c.data[d++]=k&67108863}return e}function y(a,b,c,d,e,f){var k=b&32767;for(b>>=15;0<=--f;){var m=this.data[a]&32767,g=this.data[a++]>>15,q=b*m+g*k;m=k*m+((q&32767)<<15)+c.data[d]+(e&1073741823);e=(m>>>30)+(q>>>15)+b*g+(e>>>30);c.data[d++]=m&1073741823}return e}function G(a,b,c,d,e,f){var k=b&16383;for(b>>=14;0<=--f;){var m=this.data[a]&16383,g=this.data[a++]>>14,q=b*m+g*k;m=k*m+((q&16383)<<14)+c.data[d]+e;e=(m>>28)+(q>>14)+b*g;c.data[d++]=m&268435455}return e}function v(a,b){a=C[a.charCodeAt(b)];return null==a?-1:a}function r(a){var b=g();b.fromInt(a);return b}function D(a){var b=1,c;0!=(c=a>>>16)&&(a=c,b+=16);0!=(c=a>>8)&&(a=c,b+=8);0!=(c=a>>4)&&(a=c,b+=4);0!=(c=a>>2)&&(a=c,b+=2);0!=a>>1&&(b+=1);return b}function u(a){this.m=a}function w(a){this.m=a;this.mp=a.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<a.DB-15)-1;this.mt2=2*a.t}function B(a,b){return a&b}function F(a,b){return a|b}function A(a,b){return a^b}function H(a,b){return a&~b}function z(){}function I(a){return a}function x(a){this.r2=g();this.q3=g();e.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a}if("undefined"===typeof navigator){e.prototype.am=G;var l=28}else"Microsoft Internet Explorer"==navigator.appName?(e.prototype.am=y,l=30):"Netscape"!=navigator.appName?(e.prototype.am=J,l=26):(e.prototype.am=G,l=28);e.prototype.DB=l;e.prototype.DM=(1<<l)-1;e.prototype.DV=1<<l;e.prototype.FV=Math.pow(2,52);e.prototype.F1=52-l;e.prototype.F2=2*l-52;var C=[],p;l=48;for(p=0;9>=p;++p)C[l++]=p;l=97;for(p=10;36>p;++p)C[l++]=p;l=65;for(p=10;36>p;++p)C[l++]=p;u.prototype.convert=function(a){return 0>a.s||0<=a.compareTo(this.m)?a.mod(this.m):a};u.prototype.revert=function(a){return a};u.prototype.reduce=function(a){a.divRemTo(this.m,null,a)};u.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};u.prototype.sqrTo=function(a,b){a.squareTo(b);this.reduce(b)};w.prototype.convert=function(a){var b=g();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);0>a.s&&0<b.compareTo(e.ZERO)&&this.m.subTo(b,b);return b};w.prototype.revert=function(a){var b=g();a.copyTo(b);this.reduce(b);return b};w.prototype.reduce=function(a){for(;a.t<=this.mt2;)a.data[a.t++]=0;for(var b=0;b<this.m.t;++b){var c=a.data[b]&32767,d=c*this.mpl+((c*this.mph+(a.data[b]>>15)*this.mpl&this.um)<<15)&a.DM;c=b+this.m.t;for(a.data[c]+=this.m.am(0,d,a,b,0,this.m.t);a.data[c]>=a.DV;)a.data[c]-=a.DV,a.data[++c]++}a.clamp();a.drShiftTo(this.m.t,a);0<=a.compareTo(this.m)&&a.subTo(this.m,a)};w.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};w.prototype.sqrTo=function(a,b){a.squareTo(b);this.reduce(b)};e.prototype.copyTo=function(a){for(var b=this.t-1;0<=b;--b)a.data[b]=this.data[b];a.t=this.t;a.s=this.s};e.prototype.fromInt=function(a){this.t=1;this.s=0>a?-1:0;0<a?this.data[0]=a:-1>a?this.data[0]=a+DV:this.t=0};e.prototype.fromString=function(a,b){if(16==b)b=4;else if(8==b)b=3;else if(256==b)b=8;else if(2==b)b=1;else if(32==b)b=5;else if(4==b)b=2;else{this.fromRadix(a,b);return}this.s=this.t=0;for(var c=a.length,d=!1,k=0;0<=--c;){var f=8==b?a[c]&255:v(a,c);0>f?"-"==a.charAt(c)&&(d=!0):(d=!1,0==k?this.data[this.t++]=f:k+b>this.DB?(this.data[this.t-1]|=(f&(1<<this.DB-k)-1)<<k,this.data[this.t++]=f>>this.DB-k):this.data[this.t-1]|=f<<k,k+=b,k>=this.DB&&(k-=this.DB))}8==b&&0!=(a[0]&128)&&(this.s=-1,0<k&&(this.data[this.t-1]|=(1<<this.DB-k)-1<<k));this.clamp();d&&e.ZERO.subTo(this,this)};e.prototype.clamp=function(){for(var a=this.s&this.DM;0<this.t&&this.data[this.t-1]==a;)--this.t};e.prototype.dlShiftTo=function(a,b){var c;for(c=this.t-1;0<=c;--c)b.data[c+a]=this.data[c];for(c=a-1;0<=c;--c)b.data[c]=0;b.t=this.t+a;b.s=this.s};e.prototype.drShiftTo=function(a,b){for(var c=a;c<this.t;++c)b.data[c-a]=this.data[c];b.t=Math.max(this.t-a,0);b.s=this.s};e.prototype.lShiftTo=function(a,b){var c=a%this.DB,d=this.DB-c,e=(1<<d)-1;a=Math.floor(a/this.DB);var f=this.s<<c&this.DM,h;for(h=this.t-1;0<=h;--h)b.data[h+a+1]=this.data[h]>>d|f,f=(this.data[h]&e)<<c;for(h=a-1;0<=h;--h)b.data[h]=0;b.data[a]=f;b.t=this.t+a+1;b.s=this.s;b.clamp()};e.prototype.rShiftTo=function(a,b){b.s=this.s;var c=Math.floor(a/this.DB);if(c>=this.t)b.t=0;else{a%=this.DB;var d=this.DB-a,e=(1<<a)-1;b.data[0]=this.data[c]>>a;for(var f=c+1;f<this.t;++f)b.data[f-c-1]|=(this.data[f]&e)<<d,b.data[f-c]=this.data[f]>>a;0<a&&(b.data[this.t-c-1]|=(this.s&e)<<d);b.t=this.t-c;b.clamp()}};e.prototype.subTo=function(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this.data[c]-a.data[c],b.data[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d-=a.s;c<this.t;)d+=this.data[c],b.data[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d-=a.data[c],b.data[c++]=d&this.DM,d>>=this.DB;d-=a.s}b.s=0>d?-1:0;-1>d?b.data[c++]=this.DV+d:0<d&&(b.data[c++]=d);b.t=c;b.clamp()};e.prototype.multiplyTo=function(a,b){var c=this.abs(),d=a.abs(),k=c.t;for(b.t=k+d.t;0<=--k;)b.data[k]=0;for(k=0;k<d.t;++k)b.data[k+c.t]=c.am(0,d.data[k],b,k,0,c.t);b.s=0;b.clamp();this.s!=a.s&&e.ZERO.subTo(b,b)};e.prototype.squareTo=function(a){for(var b=this.abs(),c=a.t=2*b.t;0<=--c;)a.data[c]=0;for(c=0;c<b.t-1;++c){var d=b.am(c,b.data[c],a,2*c,0,1);(a.data[c+b.t]+=b.am(c+1,2*b.data[c],a,2*c+1,d,b.t-c-1))>=b.DV&&(a.data[c+b.t]-=b.DV,a.data[c+b.t+1]=1)}0<a.t&&(a.data[a.t-1]+=b.am(c,b.data[c],a,2*c,0,1));a.s=0;a.clamp()};e.prototype.divRemTo=function(a,b,c){var d=a.abs();if(!(0>=d.t)){var k=this.abs();if(k.t<d.t)null!=b&&b.fromInt(0),null!=c&&this.copyTo(c);else{null==c&&(c=g());var f=g(),h=this.s;a=a.s;var m=this.DB-D(d.data[d.t-1]);0<m?(d.lShiftTo(m,f),k.lShiftTo(m,c)):(d.copyTo(f),k.copyTo(c));d=f.t;k=f.data[d-1];if(0!=k){var l=k*(1<<this.F1)+(1<d?f.data[d-2]>>this.F2:0),q=this.FV/l;l=(1<<this.F1)/l;var n=1<<this.F2,t=c.t,p=t-d,r=null==b?g():b;f.dlShiftTo(p,r);0<=c.compareTo(r)&&(c.data[c.t++]=1,c.subTo(r,c));e.ONE.dlShiftTo(d,r);for(r.subTo(f,f);f.t<d;)f.data[f.t++]=0;for(;0<=--p;){var u=c.data[--t]==k?this.DM:Math.floor(c.data[t]*q+(c.data[t-1]+n)*l);if((c.data[t]+=f.am(0,u,c,p,0,d))<u)for(f.dlShiftTo(p,r),c.subTo(r,c);c.data[t]<--u;)c.subTo(r,c)}null!=b&&(c.drShiftTo(d,b),h!=a&&e.ZERO.subTo(b,b));c.t=d;c.clamp();0<m&&c.rShiftTo(m,c);0>h&&e.ZERO.subTo(c,c)}}}};e.prototype.invDigit=function(){if(1>this.t)return 0;var a=this.data[0];if(0==(a&1))return 0;var b=a&3;b=b*(2-(a&15)*b)&15;b=b*(2-(a&255)*b)&255;b=b*(2-((a&65535)*b&65535))&65535;b=b*(2-a*b%this.DV)%this.DV;return 0<b?this.DV-b:-b};e.prototype.isEven=function(){return 0==(0<this.t?this.data[0]&1:this.s)};e.prototype.exp=function(a,b){if(4294967295<a||1>a)return e.ONE;var c=g(),d=g(),k=b.convert(this),f=D(a)-1;for(k.copyTo(c);0<=--f;)if(b.sqrTo(c,d),0<(a&1<<f))b.mulTo(d,k,c);else{var h=c;c=d;d=h}return b.revert(c)};e.prototype.toString=function(a){if(0>this.s)return"-"+this.negate().toString(a);if(16==a)a=4;else if(8==a)a=3;else if(2==a)a=1;else if(32==a)a=5;else if(4==a)a=2;else return this.toRadix(a);var b=(1<<a)-1,c,d=!1,e="",f=this.t,h=this.DB-f*this.DB%a;if(0<f--)for(h<this.DB&&0<(c=this.data[f]>>h)&&(d=!0,e="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));0<=f;)h<a?(c=(this.data[f]&(1<<h)-1)<<a-h,c|=this.data[--f]>>(h+=this.DB-a)):(c=this.data[f]>>(h-=a)&b,0>=h&&(h+=this.DB,--f)),0<c&&(d=!0),d&&(e+="0123456789abcdefghijklmnopqrstuvwxyz".charAt(c));return d?e:"0"};e.prototype.negate=function(){var a=g();e.ZERO.subTo(this,a);return a};e.prototype.abs=function(){return 0>this.s?this.negate():this};e.prototype.compareTo=function(a){var b=this.s-a.s;if(0!=b)return b;var c=this.t;b=c-a.t;if(0!=b)return b;for(;0<=--c;)if(0!=(b=this.data[c]-a.data[c]))return b;return 0};e.prototype.bitLength=function(){return 0>=this.t?0:this.DB*(this.t-1)+D(this.data[this.t-1]^this.s&this.DM)};e.prototype.mod=function(a){var b=g();this.abs().divRemTo(a,null,b);0>this.s&&0<b.compareTo(e.ZERO)&&a.subTo(b,b);return b};e.prototype.modPowInt=function(a,b){b=256>a||b.isEven()?new u(b):new w(b);return this.exp(a,b)};e.ZERO=r(0);e.ONE=r(1);z.prototype.convert=I;z.prototype.revert=I;z.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c)};z.prototype.sqrTo=function(a,b){a.squareTo(b)};x.prototype.convert=function(a){if(0>a.s||a.t>2*this.m.t)return a.mod(this.m);if(0>a.compareTo(this.m))return a;var b=g();a.copyTo(b);this.reduce(b);return b};x.prototype.revert=function(a){return a};x.prototype.reduce=function(a){a.drShiftTo(this.m.t-1,this.r2);a.t>this.m.t+1&&(a.t=this.m.t+1,a.clamp());this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);for(this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);0>a.compareTo(this.r2);)a.dAddOffset(1,this.m.t+1);for(a.subTo(this.r2,a);0<=a.compareTo(this.m);)a.subTo(this.m,a)};x.prototype.mulTo=function(a,b,c){a.multiplyTo(b,c);this.reduce(c)};x.prototype.sqrTo=function(a,b){a.squareTo(b);this.reduce(b)};var n=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],K=67108864/n[n.length-1];e.prototype.chunkSize=function(a){return Math.floor(Math.LN2*this.DB/Math.log(a))};e.prototype.toRadix=function(a){null==a&&(a=10);if(0==this.signum()||2>a||36<a)return"0";var b=this.chunkSize(a);b=Math.pow(a,b);var c=r(b),d=g(),e=g(),f="";for(this.divRemTo(c,d,e);0<d.signum();)f=(b+e.intValue()).toString(a).substr(1)+f,d.divRemTo(c,d,e);return e.intValue().toString(a)+f};e.prototype.fromRadix=function(a,b){this.fromInt(0);null==b&&(b=10);for(var c=this.chunkSize(b),d=Math.pow(b,c),k=!1,f=0,h=0,g=0;g<a.length;++g){var l=v(a,g);0>l?"-"==a.charAt(g)&&0==this.signum()&&(k=!0):(h=b*h+l,++f>=c&&(this.dMultiply(d),this.dAddOffset(h,0),h=f=0))}0<f&&(this.dMultiply(Math.pow(b,f)),this.dAddOffset(h,0));k&&e.ZERO.subTo(this,this)};e.prototype.fromNumber=function(a,b,c){if("number"==typeof b)if(2>a)this.fromInt(1);else for(this.fromNumber(a,c),this.testBit(a-1)||this.bitwiseTo(e.ONE.shiftLeft(a-1),F,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(b);)this.dAddOffset(2,0),this.bitLength()>a&&this.subTo(e.ONE.shiftLeft(a-1),this);else{c=[];var d=a&7;c.length=(a>>3)+1;b.nextBytes(c);c[0]=0<d?c[0]&(1<<d)-1:0;this.fromString(c,256)}};e.prototype.bitwiseTo=function(a,b,c){var d,e=Math.min(a.t,this.t);for(d=0;d<e;++d)c.data[d]=b(this.data[d],a.data[d]);if(a.t<this.t){var f=a.s&this.DM;for(d=e;d<this.t;++d)c.data[d]=b(this.data[d],f);c.t=this.t}else{f=this.s&this.DM;for(d=e;d<a.t;++d)c.data[d]=b(f,a.data[d]);c.t=a.t}c.s=b(this.s,a.s);c.clamp()};e.prototype.changeBit=function(a,b){a=e.ONE.shiftLeft(a);this.bitwiseTo(a,b,a);return a};e.prototype.addTo=function(a,b){for(var c=0,d=0,e=Math.min(a.t,this.t);c<e;)d+=this.data[c]+a.data[c],b.data[c++]=d&this.DM,d>>=this.DB;if(a.t<this.t){for(d+=a.s;c<this.t;)d+=this.data[c],b.data[c++]=d&this.DM,d>>=this.DB;d+=this.s}else{for(d+=this.s;c<a.t;)d+=a.data[c],b.data[c++]=d&this.DM,d>>=this.DB;d+=a.s}b.s=0>d?-1:0;0<d?b.data[c++]=d:-1>d&&(b.data[c++]=this.DV+d);b.t=c;b.clamp()};e.prototype.dMultiply=function(a){this.data[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()};e.prototype.dAddOffset=function(a,b){if(0!=a){for(;this.t<=b;)this.data[this.t++]=0;for(this.data[b]+=a;this.data[b]>=this.DV;)this.data[b]-=this.DV,++b>=this.t&&(this.data[this.t++]=0),++this.data[b]}};e.prototype.multiplyLowerTo=function(a,b,c){var d=Math.min(this.t+a.t,b);c.s=0;for(c.t=d;0<d;)c.data[--d]=0;var e;for(e=c.t-this.t;d<e;++d)c.data[d+this.t]=this.am(0,a.data[d],c,d,0,this.t);for(e=Math.min(a.t,b);d<e;++d)this.am(0,a.data[d],c,d,0,b-d);c.clamp()};e.prototype.multiplyUpperTo=function(a,b,c){--b;var d=c.t=this.t+a.t-b;for(c.s=0;0<=--d;)c.data[d]=0;for(d=Math.max(b-this.t,0);d<a.t;++d)c.data[this.t+d-b]=this.am(b-d,a.data[d],c,0,0,this.t+d-b);c.clamp();c.drShiftTo(1,c)};e.prototype.modInt=function(a){if(0>=a)return 0;var b=this.DV%a,c=0>this.s?a-1:0;if(0<this.t)if(0==b)c=this.data[0]%a;else for(var d=this.t-1;0<=d;--d)c=(b*c+this.data[d])%a;return c};e.prototype.millerRabin=function(a){var b=this.subtract(e.ONE),c=b.getLowestSetBit();if(0>=c)return!1;var d=b.shiftRight(c);a=a+1>>1;a>n.length&&(a=n.length);for(var k=g(),f=0;f<a;++f){k.fromInt(n[f]);var h=k.modPow(d,this);if(0!=h.compareTo(e.ONE)&&0!=h.compareTo(b)){for(var m=1;m++<c&&0!=h.compareTo(b);)if(h=h.modPowInt(2,this),0==h.compareTo(e.ONE))return!1;if(0!=h.compareTo(b))return!1}}return!0};e.prototype.clone=function(){var a=g();this.copyTo(a);return a};e.prototype.intValue=function(){if(0>this.s){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]};e.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24};e.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16};e.prototype.signum=function(){return 0>this.s?-1:0>=this.t||1==this.t&&0>=this.data[0]?0:1};e.prototype.toByteArray=function(){var a=this.t,b=[];b[0]=this.s;var c=this.DB-a*this.DB%8,d,e=0;if(0<a--)for(c<this.DB&&(d=this.data[a]>>c)!=(this.s&this.DM)>>c&&(b[e++]=d|this.s<<this.DB-c);0<=a;)if(8>c?(d=(this.data[a]&(1<<c)-1)<<8-c,d|=this.data[--a]>>(c+=this.DB-8)):(d=this.data[a]>>(c-=8)&255,0>=c&&(c+=this.DB,--a)),0!=(d&128)&&(d|=-256),0==e&&(this.s&128)!=(d&128)&&++e,0<e||d!=this.s)b[e++]=d;return b};e.prototype.equals=function(a){return 0==this.compareTo(a)};e.prototype.min=function(a){return 0>this.compareTo(a)?this:a};e.prototype.max=function(a){return 0<this.compareTo(a)?this:a};e.prototype.and=function(a){var b=g();this.bitwiseTo(a,B,b);return b};e.prototype.or=function(a){var b=g();this.bitwiseTo(a,F,b);return b};e.prototype.xor=function(a){var b=g();this.bitwiseTo(a,A,b);return b};e.prototype.andNot=function(a){var b=g();this.bitwiseTo(a,H,b);return b};e.prototype.not=function(){for(var a=g(),b=0;b<this.t;++b)a.data[b]=this.DM&~this.data[b];a.t=this.t;a.s=~this.s;return a};e.prototype.shiftLeft=function(a){var b=g();0>a?this.rShiftTo(-a,b):this.lShiftTo(a,b);return b};e.prototype.shiftRight=function(a){var b=g();0>a?this.lShiftTo(-a,b):this.rShiftTo(a,b);return b};e.prototype.getLowestSetBit=function(){for(var a=0;a<this.t;++a)if(0!=this.data[a]){var b=a*this.DB;a=this.data[a];if(0==a)a=-1;else{var c=0;0==(a&65535)&&(a>>=16,c+=16);0==(a&255)&&(a>>=8,c+=8);0==(a&15)&&(a>>=4,c+=4);0==(a&3)&&(a>>=2,c+=2);0==(a&1)&&++c;a=c}return b+a}return 0>this.s?this.t*this.DB:-1};e.prototype.bitCount=function(){for(var a=0,b=this.s&this.DM,c=0;c<this.t;++c){for(var d=this.data[c]^b,e=0;0!=d;)d&=d-1,++e;a+=e}return a};e.prototype.testBit=function(a){var b=Math.floor(a/this.DB);return b>=this.t?0!=this.s:0!=(this.data[b]&1<<a%this.DB)};e.prototype.setBit=function(a){return this.changeBit(a,F)};e.prototype.clearBit=function(a){return this.changeBit(a,H)};e.prototype.flipBit=function(a){return this.changeBit(a,A)};e.prototype.add=function(a){var b=g();this.addTo(a,b);return b};e.prototype.subtract=function(a){var b=g();this.subTo(a,b);return b};e.prototype.multiply=function(a){var b=g();this.multiplyTo(a,b);return b};e.prototype.divide=function(a){var b=g();this.divRemTo(a,b,null);return b};e.prototype.remainder=function(a){var b=g();this.divRemTo(a,null,b);return b};e.prototype.divideAndRemainder=function(a){var b=g(),c=g();this.divRemTo(a,b,c);return[b,c]};e.prototype.modPow=function(a,b){var c=a.bitLength(),d=r(1);if(0>=c)return d;var e=18>c?1:48>c?3:144>c?4:768>c?5:6;b=8>c?new u(b):b.isEven()?new x(b):new w(b);var f=[],h=3,m=e-1,l=(1<<e)-1;f[1]=b.convert(this);if(1<e)for(c=g(),b.sqrTo(f[1],c);h<=l;)f[h]=g(),b.mulTo(c,f[h-2],f[h]),h+=2;var q=a.t-1,p=!0,t=g();for(c=D(a.data[q])-1;0<=q;){if(c>=m)var n=a.data[q]>>c-m&l;else n=(a.data[q]&(1<<c+1)-1)<<m-c,0<q&&(n|=a.data[q-1]>>this.DB+c-m);for(h=e;0==(n&1);)n>>=1,--h;0>(c-=h)&&(c+=this.DB,--q);if(p)f[n].copyTo(d),p=!1;else{for(;1<h;)b.sqrTo(d,t),b.sqrTo(t,d),h-=2;0<h?b.sqrTo(d,t):(h=d,d=t,t=h);b.mulTo(t,f[n],d)}for(;0<=q&&0==(a.data[q]&1<<c);)b.sqrTo(d,t),h=d,d=t,t=h,0>--c&&(c=this.DB-1,--q)}return b.revert(d)};e.prototype.modInverse=function(a){var b=a.isEven();if(this.isEven()&&b||0==a.signum())return e.ZERO;for(var c=a.clone(),d=this.clone(),k=r(1),f=r(0),h=r(0),g=r(1);0!=c.signum();){for(;c.isEven();)c.rShiftTo(1,c),b?(k.isEven()&&f.isEven()||(k.addTo(this,k),f.subTo(a,f)),k.rShiftTo(1,k)):f.isEven()||f.subTo(a,f),f.rShiftTo(1,f);for(;d.isEven();)d.rShiftTo(1,d),b?(h.isEven()&&g.isEven()||(h.addTo(this,h),g.subTo(a,g)),h.rShiftTo(1,h)):g.isEven()||g.subTo(a,g),g.rShiftTo(1,g);0<=c.compareTo(d)?(c.subTo(d,c),b&&k.subTo(h,k),f.subTo(g,f)):(d.subTo(c,d),b&&h.subTo(k,h),g.subTo(f,g))}if(0!=d.compareTo(e.ONE))return e.ZERO;if(0<=g.compareTo(a))return g.subtract(a);if(0>g.signum())g.addTo(a,g);else return g;return 0>g.signum()?g.add(a):g};e.prototype.pow=function(a){return this.exp(a,new z)};e.prototype.gcd=function(a){var b=0>this.s?this.negate():this.clone();a=0>a.s?a.negate():a.clone();if(0>b.compareTo(a)){var c=b;b=a;a=c}c=b.getLowestSetBit();var d=a.getLowestSetBit();if(0>d)return b;c<d&&(d=c);0<d&&(b.rShiftTo(d,b),a.rShiftTo(d,a));for(;0<b.signum();)0<(c=b.getLowestSetBit())&&b.rShiftTo(c,b),0<(c=a.getLowestSetBit())&&a.rShiftTo(c,a),0<=b.compareTo(a)?(b.subTo(a,b),b.rShiftTo(1,b)):(a.subTo(b,a),a.rShiftTo(1,a));0<d&&a.lShiftTo(d,a);return a};e.prototype.isProbablePrime=function(a){var b,c=this.abs();if(1==c.t&&c.data[0]<=n[n.length-1]){for(b=0;b<n.length;++b)if(c.data[0]==n[b])return!0;return!1}if(c.isEven())return!1;for(b=1;b<n.length;){for(var d=n[b],e=b+1;e<n.length&&d<K;)d*=n[e++];for(d=c.modInt(d);b<e;)if(0==d%n[b++])return!1}return c.millerRabin(a)};E.jsbn=E.jsbn||{};E.jsbn.BigInteger=e}var A=[],v=null;"function"!==typeof define&&("object"===typeof module&&module.exports?v=function(v,e){e(require,module)}:(crosscert=window.crosscert=window.crosscert||{},B(crosscert)));(v||"function"===typeof define)&&(v||define)(["require","module"].concat(A),function(v,e){e.exports=function(e){var g=A.map(function(e){return v(e)}).concat(B);e=e||{};e.defined=e.defined||{};if(e.defined.jsbn)return e.jsbn;e.defined.jsbn=!0;for(var y=0;y<g.length;++y)g[y](e);return e.jsbn}})})();