diff --git a/authority/static/dialog/crypto-stubs.js b/authority/static/dialog/crypto-stubs.js index 0dafea28d933f2850add2f74ae8aab2924067a4e..5caec945fba86a01d10ca7acd6b9d5527bc9fdc6 100644 --- a/authority/static/dialog/crypto-stubs.js +++ b/authority/static/dialog/crypto-stubs.js @@ -2,7 +2,8 @@ // for firefoxid's client side implementation CryptoStubs = (function() { -function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(d){var c,a,b;for(c=0;c<256;++c){this.S[c]=c}a=0;for(c=0;c<256;++c){a=(a+this.S[c]+d[c%d.length])&255;b=this.S[c];this.S[c]=this.S[a];this.S[a]=b}this.i=0;this.j=0}function ARC4next(){var a;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;a=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=a;return this.S[(a+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256;var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(a){rng_pool[rng_pptr++]^=a&255;rng_pool[rng_pptr++]^=(a>>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t<z.length;++t){rng_pool[rng_pptr++]=z.charCodeAt(t)&255}}while(rng_pptr<rng_psize){t=Math.floor(65536*Math.random());rng_pool[rng_pptr++]=t>>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr){rng_pool[rng_pptr]=0}rng_pptr=0}return rng_state.next()}function rng_get_bytes(b){var a;for(a=0;a<b.length;++a){b[a]=rng_get_byte()}}function SecureRandom(){}SecureRandom.prototype.nextBytes=rng_get_bytes;"use strict";var sjcl={cipher:{},hash:{},mode:{},misc:{},codec:{},exception:{corrupt:function(b){this.toString=function(){return"CORRUPT: "+this.message};this.message=b},invalid:function(b){this.toString=function(){return"INVALID: "+this.message};this.message=b},bug:function(b){this.toString=function(){return"BUG: "+this.message};this.message=b}}};sjcl.cipher.aes=function(j){this.h[0][0][0]||this.w();var i,p,o,n,m=this.h[0][4],l=this.h[1];i=j.length;var k=1;if(i!==4&&i!==6&&i!==8){throw new sjcl.exception.invalid("invalid aes key size")}this.a=[o=j.slice(0),n=[]];for(j=i;j<4*i+28;j++){p=o[j-1];if(j%i===0||i===8&&j%i===4){p=m[p>>>24]<<24^m[p>>16&255]<<16^m[p>>8&255]<<8^m[p&255];if(j%i===0){p=p<<8^p>>>24^k<<24;k=k<<1^(k>>7)*283}}o[j]=o[j-i]^p}for(i=0;j;i++,j--){p=o[i&3?j:j-4];n[i]=j<=4||i<4?p:l[0][m[p>>>24]]^l[1][m[p>>16&255]]^l[2][m[p>>8&255]]^l[3][m[p&255]]}};sjcl.cipher.aes.prototype={encrypt:function(b){return this.H(b,0)},decrypt:function(b){return this.H(b,1)},h:[[[],[],[],[],[]],[[],[],[],[],[]]],w:function(){var B=this.h[0],A=this.h[1],y=B[4],x=A[4],w,v,u,s=[],r=[],p,q,o,n;for(w=0;w<256;w++){r[(s[w]=w<<1^(w>>7)*283)^w]=w}for(v=u=0;!y[v];v^=p||1,u=r[u]||1){o=u^u<<1^u<<2^u<<3^u<<4;o=o>>8^o&255^99;y[v]=o;x[o]=v;q=s[w=s[p=s[v]]];n=q*16843009^w*65537^p*257^v*16843008;q=s[o]*257^o*16843008;for(w=0;w<4;w++){B[w][v]=q=q<<24^q>>>8;A[w][o]=n=n<<24^n>>>8}}for(w=0;w<5;w++){B[w]=B[w].slice(0);A[w]=A[w].slice(0)}},H:function(L,K){if(L.length!==4){throw new sjcl.exception.invalid("invalid aes block size")}var J=this.a[K],I=L[0]^J[0],H=L[K?3:1]^J[1],G=L[2]^J[2];L=L[K?1:3]^J[3];var F,E,D,B=J.length/4-2,C,A=4,y=[0,0,0,0];F=this.h[K];var x=F[0],w=F[1],v=F[2],u=F[3],s=F[4];for(C=0;C<B;C++){F=x[I>>>24]^w[H>>16&255]^v[G>>8&255]^u[L&255]^J[A];E=x[H>>>24]^w[G>>16&255]^v[L>>8&255]^u[I&255]^J[A+1];D=x[G>>>24]^w[L>>16&255]^v[I>>8&255]^u[H&255]^J[A+2];L=x[L>>>24]^w[I>>16&255]^v[H>>8&255]^u[G&255]^J[A+3];A+=4;I=F;H=E;G=D}for(C=0;C<4;C++){y[K?3&-C:C]=s[I>>>24]<<24^s[H>>16&255]<<16^s[G>>8&255]<<8^s[L&255]^J[A++];F=I;I=H;H=G;G=L;L=F}return y}};sjcl.bitArray={bitSlice:function(f,d,g){f=sjcl.bitArray.P(f.slice(d/32),32-(d&31)).slice(1);return g===undefined?f:sjcl.bitArray.clamp(f,g-d)},concat:function(g,f){if(g.length===0||f.length===0){return g.concat(f)}var i=g[g.length-1],h=sjcl.bitArray.getPartial(i);return h===32?g.concat(f):sjcl.bitArray.P(f,h,i|0,g.slice(0,g.length-1))},bitLength:function(d){var c=d.length;if(c===0){return 0}return(c-1)*32+sjcl.bitArray.getPartial(d[c-1])},clamp:function(f,d){if(f.length*32<d){return f}f=f.slice(0,Math.ceil(d/32));var g=f.length;d&=31;if(g>0&&d){f[g-1]=sjcl.bitArray.partial(d,f[g-1]&2147483648>>d-1,1)}return f},partial:function(f,d,g){if(f===32){return d}return(g?d|0:d<<32-f)+f*1099511627776},getPartial:function(b){return Math.round(b/1099511627776)||32},equal:function(g,f){if(sjcl.bitArray.bitLength(g)!==sjcl.bitArray.bitLength(f)){return false}var i=0,h;for(h=0;h<g.length;h++){i|=g[h]^f[h]}return i===0},P:function(g,f,j,i){var h;h=0;if(i===undefined){i=[]}for(;f>=32;f-=32){i.push(j);j=0}if(f===0){return i.concat(g)}for(h=0;h<g.length;h++){i.push(j|g[h]>>>f);j=g[h]<<32-f}h=g.length?g[g.length-1]:0;g=sjcl.bitArray.getPartial(h);i.push(sjcl.bitArray.partial(f+g&31,f+g>32?j:i.pop(),1));return i},k:function(d,c){return[d[0]^c[0],d[1]^c[1],d[2]^c[2],d[3]^c[3]]}};sjcl.codec.utf8String={fromBits:function(g){var f="",j=sjcl.bitArray.bitLength(g),i,h;for(i=0;i<j/8;i++){if((i&3)===0){h=g[i/4]}f+=String.fromCharCode(h>>>24);h<<=8}return decodeURIComponent(escape(f))},toBits:function(g){g=unescape(encodeURIComponent(g));var f=[],i,h=0;for(i=0;i<g.length;i++){h=h<<8|g.charCodeAt(i);if((i&3)===3){f.push(h);h=0}}i&3&&f.push(sjcl.bitArray.partial(8*(i&3),h));return f}};sjcl.codec.hex={fromBits:function(f){var d="",g;for(g=0;g<f.length;g++){d+=((f[g]|0)+263882790666240).toString(16).substr(4)}return d.substr(0,sjcl.bitArray.bitLength(f)/4)},toBits:function(g){var f,i=[],h;g=g.replace(/\s|0x/g,"");h=g.length;g+="00000000";for(f=0;f<g.length;f+=8){i.push(parseInt(g.substr(f,8),16)^0)}return sjcl.bitArray.clamp(i,h*4)}};sjcl.codec.base64={D:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(j,i){var p="",o,n=0,m=sjcl.codec.base64.D,l=0,k=sjcl.bitArray.bitLength(j);for(o=0;p.length*6<k;){p+=m.charAt((l^j[o]>>>n)>>>26);if(n<6){l=j[o]<<6-n;n+=26;o++}else{l<<=6;n-=6}}for(;p.length&3&&!i;){p+="="}return p},toBits:function(i){i=i.replace(/\s|=/g,"");var h=[],n,m=0,l=sjcl.codec.base64.D,k=0,j;for(n=0;n<i.length;n++){j=l.indexOf(i.charAt(n));if(j<0){throw new sjcl.exception.invalid("this isn't base64!")}if(m>26){m-=26;h.push(k^j>>>m);k=j<<32-m}else{m+=6;k^=j<<32-m}}m&56&&h.push(sjcl.bitArray.partial(m&56,k,1));return h}};sjcl.hash.sha256=function(b){this.a[0]||this.w();if(b){this.n=b.n.slice(0);this.i=b.i.slice(0);this.e=b.e}else{this.reset()}};sjcl.hash.sha256.hash=function(b){return(new sjcl.hash.sha256).update(b).finalize()};sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.n=this.N.slice(0);this.i=[];this.e=0;return this},update:function(f){if(typeof f==="string"){f=sjcl.codec.utf8String.toBits(f)}var d,g=this.i=sjcl.bitArray.concat(this.i,f);d=this.e;f=this.e=d+sjcl.bitArray.bitLength(f);for(d=512+d&-512;d<=f;d+=512){this.C(g.splice(0,16))}return this},finalize:function(){var f,d=this.i,g=this.n;d=sjcl.bitArray.concat(d,[sjcl.bitArray.partial(1,1)]);for(f=d.length+2;f&15;f++){d.push(0)}d.push(Math.floor(this.e/4294967296));for(d.push(this.e|0);d.length;){this.C(d.splice(0,16))}this.reset();return g},N:[],a:[],w:function(){function g(a){return(a-Math.floor(a))*4294967296|0}var f=0,i=2,h;g:for(;f<64;i++){for(h=2;h*h<=i;h++){if(i%h===0){continue g}}if(f<8){this.N[f]=g(Math.pow(i,0.5))}this.a[f]=g(Math.pow(i,1/3));f++}},C:function(D){var C,B,A=D.slice(0),y=this.n,x=this.a,w=y[0],v=y[1],u=y[2],r=y[3],s=y[4],q=y[5],p=y[6],o=y[7];for(D=0;D<64;D++){if(D<16){C=A[D]}else{C=A[D+1&15];B=A[D+14&15];C=A[D&15]=(C>>>7^C>>>18^C>>>3^C<<25^C<<14)+(B>>>17^B>>>19^B>>>10^B<<15^B<<13)+A[D&15]+A[D+9&15]|0}C=C+o+(s>>>6^s>>>11^s>>>25^s<<26^s<<21^s<<7)+(p^s&(q^p))+x[D];o=p;p=q;q=s;s=r+C|0;r=u;u=v;v=w;w=C+(v&u^r&(v^u))+(v>>>2^v>>>13^v>>>22^v<<30^v<<19^v<<10)|0}y[0]=y[0]+w|0;y[1]=y[1]+v|0;y[2]=y[2]+u|0;y[3]=y[3]+r|0;y[4]=y[4]+s|0;y[5]=y[5]+q|0;y[6]=y[6]+p|0;y[7]=y[7]+o|0}};sjcl.mode.ccm={name:"ccm",encrypt:function(u,s,r,q,p){var o,n=s.slice(0),m=sjcl.bitArray,l=m.bitLength(r)/8,j=m.bitLength(n)/8;p=p||64;q=q||[];if(l<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(o=2;o<4&&j>>>8*o;o++){}if(o<15-l){o=15-l}r=m.clamp(r,8*(15-o));s=sjcl.mode.ccm.G(u,s,r,q,p,o);n=sjcl.mode.ccm.I(u,n,r,s,p,o);return m.concat(n.data,n.tag)},decrypt:function(u,s,r,q,p){p=p||64;q=q||[];var o=sjcl.bitArray,n=o.bitLength(r)/8,m=o.bitLength(s),l=o.clamp(s,m-p),j=o.bitSlice(s,m-p);m=(m-p)/8;if(n<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(s=2;s<4&&m>>>8*s;s++){}if(s<15-n){s=15-n}r=o.clamp(r,8*(15-s));l=sjcl.mode.ccm.I(u,l,r,j,p,s);u=sjcl.mode.ccm.G(u,l.data,r,q,p,s);if(!o.equal(l.tag,u)){throw new sjcl.exception.corrupt("ccm: tag doesn't match")}return l.data},G:function(r,q,p,o,n,m){var l=[],k=sjcl.bitArray,j=k.k;n/=8;if(n%2||n<4||n>16){throw new sjcl.exception.invalid("ccm: invalid tag length")}if(o.length>4294967295||q.length>4294967295){throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data")}m=[k.partial(8,(o.length?64:0)|n-2<<2|m-1)];m=k.concat(m,p);m[3]|=k.bitLength(q)/8;m=r.encrypt(m);if(o.length){p=k.bitLength(o)/8;if(p<=65279){l=[k.partial(16,p)]}else{if(p<=4294967295){l=k.concat([k.partial(16,65534)],[p])}}l=k.concat(l,o);for(o=0;o<l.length;o+=4){m=r.encrypt(j(m,l.slice(o,o+4)))}}for(o=0;o<q.length;o+=4){m=r.encrypt(j(m,q.slice(o,o+4)))}return k.clamp(m,n*8)},I:function(u,s,r,q,p,o){var n,m=sjcl.bitArray;n=m.k;var l=s.length,j=m.bitLength(s);r=m.concat([m.partial(8,o-1)],r).concat([0,0,0]).slice(0,4);q=m.bitSlice(n(q,u.encrypt(r)),0,p);if(!l){return{tag:q,data:[]}}for(n=0;n<l;n+=4){r[3]++;p=u.encrypt(r);s[n]^=p[0];s[n+1]^=p[1];s[n+2]^=p[2];s[n+3]^=p[3]}return{tag:q,data:m.clamp(s,j)}}};sjcl.mode.ocb2={name:"ocb2",encrypt:function(B,A,y,x,w,v){if(sjcl.bitArray.bitLength(y)!==128){throw new sjcl.exception.invalid("ocb iv must be 128 bits")}var u,s=sjcl.mode.ocb2.A,r=sjcl.bitArray,p=r.k,q=[0,0,0,0];y=s(B.encrypt(y));var o,n=[];x=x||[];w=w||64;for(u=0;u+4<A.length;u+=4){o=A.slice(u,u+4);q=p(q,o);n=n.concat(p(y,B.encrypt(p(y,o))));y=s(y)}o=A.slice(u);A=r.bitLength(o);u=B.encrypt(p(y,[0,0,0,A]));o=r.clamp(p(o,u),A);q=p(q,p(o,u));q=B.encrypt(p(q,p(y,s(y))));if(x.length){q=p(q,v?x:sjcl.mode.ocb2.pmac(B,x))}return n.concat(r.concat(o,r.clamp(q,w)))},decrypt:function(F,E,D,C,B,A){if(sjcl.bitArray.bitLength(D)!==128){throw new sjcl.exception.invalid("ocb iv must be 128 bits")}B=B||64;var y=sjcl.mode.ocb2.A,x=sjcl.bitArray,w=x.k,u=[0,0,0,0],v=y(F.encrypt(D)),s,r,q=sjcl.bitArray.bitLength(E)-B,p=[];C=C||[];for(D=0;D+4<q/32;D+=4){s=w(v,F.decrypt(w(v,E.slice(D,D+4))));u=w(u,s);p=p.concat(s);v=y(v)}r=q-D*32;s=F.encrypt(w(v,[0,0,0,r]));s=w(s,x.clamp(E.slice(D),r));u=w(u,s);u=F.encrypt(w(u,w(v,y(v))));if(C.length){u=w(u,A?C:sjcl.mode.ocb2.pmac(F,C))}if(!x.equal(x.clamp(u,B),x.bitSlice(E,q))){throw new sjcl.exception.corrupt("ocb: tag doesn't match")}return p.concat(x.clamp(s,r))},pmac:function(j,i){var p,o=sjcl.mode.ocb2.A,n=sjcl.bitArray,m=n.k,l=[0,0,0,0],k=j.encrypt([0,0,0,0]);k=m(k,o(o(k)));for(p=0;p+4<i.length;p+=4){k=o(k);l=m(l,j.encrypt(m(k,i.slice(p,p+4))))}i=i.slice(p);if(n.bitLength(i)<128){k=m(k,o(k));i=n.concat(i,[2147483648|0])}l=m(l,i);return j.encrypt(m(o(m(k,o(k))),l))},A:function(b){return[b[0]<<1^b[1]>>>31,b[1]<<1^b[2]>>>31,b[2]<<1^b[3]>>>31,b[3]<<1^(b[0]>>>31)*135]}};sjcl.misc.hmac=function(g,f){this.M=f=f||sjcl.hash.sha256;var i=[[],[]],h=f.prototype.blockSize/32;this.l=[new f,new f];if(g.length>h){g=f.hash(g)}for(f=0;f<h;f++){i[0][f]=g[f]^909522486;i[1][f]=g[f]^1549556828}this.l[0].update(i[0]);this.l[1].update(i[1])};sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(d,c){d=(new this.M(this.l[0])).update(d,c).finalize();return(new this.M(this.l[1])).update(d).finalize()};sjcl.misc.pbkdf2=function(w,v,u,s,r){u=u||1000;if(s<0||u<0){throw sjcl.exception.invalid("invalid params to pbkdf2")}if(typeof w==="string"){w=sjcl.codec.utf8String.toBits(w)}r=r||sjcl.misc.hmac;w=new r(w);var q,p,o,n,l=[],m=sjcl.bitArray;for(n=1;32*l.length<(s||1);n++){r=q=w.encrypt(m.concat(v,[n]));for(p=1;p<u;p++){q=w.encrypt(q);for(o=0;o<q.length;o++){r[o]^=q[o]}}l=l.concat(r)}if(s){l=m.clamp(l,s)}return l};sjcl.random={randomWords:function(g,f){var i=[];f=this.isReady(f);var h;if(f===0){throw new sjcl.exception.notready("generator isn't seeded")}else{f&2&&this.U(!(f&1))}for(f=0;f<g;f+=4){(f+1)%65536===0&&this.L();h=this.u();i.push(h[0],h[1],h[2],h[3])}this.L();return i.slice(0,g)},setDefaultParanoia:function(b){this.t=b},addEntropy:function(j,i,p){p=p||"user";var o,n,m=(new Date).valueOf(),l=this.q[p],k=this.isReady();o=this.F[p];if(o===undefined){o=this.F[p]=this.R++}if(l===undefined){l=this.q[p]=0}this.q[p]=(this.q[p]+1)%this.b.length;switch(typeof j){case"number":break;case"object":if(i===undefined){for(p=i=0;p<j.length;p++){for(n=j[p];n>0;){i++;n>>>=1}}}this.b[l].update([o,this.J++,2,i,m,j.length].concat(j));break;case"string":if(i===undefined){i=j.length}this.b[l].update([o,this.J++,3,i,m,j.length]);this.b[l].update(j);break;default:throw new sjcl.exception.bug("random: addEntropy only supports number, array or string")}this.j[l]+=i;this.f+=i;if(k===0){this.isReady()!==0&&this.K("seeded",Math.max(this.g,this.f));this.K("progress",this.getProgress())}},isReady:function(b){b=this.B[b!==undefined?b:this.t];return this.g&&this.g>=b?this.j[0]>80&&(new Date).valueOf()>this.O?3:1:this.f>=b?2:0},getProgress:function(b){b=this.B[b?b:this.t];return this.g>=b?1["0"]:this.f>b?1["0"]:this.f/b},startCollectors:function(){if(!this.m){if(window.addEventListener){window.addEventListener("load",this.o,false);window.addEventListener("mousemove",this.p,false)}else{if(document.attachEvent){document.attachEvent("onload",this.o);document.attachEvent("onmousemove",this.p)}else{throw new sjcl.exception.bug("can't attach event")}}this.m=true}},stopCollectors:function(){if(this.m){if(window.removeEventListener){window.removeEventListener("load",this.o);window.removeEventListener("mousemove",this.p)}else{if(window.detachEvent){window.detachEvent("onload",this.o);window.detachEvent("onmousemove",this.p)}}this.m=false}},addEventListener:function(d,c){this.r[d][this.Q++]=c},removeEventListener:function(g,f){var i;g=this.r[g];var h=[];for(i in g){g.hasOwnProperty[i]&&g[i]===f&&h.push(i)}for(f=0;f<h.length;f++){i=h[f];delete g[i]}},b:[new sjcl.hash.sha256],j:[0],z:0,q:{},J:0,F:{},R:0,g:0,f:0,O:0,a:[0,0,0,0,0,0,0,0],d:[0,0,0,0],s:undefined,t:6,m:false,r:{progress:{},seeded:{}},Q:0,B:[0,48,64,96,128,192,256,384,512,768,1024],u:function(){for(var b=0;b<4;b++){this.d[b]=this.d[b]+1|0;if(this.d[b]){break}}return this.s.encrypt(this.d)},L:function(){this.a=this.u().concat(this.u());this.s=new sjcl.cipher.aes(this.a)},T:function(b){this.a=sjcl.hash.sha256.hash(this.a.concat(b));this.s=new sjcl.cipher.aes(this.a);for(b=0;b<4;b++){this.d[b]=this.d[b]+1|0;if(this.d[b]){break}}},U:function(g){var f=[],i=0,h;this.O=f[0]=(new Date).valueOf()+30000;for(h=0;h<16;h++){f.push(Math.random()*4294967296|0)}for(h=0;h<this.b.length;h++){f=f.concat(this.b[h].finalize());i+=this.j[h];this.j[h]=0;if(!g&&this.z&1<<h){break}}if(this.z>=1<<this.b.length){this.b.push(new sjcl.hash.sha256);this.j.push(0)}this.f-=i;if(i>this.g){this.g=i}this.z++;this.T(f)},p:function(b){sjcl.random.addEntropy([b.x||b.clientX||b.offsetX,b.y||b.clientY||b.offsetY],2,"mouse")},o:function(){sjcl.random.addEntropy(new Date,2,"loadtime")},K:function(g,f){var i;g=sjcl.random.r[g];var h=[];for(i in g){g.hasOwnProperty(i)&&h.push(g[i])}for(i=0;i<h.length;i++){h[i](f)}}};sjcl.json={defaults:{v:1,iter:1000,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},encrypt:function(h,g,l,k){l=l||{};k=k||{};var j=sjcl.json,i=j.c({iv:sjcl.random.randomWords(4,0)},j.defaults);j.c(i,l);if(typeof i.salt==="string"){i.salt=sjcl.codec.base64.toBits(i.salt)}if(typeof i.iv==="string"){i.iv=sjcl.codec.base64.toBits(i.iv)}if(!sjcl.mode[i.mode]||!sjcl.cipher[i.cipher]||typeof h==="string"&&i.iter<=100||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||i.iv.length<2||i.iv.length>4){throw new sjcl.exception.invalid("json encrypt: invalid parameters")}if(typeof h==="string"){l=sjcl.misc.cachedPbkdf2(h,i);h=l.key.slice(0,i.ks/32);i.salt=l.salt}if(typeof g==="string"){g=sjcl.codec.utf8String.toBits(g)}l=new sjcl.cipher[i.cipher](h);j.c(k,i);k.key=h;i.ct=sjcl.mode[i.mode].encrypt(l,g,i.iv,i.adata,i.tag);return j.encode(j.V(i,j.defaults))},decrypt:function(g,f,j,i){j=j||{};i=i||{};var h=sjcl.json;f=h.c(h.c(h.c({},h.defaults),h.decode(f)),j,true);if(typeof f.salt==="string"){f.salt=sjcl.codec.base64.toBits(f.salt)}if(typeof f.iv==="string"){f.iv=sjcl.codec.base64.toBits(f.iv)}if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||typeof g==="string"&&f.iter<=100||f.ts!==64&&f.ts!==96&&f.ts!==128||f.ks!==128&&f.ks!==192&&f.ks!==256||!f.iv||f.iv.length<2||f.iv.length>4){throw new sjcl.exception.invalid("json decrypt: invalid parameters")}if(typeof g==="string"){j=sjcl.misc.cachedPbkdf2(g,f);g=j.key.slice(0,f.ks/32);f.salt=j.salt}j=new sjcl.cipher[f.cipher](g);j=sjcl.mode[f.mode].decrypt(j,f.ct,f.iv,f.adata,f.tag);h.c(i,f);i.key=g;return sjcl.codec.utf8String.fromBits(j)},encode:function(g){var f,i="{",h="";for(f in g){if(g.hasOwnProperty(f)){if(!f.match(/^[a-z0-9]+$/i)){throw new sjcl.exception.invalid("json encode: invalid property name")}i+=h+f+":";h=",";switch(typeof g[f]){case"number":case"boolean":i+=g[f];break;case"string":i+='"'+escape(g[f])+'"';break;case"object":i+='"'+sjcl.codec.base64.fromBits(g[f],1)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type")}}}return i+"}"},decode:function(g){g=g.replace(/\s/g,"");if(!g.match(/^\{.*\}$/)){throw new sjcl.exception.invalid("json decode: this isn't json!")}g=g.replace(/^\{|\}$/g,"").split(/,/);var f={},i,h;for(i=0;i<g.length;i++){if(!(h=g[i].match(/^([a-z][a-z0-9]*):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i))){throw new sjcl.exception.invalid("json decode: this isn't json!")}f[h[1]]=h[2]?parseInt(h[2],10):h[1].match(/^(ct|salt|iv)$/)?sjcl.codec.base64.toBits(h[3]):unescape(h[3])}return f},c:function(g,f,i){if(g===undefined){g={}}if(f===undefined){return g}var h;for(h in f){if(f.hasOwnProperty(h)){if(i&&g[h]!==undefined&&g[h]!==f[h]){throw new sjcl.exception.invalid("required parameter overridden")}g[h]=f[h]}}return g},V:function(g,f){var i={},h;for(h in g){if(g.hasOwnProperty(h)&&g[h]!==f[h]){i[h]=g[h]}}return i},W:function(g,f){var i={},h;for(h=0;h<f.length;h++){if(g[f[h]]!==undefined){i[f[h]]=g[f[h]]}}return i}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.S={};sjcl.misc.cachedPbkdf2=function(g,f){var i=sjcl.misc.S,h;f=f||{};h=f.iter||1000;i=i[g]=i[g]||{};h=i[h]=i[h]||{firstSalt:f.salt&&f.salt.length?f.salt.slice(0):sjcl.random.randomWords(2,0)};i=f.salt===undefined?h.firstSalt:f.salt;h[i]=h[i]||sjcl.misc.pbkdf2(g,i,f.iter);return{key:h[i].slice(0),salt:i.slice(0)}};var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64pad="=";function hex2b64(d){var b;var f;var a="";for(b=0;b+3<=d.length;b+=3){f=parseInt(d.substring(b,b+3),16);a+=b64map.charAt(f>>6)+b64map.charAt(f&63)}if(b+1==d.length){f=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(f<<2)}else{if(b+2==d.length){f=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(f>>2)+b64map.charAt((f&3)<<4)}}while((a.length&3)>0){a+=b64pad}return a}function b64tohex(g){var d="";var f;var b=0;var c;for(f=0;f<g.length;++f){if(g.charAt(f)==b64pad){break}var a=b64map.indexOf(g.charAt(f));if(a<0){continue}if(b==0){d+=int2char(a>>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(f){var d=b64tohex(f);var c;var b=new Array();for(c=0;2*c<d.length;++c){b[c]=parseInt(d.substring(2*c,2*c+2),16)}return b}var dbits;var canary=244837814094590;var j_lm=((canary&16777215)==15715070);function BigInteger(f,d,g){if(f!=null){if("number"==typeof f){this.fromNumber(f,d,g)}else{if(d==null&&"string"!=typeof f){this.fromString(f,256)}else{this.fromString(f,d)}}}}function nbi(){return new BigInteger(null)}function am1(g,a,b,f,k,h){while(--h>=0){var d=a*this[g++]+b[f]+k;k=Math.floor(d/67108864);b[f++]=d&67108863}return k}function am2(g,r,s,f,p,a){var o=r&32767,q=r>>15;while(--a>=0){var d=this[g]&32767;var k=this[g++]>>15;var b=q*d+k*o;d=o*d+((b&32767)<<15)+s[f]+(p&1073741823);p=(d>>>30)+(b>>>15)+q*k+(p>>>30);s[f++]=d&1073741823}return p}function am3(g,r,s,f,p,a){var o=r&16383,q=r>>14;while(--a>=0){var d=this[g]&16383;var k=this[g++]>>14;var b=q*d+k*o;d=o*d+((b&16383)<<14)+s[f]+p;p=(d>>28)+(b>>14)+q*k;s[f++]=d&268435455}return p}try{if(j_lm&&(navigator&&navigator.appName=="Microsoft Internet Explorer")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator&&navigator.appName!="Netscape")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}}catch(e){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";var BI_RC=new Array();var rr,vv;rr="0".charCodeAt(0);for(vv=0;vv<=9;++vv){BI_RC[rr++]=vv}rr="a".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}rr="A".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}function int2char(a){return BI_RM.charAt(a)}function intAt(b,a){var d=BI_RC[b.charCodeAt(a)];return(d==null)?-1:d}function bnpCopyTo(b){for(var a=this.t-1;a>=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(j,c){var f;if(c==16){f=4}else{if(c==8){f=3}else{if(c==256){f=8}else{if(c==2){f=1}else{if(c==32){f=5}else{if(c==4){f=2}else{this.fromRadix(j,c);return}}}}}}this.t=0;this.s=0;var h=j.length,d=false,g=0;while(--h>=0){var a=(f==8)?j[h]&255:intAt(j,h);if(a<0){if(j.charAt(h)=="-"){d=true}continue}d=false;if(g==0){this[this.t++]=a}else{if(g+f>this.DB){this[this.t-1]|=(a&((1<<(this.DB-g))-1))<<g;this[this.t++]=(a>>(this.DB-g))}else{this[this.t-1]|=a<<g}}g+=f;if(g>=this.DB){g-=this.DB}}if(f==8&&(j[0]&128)!=0){this.s=-1;if(g>0){this[this.t-1]|=((1<<(this.DB-g))-1)<<g}}this.clamp();if(d){BigInteger.ZERO.subTo(this,this)}}function bnpClamp(){var a=this.s&this.DM;while(this.t>0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return"-"+this.negate().toString(c)}var f;if(c==16){f=4}else{if(c==8){f=3}else{if(c==2){f=1}else{if(c==32){f=5}else{if(c==4){f=2}else{return this.toRadix(c)}}}}}var h=(1<<f)-1,n,a=false,j="",g=this.t;var l=this.DB-(g*this.DB)%f;if(g-->0){if(l<this.DB&&(n=this[g]>>l)>0){a=true;j=int2char(n)}while(g>=0){if(l<f){n=(this[g]&((1<<l)-1))<<(f-l);n|=this[--g]>>(l+=this.DB-f)}else{n=(this[g]>>(l-=f))&h;if(l<=0){l+=this.DB;--g}}if(n>0){a=true}if(a){j+=int2char(n)}}}return a?j:"0"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a<this.t;++a){b[a-c]=this[a]}b.t=Math.max(this.t-c,0);b.s=this.s}function bnpLShiftTo(k,f){var b=k%this.DB;var a=this.DB-b;var h=(1<<a)-1;var g=Math.floor(k/this.DB),j=(this.s<<b)&this.DM,d;for(d=this.t-1;d>=0;--d){f[d+g+1]=(this[d]>>a)|j;j=(this[d]&h)<<b}for(d=g-1;d>=0;--d){f[d]=0}f[g]=j;f.t=this.t+g+1;f.s=this.s;f.clamp()}function bnpRShiftTo(h,d){d.s=this.s;var f=Math.floor(h/this.DB);if(f>=this.t){d.t=0;return}var b=h%this.DB;var a=this.DB-b;var g=(1<<b)-1;d[0]=this[f]>>b;for(var c=f+1;c<this.t;++c){d[c-f-1]|=(this[c]&g)<<a;d[c-f]=this[c]>>b}if(b>0){d[this.t-f-1]|=(this.s&g)<<a}d.t=this.t-f;d.clamp()}function bnpSubTo(d,g){var f=0,h=0,b=Math.min(d.t,this.t);while(f<b){h+=this[f]-d[f];g[f++]=h&this.DM;h>>=this.DB}if(d.t<this.t){h-=d.s;while(f<this.t){h+=this[f];g[f++]=h&this.DM;h>>=this.DB}h+=this.s}else{h+=this.s;while(f<d.t){h-=d[f];g[f++]=h&this.DM;h>>=this.DB}h-=d.s}g.s=(h<0)?-1:0;if(h<-1){g[f++]=this.DV+h}else{if(h>0){g[f++]=h}}g.t=f;g.clamp()}function bnpMultiplyTo(c,f){var b=this.abs(),g=c.abs();var d=b.t;f.t=d+g.t;while(--d>=0){f[d]=0}for(d=0;d<g.t;++d){f[d+b.t]=b.am(0,g[d],f,d,0,b.t)}f.s=0;f.clamp();if(this.s!=c.s){BigInteger.ZERO.subTo(f,f)}}function bnpSquareTo(d){var a=this.abs();var b=d.t=2*a.t;while(--b>=0){d[b]=0}for(b=0;b<a.t-1;++b){var f=a.am(b,a[b],d,2*b,0,1);if((d[b+a.t]+=a.am(b+1,2*a[b],d,2*b+1,f,a.t-b-1))>=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t<w.t){if(h!=null){h.fromInt(0)}if(g!=null){this.copyTo(g)}return}if(g==null){g=nbi()}var d=nbi(),a=this.s,l=n.s;var v=this.DB-nbits(w[w.t-1]);if(v>0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<<this.F1)+((p>1)?d[p-2]>>this.F2:0);var B=this.FV/o,A=(1<<this.F1)/o,x=1<<this.F2;var u=g.t,s=u-p,f=(h==null)?nbi():h;d.dlShiftTo(s,f);if(g.compareTo(f)>=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t<p){d[d.t++]=0}while(--s>=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*B+(g[u-1]+x)*A);if((g[u]+=d.am(0,c,g,s,0,p))<c){d.dlShiftTo(s,f);g.subTo(f,g);while(g[u]<--c){g.subTo(f,g)}}}if(h!=null){g.drShiftTo(p,h);if(a!=l){BigInteger.ZERO.subTo(h,h)}}g.t=p;g.clamp();if(v>0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){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(b>0)?this.DV-b:-b}function Montgomery(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 montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c<this.m.t;++c){var b=a[c]&32767;var d=(b*this.mpl+(((b*this.mph+(a[c]>>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<<c))>0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=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 a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0]}function bnByteValue(){return(this.t==0)?this.s:(this[0]<<24)>>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return"0"}var g=this.chunkSize(c);var f=Math.pow(c,g);var j=nbv(f),k=nbi(),i=nbi(),h="";this.divRemTo(j,k,i);while(k.signum()>0){h=(f+i.intValue()).toString(c).substr(1)+h;k.divRemTo(j,k,i)}return i.intValue().toString(c)+h}function bnpFromRadix(n,k){this.fromInt(0);if(k==null){k=10}var g=this.chunkSize(k);var h=Math.pow(k,g),f=false,a=0,m=0;for(var c=0;c<n.length;++c){var l=intAt(n,c);if(l<0){if(n.charAt(c)=="-"&&this.signum()==0){f=true}continue}m=k*m+l;if(++a>=g){this.dMultiply(h);this.dAddOffset(m,0);a=0;m=0}}if(a>0){this.dMultiply(Math.pow(k,a));this.dAddOffset(m,0)}if(f){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(g,f,i){if("number"==typeof f){if(g<2){this.fromInt(1)}else{this.fromNumber(g,i);if(!this.testBit(g-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(g-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(f)){this.dAddOffset(2,0);if(this.bitLength()>g){this.subTo(BigInteger.ONE.shiftLeft(g-1),this)}}}}else{var d=new Array(),h=g&7;d.length=(g>>3)+1;f.nextBytes(d);if(h>0){d[0]&=((1<<h)-1)}else{d[0]=0}this.fromString(d,256)}}function bnToByteArray(){var b=this.t,c=new Array();c[0]=this.s;var f=this.DB-(b*this.DB)%8,g,a=0;if(b-->0){if(f<this.DB&&(g=this[b]>>f)!=(this.s&this.DM)>>f){c[a++]=g|(this.s<<(this.DB-f))}while(b>=0){if(f<8){g=(this[b]&((1<<f)-1))<<(8-f);g|=this[--b]>>(f+=this.DB-8)}else{g=(this[b]>>(f-=8))&255;if(f<=0){f+=this.DB;--b}}if((g&128)!=0){g|=-256}if(a==0&&(this.s&128)!=(g&128)){++a}if(a>0||g!=this.s){c[a++]=g}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,j,g){var d,h,b=Math.min(c.t,this.t);for(d=0;d<b;++d){g[d]=j(this[d],c[d])}if(c.t<this.t){h=c.s&this.DM;for(d=b;d<this.t;++d){g[d]=j(this[d],h)}g.t=this.t}else{h=this.s&this.DM;for(d=b;d<c.t;++d){g[d]=j(h,c[d])}g.t=c.t}g.s=j(this.s,c.s);g.clamp()}function op_and(a,b){return a&b}function bnAnd(b){var c=nbi();this.bitwiseTo(b,op_and,c);return c}function op_or(a,b){return a|b}function bnOr(b){var c=nbi();this.bitwiseTo(b,op_or,c);return c}function op_xor(a,b){return a^b}function bnXor(b){var c=nbi();this.bitwiseTo(b,op_xor,c);return c}function op_andnot(a,b){return a&~b}function bnAndNot(b){var c=nbi();this.bitwiseTo(b,op_andnot,c);return c}function bnNot(){var b=nbi();for(var a=0;a<this.t;++a){b[a]=this.DM&~this[a]}b.t=this.t;b.s=~this.s;return b}function bnShiftLeft(b){var a=nbi();if(b<0){this.rShiftTo(-b,a)}else{this.lShiftTo(b,a)}return a}function bnShiftRight(b){var a=nbi();if(b<0){this.lShiftTo(-b,a)}else{this.rShiftTo(b,a)}return a}function lbit(a){if(a==0){return -1}var b=0;if((a&65535)==0){a>>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a<this.t;++a){if(this[a]!=0){return a*this.DB+lbit(this[a])}}if(this.s<0){return this.t*this.DB}return -1}function cbit(a){var b=0;while(a!=0){a&=a-1;++b}return b}function bnBitCount(){var c=0,a=this.s&this.DM;for(var b=0;b<this.t;++b){c+=cbit(this[b]^a)}return c}function bnTestBit(b){var a=Math.floor(b/this.DB);if(a>=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,g){var f=0,h=0,b=Math.min(d.t,this.t);while(f<b){h+=this[f]+d[f];g[f++]=h&this.DM;h>>=this.DB}if(d.t<this.t){h+=d.s;while(f<this.t){h+=this[f];g[f++]=h&this.DM;h>>=this.DB}h+=this.s}else{h+=this.s;while(f<d.t){h+=d[f];g[f++]=h&this.DM;h>>=this.DB}h+=d.s}g.s=(h<0)?-1:0;if(h>0){g[f++]=h}else{if(h<-1){g[f++]=this.DV+h}}g.t=f;g.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,g,f){var d=Math.min(this.t+b.t,g);f.s=0;f.t=d;while(d>0){f[--d]=0}var c;for(c=f.t-this.t;d<c;++d){f[d+this.t]=this.am(0,b[d],f,d,0,this.t)}for(c=Math.min(b.t,g);d<c;++d){this.am(0,b[d],f,d,0,g-d)}f.clamp()}function bnpMultiplyUpperTo(b,f,d){--f;var c=d.t=this.t+b.t-f;d.s=0;while(--c>=0){d[c]=0}for(c=Math.max(f-this.t,0);c<b.t;++c){d[this.t+c-f]=this.am(f-c,b[c],d,0,0,this.t+c-f)}d.clamp();d.drShiftTo(1,d)}function Barrett(a){this.r2=nbi();this.q3=nbi();BigInteger.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a}function barrettConvert(a){if(a.s<0||a.t>2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<<h)-1;p[1]=v.convert(this);if(h>1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<<o))==0){v.sqrTo(b,c);y=b;b=c;c=y;if(--o<0){o=this.DB-1;--l}}}return v.revert(b)}function bnGCD(c){var b=(this.s<0)?this.negate():this.clone();var j=(c.s<0)?c.negate():c.clone();if(b.compareTo(j)<0){var f=b;b=j;j=f}var d=b.getLowestSetBit(),h=j.getLowestSetBit();if(h<0){return b}if(d<h){h=d}if(h>0){b.rShiftTo(h,b);j.rShiftTo(h,j)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=j.getLowestSetBit())>0){j.rShiftTo(d,j)}if(b.compareTo(j)>=0){b.subTo(j,b);b.rShiftTo(1,b)}else{j.subTo(b,j);j.rShiftTo(1,j)}}if(h>0){j.lShiftTo(h,j)}return j}function bnpModInt(f){if(f<=0){return 0}var c=this.DV%f,b=(this.s<0)?f-1:0;if(this.t>0){if(c==0){b=this[0]%f}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%f}}}return b}function bnModInverse(g){var k=g.isEven();if((this.isEven()&&k)||g.signum()==0){return BigInteger.ZERO}var j=g.clone(),i=this.clone();var h=nbv(1),f=nbv(0),n=nbv(0),l=nbv(1);while(j.signum()!=0){while(j.isEven()){j.rShiftTo(1,j);if(k){if(!h.isEven()||!f.isEven()){h.addTo(this,h);f.subTo(g,f)}h.rShiftTo(1,h)}else{if(!f.isEven()){f.subTo(g,f)}}f.rShiftTo(1,f)}while(i.isEven()){i.rShiftTo(1,i);if(k){if(!n.isEven()||!l.isEven()){n.addTo(this,n);l.subTo(g,l)}n.rShiftTo(1,n)}else{if(!l.isEven()){l.subTo(g,l)}}l.rShiftTo(1,l)}if(j.compareTo(i)>=0){j.subTo(i,j);if(k){h.subTo(n,h)}f.subTo(l,f)}else{i.subTo(j,i);if(k){n.subTo(h,n)}l.subTo(f,l)}}if(i.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(l.compareTo(g)>=0){return l.subtract(g)}if(l.signum()<0){l.addTo(g,l)}else{return l}if(l.signum()<0){return l.add(g)}else{return l}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(f){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d<lowprimes.length;++d){if(b[0]==lowprimes[d]){return true}}return false}if(b.isEven()){return false}d=1;while(d<lowprimes.length){var a=lowprimes[d],c=d+1;while(c<lowprimes.length&&a<lplim){a*=lowprimes[c++]}a=b.modInt(a);while(d<c){if(a%lowprimes[d++]==0){return false}}}return b.millerRabin(f)}function bnpMillerRabin(g){var h=this.subtract(BigInteger.ONE);var c=h.getLowestSetBit();if(c<=0){return false}var l=h.shiftRight(c);g=(g+1)>>1;if(g>lowprimes.length){g=lowprimes.length}var b=nbi();for(var f=0;f<g;++f){b.fromInt(lowprimes[f]);var m=b.modPow(l,this);if(m.compareTo(BigInteger.ONE)!=0&&m.compareTo(h)!=0){var d=1;while(d++<c&&m.compareTo(h)!=0){m=m.modPowInt(2,this);if(m.compareTo(BigInteger.ONE)==0){return false}}if(m.compareTo(h)!=0){return false}}}return true}BigInteger.prototype.chunkSize=bnpChunkSize;BigInteger.prototype.toRadix=bnpToRadix;BigInteger.prototype.fromRadix=bnpFromRadix;BigInteger.prototype.fromNumber=bnpFromNumber;BigInteger.prototype.bitwiseTo=bnpBitwiseTo;BigInteger.prototype.changeBit=bnpChangeBit;BigInteger.prototype.addTo=bnpAddTo;BigInteger.prototype.dMultiply=bnpDMultiply;BigInteger.prototype.dAddOffset=bnpDAddOffset;BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo;BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo;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;function parseBigInt(b,a){return new BigInteger(b,a)}function linebrk(c,d){var a="";var b=0;while(b+d<c.length){a+=c.substring(b,b+d)+"\n";b+=d}return a+c.substring(b,c.length)}function byte2Hex(a){if(a<16){return"0"+a.toString(16)}else{return a.toString(16)}}function pkcs1pad2(f,j){if(j<f.length+11){alert("Message too long for RSA");return null}var h=new Array();var d=f.length-1;while(d>=0&&j>0){var g=f.charCodeAt(d--);if(g<128){h[--j]=g}else{if((g>127)&&(g<2048)){h[--j]=(g&63)|128;h[--j]=(g>>6)|192}else{h[--j]=(g&63)|128;h[--j]=((g>>6)&63)|128;h[--j]=(g>>12)|224}}}h[--j]=0;var b=new SecureRandom();var a=new Array();while(j>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}h[--j]=a[0]}h[--j]=2;h[--j]=0;return new BigInteger(h)}function RSAKey(){this.n=null;this.e=0;this.d=null;this.p=null;this.q=null;this.dmp1=null;this.dmq1=null;this.coeff=null}function RSASetPublic(b,a){if(b!=null&&a!=null&&b.length>0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{alert("Invalid RSA public key")}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var f=this.doPublic(a);if(f==null){return null}var b=f.toString(16);if((b.length&1)==0){return b}else{return"0"+b}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;function pkcs1unpad2(h,k){var a=h.toByteArray();var g=0;while(g<a.length&&a[g]==0){++g}if(a.length-g!=k-1||a[g]!=2){return null}++g;while(a[g]!=0){if(++g>=a.length){return null}}var f="";while(++g<a.length){var j=a[g]&255;if(j<128){f+=String.fromCharCode(j)}else{if((j>191)&&(j<224)){f+=String.fromCharCode(((j&31)<<6)|(a[g+1]&63));++g}else{f+=String.fromCharCode(((j&15)<<12)|((a[g+1]&63)<<6)|(a[g+2]&63));g+=2}}}return f}function RSASetPrivate(c,a,b){if(c!=null&&a!=null&&c.length>0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{alert("Invalid RSA private key")}}function RSASetPrivateEx(h,d,f,c,b,a,i,g){if(h!=null&&d!=null&&h.length>0&&d.length>0){this.n=parseBigInt(h,16);this.e=parseInt(d,16);this.d=parseBigInt(f,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(i,16);this.coeff=parseBigInt(g,16)}else{alert("Invalid RSA private key")}}function RSAGenerate(b,j){var a=new SecureRandom();var g=b>>1;this.e=parseInt(j,16);var c=new BigInteger(j,16);for(;;){for(;;){this.p=new BigInteger(b-g,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(g,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q;this.q=i}var h=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var f=h.multiply(d);if(f.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(f);this.dmp1=this.d.mod(h);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}}function RSAPrivateKeySerializeASN1(){function g(j,k){var i=k.toByteArray();j.push(2);j.push(i.length);return j.concat(i)}var c=[];c.push(48);c.push(130);c.push(1);c.push(0);c.push(2);c.push(1);c.push(0);c=g(c,this.n);c=g(c,new BigInteger(""+this.e,10));c=g(c,this.d);c=g(c,this.p);c=g(c,this.q);c=g(c,this.dmp1);c=g(c,this.dmq1);c=g(c,this.coeff);var f=c.length-4;var a=new BigInteger(""+f,10).toByteArray();c[2]=a[0];c[3]=a[1];var b="";for(var d=0;d<c.length;d++){b+=int2char((c[d]&240)>>4);b+=int2char(c[d]&15)}b=hex2b64(b);var h="";for(var d=0;d<b.length;d++){if(d>0&&(d%64)==0){h+="\n"}h+=b[d]}return"-----BEGIN RSA PRIVATE KEY-----\n"+h+"\n-----END RSA PRIVATE KEY-----\n"}function RSAPublicKeySerializeASN1(){function g(o){var n=0;for(var q=0;q<o.length;q++){n+=o[q].length}var p=[];p.push(48);if(n<128){p.push(n)}else{var m=new BigInteger(""+n,10).toByteArray();p.push(128|m.length);for(var q=0;q<m.length;q++){p.push(m[q])}}for(var q=0;q<o.length;q++){p=p.concat(o[q])}return p}function b(n){var i=n.toByteArray();var m=[];m.push(2);m.push(i.length);return m.concat(i)}function k(m){var i=[];i.push(3);i.push(0);return i.concat(m)}var h=g([b(this.n),b(new BigInteger(""+this.e,10))]);var a=k(h);var j=g([[6,9,42,134,72,134,247,13,1,1,1],[5,0],]);var l=g([j,a]);var d="";for(var f=0;f<l.length;f++){d+=int2char((l[f]&240)>>4);d+=int2char(l[f]&15)}d=hex2b64(d);var c="";for(var f=0;f<d.length;f++){if(f>0&&(f%64)==0){c+="\n"}c+=d[f]}return"-----BEGIN PUBLIC KEY-----\n"+c+"\n-----END PUBLIC KEY-----\n"}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.serializePrivateASN1=RSAPrivateKeySerializeASN1;RSAKey.prototype.serializePublicASN1=RSAPublicKeySerializeASN1;function _asnhex_getByteLengthOfL_AtObj(b,c){if(b.substring(c+2,c+3)!="8"){return 1}var a=parseInt(b.substring(c+3,c+4));if(a==0){return -1}if(0<a&&a<10){return a+1}return -2}function _asnhex_getHexOfL_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<1){return""}return b.substring(c+2,c+2+a*2)}function _asnhex_getIntOfL_AtObj(c,d){var b=_asnhex_getHexOfL_AtObj(c,d);if(b==""){return -1}var a;if(parseInt(b.substring(0,1))<8){a=parseBigInt(b,16)}else{a=parseBigInt(b.substring(2),16)}return a.intValue()}function _asnhex_getStartPosOfV_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<0){return a}return c+(a+1)*2}function _asnhex_getHexOfV_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return c.substring(b,b+a*2)}function _asnhex_getPosOfNextSibling_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return b+a*2}function _asnhex_getPosArrayOfChildren_AtObj(g,l){var c=new Array();var j=_asnhex_getStartPosOfV_AtObj(g,l);c.push(j);var b=_asnhex_getIntOfL_AtObj(g,l);var i=j;var d=0;while(1){var f=_asnhex_getPosOfNextSibling_AtObj(g,i);if(f==null||(f-j>=(b*2))){break}if(d>=200){break}c.push(f);i=f;d++}return c}function _rsapem_pemToBase64(b){var a=b;a=a.replace("-----BEGIN RSA PRIVATE KEY-----","");a=a.replace("-----END RSA PRIVATE KEY-----","");a=a.replace(/[ \n]+/g,"");return a}function _rsapubpem_pemToBase64(b){if(b.indexOf("-----BEGIN PUBLIC KEY-----")!=0){throw"Malformed input to readPublicKeyFromPEMString: input does not start with '-----BEGIN PUBLIC KEY-----'"}var a=b;a=a.replace("-----BEGIN PUBLIC KEY-----","");a=a.replace("-----END PUBLIC KEY-----","");a=a.replace(/[ \n]+/g,"");return a}function _rsapem_getPosArrayOfChildrenFromHex(d){var k=new Array();var l=_asnhex_getStartPosOfV_AtObj(d,0);var g=_asnhex_getPosOfNextSibling_AtObj(d,l);var i=_asnhex_getPosOfNextSibling_AtObj(d,g);var b=_asnhex_getPosOfNextSibling_AtObj(d,i);var m=_asnhex_getPosOfNextSibling_AtObj(d,b);var f=_asnhex_getPosOfNextSibling_AtObj(d,m);var h=_asnhex_getPosOfNextSibling_AtObj(d,f);var c=_asnhex_getPosOfNextSibling_AtObj(d,h);var j=_asnhex_getPosOfNextSibling_AtObj(d,c);k.push(l,g,i,b,m,f,h,c,j);return k}function _rsapem_getHexValueArrayOfChildrenFromHex(i){var o=_rsapem_getPosArrayOfChildrenFromHex(i);var r=_asnhex_getHexOfV_AtObj(i,o[0]);var f=_asnhex_getHexOfV_AtObj(i,o[1]);var j=_asnhex_getHexOfV_AtObj(i,o[2]);var k=_asnhex_getHexOfV_AtObj(i,o[3]);var c=_asnhex_getHexOfV_AtObj(i,o[4]);var b=_asnhex_getHexOfV_AtObj(i,o[5]);var h=_asnhex_getHexOfV_AtObj(i,o[6]);var g=_asnhex_getHexOfV_AtObj(i,o[7]);var l=_asnhex_getHexOfV_AtObj(i,o[8]);var m=new Array();m.push(r,f,j,k,c,b,h,g,l);return m}function _rsapem_readPrivateKeyFromPEMString(f){var c=_rsapem_pemToBase64(f);var d=b64tohex(c);var b=_rsapem_getHexValueArrayOfChildrenFromHex(d);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])}function _rsapem_readPublicKeyFromPEMString(c){var h=_rsapubpem_pemToBase64(c);var g=b64tohex(h);var b=_asnhex_getPosArrayOfChildren_AtObj(g,0);var f=_asnhex_getHexOfV_AtObj(g,b[0]);var j=_asnhex_getHexOfV_AtObj(g,b[1]);j=j.substring(2,j.length);var i=_asnhex_getPosArrayOfChildren_AtObj(j,0);var a=_asnhex_getHexOfV_AtObj(j,i[0]);var d=_asnhex_getHexOfV_AtObj(j,i[1]);this.setPublic(a,d)}RSAKey.prototype.readPrivateKeyFromPEMString=_rsapem_readPrivateKeyFromPEMString;RSAKey.prototype.readPublicKeyFromPEMString=_rsapem_readPublicKeyFromPEMString;var _RSASIGN_DIHEAD=[];_RSASIGN_DIHEAD.sha1="3021300906052b0e03021a05000414";_RSASIGN_DIHEAD.sha256="3031300d060960864801650304020105000420";var _RSASIGN_HASHHEXFUNC=[];_RSASIGN_HASHHEXFUNC.sha256=function(a){return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(a))};function _rsasign_getHexPaddedDigestInfoForString(n,h,b){var d=h/4;var k=_RSASIGN_HASHHEXFUNC[b];var f=k(n);var a="0001";var l="00"+_RSASIGN_DIHEAD[b]+f;var j="";var m=d-a.length-l.length;for(var g=0;g<m;g+=2){j+="ff"}var c=a+j+l;return c}function _rsasign_signString(f,c){var g=_rsasign_getHexPaddedDigestInfoForString(f,this.n.bitLength(),c);var b=parseBigInt(g,16);var d=this.doPrivate(b);var a=d.toString(16);return a}function _rsasign_signStringWithSHA1(d){var f=_rsasign_getHexPaddedDigestInfoForString(d,this.n.bitLength(),"sha1");var b=parseBigInt(f,16);var c=this.doPrivate(b);var a=c.toString(16);return a}function _rsasign_signStringWithSHA256(d){var f=_rsasign_getHexPaddedDigestInfoForString(d,this.n.bitLength(),"sha256");var b=parseBigInt(f,16);var c=this.doPrivate(b);var a=c.toString(16);return a}function _rsasign_getDecryptSignatureBI(a,d,c){var b=new RSAKey();b.setPublic(d,c);var f=b.doPublic(a);return f}function _rsasign_getHexDigestInfoFromSig(a,c,b){var f=_rsasign_getDecryptSignatureBI(a,c,b);var d=f.toString(16).replace(/^1f+00/,"");return d}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(g){for(var f in _RSASIGN_DIHEAD){var d=_RSASIGN_DIHEAD[f];var b=d.length;if(g.substring(0,b)==d){var c=[f,g.substring(b)];return c}}return[]}function _rsasign_verifySignatureWithArgs(g,b,h,k){var f=_rsasign_getHexDigestInfoFromSig(b,h,k);var i=_rsasign_getAlgNameAndHashFromHexDisgestInfo(f);if(i.length==0){return false}var d=i[0];var j=i[1];var a=_RSASIGN_HASHHEXFUNC[d];var c=a(g);return(j==c)}function _rsasign_verifyHexSignatureForMessage(c,b){var d=parseBigInt(c,16);var a=_rsasign_verifySignatureWithArgs(b,d,this.n.toString(16),this.e.toString(16));return a}function _rsasign_verifyString(g,k){k=k.replace(/[ \n]+/g,"");var b=parseBigInt(k,16);var j=this.doPublic(b);var f=j.toString(16).replace(/^1f+00/,"");var h=_rsasign_getAlgNameAndHashFromHexDisgestInfo(f);if(h.length==0){return false}var d=h[0];var i=h[1];var a=_RSASIGN_HASHHEXFUNC[d];var c=a(g);return(i==c)}RSAKey.prototype.signString=_rsasign_signString;RSAKey.prototype.signStringWithSHA1=_rsasign_signStringWithSHA1;RSAKey.prototype.signStringWithSHA256=_rsasign_signStringWithSHA256;RSAKey.prototype.verifyString=_rsasign_verifyString;RSAKey.prototype.verifyHexSignatureForMessage=_rsasign_verifyHexSignatureForMessage;function _x509_pemToBase64(a){var b=a;b=b.replace("-----BEGIN CERTIFICATE-----","");b=b.replace("-----END CERTIFICATE-----","");b=b.replace(/[ \n]+/g,"");return b}function _x509_pemToHex(a){var c=_x509_pemToBase64(a);var b=b64tohex(c);return b}function _x509_getHexTbsCertificateFromCert(b){var a=_asnhex_getStartPosOfV_AtObj(b,0);return a}function _x509_getSubjectPublicKeyInfoPosFromCertHex(d){var c=_asnhex_getStartPosOfV_AtObj(d,0);var b=_asnhex_getPosArrayOfChildren_AtObj(d,c);if(b.length<1){return -1}if(d.substring(b[0],b[0]+10)=="a003020102"){if(b.length<6){return -1}return b[6]}else{if(b.length<5){return -1}return b[5]}}function _x509_getSubjectPublicKeyPosFromCertHex(g){var f=_x509_getSubjectPublicKeyInfoPosFromCertHex(g);if(f==-1){return -1}var b=_asnhex_getPosArrayOfChildren_AtObj(g,f);if(b.length!=2){return -1}var d=b[1];if(g.substring(d,d+2)!="03"){return -1}var c=_asnhex_getStartPosOfV_AtObj(g,d);if(g.substring(c,c+2)!="00"){return -1}return c+2}function _x509_getPublicKeyHexArrayFromCertHex(g){var f=_x509_getSubjectPublicKeyPosFromCertHex(g);var b=_asnhex_getPosArrayOfChildren_AtObj(g,f);if(b.length!=2){return[]}var d=_asnhex_getHexOfV_AtObj(g,b[0]);var c=_asnhex_getHexOfV_AtObj(g,b[1]);if(d!=null&&c!=null){return[d,c]}else{return[]}}function _x509_getPublicKeyHexArrayFromCertPEM(c){var d=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(d);return b}function _x509_readCertPEM(c){var f=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(f);var d=new RSAKey();d.setPublic(b[0],b[1]);this.subjectPublicKeyRSA=d;this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1]}function _x509_readCertPEMWithoutRSAInit(c){var d=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(d);this.subjectPublicKeyRSA.setPublic(b[0],b[1]);this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1]}function X509(){this.subjectPublicKeyRSA=null;this.subjectPublicKeyRSA_hN=null;this.subjectPublicKeyRSA_hE=null}X509.prototype.readCertPEM=_x509_readCertPEM;X509.prototype.readCertPEMWithoutRSAInit=_x509_readCertPEMWithoutRSAInit; + +function Arcfour(){this.i=0;this.j=0;this.S=new Array()}function ARC4init(d){var c,a,b;for(c=0;c<256;++c){this.S[c]=c}a=0;for(c=0;c<256;++c){a=(a+this.S[c]+d[c%d.length])&255;b=this.S[c];this.S[c]=this.S[a];this.S[a]=b}this.i=0;this.j=0}function ARC4next(){var a;this.i=(this.i+1)&255;this.j=(this.j+this.S[this.i])&255;a=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=a;return this.S[(a+this.S[this.i])&255]}Arcfour.prototype.init=ARC4init;Arcfour.prototype.next=ARC4next;function prng_newstate(){return new Arcfour()}var rng_psize=256;var rng_state;var rng_pool;var rng_pptr;function rng_seed_int(a){rng_pool[rng_pptr++]^=a&255;rng_pool[rng_pptr++]^=(a>>8)&255;rng_pool[rng_pptr++]^=(a>>16)&255;rng_pool[rng_pptr++]^=(a>>24)&255;if(rng_pptr>=rng_psize){rng_pptr-=rng_psize}}function rng_seed_time(){rng_seed_int(new Date().getTime())}if(rng_pool==null){rng_pool=new Array();rng_pptr=0;var t;if(navigator.appName=="Netscape"&&navigator.appVersion<"5"&&window.crypto){var z=window.crypto.random(32);for(t=0;t<z.length;++t){rng_pool[rng_pptr++]=z.charCodeAt(t)&255}}while(rng_pptr<rng_psize){t=Math.floor(65536*Math.random());rng_pool[rng_pptr++]=t>>>8;rng_pool[rng_pptr++]=t&255}rng_pptr=0;rng_seed_time()}function rng_get_byte(){if(rng_state==null){rng_seed_time();rng_state=prng_newstate();rng_state.init(rng_pool);for(rng_pptr=0;rng_pptr<rng_pool.length;++rng_pptr){rng_pool[rng_pptr]=0}rng_pptr=0}return rng_state.next()}function rng_get_bytes(b){var a;for(a=0;a<b.length;++a){b[a]=rng_get_byte()}}function SecureRandom(){}SecureRandom.prototype.nextBytes=rng_get_bytes;"use strict";var sjcl={cipher:{},hash:{},mode:{},misc:{},codec:{},exception:{corrupt:function(b){this.toString=function(){return"CORRUPT: "+this.message};this.message=b},invalid:function(b){this.toString=function(){return"INVALID: "+this.message};this.message=b},bug:function(b){this.toString=function(){return"BUG: "+this.message};this.message=b}}};sjcl.cipher.aes=function(j){this.h[0][0][0]||this.w();var i,p,o,n,m=this.h[0][4],l=this.h[1];i=j.length;var k=1;if(i!==4&&i!==6&&i!==8){throw new sjcl.exception.invalid("invalid aes key size")}this.a=[o=j.slice(0),n=[]];for(j=i;j<4*i+28;j++){p=o[j-1];if(j%i===0||i===8&&j%i===4){p=m[p>>>24]<<24^m[p>>16&255]<<16^m[p>>8&255]<<8^m[p&255];if(j%i===0){p=p<<8^p>>>24^k<<24;k=k<<1^(k>>7)*283}}o[j]=o[j-i]^p}for(i=0;j;i++,j--){p=o[i&3?j:j-4];n[i]=j<=4||i<4?p:l[0][m[p>>>24]]^l[1][m[p>>16&255]]^l[2][m[p>>8&255]]^l[3][m[p&255]]}};sjcl.cipher.aes.prototype={encrypt:function(b){return this.H(b,0)},decrypt:function(b){return this.H(b,1)},h:[[[],[],[],[],[]],[[],[],[],[],[]]],w:function(){var B=this.h[0],A=this.h[1],y=B[4],x=A[4],w,v,u,s=[],r=[],p,q,o,n;for(w=0;w<256;w++){r[(s[w]=w<<1^(w>>7)*283)^w]=w}for(v=u=0;!y[v];v^=p||1,u=r[u]||1){o=u^u<<1^u<<2^u<<3^u<<4;o=o>>8^o&255^99;y[v]=o;x[o]=v;q=s[w=s[p=s[v]]];n=q*16843009^w*65537^p*257^v*16843008;q=s[o]*257^o*16843008;for(w=0;w<4;w++){B[w][v]=q=q<<24^q>>>8;A[w][o]=n=n<<24^n>>>8}}for(w=0;w<5;w++){B[w]=B[w].slice(0);A[w]=A[w].slice(0)}},H:function(L,K){if(L.length!==4){throw new sjcl.exception.invalid("invalid aes block size")}var J=this.a[K],I=L[0]^J[0],H=L[K?3:1]^J[1],G=L[2]^J[2];L=L[K?1:3]^J[3];var F,E,D,B=J.length/4-2,C,A=4,y=[0,0,0,0];F=this.h[K];var x=F[0],w=F[1],v=F[2],u=F[3],s=F[4];for(C=0;C<B;C++){F=x[I>>>24]^w[H>>16&255]^v[G>>8&255]^u[L&255]^J[A];E=x[H>>>24]^w[G>>16&255]^v[L>>8&255]^u[I&255]^J[A+1];D=x[G>>>24]^w[L>>16&255]^v[I>>8&255]^u[H&255]^J[A+2];L=x[L>>>24]^w[I>>16&255]^v[H>>8&255]^u[G&255]^J[A+3];A+=4;I=F;H=E;G=D}for(C=0;C<4;C++){y[K?3&-C:C]=s[I>>>24]<<24^s[H>>16&255]<<16^s[G>>8&255]<<8^s[L&255]^J[A++];F=I;I=H;H=G;G=L;L=F}return y}};sjcl.bitArray={bitSlice:function(f,d,g){f=sjcl.bitArray.P(f.slice(d/32),32-(d&31)).slice(1);return g===undefined?f:sjcl.bitArray.clamp(f,g-d)},concat:function(g,f){if(g.length===0||f.length===0){return g.concat(f)}var i=g[g.length-1],h=sjcl.bitArray.getPartial(i);return h===32?g.concat(f):sjcl.bitArray.P(f,h,i|0,g.slice(0,g.length-1))},bitLength:function(d){var c=d.length;if(c===0){return 0}return(c-1)*32+sjcl.bitArray.getPartial(d[c-1])},clamp:function(f,d){if(f.length*32<d){return f}f=f.slice(0,Math.ceil(d/32));var g=f.length;d&=31;if(g>0&&d){f[g-1]=sjcl.bitArray.partial(d,f[g-1]&2147483648>>d-1,1)}return f},partial:function(f,d,g){if(f===32){return d}return(g?d|0:d<<32-f)+f*1099511627776},getPartial:function(b){return Math.round(b/1099511627776)||32},equal:function(g,f){if(sjcl.bitArray.bitLength(g)!==sjcl.bitArray.bitLength(f)){return false}var i=0,h;for(h=0;h<g.length;h++){i|=g[h]^f[h]}return i===0},P:function(g,f,j,i){var h;h=0;if(i===undefined){i=[]}for(;f>=32;f-=32){i.push(j);j=0}if(f===0){return i.concat(g)}for(h=0;h<g.length;h++){i.push(j|g[h]>>>f);j=g[h]<<32-f}h=g.length?g[g.length-1]:0;g=sjcl.bitArray.getPartial(h);i.push(sjcl.bitArray.partial(f+g&31,f+g>32?j:i.pop(),1));return i},k:function(d,c){return[d[0]^c[0],d[1]^c[1],d[2]^c[2],d[3]^c[3]]}};sjcl.codec.utf8String={fromBits:function(g){var f="",j=sjcl.bitArray.bitLength(g),i,h;for(i=0;i<j/8;i++){if((i&3)===0){h=g[i/4]}f+=String.fromCharCode(h>>>24);h<<=8}return decodeURIComponent(escape(f))},toBits:function(g){g=unescape(encodeURIComponent(g));var f=[],i,h=0;for(i=0;i<g.length;i++){h=h<<8|g.charCodeAt(i);if((i&3)===3){f.push(h);h=0}}i&3&&f.push(sjcl.bitArray.partial(8*(i&3),h));return f}};sjcl.codec.hex={fromBits:function(f){var d="",g;for(g=0;g<f.length;g++){d+=((f[g]|0)+263882790666240).toString(16).substr(4)}return d.substr(0,sjcl.bitArray.bitLength(f)/4)},toBits:function(g){var f,i=[],h;g=g.replace(/\s|0x/g,"");h=g.length;g+="00000000";for(f=0;f<g.length;f+=8){i.push(parseInt(g.substr(f,8),16)^0)}return sjcl.bitArray.clamp(i,h*4)}};sjcl.codec.base64={D:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(j,i){var p="",o,n=0,m=sjcl.codec.base64.D,l=0,k=sjcl.bitArray.bitLength(j);for(o=0;p.length*6<k;){p+=m.charAt((l^j[o]>>>n)>>>26);if(n<6){l=j[o]<<6-n;n+=26;o++}else{l<<=6;n-=6}}for(;p.length&3&&!i;){p+="="}return p},toBits:function(i){i=i.replace(/\s|=/g,"");var h=[],n,m=0,l=sjcl.codec.base64.D,k=0,j;for(n=0;n<i.length;n++){j=l.indexOf(i.charAt(n));if(j<0){throw new sjcl.exception.invalid("this isn't base64!")}if(m>26){m-=26;h.push(k^j>>>m);k=j<<32-m}else{m+=6;k^=j<<32-m}}m&56&&h.push(sjcl.bitArray.partial(m&56,k,1));return h}};sjcl.hash.sha256=function(b){this.a[0]||this.w();if(b){this.n=b.n.slice(0);this.i=b.i.slice(0);this.e=b.e}else{this.reset()}};sjcl.hash.sha256.hash=function(b){return(new sjcl.hash.sha256).update(b).finalize()};sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.n=this.N.slice(0);this.i=[];this.e=0;return this},update:function(f){if(typeof f==="string"){f=sjcl.codec.utf8String.toBits(f)}var d,g=this.i=sjcl.bitArray.concat(this.i,f);d=this.e;f=this.e=d+sjcl.bitArray.bitLength(f);for(d=512+d&-512;d<=f;d+=512){this.C(g.splice(0,16))}return this},finalize:function(){var f,d=this.i,g=this.n;d=sjcl.bitArray.concat(d,[sjcl.bitArray.partial(1,1)]);for(f=d.length+2;f&15;f++){d.push(0)}d.push(Math.floor(this.e/4294967296));for(d.push(this.e|0);d.length;){this.C(d.splice(0,16))}this.reset();return g},N:[],a:[],w:function(){function g(a){return(a-Math.floor(a))*4294967296|0}var f=0,i=2,h;g:for(;f<64;i++){for(h=2;h*h<=i;h++){if(i%h===0){continue g}}if(f<8){this.N[f]=g(Math.pow(i,0.5))}this.a[f]=g(Math.pow(i,1/3));f++}},C:function(D){var C,B,A=D.slice(0),y=this.n,x=this.a,w=y[0],v=y[1],u=y[2],r=y[3],s=y[4],q=y[5],p=y[6],o=y[7];for(D=0;D<64;D++){if(D<16){C=A[D]}else{C=A[D+1&15];B=A[D+14&15];C=A[D&15]=(C>>>7^C>>>18^C>>>3^C<<25^C<<14)+(B>>>17^B>>>19^B>>>10^B<<15^B<<13)+A[D&15]+A[D+9&15]|0}C=C+o+(s>>>6^s>>>11^s>>>25^s<<26^s<<21^s<<7)+(p^s&(q^p))+x[D];o=p;p=q;q=s;s=r+C|0;r=u;u=v;v=w;w=C+(v&u^r&(v^u))+(v>>>2^v>>>13^v>>>22^v<<30^v<<19^v<<10)|0}y[0]=y[0]+w|0;y[1]=y[1]+v|0;y[2]=y[2]+u|0;y[3]=y[3]+r|0;y[4]=y[4]+s|0;y[5]=y[5]+q|0;y[6]=y[6]+p|0;y[7]=y[7]+o|0}};sjcl.mode.ccm={name:"ccm",encrypt:function(u,s,r,q,p){var o,n=s.slice(0),m=sjcl.bitArray,l=m.bitLength(r)/8,j=m.bitLength(n)/8;p=p||64;q=q||[];if(l<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(o=2;o<4&&j>>>8*o;o++){}if(o<15-l){o=15-l}r=m.clamp(r,8*(15-o));s=sjcl.mode.ccm.G(u,s,r,q,p,o);n=sjcl.mode.ccm.I(u,n,r,s,p,o);return m.concat(n.data,n.tag)},decrypt:function(u,s,r,q,p){p=p||64;q=q||[];var o=sjcl.bitArray,n=o.bitLength(r)/8,m=o.bitLength(s),l=o.clamp(s,m-p),j=o.bitSlice(s,m-p);m=(m-p)/8;if(n<7){throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes")}for(s=2;s<4&&m>>>8*s;s++){}if(s<15-n){s=15-n}r=o.clamp(r,8*(15-s));l=sjcl.mode.ccm.I(u,l,r,j,p,s);u=sjcl.mode.ccm.G(u,l.data,r,q,p,s);if(!o.equal(l.tag,u)){throw new sjcl.exception.corrupt("ccm: tag doesn't match")}return l.data},G:function(r,q,p,o,n,m){var l=[],k=sjcl.bitArray,j=k.k;n/=8;if(n%2||n<4||n>16){throw new sjcl.exception.invalid("ccm: invalid tag length")}if(o.length>4294967295||q.length>4294967295){throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data")}m=[k.partial(8,(o.length?64:0)|n-2<<2|m-1)];m=k.concat(m,p);m[3]|=k.bitLength(q)/8;m=r.encrypt(m);if(o.length){p=k.bitLength(o)/8;if(p<=65279){l=[k.partial(16,p)]}else{if(p<=4294967295){l=k.concat([k.partial(16,65534)],[p])}}l=k.concat(l,o);for(o=0;o<l.length;o+=4){m=r.encrypt(j(m,l.slice(o,o+4)))}}for(o=0;o<q.length;o+=4){m=r.encrypt(j(m,q.slice(o,o+4)))}return k.clamp(m,n*8)},I:function(u,s,r,q,p,o){var n,m=sjcl.bitArray;n=m.k;var l=s.length,j=m.bitLength(s);r=m.concat([m.partial(8,o-1)],r).concat([0,0,0]).slice(0,4);q=m.bitSlice(n(q,u.encrypt(r)),0,p);if(!l){return{tag:q,data:[]}}for(n=0;n<l;n+=4){r[3]++;p=u.encrypt(r);s[n]^=p[0];s[n+1]^=p[1];s[n+2]^=p[2];s[n+3]^=p[3]}return{tag:q,data:m.clamp(s,j)}}};sjcl.mode.ocb2={name:"ocb2",encrypt:function(B,A,y,x,w,v){if(sjcl.bitArray.bitLength(y)!==128){throw new sjcl.exception.invalid("ocb iv must be 128 bits")}var u,s=sjcl.mode.ocb2.A,r=sjcl.bitArray,p=r.k,q=[0,0,0,0];y=s(B.encrypt(y));var o,n=[];x=x||[];w=w||64;for(u=0;u+4<A.length;u+=4){o=A.slice(u,u+4);q=p(q,o);n=n.concat(p(y,B.encrypt(p(y,o))));y=s(y)}o=A.slice(u);A=r.bitLength(o);u=B.encrypt(p(y,[0,0,0,A]));o=r.clamp(p(o,u),A);q=p(q,p(o,u));q=B.encrypt(p(q,p(y,s(y))));if(x.length){q=p(q,v?x:sjcl.mode.ocb2.pmac(B,x))}return n.concat(r.concat(o,r.clamp(q,w)))},decrypt:function(F,E,D,C,B,A){if(sjcl.bitArray.bitLength(D)!==128){throw new sjcl.exception.invalid("ocb iv must be 128 bits")}B=B||64;var y=sjcl.mode.ocb2.A,x=sjcl.bitArray,w=x.k,u=[0,0,0,0],v=y(F.encrypt(D)),s,r,q=sjcl.bitArray.bitLength(E)-B,p=[];C=C||[];for(D=0;D+4<q/32;D+=4){s=w(v,F.decrypt(w(v,E.slice(D,D+4))));u=w(u,s);p=p.concat(s);v=y(v)}r=q-D*32;s=F.encrypt(w(v,[0,0,0,r]));s=w(s,x.clamp(E.slice(D),r));u=w(u,s);u=F.encrypt(w(u,w(v,y(v))));if(C.length){u=w(u,A?C:sjcl.mode.ocb2.pmac(F,C))}if(!x.equal(x.clamp(u,B),x.bitSlice(E,q))){throw new sjcl.exception.corrupt("ocb: tag doesn't match")}return p.concat(x.clamp(s,r))},pmac:function(j,i){var p,o=sjcl.mode.ocb2.A,n=sjcl.bitArray,m=n.k,l=[0,0,0,0],k=j.encrypt([0,0,0,0]);k=m(k,o(o(k)));for(p=0;p+4<i.length;p+=4){k=o(k);l=m(l,j.encrypt(m(k,i.slice(p,p+4))))}i=i.slice(p);if(n.bitLength(i)<128){k=m(k,o(k));i=n.concat(i,[2147483648|0])}l=m(l,i);return j.encrypt(m(o(m(k,o(k))),l))},A:function(b){return[b[0]<<1^b[1]>>>31,b[1]<<1^b[2]>>>31,b[2]<<1^b[3]>>>31,b[3]<<1^(b[0]>>>31)*135]}};sjcl.misc.hmac=function(g,f){this.M=f=f||sjcl.hash.sha256;var i=[[],[]],h=f.prototype.blockSize/32;this.l=[new f,new f];if(g.length>h){g=f.hash(g)}for(f=0;f<h;f++){i[0][f]=g[f]^909522486;i[1][f]=g[f]^1549556828}this.l[0].update(i[0]);this.l[1].update(i[1])};sjcl.misc.hmac.prototype.encrypt=sjcl.misc.hmac.prototype.mac=function(d,c){d=(new this.M(this.l[0])).update(d,c).finalize();return(new this.M(this.l[1])).update(d).finalize()};sjcl.misc.pbkdf2=function(w,v,u,s,r){u=u||1000;if(s<0||u<0){throw sjcl.exception.invalid("invalid params to pbkdf2")}if(typeof w==="string"){w=sjcl.codec.utf8String.toBits(w)}r=r||sjcl.misc.hmac;w=new r(w);var q,p,o,n,l=[],m=sjcl.bitArray;for(n=1;32*l.length<(s||1);n++){r=q=w.encrypt(m.concat(v,[n]));for(p=1;p<u;p++){q=w.encrypt(q);for(o=0;o<q.length;o++){r[o]^=q[o]}}l=l.concat(r)}if(s){l=m.clamp(l,s)}return l};sjcl.random={randomWords:function(g,f){var i=[];f=this.isReady(f);var h;if(f===0){throw new sjcl.exception.notready("generator isn't seeded")}else{f&2&&this.U(!(f&1))}for(f=0;f<g;f+=4){(f+1)%65536===0&&this.L();h=this.u();i.push(h[0],h[1],h[2],h[3])}this.L();return i.slice(0,g)},setDefaultParanoia:function(b){this.t=b},addEntropy:function(j,i,p){p=p||"user";var o,n,m=(new Date).valueOf(),l=this.q[p],k=this.isReady();o=this.F[p];if(o===undefined){o=this.F[p]=this.R++}if(l===undefined){l=this.q[p]=0}this.q[p]=(this.q[p]+1)%this.b.length;switch(typeof j){case"number":break;case"object":if(i===undefined){for(p=i=0;p<j.length;p++){for(n=j[p];n>0;){i++;n>>>=1}}}this.b[l].update([o,this.J++,2,i,m,j.length].concat(j));break;case"string":if(i===undefined){i=j.length}this.b[l].update([o,this.J++,3,i,m,j.length]);this.b[l].update(j);break;default:throw new sjcl.exception.bug("random: addEntropy only supports number, array or string")}this.j[l]+=i;this.f+=i;if(k===0){this.isReady()!==0&&this.K("seeded",Math.max(this.g,this.f));this.K("progress",this.getProgress())}},isReady:function(b){b=this.B[b!==undefined?b:this.t];return this.g&&this.g>=b?this.j[0]>80&&(new Date).valueOf()>this.O?3:1:this.f>=b?2:0},getProgress:function(b){b=this.B[b?b:this.t];return this.g>=b?1["0"]:this.f>b?1["0"]:this.f/b},startCollectors:function(){if(!this.m){if(window.addEventListener){window.addEventListener("load",this.o,false);window.addEventListener("mousemove",this.p,false)}else{if(document.attachEvent){document.attachEvent("onload",this.o);document.attachEvent("onmousemove",this.p)}else{throw new sjcl.exception.bug("can't attach event")}}this.m=true}},stopCollectors:function(){if(this.m){if(window.removeEventListener){window.removeEventListener("load",this.o);window.removeEventListener("mousemove",this.p)}else{if(window.detachEvent){window.detachEvent("onload",this.o);window.detachEvent("onmousemove",this.p)}}this.m=false}},addEventListener:function(d,c){this.r[d][this.Q++]=c},removeEventListener:function(g,f){var i;g=this.r[g];var h=[];for(i in g){g.hasOwnProperty[i]&&g[i]===f&&h.push(i)}for(f=0;f<h.length;f++){i=h[f];delete g[i]}},b:[new sjcl.hash.sha256],j:[0],z:0,q:{},J:0,F:{},R:0,g:0,f:0,O:0,a:[0,0,0,0,0,0,0,0],d:[0,0,0,0],s:undefined,t:6,m:false,r:{progress:{},seeded:{}},Q:0,B:[0,48,64,96,128,192,256,384,512,768,1024],u:function(){for(var b=0;b<4;b++){this.d[b]=this.d[b]+1|0;if(this.d[b]){break}}return this.s.encrypt(this.d)},L:function(){this.a=this.u().concat(this.u());this.s=new sjcl.cipher.aes(this.a)},T:function(b){this.a=sjcl.hash.sha256.hash(this.a.concat(b));this.s=new sjcl.cipher.aes(this.a);for(b=0;b<4;b++){this.d[b]=this.d[b]+1|0;if(this.d[b]){break}}},U:function(g){var f=[],i=0,h;this.O=f[0]=(new Date).valueOf()+30000;for(h=0;h<16;h++){f.push(Math.random()*4294967296|0)}for(h=0;h<this.b.length;h++){f=f.concat(this.b[h].finalize());i+=this.j[h];this.j[h]=0;if(!g&&this.z&1<<h){break}}if(this.z>=1<<this.b.length){this.b.push(new sjcl.hash.sha256);this.j.push(0)}this.f-=i;if(i>this.g){this.g=i}this.z++;this.T(f)},p:function(b){sjcl.random.addEntropy([b.x||b.clientX||b.offsetX,b.y||b.clientY||b.offsetY],2,"mouse")},o:function(){sjcl.random.addEntropy(new Date,2,"loadtime")},K:function(g,f){var i;g=sjcl.random.r[g];var h=[];for(i in g){g.hasOwnProperty(i)&&h.push(g[i])}for(i=0;i<h.length;i++){h[i](f)}}};sjcl.json={defaults:{v:1,iter:1000,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},encrypt:function(h,g,l,k){l=l||{};k=k||{};var j=sjcl.json,i=j.c({iv:sjcl.random.randomWords(4,0)},j.defaults);j.c(i,l);if(typeof i.salt==="string"){i.salt=sjcl.codec.base64.toBits(i.salt)}if(typeof i.iv==="string"){i.iv=sjcl.codec.base64.toBits(i.iv)}if(!sjcl.mode[i.mode]||!sjcl.cipher[i.cipher]||typeof h==="string"&&i.iter<=100||i.ts!==64&&i.ts!==96&&i.ts!==128||i.ks!==128&&i.ks!==192&&i.ks!==256||i.iv.length<2||i.iv.length>4){throw new sjcl.exception.invalid("json encrypt: invalid parameters")}if(typeof h==="string"){l=sjcl.misc.cachedPbkdf2(h,i);h=l.key.slice(0,i.ks/32);i.salt=l.salt}if(typeof g==="string"){g=sjcl.codec.utf8String.toBits(g)}l=new sjcl.cipher[i.cipher](h);j.c(k,i);k.key=h;i.ct=sjcl.mode[i.mode].encrypt(l,g,i.iv,i.adata,i.tag);return j.encode(j.V(i,j.defaults))},decrypt:function(g,f,j,i){j=j||{};i=i||{};var h=sjcl.json;f=h.c(h.c(h.c({},h.defaults),h.decode(f)),j,true);if(typeof f.salt==="string"){f.salt=sjcl.codec.base64.toBits(f.salt)}if(typeof f.iv==="string"){f.iv=sjcl.codec.base64.toBits(f.iv)}if(!sjcl.mode[f.mode]||!sjcl.cipher[f.cipher]||typeof g==="string"&&f.iter<=100||f.ts!==64&&f.ts!==96&&f.ts!==128||f.ks!==128&&f.ks!==192&&f.ks!==256||!f.iv||f.iv.length<2||f.iv.length>4){throw new sjcl.exception.invalid("json decrypt: invalid parameters")}if(typeof g==="string"){j=sjcl.misc.cachedPbkdf2(g,f);g=j.key.slice(0,f.ks/32);f.salt=j.salt}j=new sjcl.cipher[f.cipher](g);j=sjcl.mode[f.mode].decrypt(j,f.ct,f.iv,f.adata,f.tag);h.c(i,f);i.key=g;return sjcl.codec.utf8String.fromBits(j)},encode:function(g){var f,i="{",h="";for(f in g){if(g.hasOwnProperty(f)){if(!f.match(/^[a-z0-9]+$/i)){throw new sjcl.exception.invalid("json encode: invalid property name")}i+=h+f+":";h=",";switch(typeof g[f]){case"number":case"boolean":i+=g[f];break;case"string":i+='"'+escape(g[f])+'"';break;case"object":i+='"'+sjcl.codec.base64.fromBits(g[f],1)+'"';break;default:throw new sjcl.exception.bug("json encode: unsupported type")}}}return i+"}"},decode:function(g){g=g.replace(/\s/g,"");if(!g.match(/^\{.*\}$/)){throw new sjcl.exception.invalid("json decode: this isn't json!")}g=g.replace(/^\{|\}$/g,"").split(/,/);var f={},i,h;for(i=0;i<g.length;i++){if(!(h=g[i].match(/^([a-z][a-z0-9]*):(?:(\d+)|"([a-z0-9+\/%*_.@=\-]*)")$/i))){throw new sjcl.exception.invalid("json decode: this isn't json!")}f[h[1]]=h[2]?parseInt(h[2],10):h[1].match(/^(ct|salt|iv)$/)?sjcl.codec.base64.toBits(h[3]):unescape(h[3])}return f},c:function(g,f,i){if(g===undefined){g={}}if(f===undefined){return g}var h;for(h in f){if(f.hasOwnProperty(h)){if(i&&g[h]!==undefined&&g[h]!==f[h]){throw new sjcl.exception.invalid("required parameter overridden")}g[h]=f[h]}}return g},V:function(g,f){var i={},h;for(h in g){if(g.hasOwnProperty(h)&&g[h]!==f[h]){i[h]=g[h]}}return i},W:function(g,f){var i={},h;for(h=0;h<f.length;h++){if(g[f[h]]!==undefined){i[f[h]]=g[f[h]]}}return i}};sjcl.encrypt=sjcl.json.encrypt;sjcl.decrypt=sjcl.json.decrypt;sjcl.misc.S={};sjcl.misc.cachedPbkdf2=function(g,f){var i=sjcl.misc.S,h;f=f||{};h=f.iter||1000;i=i[g]=i[g]||{};h=i[h]=i[h]||{firstSalt:f.salt&&f.salt.length?f.salt.slice(0):sjcl.random.randomWords(2,0)};i=f.salt===undefined?h.firstSalt:f.salt;h[i]=h[i]||sjcl.misc.pbkdf2(g,i,f.iter);return{key:h[i].slice(0),salt:i.slice(0)}};var b64map="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var b64pad="=";function hex2b64(d){var b;var f;var a="";for(b=0;b+3<=d.length;b+=3){f=parseInt(d.substring(b,b+3),16);a+=b64map.charAt(f>>6)+b64map.charAt(f&63)}if(b+1==d.length){f=parseInt(d.substring(b,b+1),16);a+=b64map.charAt(f<<2)}else{if(b+2==d.length){f=parseInt(d.substring(b,b+2),16);a+=b64map.charAt(f>>2)+b64map.charAt((f&3)<<4)}}while((a.length&3)>0){a+=b64pad}return a}function b64tohex(g){var d="";var f;var b=0;var c;for(f=0;f<g.length;++f){if(g.charAt(f)==b64pad){break}var a=b64map.indexOf(g.charAt(f));if(a<0){continue}if(b==0){d+=int2char(a>>2);c=a&3;b=1}else{if(b==1){d+=int2char((c<<2)|(a>>4));c=a&15;b=2}else{if(b==2){d+=int2char(c);d+=int2char(a>>2);c=a&3;b=3}else{d+=int2char((c<<2)|(a>>4));d+=int2char(a&15);b=0}}}}if(b==1){d+=int2char(c<<2)}return d}function b64toBA(f){var d=b64tohex(f);var c;var b=new Array();for(c=0;2*c<d.length;++c){b[c]=parseInt(d.substring(2*c,2*c+2),16)}return b}var dbits;var canary=244837814094590;var j_lm=((canary&16777215)==15715070);function BigInteger(f,d,g){if(f!=null){if("number"==typeof f){this.fromNumber(f,d,g)}else{if(d==null&&"string"!=typeof f){this.fromString(f,256)}else{this.fromString(f,d)}}}}function nbi(){return new BigInteger(null)}function am1(g,a,b,f,k,h){while(--h>=0){var d=a*this[g++]+b[f]+k;k=Math.floor(d/67108864);b[f++]=d&67108863}return k}function am2(g,r,s,f,p,a){var o=r&32767,q=r>>15;while(--a>=0){var d=this[g]&32767;var k=this[g++]>>15;var b=q*d+k*o;d=o*d+((b&32767)<<15)+s[f]+(p&1073741823);p=(d>>>30)+(b>>>15)+q*k+(p>>>30);s[f++]=d&1073741823}return p}function am3(g,r,s,f,p,a){var o=r&16383,q=r>>14;while(--a>=0){var d=this[g]&16383;var k=this[g++]>>14;var b=q*d+k*o;d=o*d+((b&16383)<<14)+s[f]+p;p=(d>>28)+(b>>14)+q*k;s[f++]=d&268435455}return p}try{if(j_lm&&(navigator&&navigator.appName=="Microsoft Internet Explorer")){BigInteger.prototype.am=am2;dbits=30}else{if(j_lm&&(navigator&&navigator.appName!="Netscape")){BigInteger.prototype.am=am1;dbits=26}else{BigInteger.prototype.am=am3;dbits=28}}}catch(e){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";var BI_RC=new Array();var rr,vv;rr="0".charCodeAt(0);for(vv=0;vv<=9;++vv){BI_RC[rr++]=vv}rr="a".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}rr="A".charCodeAt(0);for(vv=10;vv<36;++vv){BI_RC[rr++]=vv}function int2char(a){return BI_RM.charAt(a)}function intAt(b,a){var d=BI_RC[b.charCodeAt(a)];return(d==null)?-1:d}function bnpCopyTo(b){for(var a=this.t-1;a>=0;--a){b[a]=this[a]}b.t=this.t;b.s=this.s}function bnpFromInt(a){this.t=1;this.s=(a<0)?-1:0;if(a>0){this[0]=a}else{if(a<-1){this[0]=a+DV}else{this.t=0}}}function nbv(a){var b=nbi();b.fromInt(a);return b}function bnpFromString(j,c){var f;if(c==16){f=4}else{if(c==8){f=3}else{if(c==256){f=8}else{if(c==2){f=1}else{if(c==32){f=5}else{if(c==4){f=2}else{this.fromRadix(j,c);return}}}}}}this.t=0;this.s=0;var h=j.length,d=false,g=0;while(--h>=0){var a=(f==8)?j[h]&255:intAt(j,h);if(a<0){if(j.charAt(h)=="-"){d=true}continue}d=false;if(g==0){this[this.t++]=a}else{if(g+f>this.DB){this[this.t-1]|=(a&((1<<(this.DB-g))-1))<<g;this[this.t++]=(a>>(this.DB-g))}else{this[this.t-1]|=a<<g}}g+=f;if(g>=this.DB){g-=this.DB}}if(f==8&&(j[0]&128)!=0){this.s=-1;if(g>0){this[this.t-1]|=((1<<(this.DB-g))-1)<<g}}this.clamp();if(d){BigInteger.ZERO.subTo(this,this)}}function bnpClamp(){var a=this.s&this.DM;while(this.t>0&&this[this.t-1]==a){--this.t}}function bnToString(c){if(this.s<0){return"-"+this.negate().toString(c)}var f;if(c==16){f=4}else{if(c==8){f=3}else{if(c==2){f=1}else{if(c==32){f=5}else{if(c==4){f=2}else{return this.toRadix(c)}}}}}var h=(1<<f)-1,n,a=false,j="",g=this.t;var l=this.DB-(g*this.DB)%f;if(g-->0){if(l<this.DB&&(n=this[g]>>l)>0){a=true;j=int2char(n)}while(g>=0){if(l<f){n=(this[g]&((1<<l)-1))<<(f-l);n|=this[--g]>>(l+=this.DB-f)}else{n=(this[g]>>(l-=f))&h;if(l<=0){l+=this.DB;--g}}if(n>0){a=true}if(a){j+=int2char(n)}}}return a?j:"0"}function bnNegate(){var a=nbi();BigInteger.ZERO.subTo(this,a);return a}function bnAbs(){return(this.s<0)?this.negate():this}function bnCompareTo(b){var d=this.s-b.s;if(d!=0){return d}var c=this.t;d=c-b.t;if(d!=0){return d}while(--c>=0){if((d=this[c]-b[c])!=0){return d}}return 0}function nbits(a){var c=1,b;if((b=a>>>16)!=0){a=b;c+=16}if((b=a>>8)!=0){a=b;c+=8}if((b=a>>4)!=0){a=b;c+=4}if((b=a>>2)!=0){a=b;c+=2}if((b=a>>1)!=0){a=b;c+=1}return c}function bnBitLength(){if(this.t<=0){return 0}return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM))}function bnpDLShiftTo(c,b){var a;for(a=this.t-1;a>=0;--a){b[a+c]=this[a]}for(a=c-1;a>=0;--a){b[a]=0}b.t=this.t+c;b.s=this.s}function bnpDRShiftTo(c,b){for(var a=c;a<this.t;++a){b[a-c]=this[a]}b.t=Math.max(this.t-c,0);b.s=this.s}function bnpLShiftTo(k,f){var b=k%this.DB;var a=this.DB-b;var h=(1<<a)-1;var g=Math.floor(k/this.DB),j=(this.s<<b)&this.DM,d;for(d=this.t-1;d>=0;--d){f[d+g+1]=(this[d]>>a)|j;j=(this[d]&h)<<b}for(d=g-1;d>=0;--d){f[d]=0}f[g]=j;f.t=this.t+g+1;f.s=this.s;f.clamp()}function bnpRShiftTo(h,d){d.s=this.s;var f=Math.floor(h/this.DB);if(f>=this.t){d.t=0;return}var b=h%this.DB;var a=this.DB-b;var g=(1<<b)-1;d[0]=this[f]>>b;for(var c=f+1;c<this.t;++c){d[c-f-1]|=(this[c]&g)<<a;d[c-f]=this[c]>>b}if(b>0){d[this.t-f-1]|=(this.s&g)<<a}d.t=this.t-f;d.clamp()}function bnpSubTo(d,g){var f=0,h=0,b=Math.min(d.t,this.t);while(f<b){h+=this[f]-d[f];g[f++]=h&this.DM;h>>=this.DB}if(d.t<this.t){h-=d.s;while(f<this.t){h+=this[f];g[f++]=h&this.DM;h>>=this.DB}h+=this.s}else{h+=this.s;while(f<d.t){h-=d[f];g[f++]=h&this.DM;h>>=this.DB}h-=d.s}g.s=(h<0)?-1:0;if(h<-1){g[f++]=this.DV+h}else{if(h>0){g[f++]=h}}g.t=f;g.clamp()}function bnpMultiplyTo(c,f){var b=this.abs(),g=c.abs();var d=b.t;f.t=d+g.t;while(--d>=0){f[d]=0}for(d=0;d<g.t;++d){f[d+b.t]=b.am(0,g[d],f,d,0,b.t)}f.s=0;f.clamp();if(this.s!=c.s){BigInteger.ZERO.subTo(f,f)}}function bnpSquareTo(d){var a=this.abs();var b=d.t=2*a.t;while(--b>=0){d[b]=0}for(b=0;b<a.t-1;++b){var f=a.am(b,a[b],d,2*b,0,1);if((d[b+a.t]+=a.am(b+1,2*a[b],d,2*b+1,f,a.t-b-1))>=a.DV){d[b+a.t]-=a.DV;d[b+a.t+1]=1}}if(d.t>0){d[d.t-1]+=a.am(b,a[b],d,2*b,0,1)}d.s=0;d.clamp()}function bnpDivRemTo(n,h,g){var w=n.abs();if(w.t<=0){return}var k=this.abs();if(k.t<w.t){if(h!=null){h.fromInt(0)}if(g!=null){this.copyTo(g)}return}if(g==null){g=nbi()}var d=nbi(),a=this.s,l=n.s;var v=this.DB-nbits(w[w.t-1]);if(v>0){w.lShiftTo(v,d);k.lShiftTo(v,g)}else{w.copyTo(d);k.copyTo(g)}var p=d.t;var b=d[p-1];if(b==0){return}var o=b*(1<<this.F1)+((p>1)?d[p-2]>>this.F2:0);var B=this.FV/o,A=(1<<this.F1)/o,x=1<<this.F2;var u=g.t,s=u-p,f=(h==null)?nbi():h;d.dlShiftTo(s,f);if(g.compareTo(f)>=0){g[g.t++]=1;g.subTo(f,g)}BigInteger.ONE.dlShiftTo(p,f);f.subTo(d,d);while(d.t<p){d[d.t++]=0}while(--s>=0){var c=(g[--u]==b)?this.DM:Math.floor(g[u]*B+(g[u-1]+x)*A);if((g[u]+=d.am(0,c,g,s,0,p))<c){d.dlShiftTo(s,f);g.subTo(f,g);while(g[u]<--c){g.subTo(f,g)}}}if(h!=null){g.drShiftTo(p,h);if(a!=l){BigInteger.ZERO.subTo(h,h)}}g.t=p;g.clamp();if(v>0){g.rShiftTo(v,g)}if(a<0){BigInteger.ZERO.subTo(g,g)}}function bnMod(b){var c=nbi();this.abs().divRemTo(b,null,c);if(this.s<0&&c.compareTo(BigInteger.ZERO)>0){b.subTo(c,c)}return c}function Classic(a){this.m=a}function cConvert(a){if(a.s<0||a.compareTo(this.m)>=0){return a.mod(this.m)}else{return a}}function cRevert(a){return a}function cReduce(a){a.divRemTo(this.m,null,a)}function cMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}function cSqrTo(a,b){a.squareTo(b);this.reduce(b)}Classic.prototype.convert=cConvert;Classic.prototype.revert=cRevert;Classic.prototype.reduce=cReduce;Classic.prototype.mulTo=cMulTo;Classic.prototype.sqrTo=cSqrTo;function bnpInvDigit(){if(this.t<1){return 0}var a=this[0];if((a&1)==0){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(b>0)?this.DV-b:-b}function Montgomery(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 montConvert(a){var b=nbi();a.abs().dlShiftTo(this.m.t,b);b.divRemTo(this.m,null,b);if(a.s<0&&b.compareTo(BigInteger.ZERO)>0){this.m.subTo(b,b)}return b}function montRevert(a){var b=nbi();a.copyTo(b);this.reduce(b);return b}function montReduce(a){while(a.t<=this.mt2){a[a.t++]=0}for(var c=0;c<this.m.t;++c){var b=a[c]&32767;var d=(b*this.mpl+(((b*this.mph+(a[c]>>15)*this.mpl)&this.um)<<15))&a.DM;b=c+this.m.t;a[b]+=this.m.am(0,d,a,c,0,this.m.t);while(a[b]>=a.DV){a[b]-=a.DV;a[++b]++}}a.clamp();a.drShiftTo(this.m.t,a);if(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function montSqrTo(a,b){a.squareTo(b);this.reduce(b)}function montMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Montgomery.prototype.convert=montConvert;Montgomery.prototype.revert=montRevert;Montgomery.prototype.reduce=montReduce;Montgomery.prototype.mulTo=montMulTo;Montgomery.prototype.sqrTo=montSqrTo;function bnpIsEven(){return((this.t>0)?(this[0]&1):this.s)==0}function bnpExp(h,j){if(h>4294967295||h<1){return BigInteger.ONE}var f=nbi(),a=nbi(),d=j.convert(this),c=nbits(h)-1;d.copyTo(f);while(--c>=0){j.sqrTo(f,a);if((h&(1<<c))>0){j.mulTo(a,d,f)}else{var b=f;f=a;a=b}}return j.revert(f)}function bnModPowInt(b,a){var c;if(b<256||a.isEven()){c=new Classic(a)}else{c=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 a=nbi();this.copyTo(a);return a}function bnIntValue(){if(this.s<0){if(this.t==1){return this[0]-this.DV}else{if(this.t==0){return -1}}}else{if(this.t==1){return this[0]}else{if(this.t==0){return 0}}}return((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0]}function bnByteValue(){return(this.t==0)?this.s:(this[0]<<24)>>24}function bnShortValue(){return(this.t==0)?this.s:(this[0]<<16)>>16}function bnpChunkSize(a){return Math.floor(Math.LN2*this.DB/Math.log(a))}function bnSigNum(){if(this.s<0){return -1}else{if(this.t<=0||(this.t==1&&this[0]<=0)){return 0}else{return 1}}}function bnpToRadix(c){if(c==null){c=10}if(this.signum()==0||c<2||c>36){return"0"}var g=this.chunkSize(c);var f=Math.pow(c,g);var j=nbv(f),k=nbi(),i=nbi(),h="";this.divRemTo(j,k,i);while(k.signum()>0){h=(f+i.intValue()).toString(c).substr(1)+h;k.divRemTo(j,k,i)}return i.intValue().toString(c)+h}function bnpFromRadix(n,k){this.fromInt(0);if(k==null){k=10}var g=this.chunkSize(k);var h=Math.pow(k,g),f=false,a=0,m=0;for(var c=0;c<n.length;++c){var l=intAt(n,c);if(l<0){if(n.charAt(c)=="-"&&this.signum()==0){f=true}continue}m=k*m+l;if(++a>=g){this.dMultiply(h);this.dAddOffset(m,0);a=0;m=0}}if(a>0){this.dMultiply(Math.pow(k,a));this.dAddOffset(m,0)}if(f){BigInteger.ZERO.subTo(this,this)}}function bnpFromNumber(g,f,i){if("number"==typeof f){if(g<2){this.fromInt(1)}else{this.fromNumber(g,i);if(!this.testBit(g-1)){this.bitwiseTo(BigInteger.ONE.shiftLeft(g-1),op_or,this)}if(this.isEven()){this.dAddOffset(1,0)}while(!this.isProbablePrime(f)){this.dAddOffset(2,0);if(this.bitLength()>g){this.subTo(BigInteger.ONE.shiftLeft(g-1),this)}}}}else{var d=new Array(),h=g&7;d.length=(g>>3)+1;f.nextBytes(d);if(h>0){d[0]&=((1<<h)-1)}else{d[0]=0}this.fromString(d,256)}}function bnToByteArray(){var b=this.t,c=new Array();c[0]=this.s;var f=this.DB-(b*this.DB)%8,g,a=0;if(b-->0){if(f<this.DB&&(g=this[b]>>f)!=(this.s&this.DM)>>f){c[a++]=g|(this.s<<(this.DB-f))}while(b>=0){if(f<8){g=(this[b]&((1<<f)-1))<<(8-f);g|=this[--b]>>(f+=this.DB-8)}else{g=(this[b]>>(f-=8))&255;if(f<=0){f+=this.DB;--b}}if((g&128)!=0){g|=-256}if(a==0&&(this.s&128)!=(g&128)){++a}if(a>0||g!=this.s){c[a++]=g}}}return c}function bnEquals(b){return(this.compareTo(b)==0)}function bnMin(b){return(this.compareTo(b)<0)?this:b}function bnMax(b){return(this.compareTo(b)>0)?this:b}function bnpBitwiseTo(c,j,g){var d,h,b=Math.min(c.t,this.t);for(d=0;d<b;++d){g[d]=j(this[d],c[d])}if(c.t<this.t){h=c.s&this.DM;for(d=b;d<this.t;++d){g[d]=j(this[d],h)}g.t=this.t}else{h=this.s&this.DM;for(d=b;d<c.t;++d){g[d]=j(h,c[d])}g.t=c.t}g.s=j(this.s,c.s);g.clamp()}function op_and(a,b){return a&b}function bnAnd(b){var c=nbi();this.bitwiseTo(b,op_and,c);return c}function op_or(a,b){return a|b}function bnOr(b){var c=nbi();this.bitwiseTo(b,op_or,c);return c}function op_xor(a,b){return a^b}function bnXor(b){var c=nbi();this.bitwiseTo(b,op_xor,c);return c}function op_andnot(a,b){return a&~b}function bnAndNot(b){var c=nbi();this.bitwiseTo(b,op_andnot,c);return c}function bnNot(){var b=nbi();for(var a=0;a<this.t;++a){b[a]=this.DM&~this[a]}b.t=this.t;b.s=~this.s;return b}function bnShiftLeft(b){var a=nbi();if(b<0){this.rShiftTo(-b,a)}else{this.lShiftTo(b,a)}return a}function bnShiftRight(b){var a=nbi();if(b<0){this.lShiftTo(-b,a)}else{this.rShiftTo(b,a)}return a}function lbit(a){if(a==0){return -1}var b=0;if((a&65535)==0){a>>=16;b+=16}if((a&255)==0){a>>=8;b+=8}if((a&15)==0){a>>=4;b+=4}if((a&3)==0){a>>=2;b+=2}if((a&1)==0){++b}return b}function bnGetLowestSetBit(){for(var a=0;a<this.t;++a){if(this[a]!=0){return a*this.DB+lbit(this[a])}}if(this.s<0){return this.t*this.DB}return -1}function cbit(a){var b=0;while(a!=0){a&=a-1;++b}return b}function bnBitCount(){var c=0,a=this.s&this.DM;for(var b=0;b<this.t;++b){c+=cbit(this[b]^a)}return c}function bnTestBit(b){var a=Math.floor(b/this.DB);if(a>=this.t){return(this.s!=0)}return((this[a]&(1<<(b%this.DB)))!=0)}function bnpChangeBit(c,b){var a=BigInteger.ONE.shiftLeft(c);this.bitwiseTo(a,b,a);return a}function bnSetBit(a){return this.changeBit(a,op_or)}function bnClearBit(a){return this.changeBit(a,op_andnot)}function bnFlipBit(a){return this.changeBit(a,op_xor)}function bnpAddTo(d,g){var f=0,h=0,b=Math.min(d.t,this.t);while(f<b){h+=this[f]+d[f];g[f++]=h&this.DM;h>>=this.DB}if(d.t<this.t){h+=d.s;while(f<this.t){h+=this[f];g[f++]=h&this.DM;h>>=this.DB}h+=this.s}else{h+=this.s;while(f<d.t){h+=d[f];g[f++]=h&this.DM;h>>=this.DB}h+=d.s}g.s=(h<0)?-1:0;if(h>0){g[f++]=h}else{if(h<-1){g[f++]=this.DV+h}}g.t=f;g.clamp()}function bnAdd(b){var c=nbi();this.addTo(b,c);return c}function bnSubtract(b){var c=nbi();this.subTo(b,c);return c}function bnMultiply(b){var c=nbi();this.multiplyTo(b,c);return c}function bnDivide(b){var c=nbi();this.divRemTo(b,c,null);return c}function bnRemainder(b){var c=nbi();this.divRemTo(b,null,c);return c}function bnDivideAndRemainder(b){var d=nbi(),c=nbi();this.divRemTo(b,d,c);return new Array(d,c)}function bnpDMultiply(a){this[this.t]=this.am(0,a-1,this,0,0,this.t);++this.t;this.clamp()}function bnpDAddOffset(b,a){if(b==0){return}while(this.t<=a){this[this.t++]=0}this[a]+=b;while(this[a]>=this.DV){this[a]-=this.DV;if(++a>=this.t){this[this.t++]=0}++this[a]}}function NullExp(){}function nNop(a){return a}function nMulTo(a,c,b){a.multiplyTo(c,b)}function nSqrTo(a,b){a.squareTo(b)}NullExp.prototype.convert=nNop;NullExp.prototype.revert=nNop;NullExp.prototype.mulTo=nMulTo;NullExp.prototype.sqrTo=nSqrTo;function bnPow(a){return this.exp(a,new NullExp())}function bnpMultiplyLowerTo(b,g,f){var d=Math.min(this.t+b.t,g);f.s=0;f.t=d;while(d>0){f[--d]=0}var c;for(c=f.t-this.t;d<c;++d){f[d+this.t]=this.am(0,b[d],f,d,0,this.t)}for(c=Math.min(b.t,g);d<c;++d){this.am(0,b[d],f,d,0,g-d)}f.clamp()}function bnpMultiplyUpperTo(b,f,d){--f;var c=d.t=this.t+b.t-f;d.s=0;while(--c>=0){d[c]=0}for(c=Math.max(f-this.t,0);c<b.t;++c){d[this.t+c-f]=this.am(f-c,b[c],d,0,0,this.t+c-f)}d.clamp();d.drShiftTo(1,d)}function Barrett(a){this.r2=nbi();this.q3=nbi();BigInteger.ONE.dlShiftTo(2*a.t,this.r2);this.mu=this.r2.divide(a);this.m=a}function barrettConvert(a){if(a.s<0||a.t>2*this.m.t){return a.mod(this.m)}else{if(a.compareTo(this.m)<0){return a}else{var b=nbi();a.copyTo(b);this.reduce(b);return b}}}function barrettRevert(a){return a}function barrettReduce(a){a.drShiftTo(this.m.t-1,this.r2);if(a.t>this.m.t+1){a.t=this.m.t+1;a.clamp()}this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);while(a.compareTo(this.r2)<0){a.dAddOffset(1,this.m.t+1)}a.subTo(this.r2,a);while(a.compareTo(this.m)>=0){a.subTo(this.m,a)}}function barrettSqrTo(a,b){a.squareTo(b);this.reduce(b)}function barrettMulTo(a,c,b){a.multiplyTo(c,b);this.reduce(b)}Barrett.prototype.convert=barrettConvert;Barrett.prototype.revert=barrettRevert;Barrett.prototype.reduce=barrettReduce;Barrett.prototype.mulTo=barrettMulTo;Barrett.prototype.sqrTo=barrettSqrTo;function bnModPow(q,f){var o=q.bitLength(),h,b=nbv(1),v;if(o<=0){return b}else{if(o<18){h=1}else{if(o<48){h=3}else{if(o<144){h=4}else{if(o<768){h=5}else{h=6}}}}}if(o<8){v=new Classic(f)}else{if(f.isEven()){v=new Barrett(f)}else{v=new Montgomery(f)}}var p=new Array(),d=3,s=h-1,a=(1<<h)-1;p[1]=v.convert(this);if(h>1){var A=nbi();v.sqrTo(p[1],A);while(d<=a){p[d]=nbi();v.mulTo(A,p[d-2],p[d]);d+=2}}var l=q.t-1,x,u=true,c=nbi(),y;o=nbits(q[l])-1;while(l>=0){if(o>=s){x=(q[l]>>(o-s))&a}else{x=(q[l]&((1<<(o+1))-1))<<(s-o);if(l>0){x|=q[l-1]>>(this.DB+o-s)}}d=h;while((x&1)==0){x>>=1;--d}if((o-=d)<0){o+=this.DB;--l}if(u){p[x].copyTo(b);u=false}else{while(d>1){v.sqrTo(b,c);v.sqrTo(c,b);d-=2}if(d>0){v.sqrTo(b,c)}else{y=b;b=c;c=y}v.mulTo(c,p[x],b)}while(l>=0&&(q[l]&(1<<o))==0){v.sqrTo(b,c);y=b;b=c;c=y;if(--o<0){o=this.DB-1;--l}}}return v.revert(b)}function bnGCD(c){var b=(this.s<0)?this.negate():this.clone();var j=(c.s<0)?c.negate():c.clone();if(b.compareTo(j)<0){var f=b;b=j;j=f}var d=b.getLowestSetBit(),h=j.getLowestSetBit();if(h<0){return b}if(d<h){h=d}if(h>0){b.rShiftTo(h,b);j.rShiftTo(h,j)}while(b.signum()>0){if((d=b.getLowestSetBit())>0){b.rShiftTo(d,b)}if((d=j.getLowestSetBit())>0){j.rShiftTo(d,j)}if(b.compareTo(j)>=0){b.subTo(j,b);b.rShiftTo(1,b)}else{j.subTo(b,j);j.rShiftTo(1,j)}}if(h>0){j.lShiftTo(h,j)}return j}function bnpModInt(f){if(f<=0){return 0}var c=this.DV%f,b=(this.s<0)?f-1:0;if(this.t>0){if(c==0){b=this[0]%f}else{for(var a=this.t-1;a>=0;--a){b=(c*b+this[a])%f}}}return b}function bnModInverse(g){var k=g.isEven();if((this.isEven()&&k)||g.signum()==0){return BigInteger.ZERO}var j=g.clone(),i=this.clone();var h=nbv(1),f=nbv(0),n=nbv(0),l=nbv(1);while(j.signum()!=0){while(j.isEven()){j.rShiftTo(1,j);if(k){if(!h.isEven()||!f.isEven()){h.addTo(this,h);f.subTo(g,f)}h.rShiftTo(1,h)}else{if(!f.isEven()){f.subTo(g,f)}}f.rShiftTo(1,f)}while(i.isEven()){i.rShiftTo(1,i);if(k){if(!n.isEven()||!l.isEven()){n.addTo(this,n);l.subTo(g,l)}n.rShiftTo(1,n)}else{if(!l.isEven()){l.subTo(g,l)}}l.rShiftTo(1,l)}if(j.compareTo(i)>=0){j.subTo(i,j);if(k){h.subTo(n,h)}f.subTo(l,f)}else{i.subTo(j,i);if(k){n.subTo(h,n)}l.subTo(f,l)}}if(i.compareTo(BigInteger.ONE)!=0){return BigInteger.ZERO}if(l.compareTo(g)>=0){return l.subtract(g)}if(l.signum()<0){l.addTo(g,l)}else{return l}if(l.signum()<0){return l.add(g)}else{return l}}var lowprimes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509];var lplim=(1<<26)/lowprimes[lowprimes.length-1];function bnIsProbablePrime(f){var d,b=this.abs();if(b.t==1&&b[0]<=lowprimes[lowprimes.length-1]){for(d=0;d<lowprimes.length;++d){if(b[0]==lowprimes[d]){return true}}return false}if(b.isEven()){return false}d=1;while(d<lowprimes.length){var a=lowprimes[d],c=d+1;while(c<lowprimes.length&&a<lplim){a*=lowprimes[c++]}a=b.modInt(a);while(d<c){if(a%lowprimes[d++]==0){return false}}}return b.millerRabin(f)}function bnpMillerRabin(g){var h=this.subtract(BigInteger.ONE);var c=h.getLowestSetBit();if(c<=0){return false}var l=h.shiftRight(c);g=(g+1)>>1;if(g>lowprimes.length){g=lowprimes.length}var b=nbi();for(var f=0;f<g;++f){b.fromInt(lowprimes[f]);var m=b.modPow(l,this);if(m.compareTo(BigInteger.ONE)!=0&&m.compareTo(h)!=0){var d=1;while(d++<c&&m.compareTo(h)!=0){m=m.modPowInt(2,this);if(m.compareTo(BigInteger.ONE)==0){return false}}if(m.compareTo(h)!=0){return false}}}return true}BigInteger.prototype.chunkSize=bnpChunkSize;BigInteger.prototype.toRadix=bnpToRadix;BigInteger.prototype.fromRadix=bnpFromRadix;BigInteger.prototype.fromNumber=bnpFromNumber;BigInteger.prototype.bitwiseTo=bnpBitwiseTo;BigInteger.prototype.changeBit=bnpChangeBit;BigInteger.prototype.addTo=bnpAddTo;BigInteger.prototype.dMultiply=bnpDMultiply;BigInteger.prototype.dAddOffset=bnpDAddOffset;BigInteger.prototype.multiplyLowerTo=bnpMultiplyLowerTo;BigInteger.prototype.multiplyUpperTo=bnpMultiplyUpperTo;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;function parseBigInt(b,a){return new BigInteger(b,a)}function linebrk(c,d){var a="";var b=0;while(b+d<c.length){a+=c.substring(b,b+d)+"\n";b+=d}return a+c.substring(b,c.length)}function byte2Hex(a){if(a<16){return"0"+a.toString(16)}else{return a.toString(16)}}function pkcs1pad2(f,j){if(j<f.length+11){alert("Message too long for RSA");return null}var h=new Array();var d=f.length-1;while(d>=0&&j>0){var g=f.charCodeAt(d--);if(g<128){h[--j]=g}else{if((g>127)&&(g<2048)){h[--j]=(g&63)|128;h[--j]=(g>>6)|192}else{h[--j]=(g&63)|128;h[--j]=((g>>6)&63)|128;h[--j]=(g>>12)|224}}}h[--j]=0;var b=new SecureRandom();var a=new Array();while(j>2){a[0]=0;while(a[0]==0){b.nextBytes(a)}h[--j]=a[0]}h[--j]=2;h[--j]=0;return new BigInteger(h)}function RSAKey(){this.n=null;this.e=0;this.d=null;this.p=null;this.q=null;this.dmp1=null;this.dmq1=null;this.coeff=null}function RSASetPublic(b,a){if(b!=null&&a!=null&&b.length>0&&a.length>0){this.n=parseBigInt(b,16);this.e=parseInt(a,16)}else{alert("Invalid RSA public key")}}function RSADoPublic(a){return a.modPowInt(this.e,this.n)}function RSAEncrypt(d){var a=pkcs1pad2(d,(this.n.bitLength()+7)>>3);if(a==null){return null}var f=this.doPublic(a);if(f==null){return null}var b=f.toString(16);if((b.length&1)==0){return b}else{return"0"+b}}RSAKey.prototype.doPublic=RSADoPublic;RSAKey.prototype.setPublic=RSASetPublic;RSAKey.prototype.encrypt=RSAEncrypt;function pkcs1unpad2(h,k){var a=h.toByteArray();var g=0;while(g<a.length&&a[g]==0){++g}if(a.length-g!=k-1||a[g]!=2){return null}++g;while(a[g]!=0){if(++g>=a.length){return null}}var f="";while(++g<a.length){var j=a[g]&255;if(j<128){f+=String.fromCharCode(j)}else{if((j>191)&&(j<224)){f+=String.fromCharCode(((j&31)<<6)|(a[g+1]&63));++g}else{f+=String.fromCharCode(((j&15)<<12)|((a[g+1]&63)<<6)|(a[g+2]&63));g+=2}}}return f}function RSASetPrivate(c,a,b){if(c!=null&&a!=null&&c.length>0&&a.length>0){this.n=parseBigInt(c,16);this.e=parseInt(a,16);this.d=parseBigInt(b,16)}else{alert("Invalid RSA private key")}}function RSASetPrivateEx(h,d,f,c,b,a,i,g){if(h!=null&&d!=null&&h.length>0&&d.length>0){this.n=parseBigInt(h,16);this.e=parseInt(d,16);this.d=parseBigInt(f,16);this.p=parseBigInt(c,16);this.q=parseBigInt(b,16);this.dmp1=parseBigInt(a,16);this.dmq1=parseBigInt(i,16);this.coeff=parseBigInt(g,16)}else{alert("Invalid RSA private key")}}function RSAGenerate(b,j){var a=new SecureRandom();var g=b>>1;this.e=parseInt(j,16);var c=new BigInteger(j,16);for(;;){for(;;){this.p=new BigInteger(b-g,1,a);if(this.p.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.p.isProbablePrime(10)){break}}for(;;){this.q=new BigInteger(g,1,a);if(this.q.subtract(BigInteger.ONE).gcd(c).compareTo(BigInteger.ONE)==0&&this.q.isProbablePrime(10)){break}}if(this.p.compareTo(this.q)<=0){var i=this.p;this.p=this.q;this.q=i}var h=this.p.subtract(BigInteger.ONE);var d=this.q.subtract(BigInteger.ONE);var f=h.multiply(d);if(f.gcd(c).compareTo(BigInteger.ONE)==0){this.n=this.p.multiply(this.q);this.d=c.modInverse(f);this.dmp1=this.d.mod(h);this.dmq1=this.d.mod(d);this.coeff=this.q.modInverse(this.p);break}}}function RSAPrivateKeySerializeASN1(){function g(j,k){var i=k.toByteArray();j.push(2);j.push(i.length);return j.concat(i)}var c=[];c.push(48);c.push(130);c.push(1);c.push(0);c.push(2);c.push(1);c.push(0);c=g(c,this.n);c=g(c,new BigInteger(""+this.e,10));c=g(c,this.d);c=g(c,this.p);c=g(c,this.q);c=g(c,this.dmp1);c=g(c,this.dmq1);c=g(c,this.coeff);var f=c.length-4;var a=new BigInteger(""+f,10).toByteArray();c[2]=a[0];c[3]=a[1];var b="";for(var d=0;d<c.length;d++){b+=int2char((c[d]&240)>>4);b+=int2char(c[d]&15)}b=hex2b64(b);var h="";for(var d=0;d<b.length;d++){if(d>0&&(d%64)==0){h+="\n"}h+=b[d]}return"-----BEGIN RSA PRIVATE KEY-----\n"+h+"\n-----END RSA PRIVATE KEY-----\n"}function RSAPublicKeySerializeASN1(){function g(o){var n=0;for(var q=0;q<o.length;q++){n+=o[q].length}var p=[];p.push(48);if(n<128){p.push(n)}else{var m=new BigInteger(""+n,10).toByteArray();p.push(128|m.length);for(var q=0;q<m.length;q++){p.push(m[q])}}for(var q=0;q<o.length;q++){p=p.concat(o[q])}return p}function b(n){var i=n.toByteArray();var m=[];m.push(2);m.push(i.length);return m.concat(i)}function k(m){var i=[];i.push(3);i.push(m.length+1);i.push(0);return i.concat(m)}var h=g([b(this.n),b(new BigInteger(""+this.e,10))]);var a=k(h);var j=g([[6,9,42,134,72,134,247,13,1,1,1],[5,0],]);var l=g([j,a]);var d="";for(var f=0;f<l.length;f++){d+=int2char((l[f]&240)>>4);d+=int2char(l[f]&15)}d=hex2b64(d);var c="";for(var f=0;f<d.length;f++){if(f>0&&(f%64)==0){c+="\n"}c+=d[f]}return"-----BEGIN PUBLIC KEY-----\n"+c+"\n-----END PUBLIC KEY-----\n"}function RSADoPrivate(a){if(this.p==null||this.q==null){return a.modPow(this.d,this.n)}var c=a.mod(this.p).modPow(this.dmp1,this.p);var b=a.mod(this.q).modPow(this.dmq1,this.q);while(c.compareTo(b)<0){c=c.add(this.p)}return c.subtract(b).multiply(this.coeff).mod(this.p).multiply(this.q).add(b)}function RSADecrypt(b){var d=parseBigInt(b,16);var a=this.doPrivate(d);if(a==null){return null}return pkcs1unpad2(a,(this.n.bitLength()+7)>>3)}RSAKey.prototype.doPrivate=RSADoPrivate;RSAKey.prototype.setPrivate=RSASetPrivate;RSAKey.prototype.setPrivateEx=RSASetPrivateEx;RSAKey.prototype.generate=RSAGenerate;RSAKey.prototype.decrypt=RSADecrypt;RSAKey.prototype.serializePrivateASN1=RSAPrivateKeySerializeASN1;RSAKey.prototype.serializePublicASN1=RSAPublicKeySerializeASN1;function _asnhex_getByteLengthOfL_AtObj(b,c){if(b.substring(c+2,c+3)!="8"){return 1}var a=parseInt(b.substring(c+3,c+4));if(a==0){return -1}if(0<a&&a<10){return a+1}return -2}function _asnhex_getHexOfL_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<1){return""}return b.substring(c+2,c+2+a*2)}function _asnhex_getIntOfL_AtObj(c,d){var b=_asnhex_getHexOfL_AtObj(c,d);if(b==""){return -1}var a;if(parseInt(b.substring(0,1))<8){a=parseBigInt(b,16)}else{a=parseBigInt(b.substring(2),16)}return a.intValue()}function _asnhex_getStartPosOfV_AtObj(b,c){var a=_asnhex_getByteLengthOfL_AtObj(b,c);if(a<0){return a}return c+(a+1)*2}function _asnhex_getHexOfV_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return c.substring(b,b+a*2)}function _asnhex_getPosOfNextSibling_AtObj(c,d){var b=_asnhex_getStartPosOfV_AtObj(c,d);var a=_asnhex_getIntOfL_AtObj(c,d);return b+a*2}function _asnhex_getPosArrayOfChildren_AtObj(g,l){var c=new Array();var j=_asnhex_getStartPosOfV_AtObj(g,l);c.push(j);var b=_asnhex_getIntOfL_AtObj(g,l);var i=j;var d=0;while(1){var f=_asnhex_getPosOfNextSibling_AtObj(g,i);if(f==null||(f-j>=(b*2))){break}if(d>=200){break}c.push(f);i=f;d++}return c}function _rsapem_pemToBase64(b){var a=b;a=a.replace("-----BEGIN RSA PRIVATE KEY-----","");a=a.replace("-----END RSA PRIVATE KEY-----","");a=a.replace(/[ \n]+/g,"");return a}function _rsapubpem_pemToBase64(b){if(b.indexOf("-----BEGIN PUBLIC KEY-----")!=0){throw"Malformed input to readPublicKeyFromPEMString: input does not start with '-----BEGIN PUBLIC KEY-----'"}var a=b;a=a.replace("-----BEGIN PUBLIC KEY-----","");a=a.replace("-----END PUBLIC KEY-----","");a=a.replace(/[ \n]+/g,"");return a}function _rsapem_getPosArrayOfChildrenFromHex(d){var k=new Array();var l=_asnhex_getStartPosOfV_AtObj(d,0);var g=_asnhex_getPosOfNextSibling_AtObj(d,l);var i=_asnhex_getPosOfNextSibling_AtObj(d,g);var b=_asnhex_getPosOfNextSibling_AtObj(d,i);var m=_asnhex_getPosOfNextSibling_AtObj(d,b);var f=_asnhex_getPosOfNextSibling_AtObj(d,m);var h=_asnhex_getPosOfNextSibling_AtObj(d,f);var c=_asnhex_getPosOfNextSibling_AtObj(d,h);var j=_asnhex_getPosOfNextSibling_AtObj(d,c);k.push(l,g,i,b,m,f,h,c,j);return k}function _rsapem_getHexValueArrayOfChildrenFromHex(i){var o=_rsapem_getPosArrayOfChildrenFromHex(i);var r=_asnhex_getHexOfV_AtObj(i,o[0]);var f=_asnhex_getHexOfV_AtObj(i,o[1]);var j=_asnhex_getHexOfV_AtObj(i,o[2]);var k=_asnhex_getHexOfV_AtObj(i,o[3]);var c=_asnhex_getHexOfV_AtObj(i,o[4]);var b=_asnhex_getHexOfV_AtObj(i,o[5]);var h=_asnhex_getHexOfV_AtObj(i,o[6]);var g=_asnhex_getHexOfV_AtObj(i,o[7]);var l=_asnhex_getHexOfV_AtObj(i,o[8]);var m=new Array();m.push(r,f,j,k,c,b,h,g,l);return m}function _rsapem_readPrivateKeyFromPEMString(f){var c=_rsapem_pemToBase64(f);var d=b64tohex(c);var b=_rsapem_getHexValueArrayOfChildrenFromHex(d);this.setPrivateEx(b[1],b[2],b[3],b[4],b[5],b[6],b[7],b[8])}function _rsapem_readPublicKeyFromPEMString(c){var h=_rsapubpem_pemToBase64(c);var g=b64tohex(h);var b=_asnhex_getPosArrayOfChildren_AtObj(g,0);var f=_asnhex_getHexOfV_AtObj(g,b[0]);var j=_asnhex_getHexOfV_AtObj(g,b[1]);j=j.substring(2,j.length);var i=_asnhex_getPosArrayOfChildren_AtObj(j,0);var a=_asnhex_getHexOfV_AtObj(j,i[0]);var d=_asnhex_getHexOfV_AtObj(j,i[1]);this.setPublic(a,d)}RSAKey.prototype.readPrivateKeyFromPEMString=_rsapem_readPrivateKeyFromPEMString;RSAKey.prototype.readPublicKeyFromPEMString=_rsapem_readPublicKeyFromPEMString;var _RSASIGN_DIHEAD=[];_RSASIGN_DIHEAD.sha1="3021300906052b0e03021a05000414";_RSASIGN_DIHEAD.sha256="3031300d060960864801650304020105000420";var _RSASIGN_HASHHEXFUNC=[];_RSASIGN_HASHHEXFUNC.sha256=function(a){return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(a))};function _rsasign_getHexPaddedDigestInfoForString(n,h,b){var d=h/4;var k=_RSASIGN_HASHHEXFUNC[b];var f=k(n);var a="0001";var l="00"+_RSASIGN_DIHEAD[b]+f;var j="";var m=d-a.length-l.length;for(var g=0;g<m;g+=2){j+="ff"}var c=a+j+l;return c}function _rsasign_signString(f,c){var g=_rsasign_getHexPaddedDigestInfoForString(f,this.n.bitLength(),c);var b=parseBigInt(g,16);var d=this.doPrivate(b);var a=d.toString(16);return a}function _rsasign_signStringWithSHA1(d){var f=_rsasign_getHexPaddedDigestInfoForString(d,this.n.bitLength(),"sha1");var b=parseBigInt(f,16);var c=this.doPrivate(b);var a=c.toString(16);return a}function _rsasign_signStringWithSHA256(d){var f=_rsasign_getHexPaddedDigestInfoForString(d,this.n.bitLength(),"sha256");var b=parseBigInt(f,16);var c=this.doPrivate(b);var a=c.toString(16);return a}function _rsasign_getDecryptSignatureBI(a,d,c){var b=new RSAKey();b.setPublic(d,c);var f=b.doPublic(a);return f}function _rsasign_getHexDigestInfoFromSig(a,c,b){var f=_rsasign_getDecryptSignatureBI(a,c,b);var d=f.toString(16).replace(/^1f+00/,"");return d}function _rsasign_getAlgNameAndHashFromHexDisgestInfo(g){for(var f in _RSASIGN_DIHEAD){var d=_RSASIGN_DIHEAD[f];var b=d.length;if(g.substring(0,b)==d){var c=[f,g.substring(b)];return c}}return[]}function _rsasign_verifySignatureWithArgs(g,b,h,k){var f=_rsasign_getHexDigestInfoFromSig(b,h,k);var i=_rsasign_getAlgNameAndHashFromHexDisgestInfo(f);if(i.length==0){return false}var d=i[0];var j=i[1];var a=_RSASIGN_HASHHEXFUNC[d];var c=a(g);return(j==c)}function _rsasign_verifyHexSignatureForMessage(c,b){var d=parseBigInt(c,16);var a=_rsasign_verifySignatureWithArgs(b,d,this.n.toString(16),this.e.toString(16));return a}function _rsasign_verifyString(g,k){k=k.replace(/[ \n]+/g,"");var b=parseBigInt(k,16);var j=this.doPublic(b);var f=j.toString(16).replace(/^1f+00/,"");var h=_rsasign_getAlgNameAndHashFromHexDisgestInfo(f);if(h.length==0){return false}var d=h[0];var i=h[1];var a=_RSASIGN_HASHHEXFUNC[d];var c=a(g);return(i==c)}RSAKey.prototype.signString=_rsasign_signString;RSAKey.prototype.signStringWithSHA1=_rsasign_signStringWithSHA1;RSAKey.prototype.signStringWithSHA256=_rsasign_signStringWithSHA256;RSAKey.prototype.verifyString=_rsasign_verifyString;RSAKey.prototype.verifyHexSignatureForMessage=_rsasign_verifyHexSignatureForMessage;function _x509_pemToBase64(a){var b=a;b=b.replace("-----BEGIN CERTIFICATE-----","");b=b.replace("-----END CERTIFICATE-----","");b=b.replace(/[ \n]+/g,"");return b}function _x509_pemToHex(a){var c=_x509_pemToBase64(a);var b=b64tohex(c);return b}function _x509_getHexTbsCertificateFromCert(b){var a=_asnhex_getStartPosOfV_AtObj(b,0);return a}function _x509_getSubjectPublicKeyInfoPosFromCertHex(d){var c=_asnhex_getStartPosOfV_AtObj(d,0);var b=_asnhex_getPosArrayOfChildren_AtObj(d,c);if(b.length<1){return -1}if(d.substring(b[0],b[0]+10)=="a003020102"){if(b.length<6){return -1}return b[6]}else{if(b.length<5){return -1}return b[5]}}function _x509_getSubjectPublicKeyPosFromCertHex(g){var f=_x509_getSubjectPublicKeyInfoPosFromCertHex(g);if(f==-1){return -1}var b=_asnhex_getPosArrayOfChildren_AtObj(g,f);if(b.length!=2){return -1}var d=b[1];if(g.substring(d,d+2)!="03"){return -1}var c=_asnhex_getStartPosOfV_AtObj(g,d);if(g.substring(c,c+2)!="00"){return -1}return c+2}function _x509_getPublicKeyHexArrayFromCertHex(g){var f=_x509_getSubjectPublicKeyPosFromCertHex(g);var b=_asnhex_getPosArrayOfChildren_AtObj(g,f);if(b.length!=2){return[]}var d=_asnhex_getHexOfV_AtObj(g,b[0]);var c=_asnhex_getHexOfV_AtObj(g,b[1]);if(d!=null&&c!=null){return[d,c]}else{return[]}}function _x509_getPublicKeyHexArrayFromCertPEM(c){var d=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(d);return b}function _x509_readCertPEM(c){var f=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(f);var d=new RSAKey();d.setPublic(b[0],b[1]);this.subjectPublicKeyRSA=d;this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1]}function _x509_readCertPEMWithoutRSAInit(c){var d=_x509_pemToHex(c);var b=_x509_getPublicKeyHexArrayFromCertHex(d);this.subjectPublicKeyRSA.setPublic(b[0],b[1]);this.subjectPublicKeyRSA_hN=b[0];this.subjectPublicKeyRSA_hE=b[1]}function X509(){this.subjectPublicKeyRSA=null;this.subjectPublicKeyRSA_hN=null;this.subjectPublicKeyRSA_hE=null}X509.prototype.readCertPEM=_x509_readCertPEM;X509.prototype.readCertPEMWithoutRSAInit=_x509_readCertPEMWithoutRSAInit; function randomString(length) { if (typeof length !== 'number') length = 64; diff --git a/authority/static/dialog/crypto.js b/authority/static/dialog/crypto.js index fcf13432cfd1c811757f5d619f1d197a2a586f13..9bfb2763a09ba7b259a47acb96652e8ee7901343 100644 --- a/authority/static/dialog/crypto.js +++ b/authority/static/dialog/crypto.js @@ -1621,7 +1621,8 @@ function RSAPublicKeySerializeASN1() { function encodeBitString(bits) { var bytes=[]; - bytes.push(0x03); // INTEGER + bytes.push(0x03); // BIT STRING + bytes.push(bits.length+1); // #Bytes bytes.push(0);// remainder return bytes.concat(bits); }