sjcl.min.js 18 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";var r=void 0,z=!1;var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};
  2. "undefined"!==typeof module&&module.exports&&(module.exports=sjcl);"function"===typeof define&&define([],function(){return sjcl});
  3. sjcl.cipher.aes=function(a){this.l[0][0][0]||this.o();var b,c,e,d,g=this.l[0][4],f=this.l[1];b=a.length;var h=1;if(4!==b&&6!==b&&8!==b)throw new sjcl.exception.invalid("invalid aes key size");this.b=[e=a.slice(0),d=[]];for(a=b;a<4*b+28;a++){c=e[a-1];if(0===a%b||8===b&&4===a%b)c=g[c>>>24]<<24^g[c>>16&255]<<16^g[c>>8&255]<<8^g[c&255],0===a%b&&(c=c<<8^c>>>24^h<<24,h=h<<1^283*(h>>7));e[a]=e[a-b]^c}for(b=0;a;b++,a--)c=e[b&3?a:a-4],d[b]=4>=a||4>b?c:f[0][g[c>>>24]]^f[1][g[c>>16&255]]^f[2][g[c>>8&255]]^f[3][g[c&
  4. 255]]};
  5. sjcl.cipher.aes.prototype={encrypt:function(a){return aa(this,a,0)},decrypt:function(a){return aa(this,a,1)},l:[[[],[],[],[],[]],[[],[],[],[],[]]],o:function(){var a=this.l[0],b=this.l[1],c=a[4],e=b[4],d,g,f,h=[],k=[],n,m,l,p;for(d=0;0x100>d;d++)k[(h[d]=d<<1^283*(d>>7))^d]=d;for(g=f=0;!c[g];g^=n||1,f=k[f]||1){l=f^f<<1^f<<2^f<<3^f<<4;l=l>>8^l&255^99;c[g]=l;e[l]=g;m=h[d=h[n=h[g]]];p=0x1010101*m^0x10001*d^0x101*n^0x1010100*g;m=0x101*h[l]^0x1010100*l;for(d=0;4>d;d++)a[d][g]=m=m<<24^m>>>8,b[d][l]=p=p<<24^p>>>8}for(d=
  6. 0;5>d;d++)a[d]=a[d].slice(0),b[d]=b[d].slice(0)}};
  7. function aa(a,b,c){if(4!==b.length)throw new sjcl.exception.invalid("invalid aes block size");var e=a.b[c],d=b[0]^e[0],g=b[c?3:1]^e[1],f=b[2]^e[2];b=b[c?1:3]^e[3];var h,k,n,m=e.length/4-2,l,p=4,u=[0,0,0,0];h=a.l[c];a=h[0];var C=h[1],A=h[2],D=h[3],B=h[4];for(l=0;l<m;l++)h=a[d>>>24]^C[g>>16&255]^A[f>>8&255]^D[b&255]^e[p],k=a[g>>>24]^C[f>>16&255]^A[b>>8&255]^D[d&255]^e[p+1],n=a[f>>>24]^C[b>>16&255]^A[d>>8&255]^D[g&255]^e[p+2],b=a[b>>>24]^C[d>>16&255]^A[g>>8&255]^D[f&255]^e[p+3],p+=4,d=h,g=k,f=n;for(l=
  8. 0;4>l;l++)u[c?3&-l:l]=B[d>>>24]<<24^B[g>>16&255]<<16^B[f>>8&255]<<8^B[b&255]^e[p++],h=d,d=g,g=f,f=b,b=h;return u}
  9. sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.K(a.slice(b/32),32-(b&31)).slice(1);return c===r?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var e=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-e^a[b/32+1|0]>>>e:a[b/32|0]>>>e)&(1<<c)-1},concat:function(a,b){if(0===a.length||0===b.length)return a.concat(b);var c=a[a.length-1],e=sjcl.bitArray.getPartial(c);return 32===e?a.concat(b):sjcl.bitArray.K(b,e,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;return 0===
  10. b?0:32*(b-1)+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(32*a.length<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b&=31;0<c&&b&&(a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1));return a},partial:function(a,b,c){return 32===a?b:(c?b|0:b<<32-a)+0x10000000000*a},getPartial:function(a){return Math.round(a/0x10000000000)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return z;var c=0,e;for(e=0;e<a.length;e++)c|=a[e]^b[e];return 0===
  11. c},K:function(a,b,c,e){var d;d=0;for(e===r&&(e=[]);32<=b;b-=32)e.push(c),c=0;if(0===b)return e.concat(a);for(d=0;d<a.length;d++)e.push(c|a[d]>>>b),c=a[d]<<32-b;d=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(d);e.push(sjcl.bitArray.partial(b+a&31,32<b+a?c:e.pop(),1));return e},C:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]},byteswapM:function(a){var b,c;for(b=0;b<a.length;++b)c=a[b],a[b]=c>>>24|c>>>8&0xff00|(c&0xff00)<<8|c<<24;return a}};
  12. sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),e,d;for(e=0;e<c/8;e++)0===(e&3)&&(d=a[e/4]),b+=String.fromCharCode(d>>>24),d<<=8;return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,e=0;for(c=0;c<a.length;c++)e=e<<8|a.charCodeAt(c),3===(c&3)&&(b.push(e),e=0);c&3&&b.push(sjcl.bitArray.partial(8*(c&3),e));return b}};
  13. sjcl.codec.base64={F:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",fromBits:function(a,b,c){var e="",d=0,g=sjcl.codec.base64.F,f=0,h=sjcl.bitArray.bitLength(a);c&&(g=g.substr(0,62)+"-_");for(c=0;6*e.length<h;)e+=g.charAt((f^a[c]>>>d)>>>26),6>d?(f=a[c]<<6-d,d+=26,c++):(f<<=6,d-=6);for(;e.length&3&&!b;)e+="=";return e},toBits:function(a,b){a=a.replace(/\s|=/g,"");var c=[],e,d=0,g=sjcl.codec.base64.F,f=0,h;b&&(g=g.substr(0,62)+"-_");for(e=0;e<a.length;e++){h=g.indexOf(a.charAt(e));
  14. if(0>h)throw new sjcl.exception.invalid("this isn't base64!");26<d?(d-=26,c.push(f^h>>>d),f=h<<32-d):(d+=6,f^=h<<32-d)}d&56&&c.push(sjcl.bitArray.partial(d&56,f,1));return c}};sjcl.codec.base64url={fromBits:function(a){return sjcl.codec.base64.fromBits(a,1,1)},toBits:function(a){return sjcl.codec.base64.toBits(a,1)}};
  15. sjcl.codec.bytes={fromBits:function(a){var b=[],c=sjcl.bitArray.bitLength(a),e,d;for(e=0;e<c/8;e++)0===(e&3)&&(d=a[e/4]),b.push(d>>>24),d<<=8;return b},toBits:function(a){var b=[],c,e=0;for(c=0;c<a.length;c++)e=e<<8|a[c],3===(c&3)&&(b.push(e),e=0);c&3&&b.push(sjcl.bitArray.partial(8*(c&3),e));return b}};sjcl.hash.sha256=function(a){this.b[0]||this.o();a?(this.e=a.e.slice(0),this.d=a.d.slice(0),this.c=a.c):this.reset()};sjcl.hash.sha256.hash=function(a){return(new sjcl.hash.sha256).update(a).finalize()};
  16. sjcl.hash.sha256.prototype={blockSize:512,reset:function(){this.e=this.i.slice(0);this.d=[];this.c=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.d=sjcl.bitArray.concat(this.d,a);b=this.c;a=this.c=b+sjcl.bitArray.bitLength(a);for(b=512+b&-512;b<=a;b+=512)this.n(c.splice(0,16));return this},finalize:function(){var a,b=this.d,c=this.e,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+2;a&15;a++)b.push(0);b.push(Math.floor(this.c/
  17. 4294967296));for(b.push(this.c|0);b.length;)this.n(b.splice(0,16));this.reset();return c},i:[],b:[],o:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}var b=0,c=2,e;a:for(;64>b;c++){for(e=2;e*e<=c;e++)if(0===c%e)continue a;8>b&&(this.i[b]=a(Math.pow(c,0.5)));this.b[b]=a(Math.pow(c,1/3));b++}},n:function(a){var b,c,e=a.slice(0),d=this.e,g=this.b,f=d[0],h=d[1],k=d[2],n=d[3],m=d[4],l=d[5],p=d[6],u=d[7];for(a=0;64>a;a++)16>a?b=e[a]:(b=e[a+1&15],c=e[a+14&15],b=e[a&15]=(b>>>7^b>>>18^b>>>3^
  18. b<<25^b<<14)+(c>>>17^c>>>19^c>>>10^c<<15^c<<13)+e[a&15]+e[a+9&15]|0),b=b+u+(m>>>6^m>>>11^m>>>25^m<<26^m<<21^m<<7)+(p^m&(l^p))+g[a],u=p,p=l,l=m,m=n+b|0,n=k,k=h,h=f,f=b+(h&k^n&(h^k))+(h>>>2^h>>>13^h>>>22^h<<30^h<<19^h<<10)|0;d[0]=d[0]+f|0;d[1]=d[1]+h|0;d[2]=d[2]+k|0;d[3]=d[3]+n|0;d[4]=d[4]+m|0;d[5]=d[5]+l|0;d[6]=d[6]+p|0;d[7]=d[7]+u|0}};sjcl.hash.sha512=function(a){this.b[0]||this.o();a?(this.e=a.e.slice(0),this.d=a.d.slice(0),this.c=a.c):this.reset()};sjcl.hash.sha512.hash=function(a){return(new sjcl.hash.sha512).update(a).finalize()};
  19. sjcl.hash.sha512.prototype={blockSize:1024,reset:function(){this.e=this.i.slice(0);this.d=[];this.c=0;return this},update:function(a){"string"===typeof a&&(a=sjcl.codec.utf8String.toBits(a));var b,c=this.d=sjcl.bitArray.concat(this.d,a);b=this.c;a=this.c=b+sjcl.bitArray.bitLength(a);for(b=1024+b&-1024;b<=a;b+=1024)this.n(c.splice(0,32));return this},finalize:function(){var a,b=this.d,c=this.e,b=sjcl.bitArray.concat(b,[sjcl.bitArray.partial(1,1)]);for(a=b.length+4;a&31;a++)b.push(0);b.push(0);b.push(0);
  20. b.push(Math.floor(this.c/0x100000000));for(b.push(this.c|0);b.length;)this.n(b.splice(0,32));this.reset();return c},i:[],S:[12372232,13281083,9762859,1914609,15106769,4090911,4308331,8266105],b:[],U:[2666018,15689165,5061423,9034684,4764984,380953,1658779,7176472,197186,7368638,14987916,16757986,8096111,1480369,13046325,6891156,15813330,5187043,9229749,11312229,2818677,10937475,4324308,1135541,6741931,11809296,16458047,15666916,11046850,698149,229999,945776,13774844,2541862,12856045,9810911,11494366,
  21. 7844520,15576806,8533307,15795044,4337665,16291729,5553712,15684120,6662416,7413802,12308920,13816008,4303699,9366425,10176680,13195875,4295371,6546291,11712675,15708924,1519456,15772530,6568428,6495784,8568297,13007125,7492395,2515356,12632583,14740254,7262584,1535930,13146278,16321966,1853211,294276,13051027,13221564,1051980,4080310,6651434,14088940,4675607],o:function(){function a(a){return 0x100000000*(a-Math.floor(a))|0}function b(a){return 0x10000000000*(a-Math.floor(a))&255}var c=0,e=2,d;a:for(;80>
  22. c;e++){for(d=2;d*d<=e;d++)if(0===e%d)continue a;8>c&&(this.i[2*c]=a(Math.pow(e,0.5)),this.i[2*c+1]=b(Math.pow(e,0.5))<<24|this.S[c]);this.b[2*c]=a(Math.pow(e,1/3));this.b[2*c+1]=b(Math.pow(e,1/3))<<24|this.U[c];c++}},n:function(a){var b,c,e=a.slice(0),d=this.e,g=this.b,f=d[0],h=d[1],k=d[2],n=d[3],m=d[4],l=d[5],p=d[6],u=d[7],C=d[8],A=d[9],D=d[10],B=d[11],ea=d[12],P=d[13],fa=d[14],Q=d[15],v=f,s=h,G=k,E=n,H=m,F=l,V=p,I=u,w=C,t=A,R=D,J=B,S=ea,K=P,W=fa,L=Q;for(a=0;80>a;a++){if(16>a)b=e[2*a],c=e[2*a+1];
  23. else{c=e[2*(a-15)];var q=e[2*(a-15)+1];b=(q<<31|c>>>1)^(q<<24|c>>>8)^c>>>7;var x=(c<<31|q>>>1)^(c<<24|q>>>8)^(c<<25|q>>>7);c=e[2*(a-2)];var y=e[2*(a-2)+1],q=(y<<13|c>>>19)^(c<<3|y>>>29)^c>>>6,y=(c<<13|y>>>19)^(y<<3|c>>>29)^(c<<26|y>>>6),X=e[2*(a-7)],Y=e[2*(a-16)],M=e[2*(a-16)+1];c=x+e[2*(a-7)+1];b=b+X+(c>>>0<x>>>0?1:0);c+=y;b+=q+(c>>>0<y>>>0?1:0);c+=M;b+=Y+(c>>>0<M>>>0?1:0)}e[2*a]=b|=0;e[2*a+1]=c|=0;var X=w&R^~w&S,ga=t&J^~t&K,y=v&G^v&H^G&H,ka=s&E^s&F^E&F,Y=(s<<4|v>>>28)^(v<<30|s>>>2)^(v<<25|s>>>7),
  24. M=(v<<4|s>>>28)^(s<<30|v>>>2)^(s<<25|v>>>7),la=g[2*a],ha=g[2*a+1],q=L+((w<<18|t>>>14)^(w<<14|t>>>18)^(t<<23|w>>>9)),x=W+((t<<18|w>>>14)^(t<<14|w>>>18)^(w<<23|t>>>9))+(q>>>0<L>>>0?1:0),q=q+ga,x=x+(X+(q>>>0<ga>>>0?1:0)),q=q+ha,x=x+(la+(q>>>0<ha>>>0?1:0)),q=q+c|0,x=x+(b+(q>>>0<c>>>0?1:0));c=M+ka;b=Y+y+(c>>>0<M>>>0?1:0);W=S;L=K;S=R;K=J;R=w;J=t;t=I+q|0;w=V+x+(t>>>0<I>>>0?1:0)|0;V=H;I=F;H=G;F=E;G=v;E=s;s=q+c|0;v=x+b+(s>>>0<q>>>0?1:0)|0}h=d[1]=h+s|0;d[0]=f+v+(h>>>0<s>>>0?1:0)|0;n=d[3]=n+E|0;d[2]=k+G+(n>>>
  25. 0<E>>>0?1:0)|0;l=d[5]=l+F|0;d[4]=m+H+(l>>>0<F>>>0?1:0)|0;u=d[7]=u+I|0;d[6]=p+V+(u>>>0<I>>>0?1:0)|0;A=d[9]=A+t|0;d[8]=C+w+(A>>>0<t>>>0?1:0)|0;B=d[11]=B+J|0;d[10]=D+R+(B>>>0<J>>>0?1:0)|0;P=d[13]=P+K|0;d[12]=ea+S+(P>>>0<K>>>0?1:0)|0;Q=d[15]=Q+L|0;d[14]=fa+W+(Q>>>0<L>>>0?1:0)|0}};
  26. sjcl.mode.ccm={name:"ccm",q:[],listenProgress:function(a){sjcl.mode.ccm.q.push(a)},unListenProgress:function(a){a=sjcl.mode.ccm.q.indexOf(a);-1<a&&sjcl.mode.ccm.q.splice(a,1)},P:function(a){var b=sjcl.mode.ccm.q.slice(),c;for(c=0;c<b.length;c+=1)b[c](a)},encrypt:function(a,b,c,e,d){var g,f=b.slice(0),h=sjcl.bitArray,k=h.bitLength(c)/8,n=h.bitLength(f)/8;d=d||64;e=e||[];if(7>k)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(g=2;4>g&&n>>>8*g;g++);g<15-k&&(g=15-k);c=h.clamp(c,
  27. 8*(15-g));b=sjcl.mode.ccm.H(a,b,c,e,d,g);f=sjcl.mode.ccm.I(a,f,c,b,d,g);return h.concat(f.data,f.tag)},decrypt:function(a,b,c,e,d){d=d||64;e=e||[];var g=sjcl.bitArray,f=g.bitLength(c)/8,h=g.bitLength(b),k=g.clamp(b,h-d),n=g.bitSlice(b,h-d),h=(h-d)/8;if(7>f)throw new sjcl.exception.invalid("ccm: iv must be at least 7 bytes");for(b=2;4>b&&h>>>8*b;b++);b<15-f&&(b=15-f);c=g.clamp(c,8*(15-b));k=sjcl.mode.ccm.I(a,k,c,n,d,b);a=sjcl.mode.ccm.H(a,k.data,c,e,d,b);if(!g.equal(k.tag,a))throw new sjcl.exception.corrupt("ccm: tag doesn't match");
  28. return k.data},W:function(a,b,c,e,d,g){var f=[],h=sjcl.bitArray,k=h.C;e=[h.partial(8,(b.length?64:0)|e-2<<2|g-1)];e=h.concat(e,c);e[3]|=d;e=a.encrypt(e);if(b.length){c=h.bitLength(b)/8;65279>=c?f=[h.partial(16,c)]:0xffffffff>=c&&(f=h.concat([h.partial(16,65534)],[c]));f=h.concat(f,b);for(b=0;b<f.length;b+=4)e=a.encrypt(k(e,f.slice(b,b+4).concat([0,0,0])))}return e},H:function(a,b,c,e,d,g){var f=sjcl.bitArray,h=f.C;d/=8;if(d%2||4>d||16<d)throw new sjcl.exception.invalid("ccm: invalid tag length");
  29. if(0xffffffff<e.length||0xffffffff<b.length)throw new sjcl.exception.bug("ccm: can't deal with 4GiB or more data");c=sjcl.mode.ccm.W(a,e,c,d,f.bitLength(b)/8,g);for(e=0;e<b.length;e+=4)c=a.encrypt(h(c,b.slice(e,e+4).concat([0,0,0])));return f.clamp(c,8*d)},I:function(a,b,c,e,d,g){var f,h=sjcl.bitArray;f=h.C;var k=b.length,n=h.bitLength(b),m=k/50,l=m;c=h.concat([h.partial(8,g-1)],c).concat([0,0,0]).slice(0,4);e=h.bitSlice(f(e,a.encrypt(c)),0,d);if(!k)return{tag:e,data:[]};for(f=0;f<k;f+=4)f>m&&(sjcl.mode.ccm.P(f/
  30. k),m+=l),c[3]++,d=a.encrypt(c),b[f]^=d[0],b[f+1]^=d[1],b[f+2]^=d[2],b[f+3]^=d[3];return{tag:e,data:h.clamp(b,n)}}};sjcl.prng=function(a){this.f=[new sjcl.hash.sha256];this.j=[0];this.B=0;this.r={};this.A=0;this.G={};this.J=this.g=this.k=this.R=0;this.b=[0,0,0,0,0,0,0,0];this.h=[0,0,0,0];this.v=r;this.w=a;this.p=z;this.u={progress:{},seeded:{}};this.m=this.Q=0;this.s=1;this.t=2;this.M=0x10000;this.D=[0,48,64,96,128,192,0x100,384,512,768,1024];this.N=3E4;this.L=80};
  31. sjcl.prng.prototype={randomWords:function(a,b){var c=[],e;e=this.isReady(b);var d;if(e===this.m)throw new sjcl.exception.notReady("generator isn't seeded");if(e&this.t){e=!(e&this.s);d=[];var g=0,f;this.J=d[0]=(new Date).valueOf()+this.N;for(f=0;16>f;f++)d.push(0x100000000*Math.random()|0);for(f=0;f<this.f.length&&!(d=d.concat(this.f[f].finalize()),g+=this.j[f],this.j[f]=0,!e&&this.B&1<<f);f++);this.B>=1<<this.f.length&&(this.f.push(new sjcl.hash.sha256),this.j.push(0));this.g-=g;g>this.k&&(this.k=
  32. g);this.B++;this.b=sjcl.hash.sha256.hash(this.b.concat(d));this.v=new sjcl.cipher.aes(this.b);for(e=0;4>e&&!(this.h[e]=this.h[e]+1|0,this.h[e]);e++);}for(e=0;e<a;e+=4)0===(e+1)%this.M&&ba(this),d=N(this),c.push(d[0],d[1],d[2],d[3]);ba(this);return c.slice(0,a)},setDefaultParanoia:function(a,b){if(0===a&&"Setting paranoia=0 will ruin your security; use it only for testing"!==b)throw"Setting paranoia=0 will ruin your security; use it only for testing";this.w=a},addEntropy:function(a,b,c){c=c||"user";
  33. var e,d,g=(new Date).valueOf(),f=this.r[c],h=this.isReady(),k=0;e=this.G[c];e===r&&(e=this.G[c]=this.R++);f===r&&(f=this.r[c]=0);this.r[c]=(this.r[c]+1)%this.f.length;switch(typeof a){case "number":b===r&&(b=1);this.f[f].update([e,this.A++,1,b,g,1,a|0]);break;case "object":c=Object.prototype.toString.call(a);if("[object Uint32Array]"===c){d=[];for(c=0;c<a.length;c++)d.push(a[c]);a=d}else{"[object Array]"!==c&&(k=1);for(c=0;c<a.length&&!k;c++)"number"!==typeof a[c]&&(k=1)}if(!k){if(b===r)for(c=b=0;c<
  34. a.length;c++)for(d=a[c];0<d;)b++,d>>>=1;this.f[f].update([e,this.A++,2,b,g,a.length].concat(a))}break;case "string":b===r&&(b=a.length);this.f[f].update([e,this.A++,3,b,g,a.length]);this.f[f].update(a);break;default:k=1}if(k)throw new sjcl.exception.bug("random: addEntropy only supports number, array of numbers or string");this.j[f]+=b;this.g+=b;h===this.m&&(this.isReady()!==this.m&&ca("seeded",Math.max(this.k,this.g)),ca("progress",this.getProgress()))},isReady:function(a){a=this.D[a!==r?a:this.w];
  35. return this.k&&this.k>=a?this.j[0]>this.L&&(new Date).valueOf()>this.J?this.t|this.s:this.s:this.g>=a?this.t|this.m:this.m},getProgress:function(a){a=this.D[a?a:this.w];return this.k>=a?1:this.g>a?1:this.g/a},startCollectors:function(){if(!this.p){this.a={loadTimeCollector:O(this,this.V),mouseCollector:O(this,this.X),keyboardCollector:O(this,this.T),accelerometerCollector:O(this,this.O),touchCollector:O(this,this.Y)};if(window.addEventListener)window.addEventListener("load",this.a.loadTimeCollector,
  36. z),window.addEventListener("mousemove",this.a.mouseCollector,z),window.addEventListener("keypress",this.a.keyboardCollector,z),window.addEventListener("devicemotion",this.a.accelerometerCollector,z),window.addEventListener("touchmove",this.a.touchCollector,z);else if(document.attachEvent)document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector);else throw new sjcl.exception.bug("can't attach event");
  37. this.p=!0}},stopCollectors:function(){this.p&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,z),window.removeEventListener("mousemove",this.a.mouseCollector,z),window.removeEventListener("keypress",this.a.keyboardCollector,z),window.removeEventListener("devicemotion",this.a.accelerometerCollector,z),window.removeEventListener("touchmove",this.a.touchCollector,z)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",
  38. this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.p=z)},addEventListener:function(a,b){this.u[a][this.Q++]=b},removeEventListener:function(a,b){var c,e,d=this.u[a],g=[];for(e in d)d.hasOwnProperty(e)&&d[e]===b&&g.push(e);for(c=0;c<g.length;c++)e=g[c],delete d[e]},T:function(){T(1)},X:function(a){var b,c;try{b=a.x||a.clientX||a.offsetX||0,c=a.y||a.clientY||a.offsetY||0}catch(e){c=b=0}0!=b&&0!=c&&sjcl.random.addEntropy([b,c],2,"mouse");T(0)},Y:function(a){a=a.touches[0]||
  39. a.changedTouches[0];sjcl.random.addEntropy([a.pageX||a.clientX,a.pageY||a.clientY],1,"touch");T(0)},V:function(){T(2)},O:function(a){a=a.accelerationIncludingGravity.x||a.accelerationIncludingGravity.y||a.accelerationIncludingGravity.z;if(window.orientation){var b=window.orientation;"number"===typeof b&&sjcl.random.addEntropy(b,1,"accelerometer")}a&&sjcl.random.addEntropy(a,2,"accelerometer");T(0)}};
  40. function ca(a,b){var c,e=sjcl.random.u[a],d=[];for(c in e)e.hasOwnProperty(c)&&d.push(e[c]);for(c=0;c<d.length;c++)d[c](b)}function T(a){"undefined"!==typeof window&&window.performance&&"function"===typeof window.performance.now?sjcl.random.addEntropy(window.performance.now(),a,"loadtime"):sjcl.random.addEntropy((new Date).valueOf(),a,"loadtime")}function ba(a){a.b=N(a).concat(N(a));a.v=new sjcl.cipher.aes(a.b)}
  41. function N(a){for(var b=0;4>b&&!(a.h[b]=a.h[b]+1|0,a.h[b]);b++);return a.v.encrypt(a.h)}function O(a,b){return function(){b.apply(a,arguments)}}sjcl.random=new sjcl.prng(6);
  42. a:try{var U,Z,$,da;if(da="undefined"!==typeof module){var ia;if(ia=module.exports){var ja;try{ja=require("crypto")}catch(ma){ja=null}ia=(Z=ja)&&Z.randomBytes}da=ia}if(da)U=Z.randomBytes(128),U=new Uint32Array((new Uint8Array(U)).buffer),sjcl.random.addEntropy(U,1024,"crypto['randomBytes']");else if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){$=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues)window.crypto.getRandomValues($);else if(window.msCrypto&&window.msCrypto.getRandomValues)window.msCrypto.getRandomValues($);
  43. else break a;sjcl.random.addEntropy($,1024,"crypto['getRandomValues']")}}catch(na){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(na))};