/* * * Client Encryption of Forms. * * Includes: * * RSA and ECC in JavaScript | http://www-cs-students.stanford.edu/~tjw/jsbn/ * * Stanford Javascript Crypto Library | http://crypto.stanford.edu/sjcl/ * * JSON in JavaScript | http://www.JSON.org/ * * Version: 0_1_24 * Author: ADYEN (c) 2014 */ (function(be,ax){var ay,aq,Q=true,U=function(){return""};(function(){try{var e=[new Uint8Array(1),new Uint32Array(1),new Int32Array(1)];return}catch(q){}function t(A,z){return this.slice(A,z)}function y(A,C){if(arguments.length<2){C=0}for(var z=0,B=A.length;z>2,G=((y&3)<<4)|(z>>4);var t=C+1>6):64;var u=C+2>6)+aW.charAt(u&63)}if(q+1==y.length){u=parseInt(y.substring(q,q+1),16);t+=aW.charAt(u<<2)}else{if(q+2==y.length){u=parseInt(y.substring(q,q+2),16);t+=aW.charAt(u>>2)+aW.charAt((u&3)<<4)}}while((t.length&3)>0){t+=aR}return t}function d(u){var z="";var y;var t=0;var q;for(y=0;y>2);q=v&3;t=1}else{if(t==1){z+=bq((q<<2)|(v>>4));q=v&15;t=2}else{if(t==2){z+=bq(q);z+=bq(v>>2);q=v&3;t=3}else{z+=bq((q<<2)|(v>>4));z+=bq(v&15);t=0}}}}if(t==1){z+=bq(q<<2)}return z}function aJ(t){var u=d(t);var y;var q=new Array();for(y=0;2*y=0){var B=t*this[z++]+q[A]+u;u=Math.floor(B/67108864);q[A++]=B&67108863}return u}function bp(C,u,t,D,z,G){var A=u&32767,y=u>>15;while(--G>=0){var E=this[C]&32767;var B=this[C++]>>15;var F=y*E+B*A;E=A*E+((F&32767)<<15)+t[D]+(z&1073741823);z=(E>>>30)+(F>>>15)+y*B+(z>>>30);t[D++]=E&1073741823}return z}function bo(C,u,t,D,z,G){var A=u&16383,y=u>>14;while(--G>=0){var E=this[C]&16383;var B=this[C++]>>14;var F=y*E+B*A;E=A*E+((F&16383)<<14)+t[D]+z;z=(E>>28)+(F>>14)+y*B;t[D++]=E&268435455}return z}if(aV&&(navigator.appName=="Microsoft Internet Explorer")){bi.prototype.am=bp;bm=30}else{if(aV&&(navigator.appName!="Netscape")){bi.prototype.am=c;bm=26}else{bi.prototype.am=bo;bm=28}}bi.prototype.DB=bm;bi.prototype.DM=((1<=0;--q){e[q]=this[q]}e.t=this.t;e.s=this.s}function x(e){this.t=1;this.s=(e<0)?-1:0;if(e>0){this[0]=e}else{if(e<-1){this[0]=e+this.DV}else{this.t=0}}}function f(q){var e=m();e.fromInt(q);return e}function V(t,B){var z;if(B==16){z=4}else{if(B==8){z=3}else{if(B==256){z=8}else{if(B==2){z=1}else{if(B==32){z=5}else{if(B==4){z=2}else{this.fromRadix(t,B);return}}}}}}this.t=0;this.s=0;var u=t.length,A=false,y=0;while(--u>=0){var q=(z==8)?t[u]&255:Y(t,u);if(q<0){if(t.charAt(u)=="-"){A=true}continue}A=false;if(y==0){this[this.t++]=q}else{if(y+z>this.DB){this[this.t-1]|=(q&((1<<(this.DB-y))-1))<>(this.DB-y))}else{this[this.t-1]|=q<=this.DB){y-=this.DB}}if(z==8&&(t[0]&128)!=0){this.s=-1;if(y>0){this[this.t-1]|=((1<<(this.DB-y))-1)<0&&this[this.t-1]==e){--this.t}}function P(C){if(this.s<0){return"-"+this.negate().toString(C)}var B;if(C==16){B=4}else{if(C==8){B=3}else{if(C==2){B=1}else{if(C==32){B=5}else{if(C==4){B=2}else{return this.toRadix(C)}}}}}var z=(1<0){if(u>u)>0){q=true;y=bq(t)}while(A>=0){if(u>(u+=this.DB-B)}else{t=(this[A]>>(u-=B))&z;if(u<=0){u+=this.DB;--A}}if(t>0){q=true}if(q){y+=bq(t)}}}return q?y:"0"}function av(){var e=m();bi.ZERO.subTo(this,e);return e}function bb(){return(this.s<0)?this.negate():this}function af(e){var q=this.s-e.s;if(q!=0){return q}var t=this.t;q=t-e.t;if(q!=0){return(this.s<0)?-q:q}while(--t>=0){if((q=this[t]-e[t])!=0){return q}}return 0}function o(q){var t=1,e;if((e=q>>>16)!=0){q=e;t+=16}if((e=q>>8)!=0){q=e;t+=8}if((e=q>>4)!=0){q=e;t+=4}if((e=q>>2)!=0){q=e;t+=2}if((e=q>>1)!=0){q=e;t+=1}return t}function S(){if(this.t<=0){return 0}return this.DB*(this.t-1)+o(this[this.t-1]^(this.s&this.DM))}function bh(t,e){var q;for(q=this.t-1;q>=0;--q){e[q+t]=this[q]}for(q=t-1;q>=0;--q){e[q]=0}e.t=this.t+t;e.s=this.s}function aT(t,e){for(var q=t;q=0;--C){B[C+A+1]=(this[C]>>t)|y;y=(this[C]&z)<=0;--C){B[C]=0}B[A]=y;B.t=this.t+A+1;B.s=this.s;B.clamp()}function s(u,A){A.s=this.s;var z=Math.floor(u/this.DB);if(z>=this.t){A.t=0;return}var q=u%this.DB;var t=this.DB-q;var y=(1<>q;for(var B=z+1;B>q}if(q>0){A[this.t-z-1]|=(this.s&y)<>=this.DB}if(z.t>=this.DB}t+=this.s}else{t+=this.s;while(y>=this.DB}t-=z.s}u.s=(t<0)?-1:0;if(t<-1){u[y++]=this.DV+t}else{if(t>0){u[y++]=t}}u.t=y;u.clamp()}function ab(z,u){var q=this.abs(),t=z.abs();var y=q.t;u.t=y+t.t;while(--y>=0){u[y]=0}for(y=0;y=0){y[q]=0}for(q=0;q=t.DV){y[q+t.t]-=t.DV;y[q+t.t+1]=1}}if(y.t>0){y[y.t-1]+=t.am(q,t[q],y,2*q,0,1)}y.s=0;y.clamp()}function ac(G,J,K){var t=G.abs();if(t.t<=0){return}var I=this.abs();if(I.t0){t.lShiftTo(y,M);I.lShiftTo(y,K)}else{t.copyTo(M);I.copyTo(K)}var E=M.t;var bs=M[E-1];if(bs==0){return}var F=bs*(1<1)?M[E-2]>>this.F2:0);var D=this.FV/F,e=(1<=0){K[K.t++]=1;K.subTo(L,K)}bi.ONE.dlShiftTo(E,L);L.subTo(M,M);while(M.t=0){var br=(K[--B]==bs)?this.DM:Math.floor(K[B]*D+(K[B-1]+q)*e);if((K[B]+=M.am(0,br,K,C,0,E))0){K.rShiftTo(y,K)}if(bt<0){bi.ZERO.subTo(K,K)}}function ao(e){var q=m();this.abs().divRemTo(e,null,q);if(this.s<0&&q.compareTo(bi.ZERO)>0){e.subTo(q,q)}return q}function al(e){this.m=e}function aN(e){if(e.s<0||e.compareTo(this.m)>=0){return e.mod(this.m)}else{return e}}function ba(e){return e}function aj(e){e.divRemTo(this.m,null,e)}function ag(q,t,e){q.multiplyTo(t,e);this.reduce(e)}function bk(q,e){q.squareTo(e);this.reduce(e)}al.prototype.convert=aN;al.prototype.revert=ba;al.prototype.reduce=aj;al.prototype.mulTo=ag;al.prototype.sqrTo=bk;function Z(){if(this.t<1){return 0}var q=this[0];if((q&1)==0){return 0}var e=q&3;e=(e*(2-(q&15)*e))&15;e=(e*(2-(q&255)*e))&255;e=(e*(2-(((q&65535)*e)&65535)))&65535;e=(e*(2-q*e%this.DV))%this.DV;return(e>0)?this.DV-e:-e}function j(e){this.m=e;this.mp=e.invDigit();this.mpl=this.mp&32767;this.mph=this.mp>>15;this.um=(1<<(e.DB-15))-1;this.mt2=2*e.t}function a9(q){var e=m();q.abs().dlShiftTo(this.m.t,e);e.divRemTo(this.m,null,e);if(q.s<0&&e.compareTo(bi.ZERO)>0){this.m.subTo(e,e)}return e}function bj(q){var e=m();q.copyTo(e);this.reduce(e);return e}function at(q){while(q.t<=this.mt2){q[q.t++]=0}for(var u=0;u>15)*this.mpl)&this.um)<<15))&q.DM;e=u+this.m.t;q[e]+=this.m.am(0,t,q,u,0,this.m.t);while(q[e]>=q.DV){q[e]-=q.DV;q[++e]++}}q.clamp();q.drShiftTo(this.m.t,q);if(q.compareTo(this.m)>=0){q.subTo(this.m,q)}}function bc(q,e){q.squareTo(e);this.reduce(e)}function X(q,t,e){q.multiplyTo(t,e);this.reduce(e)}j.prototype.convert=a9;j.prototype.revert=bj;j.prototype.reduce=at;j.prototype.mulTo=X;j.prototype.sqrTo=bc;function n(){return((this.t>0)?(this[0]&1):this.s)==0}function W(u,t){if(u>4294967295||u<1){return bi.ONE}var y=m(),q=m(),z=t.convert(this),A=o(u)-1;z.copyTo(y);while(--A>=0){t.sqrTo(y,q);if((u&(1<0){t.mulTo(q,z,y)}else{var e=y;y=q;q=e}}return t.revert(y)}function bd(e,q){var t;if(e<256||q.isEven()){t=new al(q)}else{t=new j(q)}return this.exp(e,t)}bi.prototype.copyTo=aU;bi.prototype.fromInt=x;bi.prototype.fromString=V;bi.prototype.clamp=ap;bi.prototype.dlShiftTo=bh;bi.prototype.drShiftTo=aT;bi.prototype.lShiftTo=R;bi.prototype.rShiftTo=s;bi.prototype.subTo=aY;bi.prototype.multiplyTo=ab;bi.prototype.squareTo=au;bi.prototype.divRemTo=ac;bi.prototype.invDigit=Z;bi.prototype.isEven=n;bi.prototype.exp=W;bi.prototype.toString=P;bi.prototype.negate=av;bi.prototype.abs=bb;bi.prototype.compareTo=af;bi.prototype.bitLength=S;bi.prototype.mod=ao;bi.prototype.modPowInt=bd;bi.ZERO=f(0);bi.ONE=f(1);function r(){this.i=0;this.j=0;this.S=new Array}function h(u){var q,t,e;for(q=0;q<256;++q){this.S[q]=q}t=0;for(q=0;q<256;++q){t=t+this.S[q]+u[q%u.length]&255;e=this.S[q];this.S[q]=this.S[t];this.S[t]=e}this.i=0;this.j=0}function b(){var e;this.i=this.i+1&255;this.j=this.j+this.S[this.i]&255;e=this.S[this.i];this.S[this.i]=this.S[this.j];this.S[this.j]=e;return this.S[e+this.S[this.i]&255]}function bf(){return new r}r.prototype.init=h;r.prototype.next=b;var an=256;var w;var aB;var aZ;function g(e){aB[aZ++]^=e&255;aB[aZ++]^=(e>>8)&255;aB[aZ++]^=(e>>16)&255;aB[aZ++]^=(e>>24)&255;if(aZ>=an){aZ-=an}}function aA(){g(new Date().getTime())}if(aB==null){aB=[];aZ=0;var ai;try{if(window.crypto&&window.crypto.getRandomValues){var aw=new Uint8Array(32);window.crypto.getRandomValues(aw);for(ai=0;ai<32;++ai){aB[aZ++]=aw[ai]}}else{if(window.msCrypto&&window.msCrypto.getRandomValues){var aw=new Uint8Array(32);window.msCrypto.getRandomValues(aw);for(ai=0;ai<32;++ai){aB[aZ++]=aw[ai]}}else{if(window.crypto&&window.crypto.random){var ad=window.crypto.random(32);for(ai=0;ai>>8;aB[aZ++]=ai&255}aZ=0;aA()}function aa(){if(w==null){aA();w=bf();w.init(aB);for(aZ=0;aZ=0&&t>0){u[--t]=A[y--]}u[--t]=0;var z=new a1();var q=new Array();while(t>2){q[0]=0;while(q[0]==0){z.nextBytes(q)}u[--t]=q[0]}u[--t]=2;u[--t]=0;return new bi(u)}function am(){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 N(e,q){if(e!=null&&q!=null&&e.length>0&&q.length>0){this.n=l(e,16);this.e=parseInt(q,16)}else{alert("Invalid RSA public key")}}function aS(e){return e.modPowInt(this.e,this.n)}function O(q){var t=a5(q,(this.n.bitLength()+7)>>3);if(t==null){return null}var u=this.doPublic(t);if(u==null){return null}var y=u.toString(16);if((y.length&1)==0){return y}else{return"0"+y}}function i(q){var e=this.encrypt(q);if(e){return a2(e)}else{return null}}am.prototype.doPublic=aS;am.prototype.setPublic=N;am.prototype.encrypt=O;am.prototype.encrypt_b64=i;"use strict";function ak(e){throw e}var ai=void 0,ah=!1;var k={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(e){this.toString=function(){return"CORRUPT: "+this.message};this.message=e},invalid:function(e){this.toString=function(){return"INVALID: "+this.message};this.message=e},bug:function(e){this.toString=function(){return"BUG: "+this.message};this.message=e},notReady:function(e){this.toString=function(){return"NOT READY: "+this.message};this.message=e}}};"undefined"!==typeof module&&module.exports&&(module.exports=k);"function"===typeof ay&&ay([],function(){return k});k.cipher.aes=function(u){this.k[0][0][0]||this.D();var y,z,A,B,e=this.k[0][4],q=this.k[1];y=u.length;var t=1;4!==y&&(6!==y&&8!==y)&&ak(new k.exception.invalid("invalid aes key size"));this.b=[A=u.slice(0),B=[]];for(u=y;u<4*y+28;u++){z=A[u-1];if(0===u%y||8===y&&4===u%y){z=e[z>>>24]<<24^e[z>>16&255]<<16^e[z>>8&255]<<8^e[z&255],0===u%y&&(z=z<<8^z>>>24^t<<24,t=t<<1^283*(t>>7))}A[u]=A[u-y]^z}for(y=0;u;y++,u--){z=A[y&3?u:u-4],B[y]=4>=u||4>y?z:q[0][e[z>>>24]]^q[1][e[z>>16&255]]^q[2][e[z>>8&255]]^q[3][e[z&255]]}};k.cipher.aes.prototype={encrypt:function(e){return ae(this,e,0)},decrypt:function(e){return ae(this,e,1)},k:[[[],[],[],[],[]],[[],[],[],[],[]]],D:function(){var y=this.k[0],z=this.k[1],A=y[4],B=z[4],C,D,E,F=[],e=[],G,t,q,u;for(C=0;256>C;C++){e[(F[C]=C<<1^283*(C>>7))^C]=C}for(D=E=0;!A[D];D^=G||1,E=e[E]||1){q=E^E<<1^E<<2^E<<3^E<<4;q=q>>8^q&255^99;A[D]=q;B[q]=D;t=F[C=F[G=F[D]]];u=16843009*t^65537*C^257*G^16843008*D;t=257*F[q]^16843008*q;for(C=0;4>C;C++){y[C][D]=t=t<<24^t>>>8,z[C][q]=u=u<<24^u>>>8}}for(C=0;5>C;C++){y[C]=y[C].slice(0),z[C]=z[C].slice(0)}}};function ae(K,L,e){4!==L.length&&ak(new k.exception.invalid("invalid aes block size"));var q=K.b[e],t=L[0]^q[0],u=L[e?3:1]^q[1],y=L[2]^q[2];L=L[e?1:3]^q[3];var z,B,A,D=q.length/4-2,C,E=4,G=[0,0,0,0];z=K.k[e];K=z[0];var F=z[1],H=z[2],I=z[3],J=z[4];for(C=0;C>>24]^F[u>>16&255]^H[y>>8&255]^I[L&255]^q[E],B=K[u>>>24]^F[y>>16&255]^H[L>>8&255]^I[t&255]^q[E+1],A=K[y>>>24]^F[L>>16&255]^H[t>>8&255]^I[u&255]^q[E+2],L=K[L>>>24]^F[t>>16&255]^H[u>>8&255]^I[y&255]^q[E+3],E+=4,t=z,u=B,y=A}for(C=0;4>C;C++){G[e?3&-C:C]=J[t>>>24]<<24^J[u>>16&255]<<16^J[y>>8&255]<<8^J[L&255]^q[E++],z=t,t=u,u=y,y=L,L=z}return G}k.bitArray={bitSlice:function(t,u,q){t=k.bitArray.P(t.slice(u/32),32-(u&31)).slice(1);return q===ai?t:k.bitArray.clamp(t,q-u)},extract:function(u,y,q){var t=Math.floor(-y-q&31);return((y+q-1^y)&-32?u[y/32|0]<<32-t^u[y/32+1|0]>>>t:u[y/32|0]>>>t)&(1<>u-1,1));return t},partial:function(t,u,q){return 32===t?u:(q?u|0:u<<32-t)+1099511627776*t},getPartial:function(e){return Math.round(e/1099511627776)||32},equal:function(u,y){if(k.bitArray.bitLength(u)!==k.bitArray.bitLength(y)){return ah}var q=0,t;for(t=0;t>>y),e=u[t]<<32-y}t=u.length?u[u.length-1]:0;u=k.bitArray.getPartial(t);q.push(k.bitArray.partial(y+u&31,32>>24|q>>>8&65280|(q&65280)<<8|q<<24}return t}};k.codec.utf8String={fromBits:function(u){var y="",e=k.bitArray.bitLength(u),q,t;for(q=0;q>>24),t<<=8}return decodeURIComponent(escape(y))},toBits:function(u){u=unescape(encodeURIComponent(u));var y=[],q,t=0;for(q=0;q>>B)>>>26),6>B?(q=u[z]<<6-B,B+=26,z++):(q<<=6,B-=6)}for(;A.length&3&&!y;){A+="="}return A},toBits:function(u,y){u=u.replace(/\s|=/g,"");var z=[],A,B=0,e=k.codec.base64.J,q=0,t;y&&(e=e.substr(0,62)+"-_");for(A=0;At&&ak(new k.exception.invalid("this isn't base64!")),26>>B),q=t<<32-B):(B+=6,q^=t<<32-B)}B&56&&z.push(k.bitArray.partial(B&56,q,1));return z}};k.codec.base64url={fromBits:function(e){return k.codec.base64.fromBits(e,1,1)},toBits:function(e){return k.codec.base64.toBits(e,1)}};k.hash.sha256=function(e){this.b[0]||this.D();e?(this.r=e.r.slice(0),this.o=e.o.slice(0),this.h=e.h):this.reset()};k.hash.sha256.hash=function(e){return(new k.hash.sha256).update(e).finalize()};k.hash.sha256.prototype={blockSize:512,reset:function(){this.r=this.N.slice(0);this.o=[];this.h=0;return this},update:function(t){"string"===typeof t&&(t=k.codec.utf8String.toBits(t));var u,q=this.o=k.bitArray.concat(this.o,t);u=this.h;t=this.h=u+k.bitArray.bitLength(t);for(u=512+u&-512;u<=t;u+=512){ad(this,q.splice(0,16))}return this},finalize:function(){var t,u=this.o,q=this.r,u=k.bitArray.concat(u,[k.bitArray.partial(1,1)]);for(t=u.length+2;t&15;t++){u.push(0)}u.push(Math.floor(this.h/4294967296));for(u.push(this.h|0);u.length;){ad(this,u.splice(0,16))}this.reset();return q},N:[],b:[],D:function(){function u(e){return 4294967296*(e-Math.floor(e))|0}var y=0,q=2,t;u:for(;64>y;q++){for(t=2;t*t<=q;t++){if(0===q%t){continue u}}8>y&&(this.N[y]=u(Math.pow(q,0.5)));this.b[y]=u(Math.pow(q,1/3));y++}}};function ad(u,y){var z,B,D,E=y.slice(0),F=u.r,G=u.b,I=F[0],H=F[1],q=F[2],J=F[3],A=F[4],e=F[5],C=F[6],t=F[7];for(z=0;64>z;z++){16>z?B=E[z]:(B=E[z+1&15],D=E[z+14&15],B=E[z&15]=(B>>>7^B>>>18^B>>>3^B<<25^B<<14)+(D>>>17^D>>>19^D>>>10^D<<15^D<<13)+E[z&15]+E[z+9&15]|0),B=B+t+(A>>>6^A>>>11^A>>>25^A<<26^A<<21^A<<7)+(C^A&(e^C))+G[z],t=C,C=e,e=A,A=J+B|0,J=q,q=H,H=I,I=B+(H&q^J&(H^q))+(H>>>2^H>>>13^H>>>22^H<<30^H<<19^H<<10)|0}F[0]=F[0]+I|0;F[1]=F[1]+H|0;F[2]=F[2]+q|0;F[3]=F[3]+J|0;F[4]=F[4]+A|0;F[5]=F[5]+e|0;F[6]=F[6]+C|0;F[7]=F[7]+t|0}k.mode.ccm={name:"ccm",encrypt:function(B,C,D,e,q){var t,u=C.slice(0),y=k.bitArray,A=y.bitLength(D)/8,z=y.bitLength(u)/8;q=q||64;e=e||[];7>A&&ak(new k.exception.invalid("ccm: iv must be at least 7 bytes"));for(t=2;4>t&&z>>>8*t;t++){}t<15-A&&(t=15-A);D=y.clamp(D,8*(15-t));C=k.mode.ccm.L(B,C,D,e,q,t);u=k.mode.ccm.p(B,u,D,C,q,t);return y.concat(u.data,u.tag)},decrypt:function(B,C,D,e,q){q=q||64;e=e||[];var t=k.bitArray,u=t.bitLength(D)/8,y=t.bitLength(C),A=t.clamp(C,y-q),z=t.bitSlice(C,y-q),y=(y-q)/8;7>u&&ak(new k.exception.invalid("ccm: iv must be at least 7 bytes"));for(C=2;4>C&&y>>>8*C;C++){}C<15-u&&(C=15-u);D=t.clamp(D,8*(15-C));A=k.mode.ccm.p(B,A,D,z,q,C);B=k.mode.ccm.L(B,A.data,D,e,q,C);t.equal(A.tag,B)||ak(new k.exception.corrupt("ccm: tag doesn't match"));return A.data},L:function(C,e,q,t,u,y){var z=[],A=k.bitArray,B=A.l;u/=8;(u%2||4>u||16=q?z=[A.partial(16,q)]:4294967295>=q&&(z=A.concat([A.partial(16,65534)],[q]));z=A.concat(z,t);for(t=0;tB.bitLength(z)&&(t=e(t,A(t)),z=B.concat(z,[-2147483648,0,0,0]));q=e(q,z);return u.encrypt(e(A(e(t,A(t))),q))},H:function(e){return[e[0]<<1^e[1]>>>31,e[1]<<1^e[2]>>>31,e[2]<<1^e[3]>>>31,e[3]<<1^135*(e[0]>>>31)]}};k.mode.gcm={name:"gcm",encrypt:function(y,z,e,q,t){var u=z.slice(0);z=k.bitArray;q=q||[];y=k.mode.gcm.p(!0,y,u,q,e,t||128);return z.concat(y.data,y.tag)},decrypt:function(u,y,z,A,B){var e=y.slice(0),q=k.bitArray,t=q.bitLength(e);B=B||128;A=A||[];B<=t?(y=q.bitSlice(e,t-B),e=q.bitSlice(e,0,t-B)):(y=e,e=[]);u=k.mode.gcm.p(ah,u,e,A,z,B);q.equal(u.tag,y)||ak(new k.exception.corrupt("gcm: tag doesn't match"));return u.data},Z:function(u,y){var z,A,B,e,q,t=k.bitArray.l;B=[0,0,0,0];e=y.slice(0);for(z=0;128>z;z++){(A=0!==(u[Math.floor(z/32)]&1<<31-z%32))&&(B=t(B,e));q=0!==(e[3]&1);for(A=3;0>>1|(e[A-1]&1)<<31}e[0]>>>=1;q&&(e[0]^=-520093696)}return B},g:function(u,y,e){var q,t=e.length;y=y.slice(0);for(q=0;qt&&(u=y.hash(u));for(q=0;qD||0>C)&&ak(k.exception.invalid("invalid params to pbkdf2"));"string"===typeof A&&(A=k.codec.utf8String.toBits(A));"string"===typeof B&&(B=k.codec.utf8String.toBits(B));E=E||k.misc.hmac;A=new E(A);var e,q,t,y,u=[],z=k.bitArray;for(y=1;32*u.length<(D||1);y++){E=e=A.encrypt(z.concat(B,[y]));for(q=1;qu;u++){q.push(4294967296*Math.random()|0)}for(u=0;u=1<this.j&&(this.j=t);this.F++;this.b=k.hash.sha256.hash(this.b.concat(q));this.A=new k.cipher.aes(this.b);for(e=0;4>e&&!(this.f[e]=this.f[e]+1|0,this.f[e]);e++){}}for(e=0;e>>=1}}}this.c[z].update([t,this.C++,2,e,y,C.length].concat(C))}break;case"string":e===ai&&(e=C.length);this.c[z].update([t,this.C++,3,e,y,C.length]);this.c[z].update(C);break;default:B=1}B&&ak(new k.exception.bug("random: addEntropy only supports number, array of numbers or string"));this.i[z]+=e;this.d+=e;A===this.m&&(this.isReady()!==this.m&&aO("seeded",Math.max(this.j,this.d)),aO("progress",this.getProgress()))},isReady:function(e){e=this.I[e!==ai?e:this.B];return this.j&&this.j>=e?this.i[0]>this.R&&(new Date).valueOf()>this.O?this.u|this.t:this.t:this.d>=e?this.u|this.m:this.m},getProgress:function(e){e=this.I[e?e:this.B];return this.j>=e?1:this.d>e?1:this.d/e},startCollectors:function(){this.q||(this.a={loadTimeCollector:aM(this,this.aa),mouseCollector:aM(this,this.ba),keyboardCollector:aM(this,this.$),accelerometerCollector:aM(this,this.U)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,ah),window.addEventListener("mousemove",this.a.mouseCollector,ah),window.addEventListener("keypress",this.a.keyboardCollector,ah),window.addEventListener("devicemotion",this.a.accelerometerCollector,ah)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):ak(new k.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,ah),window.removeEventListener("mousemove",this.a.mouseCollector,ah),window.removeEventListener("keypress",this.a.keyboardCollector,ah),window.removeEventListener("devicemotion",this.a.accelerometerCollector,ah)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=ah)},addEventListener:function(e,q){this.w[e][this.V++]=q},removeEventListener:function(y,z){var e,q,t=this.w[y],u=[];for(q in t){t.hasOwnProperty(q)&&t[q]===z&&u.push(q)}for(e=0;eq&&!(e.f[q]=e.f[q]+1|0,e.f[q]);q++){}return e.A.encrypt(e.f)}function aM(e,q){return function(){q.apply(e,arguments)}}k.random=new k.prng(6);a:try{var aK,aI,aH,aG;if(aG="undefined"!==typeof module){var aF;if(aF=module.exports){var aE;try{aE=require("crypto")}catch(aD){aE=null}aF=(aI=aE)&&aI.randomBytes}aG=aF}if(aG){aK=aI.randomBytes(128),aK=new Uint32Array((new Uint8Array(aK)).buffer),k.random.addEntropy(aK,1024,"crypto['randomBytes']")}else{if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){aH=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues){window.crypto.getRandomValues(aH)}else{if(window.msCrypto&&window.msCrypto.getRandomValues){window.msCrypto.getRandomValues(aH)}else{break a}}k.random.addEntropy(aH,1024,"crypto['getRandomValues']")}}}catch(aC){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(aC))}k.json={defaults:{v:1,iter:1000,ks:128,ts:64,mode:"ccm",adata:"",cipher:"aes"},Y:function(y,z,A,e){A=A||{};e=e||{};var q=k.json,t=q.e({iv:k.random.randomWords(4,0)},q.defaults),u;q.e(t,A);A=t.adata;"string"===typeof t.salt&&(t.salt=k.codec.base64.toBits(t.salt));"string"===typeof t.iv&&(t.iv=k.codec.base64.toBits(t.iv));(!k.mode[t.mode]||!k.cipher[t.cipher]||"string"===typeof y&&100>=t.iter||64!==t.ts&&96!==t.ts&&128!==t.ts||128!==t.ks&&192!==t.ks&&256!==t.ks||2>t.iv.length||4=z.iter||64!==z.ts&&96!==z.ts&&128!==z.ts||128!==z.ks&&192!==z.ks&&256!==z.ks||!z.iv||2>z.iv.length||4>>24);y<<=8}return z};e.toBits=e.toBits||function(z){var y=[],t,u=0;for(t=0;t=48&&E.keyCode<=57||E.keyCode>=96&&E.keyCode<=105){p("log",D,"KN")}else{if(E.keyCode>=65&&E.keyCode<=90){p("log",D,"KL")}else{p("log",D,"KU");p("log",D+"UnkKeys",E.keyCode)}}break}},true);return}if(z==="set"){u[A]=D;return}if(z==="log"){var y=A+"FieldLog";var C=(new Date().getTime())-q;C=Math.round(C/100);if(!u.hasOwnProperty(y)){u[y]=D+"@"+C}else{u[y]+=","+D+"@"+C}if(u[y].length>1500){u[y]=u[y].substring(u[y].length-1500);u[y]=u[y].substring(u[y].indexOf(",")+1)}return}if(z==="extend"){for(var B in u){if(B==="number"||B==="expiryMonth"||B==="expiryYear"||B==="generationtime"||B==="holderName"||B==="cvc"){continue}if(u.hasOwnProperty(B)){A[B]=""+u[B]}}return}if(!u.hasOwnProperty(z)){u[z]=1}else{u[z]++}}})();function e(F){var A=function(){return{}};if(window.jQuery&&typeof window.jQuery._data=="function"){A=function(u){return window.jQuery._data(u,"events")}}var B=F,L=0,z=[],M=["onmousedown","onmouseup","onmouseover","onmouseout","onclick","onmousemove","ondblclick","onerror","onresize","onscroll","onkeydown","onkeyup","onkeypress","onchange","onsubmit"],E="Own",bs="Par",br=M.length;var G=0;while(B&&B!==B.documentElement){G++;var C=br,I,D,H=(B.nodeName||B.tagName||"").toUpperCase().substring(0,3);while(C--){I=M[C];if(B[name]){I=I+((B===F)?E:bs)+H;L++;z[I]=z[I]||0;z[I]++}}var y=A(B);if(typeof y==="object"){for(var I in y){if(y.hasOwnProperty(I)){D=y[I].length;I=I+((B===F)?E:bs)+H;z[I]=z[I]||0;z[I]+=D;L+=D}}}if(!B.parentNode){break}B=B.parentNode}var K=["total="+L];for(var J in z){if(z.hasOwnProperty(J)&&z[J]>0){K.push(J+"="+z[J])}}return K.join("&")}if(window&&(window.attachEvent||window.addEventListener)){t(window,"focus",function(){p("activate");if(window.location&&typeof window.location.href=="string"){p("set","referrer",window.location.href)}});t(window,"blur",function(){p("deactivate")})}}());var az=be.adyen=be.adyen||{};var a7=az.encrypt=az.encrypt||{createEncryption:function(q,e){return new a4(q,e)}};if(typeof ax==="function"&&ax.amd){ax("adyen/encrypt",[],function(){return a7})}else{if(typeof module!=="undefined"&&module.exports){module.exports=a7}}a7.errors=a7.errors||{};a7.version="0_1_24";var a0={};a0.luhnCheck=(function(){var e={};return function(){var y=arguments;var q=arguments.length;var E=q>0?y[0]:this.cardnumber;if(isNaN(parseInt(E,10))){return false}var t=E.length;var C=t&1;var A=0;if(typeof e[E]==="undefined"){if(t>=14){p("luhnCount")}for(var z=0;z9){D-=9}}A+=D}if(A%10===0){p("luhnOkCount");e[E]=true}else{p("luhnFailCount");e[E]=false}}var B=0;for(var u in e){if(e.hasOwnProperty(u)&&u.length===t){B++}}p("set","luhnSameLengthCount",B);return e[E]}})();a0.numberCheck=function(e){return((e||"").replace(/[^\d]/g,"").match(/^\d{10,20}$/)&&a0.luhnCheck(e))?true:false};a0.cvcCheck=function(e){return(e&&e.match&&e.match(/^\d{3,4}$/))?true:false};a0.yearCheck=function(t){if(!t||!t.match||!t.match(/^2\d{3}$/)){return false}var q=parseInt(t,10),e=(new Date()).getFullYear();return q>=e-2&&q<=e+15};a0.monthCheck=function(e){var q=(e||"").replace(/^0(\d)$/,"$1");return(q.match(/^([1-9]|10|11|12)$/)&&parseInt(q,10)>=1&&parseInt(q,10)<=12)?true:false};a0.holderNameCheck=function(e){return(e&&e.match&&e.match(/\S/))?true:false};a0.generationTimeValidDate=function(q){if(typeof q!=="string"){return false}var e=q.match(/^(\d{4})-?(\d{2})-?(\d{2})$/);return(e&&(""+e[1]).match(/^20[1-9][0-9]$/)&&(""+e[2]).match(/^(12|11|10|0[1-9])$/)&&(""+e[3]).match(/^(31|30|20|10|[012][1-9])$/))?true:false};a0.generationTimeValidTime=function(t){if(typeof t!=="string"){return false}var q=/(Z|[\+\-][012345][0-9]:?[012345][0-9])$/;var e=t.replace(q,"").replace(/\.\d+$/,"");return e.match(/^[012345][0-9]:?[012345][0-9]:?[012345][0-9]$/)};a0.generationTimeCheck=function(q){if(typeof q!=="string"){return false}var e=q.split("T");return(e.length===2&&a0.generationTimeValidDate(e[0])&&a0.generationTimeValidTime(e[1]))?true:false};var a4=function(u,t){try{if(t.randomBytes){k.random.addEntropy(t.randomBytes,1024,"crypto.randomBytes")}k.random.startCollectors()}catch(y){}if(t.stopDeviceFingerprint===true){Q=false}if(Q){try{U()}catch(y){}}this.key=u;this.options=t||{};if(typeof this.options.numberIgnoreNonNumeric==="undefined"){this.options.numberIgnoreNonNumeric=true}if(typeof this.options.cvcIgnoreFornumber!=="undefined"){delete this.options.cvcIgnoreFornumber}if(typeof this.options.fourDigitCvcForBins==="undefined"){this.options.fourDigitCvcForBins="34,37"}if(typeof this.options.cvcLengthFornumber!=="undefined"){delete this.options.cvcLengthFornumber}if(typeof this.options.cvcIgnoreBins==="string"){var z=[];this.options.cvcIgnoreBins.replace(/\d+/g,function(e){if(e.length>0&&!isNaN(parseInt(e,10))){z.push(e)}return e});if(z.length>0){this.options.cvcIgnoreFornumber=new RegExp("^\\s*("+z.join("|")+")")}}else{if(typeof this.options.cvcIgnoreBins!=="undefined"){delete this.options.cvcIgnoreBins}}if(typeof this.options.fourDigitCvcForBins==="string"){var q=[];this.options.fourDigitCvcForBins.replace(/\d+/g,function(e){if(e.length>0&&!isNaN(parseInt(e,10))){q.push(e)}return e});if(q.length>0){this.options.cvcLengthFornumber={matcher:new RegExp("^\\s*("+q.join("|")+")"),requiredLength:4}}}delete this.options.fourDigitCvcForBins;p("initializeCount")};a4.prototype.createRSAKey=function(){var e=this.key.split("|");if(e.length!==2){throw"Malformed public key"}var u=e[0];var q=e[1];var t=new am();t.setPublic(q,u);return t};a4.prototype.createAESKey=function(){return new bn()};a4.prototype.encrypt=function(t,q){var u={};for(var y in t){if(t.hasOwnProperty(y)){u[y]=t[y]}}var C,G,D,F,B,A,z={};if(typeof u.number!=="undefined"){z.number=u.number}if(typeof u.cvc!=="undefined"){z.cvc=u.cvc}if(typeof u.expiryMonth!=="undefined"){z.month=u.expiryMonth}if(typeof u.expiryYear!=="undefined"){z.year=u.expiryYear}if(typeof u.holderName!=="undefined"){z.holderName=u.holderName}if(typeof u.generationtime!=="undefined"){z.generationtime=u.generationtime}if(this.options.enableValidations!==false&&this.validate(z).valid===false){return false}for(var H=0;H<11;H++){if(k.random&&k.random.isReady(H)){p("set","sjclStrength",H)}else{break}}p("extend",u);if(Q){try{u.dfValue=U()}catch(E){}}else{if(q){u.dfValue=q}}C=this.createRSAKey();G=this.createAESKey();D=G.encrypt(JSON.stringify(u));F=k.codec.bytes.fromBits(G.key());B=C.encrypt_b64(F);A="adyenjs_"+a7.version+"$";return[A,B,"$",D].join("")};a4.prototype.validate=function(u){var e={};e.valid=true;if(typeof u!=="object"){e.valid=false;return e}for(var y in u){if(!u.hasOwnProperty(y)||typeof u[y]==="undefined"){continue}var A=u[y];if(this.options[y+"IgnoreNonNumeric"]){A=A.replace(/\D/g,"")}if(this.options[y+"SkipValidation"]){continue}for(var t in u){if(u.hasOwnProperty(t)){var q=this.options[y+"IgnoreFor"+t];var z=this.options[y+"LengthFor"+t];if(q&&u[t].match(q)){e[y]=true;continue}else{if(z&&z.matcher&&z.requiredLength&&u[t].match(z.matcher)){if(A.length!==z.requiredLength){e[y]=false;continue}}}}}if(e.hasOwnProperty(y)){e.valid=e.valid&&e[y];continue}switch(y){case"number":e.number=a0.numberCheck(A);e.luhn=e.number;e.valid=e.valid&&e.number;break;case"expiryYear":case"year":e.year=a0.yearCheck(A);e.expiryYear=e.year;e.valid=e.valid&&e.year;break;case"cvc":e.cvc=a0.cvcCheck(A);e.valid=e.valid&&e.cvc;break;case"expiryMonth":case"month":e.month=a0.monthCheck(A);e.expiryMonth=e.month;e.valid=e.valid&&e.month;break;case"holderName":e.holderName=a0.holderNameCheck(A);e.valid=e.valid&&e.holderName;break;case"generationtime":e.generationtime=a0.generationTimeCheck(A);e.valid=e.valid&&e.generationtime;break;default:e.unknown=e.unknown||[];e.unknown.push(y);e.valid=false}}return e};a4.prototype.monitor=function(q,e){if(typeof q!=="string"||(q!=="number"&&q!=="cvc"&&q!=="holderName")){throw new Error("invalid fieldname. Expected 'number', 'cvc' or 'holderName', but received '"+q+"'")}p("bind",e,q)};var bn=function(){};bn.prototype={constructor:bn,key:function(){this._key=this._key||k.random.randomWords(8,6);return this._key},encrypt:function(e){return this.encryptWithIv(e,k.random.randomWords(3,6))},encryptWithIv:function(z,q){var t,u,e,y;t=new k.cipher.aes(this.key());u=k.codec.utf8String.toBits(z);e=k.mode.ccm.encrypt(t,u,q);y=k.bitArray.concat(q,e);return k.codec.base64.fromBits(y)}}})(this,typeof define==="function"?define:null);