/* * * 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_19 * Author: ADYEN (c) 2014 */ (function(bd,aw){var ax,ap,T=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)+aV.charAt(u&63)}if(q+1==y.length){u=parseInt(y.substring(q,q+1),16);t+=aV.charAt(u<<2)}else{if(q+2==y.length){u=parseInt(y.substring(q,q+2),16);t+=aV.charAt(u>>2)+aV.charAt((u&3)<<4)}}while((t.length&3)>0){t+=aQ}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+=bp((q<<2)|(v>>4));q=v&15;t=2}else{if(t==2){z+=bp(q);z+=bp(v>>2);q=v&3;t=3}else{z+=bp((q<<2)|(v>>4));z+=bp(v&15);t=0}}}}if(t==1){z+=bp(q<<2)}return z}function aI(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 bo(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 bn(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(aU&&(navigator.appName=="Microsoft Internet Explorer")){bh.prototype.am=bo;bl=30}else{if(aU&&(navigator.appName!="Netscape")){bh.prototype.am=c;bl=26}else{bh.prototype.am=bn;bl=28}}bh.prototype.DB=bl;bh.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 U(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:X(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=bp(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+=bp(t)}}}return q?y:"0"}function au(){var e=m();bh.ZERO.subTo(this,e);return e}function ba(){return(this.s<0)?this.negate():this}function ae(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 R(){if(this.t<=0){return 0}return this.DB*(this.t-1)+o(this[this.t-1]^(this.s&this.DM))}function bg(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 aS(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 aa(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 ab(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 br=M[E-1];if(br==0){return}var F=br*(1<1)?M[E-2]>>this.F2:0);var D=this.FV/F,e=(1<=0){K[K.t++]=1;K.subTo(L,K)}bh.ONE.dlShiftTo(E,L);L.subTo(M,M);while(M.t=0){var bq=(K[--B]==br)?this.DM:Math.floor(K[B]*D+(K[B-1]+q)*e);if((K[B]+=M.am(0,bq,K,C,0,E))0){K.rShiftTo(y,K)}if(bs<0){bh.ZERO.subTo(K,K)}}function an(e){var q=m();this.abs().divRemTo(e,null,q);if(this.s<0&&q.compareTo(bh.ZERO)>0){e.subTo(q,q)}return q}function ak(e){this.m=e}function aM(e){if(e.s<0||e.compareTo(this.m)>=0){return e.mod(this.m)}else{return e}}function a9(e){return e}function ai(e){e.divRemTo(this.m,null,e)}function af(q,t,e){q.multiplyTo(t,e);this.reduce(e)}function bj(q,e){q.squareTo(e);this.reduce(e)}ak.prototype.convert=aM;ak.prototype.revert=a9;ak.prototype.reduce=ai;ak.prototype.mulTo=af;ak.prototype.sqrTo=bj;function Y(){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 a8(q){var e=m();q.abs().dlShiftTo(this.m.t,e);e.divRemTo(this.m,null,e);if(q.s<0&&e.compareTo(bh.ZERO)>0){this.m.subTo(e,e)}return e}function bi(q){var e=m();q.copyTo(e);this.reduce(e);return e}function ar(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 bb(q,e){q.squareTo(e);this.reduce(e)}function W(q,t,e){q.multiplyTo(t,e);this.reduce(e)}j.prototype.convert=a8;j.prototype.revert=bi;j.prototype.reduce=ar;j.prototype.mulTo=W;j.prototype.sqrTo=bb;function n(){return((this.t>0)?(this[0]&1):this.s)==0}function V(u,t){if(u>4294967295||u<1){return bh.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 bc(e,q){var t;if(e<256||q.isEven()){t=new ak(q)}else{t=new j(q)}return this.exp(e,t)}bh.prototype.copyTo=aT;bh.prototype.fromInt=x;bh.prototype.fromString=U;bh.prototype.clamp=ao;bh.prototype.dlShiftTo=bg;bh.prototype.drShiftTo=aS;bh.prototype.lShiftTo=Q;bh.prototype.rShiftTo=s;bh.prototype.subTo=aX;bh.prototype.multiplyTo=aa;bh.prototype.squareTo=at;bh.prototype.divRemTo=ab;bh.prototype.invDigit=Y;bh.prototype.isEven=n;bh.prototype.exp=V;bh.prototype.toString=P;bh.prototype.negate=au;bh.prototype.abs=ba;bh.prototype.compareTo=ae;bh.prototype.bitLength=R;bh.prototype.mod=an;bh.prototype.modPowInt=bc;bh.ZERO=f(0);bh.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 be(){return new r}r.prototype.init=h;r.prototype.next=b;var am=256;var w;var aA;var aY;function g(e){aA[aY++]^=e&255;aA[aY++]^=(e>>8)&255;aA[aY++]^=(e>>16)&255;aA[aY++]^=(e>>24)&255;if(aY>=am){aY-=am}}function az(){g(new Date().getTime())}if(aA==null){aA=[];aY=0;var ah;try{if(window.crypto&&window.crypto.getRandomValues){var av=new Uint8Array(32);window.crypto.getRandomValues(av);for(ah=0;ah<32;++ah){aA[aY++]=av[ah]}}else{if(window.msCrypto&&window.msCrypto.getRandomValues){var av=new Uint8Array(32);window.msCrypto.getRandomValues(av);for(ah=0;ah<32;++ah){aA[aY++]=av[ah]}}else{if(window.crypto&&window.crypto.random){var ac=window.crypto.random(32);for(ah=0;ah>>8;aA[aY++]=ah&255}aY=0;az()}function Z(){if(w==null){az();w=be();w.init(aA);for(aY=0;aY=0&&t>0){u[--t]=A[y--]}u[--t]=0;var z=new a0();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 bh(u)}function al(){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 aR(e){return e.modPowInt(this.e,this.n)}function O(q){var t=a4(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 a1(e)}else{return null}}al.prototype.doPublic=aR;al.prototype.setPublic=N;al.prototype.encrypt=O;al.prototype.encrypt_b64=i;"use strict";function aj(e){throw e}var ah=void 0,ag=!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 ax&&ax([],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)&&aj(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 ad(this,e,0)},decrypt:function(e){return ad(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 ad(K,L,e){4!==L.length&&aj(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===ah?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 ag}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&&aj(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){ac(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;){ac(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 ac(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&&aj(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&&aj(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)||aj(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(ag,u,e,A,z,B);q.equal(u.tag,y)||aj(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)&&aj(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===ah&&(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&&aj(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&&aN("seeded",Math.max(this.j,this.d)),aN("progress",this.getProgress()))},isReady:function(e){e=this.I[e!==ah?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:aL(this,this.aa),mouseCollector:aL(this,this.ba),keyboardCollector:aL(this,this.$),accelerometerCollector:aL(this,this.U)},window.addEventListener?(window.addEventListener("load",this.a.loadTimeCollector,ag),window.addEventListener("mousemove",this.a.mouseCollector,ag),window.addEventListener("keypress",this.a.keyboardCollector,ag),window.addEventListener("devicemotion",this.a.accelerometerCollector,ag)):document.attachEvent?(document.attachEvent("onload",this.a.loadTimeCollector),document.attachEvent("onmousemove",this.a.mouseCollector),document.attachEvent("keypress",this.a.keyboardCollector)):aj(new k.exception.bug("can't attach event")),this.q=!0)},stopCollectors:function(){this.q&&(window.removeEventListener?(window.removeEventListener("load",this.a.loadTimeCollector,ag),window.removeEventListener("mousemove",this.a.mouseCollector,ag),window.removeEventListener("keypress",this.a.keyboardCollector,ag),window.removeEventListener("devicemotion",this.a.accelerometerCollector,ag)):document.detachEvent&&(document.detachEvent("onload",this.a.loadTimeCollector),document.detachEvent("onmousemove",this.a.mouseCollector),document.detachEvent("keypress",this.a.keyboardCollector)),this.q=ag)},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 aL(e,q){return function(){q.apply(e,arguments)}}k.random=new k.prng(6);a:try{var aJ,aH,aG,aF;if(aF="undefined"!==typeof module){var aE;if(aE=module.exports){var aD;try{aD=require("crypto")}catch(aC){aD=null}aE=(aH=aD)&&aH.randomBytes}aF=aE}if(aF){aJ=aH.randomBytes(128),aJ=new Uint32Array((new Uint8Array(aJ)).buffer),k.random.addEntropy(aJ,1024,"crypto['randomBytes']")}else{if("undefined"!==typeof window&&"undefined"!==typeof Uint32Array){aG=new Uint32Array(32);if(window.crypto&&window.crypto.getRandomValues){window.crypto.getRandomValues(aG)}else{if(window.msCrypto&&window.msCrypto.getRandomValues){window.msCrypto.getRandomValues(aG)}else{break a}}k.random.addEntropy(aG,1024,"crypto['getRandomValues']")}}}catch(aB){"undefined"!==typeof window&&window.console&&(console.log("There was an error collecting entropy from the browser:"),console.log(aB))}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",br="Par",bq=M.length;var G=0;while(B&&B!==B.documentElement){G++;var C=bq,I,D,H=(B.nodeName||B.tagName||"").toUpperCase().substring(0,3);while(C--){I=M[C];if(B[name]){I=I+((B===F)?E:br)+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:br)+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 ay=bd.adyen=bd.adyen||{};var a6=ay.encrypt=ay.encrypt||{createEncryption:function(q,e){return new a3(q,e)}};if(typeof aw==="function"&&aw.amd){aw("adyen/encrypt",[],function(){return a6})}else{if(typeof module!=="undefined"&&module.exports){module.exports=a6}}a6.errors=a6.errors||{};a6.version="0_1_19";var aZ={};aZ.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]}})();aZ.numberCheck=function(e){return((e||"").replace(/[^\d]/g,"").match(/^\d{10,20}$/)&&aZ.luhnCheck(e))?true:false};aZ.cvcCheck=function(e){return(e&&e.match&&e.match(/^\d{3,4}$/))?true:false};aZ.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};aZ.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};aZ.holderNameCheck=function(e){return(e&&e.match&&e.match(/\S/))?true:false};aZ.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};aZ.generationTimeValidTime=function(t){if(typeof t!=="string"){return false}var q=/(Z|[\+\-][012345][0-9]:?[012345][0-9])$/;if(!t.match(q)){return false}var e=t.replace(q,"").replace(/\.\d{3}$/,"");return e.match(/^[012345][0-9]:?[012345][0-9]:?[012345][0-9]$/)};aZ.generationTimeCheck=function(q){if(typeof q!=="string"){return false}var e=q.split("T");return(e.length===2&&aZ.generationTimeValidDate(e[0])&&aZ.generationTimeValidTime(e[1]))?true:false};var a3=function(u,t){try{k.random.startCollectors()}catch(y){}try{T()}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")};a3.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 al();t.setPublic(q,u);return t};a3.prototype.createAESKey=function(){return new bm()};a3.prototype.encrypt=function(q){var t={};for(var u in q){if(q.hasOwnProperty(u)){t[u]=q[u]}}var B,F,C,E,A,z,y={};if(typeof t.number!=="undefined"){y.number=t.number}if(typeof t.cvc!=="undefined"){y.cvc=t.cvc}if(typeof t.expiryMonth!=="undefined"){y.month=t.expiryMonth}if(typeof t.expiryYear!=="undefined"){y.year=t.expiryYear}if(typeof t.holderName!=="undefined"){y.holderName=t.holderName}if(typeof t.generationtime!=="undefined"){y.generationtime=t.generationtime}if(this.options.enableValidations!==false&&this.validate(y).valid===false){return false}p("extend",t);try{t.dfValue=T()}catch(D){}B=this.createRSAKey();F=this.createAESKey();C=F.encrypt(JSON.stringify(t));E=k.codec.bytes.fromBits(F.key);A=B.encrypt_b64(E);z="adyenjs_"+a6.version+"$";return[z,A,"$",C].join("")};a3.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=aZ.numberCheck(A);e.luhn=e.number;e.valid=e.valid&&e.number;break;case"expiryYear":case"year":e.year=aZ.yearCheck(A);e.expiryYear=e.year;e.valid=e.valid&&e.year;break;case"cvc":e.cvc=aZ.cvcCheck(A);e.valid=e.valid&&e.cvc;break;case"expiryMonth":case"month":e.month=aZ.monthCheck(A);e.expiryMonth=e.month;e.valid=e.valid&&e.month;break;case"holderName":e.holderName=aZ.holderNameCheck(A);e.valid=e.valid&&e.holderName;break;case"generationtime":e.generationtime=aZ.generationTimeCheck(A);e.valid=e.valid&&e.generationtime;break;default:e.unknown=e.unknown||[];e.unknown.push(y);e.valid=false}}return e};var bm=function(){};bm.prototype={constructor:bm,key:k.random.randomWords(8,0),encrypt:function(e){return this.encryptWithIv(e,k.random.randomWords(3,0))},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);