diff --git a/lib/msrcrypto.js b/lib/msrcrypto.js index d71cf15..772c5be 100644 --- a/lib/msrcrypto.js +++ b/lib/msrcrypto.js @@ -17,7 +17,7 @@ //******************************************************************************* "use strict"; -var msrCryptoVersion = "1.6.3"; +var msrCryptoVersion = "1.6.4"; (function(root, factory) { @@ -7333,8 +7333,8 @@ var msrCryptoVersion = "1.6.3"; }; - operations.register("deriveKey", "concat", msrcryptoKdf.deriveKey); - operations.register("deriveBits", "concat", msrcryptoKdf.deriveBits); + operations.register("deriveKey", "CONCAT", msrcryptoKdf.deriveKey); + operations.register("deriveBits", "CONCAT", msrcryptoKdf.deriveBits); } diff --git a/lib/msrcrypto.min.js b/lib/msrcrypto.min.js index 9904bd3..6a9a3cc 100644 --- a/lib/msrcrypto.min.js +++ b/lib/msrcrypto.min.js @@ -15,4 +15,4 @@ // limitations under the License. // //******************************************************************************* -"use strict";var msrCryptoVersion="1.6.3";!function(e,r){"function"==typeof define&&define.amd?define([],function(){return e.msrCrypto=r(e)}):"object"==typeof exports?module.exports=r(e):e.msrCrypto=r(e)}(this,function(e){e=e||{};return function(){var r={register:function(e,t,n){r[e]||(r[e]={});var o=r[e];o[t]||(o[t]=n)},exists:function(e,t){return!!r[e]&&!!r[e][t]}},t=function(){if("undefined"!=typeof document)try{throw new Error}catch(r){if(r.stack){var e=/\w+:\/\/(.+?\/)*.+\.js/.exec(r.stack);return e&&e.length>0?e[0]:null}}else if("undefined"!=typeof self)return self.location.href;return null}(),n="undefined"!=typeof Worker,o="function"==typeof importScripts&&self instanceof WorkerGlobalScope,a=!1,u="undefined"!=typeof ArrayBuffer,s=function(){try{return Object.defineProperty({},"oncomplete",{}),!0}catch(e){return!1}}(),c=!1,l=function(e,r,t,n,o){if(s){var i={};n&&(i.get=n),o&&(i.set=o),Object.defineProperty(e,r,i)}else e[r]=t},f={},h=function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function r(r){for(r=r.replace(/-/g,"+").replace(/_/g,"/");r.length%4!=0;)r+="=";var t,n,o,i,a,u,s,c=[];for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,""),s=0;s>4,n=(15&i)<<4|(a=e.indexOf(r.charAt(s+2)))>>2,o=(3&a)<<6|(u=e.indexOf(r.charAt(s+3))),c.push(t),64!==a&&c.push(n),64!==u&&c.push(o);return c}function t(e){return Object.prototype.toString.call(e).slice(8,-1)}function n(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e]}function o(e){if(!e)return[];if(e.pop)return e;if("ArrayBuffer"===t(e)?e=new Uint8Array(e):e.BYTES_PER_ELEMENT>1&&(e=new Uint8Array(e.buffer)),1===e.length)return[e[0]];if(e.length<65536)return Array.apply(null,e);for(var r=new Array(e.length),n=0;n>2,l=(3&a)<<4|(u=p[y+1])>>4,f=(15&u)<<2|(s=p[y+2])>>6,h=63&s,isNaN(u)?f=h=64:isNaN(s)&&(h=64),g=g+e.charAt(c)+e.charAt(l)+e.charAt(f)+e.charAt(h);return n?g.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,""):g},fromBase64:r,checkParam:function(e,r,n){if(!e)throw new Error(n);if(r&&t(e)!==r)throw new Error(n);return!0},getObjectType:t,bytesToHexString:function(e,r){var t="";void 0===r&&(r=!1);for(var n=0;n>>6|192,r[n++]=63&o|128):o<55296||o>57343?(r[n++]=o>>>12|224,r[n++]=o>>>6&63|128,r[n++]=63&o|128):(o=1024*(o-55296)+(e.charCodeAt(++t)-56320)+65536,r[n++]=o>>>18|240,r[n++]=o>>>12&63|128,r[n++]=o>>>6&63|128,r[n++]=63&o|128)}return r},bytesToString:function(e){var r,t="";e=o(e);for(var n=0;n65535){var a=Math.floor((r-65536)/1024)+55296,u=(r-65536)%1024+56320;t+=String.fromCharCode(a,u)}else t+=String.fromCharCode(r)}return t},unpackData:function(e,t,n){var o,i=r(e),a=[];if(isNaN(t))return i;for(o=0;o=2;)r.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return r},int32ToBytes:n,int32ArrayToBytes:function(e){for(var r=[],t=0;t255)return!1;return!0}}}(),y=(p={0:"CUSTOM",1:"BOOLEAN",2:"INTEGER",3:"BIT STRING",4:"OCTET STRING",5:"NULL",6:"OBJECT IDENTIFIER",16:"SEQUENCE",17:"SET",19:"PRINTABLE STRING",23:"UTCTime"},{parse:function e(r,t){t=!!t;var n,o,i,a=p[31&r[0]],u=r[1],s=0,c=!!(32&r[0]);if(128&u)for(s=0,u=0;s<(127&r[1]);s++)u=(u<<8)+r[2+s];if(i=2+s,void 0===a||u>r.length)return null;var l=c?[]:{};if(l.type=a,l.header=i,l.data=r.slice(0,u+i),c||t)for("BIT STRING"===l.type&&0===r[i]&&s++,n=r.slice(i,l.data.length);n.length>0&&null!==(o=e(n));)l.push(o),n=n.slice(o.data.length);return l},encode:function(e){throw new Error("not implemented")},toString:function(e){return function e(r,t){var n=new Array(t+1).join(" ")+r.type+" ("+r.length+") "+bytesToHexString(r.data).substring(0,16)+"\n";if(!r.children)return n;for(var o=0;o0;)t[n+o]=e[r+o]}function h(e){var r,t=0;for(r=0;r=0;c--)i+=a[s++]*(255&e[c]),a[s]===n&&(s=0,o[u++]=i,i=0);for(0!==i&&(o[u]=i);null==o[--t];)o[t]=0;return o}function g(r,t){if(void 0===t)if(r<=1)t=1;else{var o=Math.log(r)/Math.LN2;t=Math.ceil(o/e)}for(var i=[];r>0;)i.push(r%n),r=Math.floor(r/n);for(;i.length=0;r--)if(void 0!==e[r]&&0!==e[r])return r;return 0===e[0]?-1:0}function d(e,r){var t,n,o=0;for(n=0;n=e||o<0)throw new Error("bit count must be smaller than DIGIT_BITS and positive in shiftLeft");void 0===i&&(i=r.length);var a=e-o;n[i]=r[i-1]>>>e-o||n[i];for(var u=i-1;u>0;u--)n[u]=(r[u]<>>a)&t;n[0]=r[0]<>=e;for(u=s;u>=e;return o.length=a.length,0!==c&&(o[u]=c&t),c}function k(r,n,o){var i=n.length;if(r.length>=e;for(;a>=e;return u}function E(e,r,n){r="number"==typeof r?[r]:r;var o,a,u,s,c,l,f,h,y=e.length,g=r.length;for(o=0;o=0;v--)y=l*n+r[v],i[v]=y/g&t,l=y-i[v]*g&t;return i.length=b,m(i),a[0]=l,void(a.length=1)}var E=e-1-function(r){for(var t=0,n=0;n>>n&1)&n);return t}(o[k-1]),x=u||[];x.length=k,w(o,x,E,k);var S=s||[];for(S.length=b,w(r,S,E,b),S[b]=S[b]||0,i.length=b-k+1,a.length=k,v=b-k;v>=0;v--){for(c=Math.floor((S[v+k]*n+S[v+k-1])/x[k-1]),l=S[v+k]*n+S[v+k-1]-c*x[k-1];(c>=n||c*x[k-2]>l*n+S[v+k-2])&&(c-=1,(l+=x[k-1])>e;S[v+k]=S[v+k]+h&t}}for(d=0;d>>E|S[d+1]<0);v.subtract(n,d,o.temp2),s(S,n,o.temp2)}function u(e,r,t){var n,o,i,a,u;for(n=0;n>>=1)u===t&&(c[++s]=0,u=0),c[s]+=(1&n)<>>31,a=0;a0),v.subtract(r,c,f),s(u,r,f),m(r)},ctx:n}}return{DIGIT_BITS:e,DIGIT_NUM_BYTES:r,DIGIT_MASK:t,DIGIT_BASE:n,DIGIT_MAX:o,Zero:s,One:c,normalizeDigitArray:m,bytesToDigits:y,stringToDigits:function(e,r){e=e.replace(/^\s+|\s+$/g,"");var t=[0],n=[0];r=r||10;for(var o=0;o=r;)c[0]=c[0]*r,h=h.concat("0");for(t=0;tn&&0===u[0];)u.shift();return u},isZero:h,isEven:function(e){return 0==(1&e[0])},shiftRight:function(r,n,o,i){if(void 0===o)o=1;else if(o>=e||o<0)throw new Error("Invalid bit count for shiftRight");void 0===i&&(i=r.length);for(var a=i-1,u=e-o,s=0;s>>o)&t;n[a]=r[a]>>>o},shiftLeft:w,compareDigits:d,bitLength:function(e){for(var r=0,t=0;r=0&&0===t;){var o=1<=0)throw new Error("The number provided is not an element of this group");return m(r,this.m_digitWidth,!0),c(r,this)},createElementFromDigits:function(e){return v.normalizeDigitArray(e,this.m_digitWidth,!0),c(e,this)},equals:function(e){return 0===d(this.m_modulus,e.m_modulus)},add:function(r,n,o){var i,a=this.m_digitWidth,u=o.m_digits;v.add(r.m_digits,n.m_digits,u);var s=(d(u,this.m_modulus)>>>31)-1&t,c=0;for(i=0;i>=e;u.length=a},subtract:function(r,n,o){var i,a=this.m_digitWidth,u=o.m_digits,s=v.subtract(r.m_digits,n.m_digits,o.m_digits);if(-1===s)for(s=0,i=0;i>=e},multiply:function(e,r,t){return v.modMul(e.m_digits,r.m_digits,this.m_modulus,t.m_digits,u,s)},inverse:function(e,r){v.modInv(e.m_digits,this.m_modulus,r.m_digits)},modexp:function(e,r,t){if(t=t||c([],this),0===d(r,i))t.m_digits=g(1,this.m_digitWidth);else if(0===d(r,a)){for(var n=0;n0&&(n=r,o=e),S(n,o,void 0,void 0,t),m(t)},sequenceEqual:function(e,r){for(var t=e.length===r.length,n=0;n=0;){for(var o=0;o<8;){var i=1<>>=v.DIGIT_BITS;i<<=v.DIGIT_BITS-1,v.shiftRight(t,t),t[n-1]|=i}else v.shiftRight(r,t)}function T(e,r,t){o.montgomeryMultiply(e,r,t)}function I(e,r){o.montgomeryMultiply(e,e,r)}function K(e,r){var t=r.clone();if(R(t),!N(t))throw new Error("Invalid Parameter");var n=r.clone();q(n);var o,i=[r.clone()],a=n.clone(),u=n.clone();C(n,u),U(u);for(var s=1;s=0)throw new Error("The scalar k must be in the range 1 <= k < order.");if(r=r.slice(),1===t.curve.type){var a=void 0!==t.ta;a||L(t),function(e,r,t,o){if(!O(r))throw new Error("Invalid Parameter");var i=r.curve.rbits;o=void 0===o||o;var a,u,s=n<=8?5:6,c=Math.floor((i+(s-2))/(s-1));e=e.slice();var l=r.clone();L(l),o&&(G(l,l),G(l,l));var f=j(1<=0;a--){for(u=0;u>>31);A(r.curve.p,m.x,y);for(var b=0;b=0;g--){for(var p=0;p>>31),w=0;w=o&&(l=y(l))},finish:g,der:r,hashLen:a,maxMessageSize:4294967295}},M=function(){function e(e,t,n,o,i){var a,u,s,c,l=4294967295,f=n[0],h=n[1],y=n[2],g=n[3],p=n[4];for(u=0;u<16;u++)i[u]=r.bytesToInt32(e,64*t+4*u);for(a=16;a<80;a++)c=i[a-3]^i[a-8]^i[a-14]^i[a-16],i[a]=c<<1|c>>>31;for(u=0;u<80;u++)s=f<<5|f>>>27,s+=u>=60?h^y^g:u>=40?h&y^h&g^y&g:u>=20?h^y^g:h&y^~h&g,s+=p+o[u]+i[u],p=g,g=y,y=h<<30|h>>>2,h=f,f=s;return n[0]+=f&l,n[1]+=h&l,n[2]+=y&l,n[3]+=g&l,n[4]+=p&l,n}var r=h,t=r.unpackData,n=t("Z0UjAe/Nq4mYutz+EDJUdsPS4fA=",4,1),o=t("WoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroY8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdY",4,1),i=t("MCEwCQYFKw4DAhoFAAQU");return{sha1:function(){return A("SHA-1",i,n,o,64,e,160)}}}();void 0!==r&&(M.instances={},M.getInstance=function(e){return M.instances[e]||(M.instances[e]=M.sha1())},M.deleteInstance=function(e){M.instances[e]=null,delete M.instances[e]},M.hash=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?M.sha1.finish():M.sha1().computeHash(e.buffer);M.sha1.process(e.buffer)},r.register("digest","SHA-1",M.hash)),f["SHA-1"]=M.sha1;var D=function(){var e=h;function r(r,t,n,o,i){var a,u,s,c,l,f=n[0],h=n[1],y=n[2],g=n[3],p=n[4],d=n[5],v=n[6],m=n[7];for(u=0;u<16;u++)i[u]=e.bytesToInt32(r,64*t+4*u);for(a=16;a<64;a++)c=i[a-15],l=i[a-2],i[a]=((l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10)+i[a-7]+((c>>>7|c<<25)^(c>>>18|c<<14)^c>>>3)+i[a-16],i[a]=4294967295&i[a];for(u=0;u<64;u++)g+=s=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&d^~p&v)+o[u]+i[u],s+=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&(h^y)^h&y),m=v,v=d,d=p,p=g,g=y,y=h,h=f,f=s;return n[0]=n[0]+f>>>0,n[1]=n[1]+h>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+g>>>0,n[4]=n[4]+p>>>0,n[5]=n[5]+d>>>0,n[6]=n[6]+v>>>0,n[7]=n[7]+m>>>0,n}var t,n,o,i,a,u=e.unpackData;return n=u("wQWe2DZ81QcwcN0X9w5ZOf/ACzFoWBURZPmPp776T6Q",4,1),o=u("agnmZ7tnroU8bvNypU/1OlEOUn+bBWiMH4PZq1vgzRk",4,1),t=u("QoovmHE3RJG1wPvP6bXbpTlWwltZ8RHxkj+CpKscXtXYB6qYEoNbASQxhb5VDH3Dcr5ddIDesf6b3AanwZvxdOSbacHvvkeGD8GdxiQMocwt6SxvSnSEqlywqdx2+YjamD5RUqgxxm2wAyfIv1l/x8bgC/PVp5FHBspjURQpKWcntwqFLhshOE0sbfxTOA0TZQpzVHZqCruBwskuknIshaK/6KGoGmZLwkuLcMdsUaPRkugZ1pkGJPQONYUQaqBwGaTBFh43bAgnSHdMNLC8tTkcDLNO2KpKW5zKT2gub/N0j4LueKVjb4TIeBSMxwIIkL7/+qRQbOu++aP3xnF48g",4,1),i=u("MC0wDQYJYIZIAWUDBAIEBQAEHA"),a=u("MDEwDQYJYIZIAWUDBAIBBQAEIA"),{sha224:function(){return A("SHA-224",i,n,t,64,r,224)},sha256:function(){return A("SHA-256",a,o,t,64,r,256)}}}();void 0!==r&&(D.instance224=D.instance224||D.sha224(),D.instance256=D.instance256||D.sha256(),D.instances={},D.getInstance224=function(e){return D.instances[e]||(D.instances[e]=D.sha224())},D.getInstance256=function(e){return D.instances[e]||(D.instances[e]=D.sha256())},D.deleteInstance=function(e){D.instances[e]=null,delete D.instances[e]},D.hash256=function(e){if("process"===e.operationSubType)return D.getInstance256(e.workerid).process(e.buffer),null;if("finish"===e.operationSubType){var r=D.getInstance256(e.workerid).finish();return D.deleteInstance(e.workerid),r}if("abort"!==e.operationSubType)return D.instance256.computeHash(e.buffer);D.deleteInstance(e.workerid)},D.hash224=function(e){if("process"!==e.operationSubType){if("finish"===e.operationSubType&&D.getInstance224(e.workerid).finish(),"abort"!==e.operationSubType)return D.instance224.computeHash(e.buffer);msrcryptoSha224.deleteInstance(e.workerid)}else D.getInstance224(e.workerid).process(e.buffer)},r.register("digest","SHA-224",D.hash224),r.register("digest","SHA-256",D.hash256)),f["SHA-224"]=D.sha224,f["SHA-256"]=D.sha256;var T=function(){function e(e,r,t,n,o){var i=r+n|0,a=i>>>0>>0;o[0]=e+t+a|0,o[1]=i}function r(r,t,n,o,i){var a,u,s,c,l,f,h,y,g,p=[],d=[],v=[],m=n[0],w=n[1],b=n[2],k=n[3],E=n[4],x=n[5],S=n[6],A=n[7],M=n[8],D=n[9],T=n[10],I=n[11],K=n[12],C=n[13],H=n[14],P=n[15];for(a=0;a<32;a++)g=128*t+4*a,i[a]=r.slice(g,g+4),i[a]=i[a][0]<<24|i[a][1]<<16|i[a][2]<<8|i[a][3];for(a=32;a<160;a+=2)s=((h=i[a-30])>>>1|(y=i[a-29])<<31)^(h>>>8|y<<24)^h>>>7,c=(y>>>1|h<<31)^(y>>>8|h<<24)^(y>>>7|h<<25),e(l=((h=i[a-4])>>>19|(y=i[a-3])<<13)^(y>>>29|h<<3)^h>>>6,f=(y>>>19|h<<13)^(h>>>29|y<<3)^(y>>>6|h<<26),i[a-14],i[a-13],p),e(s,c,p[0],p[1],p),e(i[a-32],i[a-31],p[0],p[1],p),i[a]=p[0],i[a+1]=p[1];for(u=0;u<160;u+=2)l=M&T^K&~M,f=D&I^C&~D,e(H,P,s=(M>>>14|D<<18)^(M>>>18|D<<14)^(D>>>9|M<<23),c=(D>>>14|M<<18)^(D>>>18|M<<14)^(M>>>9|D<<23),p),e(l,f,o[u],o[u+1],d),e(p[0],p[1],i[u],i[u+1],v),e(d[0],d[1],v[0],v[1],v),e(v[0],v[1],S,A,p),S=p[0],A=p[1],f=w&(k^x)^k&x,l=m&(b^E)^b&E,e(v[0],v[1],s=(m>>>28|w<<4)^(w>>>2|m<<30)^(w>>>7|m<<25),c=(w>>>28|m<<4)^(m>>>2|w<<30)^(m>>>7|w<<25),p),e(l,f,s=p[0],c=p[1],p),H=K,P=C,K=T,C=I,T=M,I=D,M=S,D=A,S=E,A=x,E=b,x=k,b=m,k=w,m=s=p[0],w=c=p[1];return e(n[0],n[1],m,w,p),n[0]=p[0],n[1]=p[1],e(n[2],n[3],b,k,p),n[2]=p[0],n[3]=p[1],e(n[4],n[5],E,x,p),n[4]=p[0],n[5]=p[1],e(n[6],n[7],S,A,p),n[6]=p[0],n[7]=p[1],e(n[8],n[9],M,D,p),n[8]=p[0],n[9]=p[1],e(n[10],n[11],T,I,p),n[10]=p[0],n[11]=p[1],e(n[12],n[13],K,C,p),n[12]=p[0],n[13]=p[1],e(n[14],n[15],H,P,p),n[14]=p[0],n[15]=p[1],n}var t,n,o,i,a,u,s,c=h.unpackData;return t=c("y7udXcEFnthimikqNnzVB5FZAVowcN0XFS/s2PcOWTlnMyZn/8ALMY60SodoWBUR2wwuDWT5j6dHtUgdvvpPpA==",4,1),n=c("agnmZ/O8yQi7Z66FhMqnOzxu83L+lPgrpU/1Ol8dNvFRDlJ/reaC0ZsFaIwrPmwfH4PZq/tBvWtb4M0ZE34heQ",4,1),o=c("QoovmNcoriJxN0SRI+9lzbXA+8/sTTsv6bXbpYGJ27w5VsJb80i1OFnxEfG2BdAZkj+CpK8ZT5urHF7V2m2BGNgHqpijAwJCEoNbAUVwb74kMYW+TuSyjFUMfcPV/7Ticr5ddPJ7iW+A3rH+OxaWsZvcBqclxxI1wZvxdM9pJpTkm2nBnvFK0u++R4Y4TyXjD8GdxouM1bUkDKHMd6ycZS3pLG9ZKwJ1SnSEqm6m5INcsKncvUH71Hb5iNqDEVO1mD5RUu5m36uoMcZtLbQyELADJ8iY+yE/v1l/x77vDuTG4AvzPaiPwtWnkUeTCqclBspjUeADgm8UKSlnCg5ucCe3CoVG0i/8LhshOFwmySZNLG38WsQq7VM4DROdlbPfZQpzVIuvY952agq7PHeyqIHCyS5H7a7mknIshRSCNTuiv+ihTPEDZKgaZku8QjABwkuLcND4l5HHbFGjBlS+MNGS6BnW71IY1pkGJFVlqRD0DjWFV3EgKhBqoHAyu9G4GaTBFrjS0MgeN2wIUUGrUydId0zfjuuZNLC8teGbSKg5HAyzxclaY07YqkrjQYrLW5zKT3dj43NoLm/z1rK4o3SPgu5d77L8eKVjb0MXL2CEyHgUofCrcozHAggaZDnskL7/+iNjHiikUGzr3oK96b75o/eyxnkVxnF48uNyUyvKJz7O6iZhnNGGuMchwMIH6tp91s3g6x71fU9/7m7ReAbwZ6pyF2+6CmN9xaLImKYRP5gEvvkNrhtxCzUTHEcbKNt39SMEfYQyyqt7QMckkzyevgoVyb68Qx1nxJwQDUxMxdS+yz5Ctll/KZz8ZX4qX8tvqzrW+uxsRBmMSkdYFw==",4,1),i=c("MEEwDQYJYIZIAWUDBAICBQAEMA"),a=c("MFEwDQYJYIZIAWUDBAIDBQAEQA"),u=c("MC0wDQYJYIZIAWUDBAIFBQAEHA"),s=c("MDEwDQYJYIZIAWUDBAIGBQAEIA"),{sha384:function(){return A("SHA-384",i,t,o,128,r,384)},sha512:function(){return A("SHA-512",a,n,o,128,r,512)},sha512_224:function(){return A("SHA-512.224",u,n,o,128,r,224)},sha512_256:function(){return A("SHA-512.256",s,n,o,128,r,256)}}}();void 0!==r&&(T.instances={},T.getInstance384=function(e){return T.instances[e]||(T.instances[e]=T.sha384())},T.getInstance512=function(e){return T.instances[e]||(T.instances[e]=T.sha512())},T.deleteInstance=function(e){T.instances[e]=null,delete T.instances[e]},T.hash384=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?T.sha384.finish():T.sha384().computeHash(e.buffer);T.sha384.process(e.buffer)},T.hash512=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?T.sha512.finish():T.sha512().computeHash(e.buffer);T.sha512.process(e.buffer)},r.register("digest","SHA-384",T.hash384),r.register("digest","SHA-512",T.hash512)),f["SHA-384"]=T.sha384,f["SHA-512"]=T.sha512;var I=function(e,r){var t,n,o,i,a,u={384:128,512:128}[r.name.replace(/SHA-/,"")]||64,s=e.length===u?e:e.length>u?l(r.computeHash(e),u):l(e,u);function c(e,r){for(var t=new Array(e),n=0;n6&&y%t==4&&f(r);var d=c(g(h,y-t),r);i=d,u=0,(o=h)[4*(a=y)]=i[4*u],o[4*a+1]=i[4*u+1],o[4*a+2]=i[4*u+2],o[4*a+3]=i[4*u+3],y+=1}return h}(e),{encrypt:function(e){var r,t=e;for(l(t,o,0),r=1;r<=n-1;r+=1)f(t),i(t),u(t),l(t,o,4*r*4);return f(t),i(t),l(t,o,4*n*4),t},decrypt:function(e){var r,t=e;for(l(t,o,4*n*4),r=n-1;r>=1;r-=1)a(t),y(t),l(t,o,4*r*4),s(t);return a(t),y(t),l(t,o,0),t},clear:function(){},keyLength:r,blockSize:128}}},j=j||{};j.pkcsv7=function(e){return{pad:function(r){var t=r[r.length-1>=0?r.length-1:0],n=t.length;if(n===e){var o,i=[];for(o=0;o>7-a%8&1)),n=0;n<16;n++)c[n]=c[n]^l[n]&t;t=255&-(1&l[15]),m(l),l[0]^=225&t}return c}function m(e){for(var r=e.length-1;r>0;r--)e[r]=(1&e[r-1])<<7|e[r]>>>1;return e[0]=e[0]>>>1,e}function w(e){for(var r=256,t=1;t<=4;t++)r=(r>>>8)+e[e.length-t],e[e.length-t]=255&r;return e}function b(r,t){var n,o=Math.ceil(t.length/16),i=[];a!==r&&(a=r.slice());for(var s=0;s>>24&255,e>>>16&255,e>>>8&255,255&e]}function E(){g=0,s=[],y=[],l=u.getVector(16),f=[],a=r=t=null}return{init:function(e,a,s){if(t=a||[],(n=isNaN(s)?128:s)%8!=0)throw new Error("DataError");if(12===(r=e).length)o=r.concat([0,0,0,1]);else{var f=16*Math.ceil(r.length/16)-r.length;o=p(c,r.concat(u.getVector(f+8)).concat(k(8*r.length))),l=u.getVector(16)}var h,y;i=w(o.slice()),p(c,(h=t,y=16*Math.ceil(t.length/16)-t.length,h.concat(u.getVector(y))))},encrypt:function(e){g=e.length;var r=b(i,e);p(c,r);var t=d(),a=b(o,t).slice(0,n/8);return E(),r.slice().concat(a)},decrypt:function(e,r){g=e.length;var t=b(i,e);p(c,e);var a=d(),s=b(o,a).slice(0,n/8);return E(),u.arraysEqual(s,r)?t:null},processEncrypt:function(e){var r=(s=s.concat(e)).slice(0,16*Math.floor(s.length/16));g+=r.length,s=s.slice(r.length);var t=b(a||i,r);y=y.concat(t),p(c,t)},processDecrypt:function(e){var r=(s=s.concat(e)).slice(0,16*Math.floor((s.length-n/8)/16));g+=r.length,s=s.slice(r.length);var t=b(a||i,r);y=y.concat(t),p(c,r)},finishEncrypt:function(){var e=b(a,s);y=y.concat(e),g+=s.length;var r=d(),t=b(o,r).slice(0,n/8),i=y.slice().concat(t);return E(),i},finishDecrypt:function(){var e=Math.floor(n/8),r=s.slice(-e);s=s.slice(0,s.length-e);var t=b(a,s);y=y.concat(t),g+=s.length;var i=d(),c=b(o,i).slice(0,n/8),l=y.slice();return E(),u.arraysEqual(c,r)?l:null}}};if(void 0!==r){var G={};V.encrypt=function(e){var r,t=e.workerid;if(G[t]||(G[t]=V(O.aes(e.keyData)),G[t].init(e.algorithm.iv,e.algorithm.additionalData,e.algorithm.tagLength)),"process"!==e.operationSubType)return"finish"===e.operationSubType?(r=G[t].finishEncrypt(),G[t]=null,r):(r=G[t].encrypt(e.buffer),G[t]=null,r);G[t].processEncrypt(e.buffer)},V.decrypt=function(e){var r,t=e.workerid;if(G[t]||(G[t]=V(O.aes(e.keyData)),G[t].init(e.algorithm.iv,e.algorithm.additionalData,e.algorithm.tagLength)),"process"!==e.operationSubType){if("finish"===e.operationSubType){if(r=G[t].finishDecrypt(),G[t]=null,null===r)throw new Error("OperationError");return r}var n=e.algorithm.tagLength?Math.floor(e.algorithm.tagLength/8):16,o=e.buffer.slice(0,e.buffer.length-n),i=e.buffer.slice(-n);if(r=G[t].decrypt(o,i),G[t]=null,null===r)throw new Error("OperationError");return r}G[t].processDecrypt(e.buffer)},V.generateKey=function(e){if(e.algorithm.length%8!=0)throw new Error;return{type:"keyGeneration",keyData:J.getBytes(Math.floor(e.algorithm.length/8)),keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:e.usages,type:"secret"}}},V.importKey=function(e){var r,t=8*e.keyData.length;if("jwk"===e.format)r=d.jwkToKey(e.keyData,e.algorithm,["k"]);else{if("raw"!==e.format)throw new Error("unsupported import format");if(128!==t&&192!==t&&256!==t)throw new Error("invalid key length (should be 128, 192, or 256 bits)");r={k:h.toArray(e.keyData)}}return{type:"keyImport",keyData:r.k,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||r.extractable,usages:e.usages,type:"secret"}}},V.exportKey=function(e){if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};if("raw"===e.format)return{type:"keyExport",keyHandle:e.keyData};throw new Error("unsupported export format")},r.register("importKey","AES-GCM",V.importKey),r.register("exportKey","AES-GCM",V.exportKey),r.register("generateKey","AES-GCM",V.generateKey),r.register("encrypt","AES-GCM",V.encrypt),r.register("decrypt","AES-GCM",V.decrypt)}function Z(){if(!(this instanceof Z))throw new Error("create MsrcryptoPrng object with new keyword");var e,r,t,n,o=!1,i=1,a=Math.pow(2,48);function u(e){var r;for(r=e.length-1;r>=0&&(e[r]+=1,e[r]>=256&&(e[r]=0),!e[r]);r-=1);}function s(){e=h.getVector(32),r=h.getVector(16),t=32,n=48,i=1}function c(e,r){if((r=r||[0]).length>n)throw new Error("Incorrect entropy or additionalEntropy length");r=r.concat(h.getVector(n-r.length)),e=e.concat(h.getVector((n-e.length%n)%n));for(var t=0;t=65536)throw new Error("too much random requested");if(i>a)throw new Error("Reseeding is required");if(o&&o.length>0){for(;o.length=0;)a=(u=a*f+n[i--])-(u/s|0)*s;r[o]=a}}function i(e,r){var t=e,n=[];v.subtract(t,[1],n);var o=function(e){var r,t=0,n=0;if(v.isZero(e))return 0;for(t=0;0===e[t];t++);for(n=0,r=2;e[t]%r==0;r*=2,n++);return t*v.DIGIT_BITS+n}(n),i=[];v.shiftRight(n,i,o);for(var u,s=function(e){var r=0,t=0,n=0;if(v.isZero(e))return 0;for(r=e.length-1;0===e[r];r--);for(n=1<<(t=v.DIGIT_BITS-1);t>0&&0==(e[r]&n);n>>>=1,t--);return r*v.DIGIT_BITS+t}(t),c=v.MontgomeryMultiplier(t),l=1;l<=r;l++){var f=!1;do{u=a(s)}while(v.compareDigits(u,n)>=0);var h=[];if(c.modExp(u,i,h,!0),0!==v.compareDigits(h,[1])&&0!==v.compareDigits(h,n)){for(var y=1;y>>24&255,i>>>16&255,i>>>8&255,255&i],o=t.computeHash(e.concat(n)),a=a.concat(o);return a.slice(0,r)},checkMessageVsMaxHash:function(e,r){if(e.length>(r.maxMessageSize||4294967295))throw new Error("message too long")}};(Q=Q||{}).oaep=function(e,r){var t=h,n=J,o=e.n.length;if(null===r)throw new Error("must supply hashFunction");return{pad:function(e,i){return function(e,i){var a,u,s,c,l,f,h,y,g;if(e.length>o-r.hashLen/8*2-2)throw new Error("Message too long.");return null==i&&(i=[]),a=r.computeHash(i),u=o-e.length-2*a.length-2,s=t.getVector(u),c=a.concat(s,[1],e),l=n.getBytes(a.length),f=X.mgf1(l,o-a.length-1,r),h=t.xorVectors(c,f),y=X.mgf1(h,a.length,r),g=t.xorVectors(l,y),e=[0].concat(g).concat(h).slice()}(e,i)},unpad:function(e,n){return function(e,n){var i,a,u,s,c,l,f,h,y=0,g=0===e[0];for(n||(n=[]),i=r.computeHash(n),a=e.slice(1,i.length+1),u=e.slice(i.length+1),s=X.mgf1(u,i.length,r),c=t.xorVectors(a,s),l=X.mgf1(c,o-i.length-1,r),h=(f=t.xorVectors(u,l)).slice(0,i.length),g=g&&t.arraysEqual(i,h),f=f.slice(i.length);!f[y++];);return{valid:g,data:f.slice(y)}}(e,n)}}},(Q=Q||{}).pkcs1Encrypt=function(e){var r=J,t=e.n.length;return{pad:function(e){return function(e){var n;if(e.length>t-11)throw new Error("message too long");return n=r.getNonZeroBytes(t-e.length-3),[0,2].concat(n,[0],e)}(e)},unpad:function(e){return function(e){var r,t=function(e){for(var r=0===e[0]&&2===e[1],t=2;t<10;t++)r=r&&!!e[t];return r}(e),n=0;for(r=1;r>>8-(8*u-a);for(var g=0;g0){var i=n;n=o,o=i}var a=[];v.multiply(n,o,a);var u=[];v.subtract(n,[1],u);var s=[];v.subtract(o,[1],s);var c=[];v.multiply(u,s,c);var l=[];v.gcd(t,c,l);var f=0===v.compareDigits(l,v.One)}while(!f);var h=[];v.modInv(t,c,h);var y=[];v.reduce(h,u,y);var g=[];v.reduce(h,s,g);var p=[];v.modInv(o,n,p);var d=v.digitsToBytes;return{privateKey:{n:d(a),e:d(t),d:d(h),p:d(n),q:d(o),dp:d(y),dq:d(g),qi:d(p)},publicKey:{n:d(a),e:d(t)}}},$.generateKeyPair=function(e){if(void 0===e.algorithm.modulusLength)throw new Error("missing modulusLength");var r,t=v.bytesToDigits;switch(e.algorithm.modulusLength){case 1024:case 2048:case 4096:r=$.genRsaKeyFromRandom(e.algorithm.modulusLength,e.algorithm.publicExponent);break;default:throw new Error("invalid modulusLength")}var n=r.privateKey;n.ctxp=new v.MontgomeryMultiplier(t(n.p)).ctx,n.ctxq=new v.MontgomeryMultiplier(t(n.q)).ctx;var o,i,a=e.algorithm.name;return a.slice(a.indexOf("-")+1).toUpperCase(),"RSASSA-PKCS1-V1_5"===a||"RSA-PSS"===a?(o=["verify"],i=["sign"]):(o=["encrypt"],i=["decrypt"]),{type:"keyGeneration",keyPair:{publicKey:{keyData:r.publicKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:o,type:"public"}},privateKey:{keyData:r.privateKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:i,type:"private"}}}}},r.register("sign","RSASSA-PKCS1-V1_5",$.sign),r.register("sign","RSA-PSS",$.sign),r.register("verify","RSASSA-PKCS1-V1_5",$.verify),r.register("verify","RSA-PSS",$.verify),r.register("encrypt","RSAES-PKCS1-V1_5",$.workerEncrypt),r.register("decrypt","RSAES-PKCS1-V1_5",$.workerDecrypt),r.register("encrypt","RSA-OAEP",$.workerEncrypt),r.register("decrypt","RSA-OAEP",$.workerDecrypt),r.register("importKey","RSA-OAEP",$.importKey),r.register("importKey","RSAES-PKCS1-V1_5",$.importKey),r.register("importKey","RSASSA-PKCS1-V1_5",$.importKey),r.register("importKey","RSA-PSS",$.importKey),r.register("exportKey","RSA-OAEP",$.exportKey),r.register("exportKey","RSAES-PKCS1-V1_5",$.exportKey),r.register("exportKey","RSASSA-PKCS1-V1_5",$.exportKey),r.register("exportKey","RSA-PSS",$.exportKey),r.register("generateKey","RSA-OAEP",$.generateKeyPair),r.register("generateKey","RSAES-PKCS1-V1_5",$.generateKeyPair),r.register("generateKey","RSASSA-PKCS1-V1_5",$.generateKeyPair),r.register("generateKey","RSA-PSS",$.generateKeyPair));var ee=function(e){var r=h;return{deriveKey:function(t,n,o){for(var i=Math.ceil(o/(e.hashLen/8)),a=1,u=t.concat(n),s=[],c=0;c>>24&255,n>>>16&255,n>>>8&255,255&n]),a=0;a255*r)throw new Error("The length provided for HKDF is too large.");for(0===u.length&&(u=h.getVector(r)),(n={workerid:0,keyHandle:{algorithm:o},keyData:u,buffer:i}).keyData=I.signHmac(n),t=0;t>>c;return(s=i?s.slice(0,Math.ceil(i/8)):s)[s.length-1]=s[s.length-1]&l,s},computePublicKey:function(e){n.generator.isInMontgomeryForm||o.convertToMontgomeryForm(n.generator);var i=n.allocatePointStorage();return o.convertToJacobianForm(i),o.convertToMontgomeryForm(i),o.scalarMultiply(r(e),n.generator,i),{x:t(i.x),y:t(i.y)}}}};void 0!==r&&(oe.deriveBits=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=e.keyData,n=e.additionalKeyData;return oe(r).deriveBits(t,n,e.length)},oe.deriveKey=function(e){throw new Error("not supported")},oe.generateKey=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=oe(r).generateKey();return{type:"keyPairGeneration",keyPair:{publicKey:{keyData:t.publicKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:[],type:"public"}},privateKey:{keyData:t.privateKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:e.usages,type:"private"}}}}},oe.importKey=function(e){if("raw"===e.format){var r=e.keyData;if(4!==r[0])throw new Error("DataError");var t=~~((r.length-1)/2),n=e.algorithm.namedCurve.toUpperCase(),o=r.slice(1,t+1),i=r.slice(t+1);if(!1===m.validatePoint(n,o,i))throw new Error("DataError");return{type:"keyImport",keyData:{x:o,y:i},keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:"public"}}}if("jwk"===e.format){var a=d.jwkToKey(e.keyData,e.algorithm,["x","y","d","crv"]);if(a.d&&(!a.x||!a.y)){var u=m.createCurve(e.algorithm.namedCurve.toUpperCase()),s=oe(u).computePublicKey(a.d);a.x=s.x,a.y=s.y}if(!1===m.validatePoint(e.algorithm.namedCurve.toUpperCase(),a.x,a.y))throw new Error("DataError");return{type:"keyImport",keyData:a,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:a.d?"private":"public"}}}},oe.exportKey=function(e){if("raw"===e.format&&"public"===e.keyHandle.type)return{type:"keyExport",keyHandle:[4].concat(e.keyData.x,e.keyData.y)};if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};throw new Error("unsupported export format.")},r.register("importKey","ECDH",oe.importKey),r.register("exportKey","ECDH",oe.exportKey),r.register("generateKey","ECDH",oe.generateKey),r.register("deriveBits","ECDH",oe.deriveBits),r.register("deriveKey","ECDH",oe.deriveKey));var ie,ae=function(e){var r=v.bytesToDigits,t=v.digitsToBytes,n=new m.EllipticCurveOperatorFp(e),o=t(e.order).length,i=1===e.type;function a(r){var t=e.allocatePointStorage();return n.scalarMultiply(r,e.generator,t),{publicKey:t,privateKey:r}}function u(r){var t=[];return r||(r=J.getBytes(e.order.length*v.DIGIT_NUM_BYTES)),v.reduce(v.bytesToDigits(r),e.order,t),a(t)}function s(t){t.length>o&&(t.length=o);var n=r(t);if(i){var a=8-e.rbits%8;v.shiftRight(n,n,a)}return v.reduce(n,e.order,n),n}return{createKey:function(e){return a(r(e))},generateKey:u,sign:function(n,i,a){a||(a=u());var c=a.publicKey.x,l=a.privateKey,f=r(n.d),y=s(i.slice()),g=[],p=[];v.reduce(c,e.order,c),v.modMul(c,f,e.order,g),v.add(g,y,g),v.reduce(g,e.order,g),v.modInvCT(l,e.order,p),v.modMul(g,p,e.order,g);var d=h.padFront(t(c,!0,o),0,o),m=h.padFront(t(g,!0,o),0,o);return d.concat(m)},verify:function(t,o,a){var u=Math.floor(o.length/2),c=r(o.slice(0,u)),l=r(o.slice(u)),f=s(a.slice()),h=[],y=[],g=new m.EllipticCurvePointFp(e,!1,r(t.x),r(t.y),null,!1);v.modInv(l,e.order,l),v.modMul(f,l,e.order,h),v.modMul(c,l,e.order,y);var p=e.allocatePointStorage(),d=e.allocatePointStorage();return i?(v.add(h,h,h),v.add(h,h,h),v.reduce(h,e.order,h),n.scalarMultiply(h,e.generator,p,!1),n.scalarMultiply(y,g,d,!1),n.convertToExtendedProjective(p),n.convertToExtendedProjective(d),n.add(d,p,p),n.normalize(p)):(n.scalarMultiply(h,e.generator,p),n.scalarMultiply(y,g,d),n.convertToJacobianForm(p),n.convertToMontgomeryForm(p),n.convertToMontgomeryForm(d),n.mixedAdd(p,d,p),n.convertToAffineForm(p),n.convertToStandardForm(p)),!p.isInfinity&&(v.reduce(p.x,e.order,p.x),0===v.compareDigits(p.x,c))}}};void 0!==r&&(ae.sign=function(e){h.checkParam(e.algorithm.hash,"Object","algorithm.hash"),h.checkParam(e.algorithm.hash.name,"String","algorithm.hash.name"),h.checkParam(e.keyHandle.algorithm.namedCurve,"String","p.keyHandle.algorithm.namedCurve");var r=e.algorithm.hash.name,t=m.createCurve(e.keyHandle.algorithm.namedCurve.toUpperCase()),n=f[r.toUpperCase()]().computeHash(e.buffer);return ae(t).sign(e.keyData,n)},ae.verify=function(e){var r=e.algorithm.hash.name,t=m.createCurve(e.keyHandle.algorithm.namedCurve.toUpperCase()),n=f[r.toUpperCase()]().computeHash(e.buffer);return ae(t).verify(e.keyData,e.signature,n)},ae.generateKey=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=ae(r).generateKey(),n=v.digitsToBytes;function o(e){return e}var i=o(n(t.publicKey.x)),a=o(n(t.publicKey.y)),u=o(n(t.privateKey));return{type:"keyPairGeneration",keyPair:{publicKey:{keyData:{x:i,y:a},keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:["verify"],type:"public"}},privateKey:{keyData:{x:i,y:a,d:u},keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:["sign"],type:"private"}}}}},ae.importKey=function(e){if("raw"===e.format){var r=e.keyData;if(4!==r[0])throw new Error("DataError");var t=~~((r.length-1)/2),n=e.algorithm.namedCurve.toUpperCase(),o=r.slice(1,t+1),i=r.slice(t+1);if(!1===m.validatePoint(n,o,i))throw new Error("DataError");return{type:"keyImport",keyData:{x:o,y:i},keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:"public"}}}if("jwk"===e.format){var a=d.jwkToKey(e.keyData,e.algorithm,["x","y","d","crv"]);if(a.d&&(!a.x||!a.y)){var u=ae.curves[e.algorithm.namedCurve](),s=ae(u).computePublicKey(a.d);a.x=s.x,a.y=s.y}if(!1===m.validatePoint(e.algorithm.namedCurve.toUpperCase(),a.x,a.y))throw new Error("DataError");return{type:"keyImport",keyData:a,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:a.d?"private":"public"}}}},ae.exportKey=function(e){if("raw"===e.format&&"public"===e.keyHandle.type)return{type:"keyExport",keyHandle:[4].concat(e.keyData.x,e.keyData.y)};if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};throw new Error("unsupported export format.")},r.register("sign","ECDSA",ae.sign),r.register("verify","ECDSA",ae.verify),r.register("generateKey","ECDSA",ae.generateKey),r.register("importKey","ECDSA",ae.importKey),r.register("exportKey","ECDSA",ae.exportKey));var ue=h;ie=function(){function e(){var e;return{postMessage:function(r){try{r.workerid=this.id,e=g.jsCryptoRunner({data:r})}catch(e){return void this.onerror({data:e,type:"error"})}this.onmessage({data:e})},onmessage:null,onerror:null,terminate:function(){}}}var o=function(e){return{process:function(r){return e.process(r)},finish:function(){return e.finish()},abort:function(){return e.abort()}}};function i(e){var r,t,n;return{dispatchEvent:function(o){"error"!==o.type?"process"!==o.data.type&&"finish"!==o.data.type?(this.result=e(o.data),t.apply(r,[this.result])):e(o.data.result,!0):n&&n.apply(r,[o])},promise:r=new Promise(function(e,r){t=e,n=r}),result:null}}function a(e){var r=[],t=i(function(e,t){var n;if(e=e&&(n=e,u&&n.pop?new Uint8Array(n).buffer:n),!t)return e;r.resolve(e)});return t.stream=e.algorithm.stream,r.add=function(e){var t,n,o=new Promise(function(e,r){t=e,n=r});return o.label=e,r.push({resolve:t,reject:n,promise:o}),o},r.resolve=function(e){var t=r.shift();t.resolve.apply(t.promise,[e])},t.process=function(t){return e.operationSubType="process",e.buffer=ue.toArray(t),l.continueJob(this,ue.clone(e)),r.add("process")},t.finish=function(){return e.operationSubType="finish",e.buffer=[],l.continueJob(this,ue.clone(e)),r.add("finish")},t.abort=function(){l.abortJob(this)},t.algorithm=e.algorithm||null,t.key=e.keyHandle||null,t}var s=[];s.add=function(e,r){s.push({keyHandle:e,keyData:r})},s.remove=function(e){for(var r=0;r=0;r-=1)i[r].isWebWorker===e&&(i[r].terminate(),i.splice(r,1))}(!c);for(var e=0;e0){var r,t=a.shift();if(k(t.operation,t.data),"process"===t.data.operationSubType){for(r=0;r=0;r--)t.operation===a[r].operation&&a.splice(r,1)}}else(function(){for(var e=0,r=0;ro&&p(e)}function w(r){var n;if("pending"===y)throw new Error("Creating new worker while workerstatus=pending");if("ready"===y)try{(n=new Worker(t)).postMessage({prngSeed:J.getBytes(48)}),n.isWebWorker=!0}catch(r){c=!1,y="failed",n.terminate(),(n=e()).isWebWorker=!1}else(n=e()).isWebWorker=!1;return n.operation=r,n.id=s++,n.busy=!1,n.onmessage=function(e){if(!0!==e.data.initialized){var r=n.operation;e.target||(e.target={data:n.data});for(var t=0;t=r)v(e,t);else{if(null===n&&(n=w(e)),null===n)throw v(e,t),new Error("could not create new worker");n.operation=e,n.busy=!0,t.workerid=n.id,E(n,t)}else v(e,t)}function k(e,r){var t=d(e);t?E(t,r):b(e,r)}function E(e,r){if(r.workerid=e.id,c)e.postMessage(r);else{var t=(o=r,function(){return e.postMessage(o)});n=t,l.push(n),f(h,0)}var n,o}return{runJob:b,continueJob:k,abortJob:function(e){var r=d(e);r&&p(r)},useWebWorkers:function(e){if("unavailable"!==y){if(!(!0===e&&"ready"===y||!1===e&&"available"===y)){if(!1===e&&"ready"===y)return c=!1,y="available",void ue.consoleLog("web workers disabled.");if("pending"!==y){y="pending";var r=new Worker(t);r.addEventListener("message",n,!1),r.addEventListener("error",n,!1),r.postMessage({prngSeed:J.getBytes(48)})}}}else ue.consoleLog("web workers not available in this browser.");function n(e){var t=!(!e.data||!0!==e.data.initialized);if(r.removeEventListener("message",n,!1),r.removeEventListener("error",n,!1),r.terminate(),y=t?"ready":"failed",c=t,ue.consoleLog("web worker initialization "+(t?"succeeded. Now using web workers.":"failed. running synchronously."+(e.message||""))),a.length>0){var o=a.shift();b(o.operation,o.data)}}}}}(),f=[{name:"algorithm",type:"Object",required:!0},{name:"keyHandle",type:"Object",required:!0},{name:"buffer",type:"Array",required:!1},{name:"signature",type:"Array",required:!0},{name:"format",type:"String",required:!0},{name:"keyData",type:"Object",required:!0},{name:"extractable",type:"Boolean",required:!1},{name:"usages",type:"Array",required:!1},{name:"derivedKeyType",type:"Object",required:!0},{name:"length",type:"Number",required:!1},{name:"extractable",type:"Boolean",required:!0},{name:"usages",type:"Array",required:!0},{name:"keyData",type:"Array",required:!0}],y={encrypt:[0,1,2],decrypt:[0,1,2],sign:[0,1,2],verify:[0,1,3,2],digest:[0,2],generateKey:[0,6,7],importKeyRaw:[4,12,0,10,11],importKeyJwk:[4,5,0,10,11],exportKey:[0,4,1,6,7],deriveKey:[0,1,8,6,7],deriveBits:[0,1,9],wrapKey:[1,1,0],unwrapKey:[2,0,1,6,7]};function p(e){var r=s.lookup(e);if(!r)throw new Error("key not found");return r}function d(e,t,n){var u=function(e,r){var t,n,o,i,a={operationType:e};for("importKey"!==e||"raw"!==r[0]&&"spki"!==r[0]||(e="importKeyRaw"),"importKey"===e&&"jwk"===r[0]&&(e="importKeyJwk"),t=y[e],i=0;i=n&&f.stopCollectors()}var l=e&&e.addEventListener||"undefined"!=typeof document&&document.attachEvent,f={startCollectors:function(){if(!this.collectorsRegistered){if(e.addEventListener)e.addEventListener("mousemove",this.MouseEventCallBack,!0),e.addEventListener("load",this.LoadTimeCallBack,!0);else{if(!document.attachEvent)throw new Error("Can't attach events for entropy collection");document.attachEvent("onmousemove",this.MouseEventCallBack),document.attachEvent("onload",this.LoadTimeCallBack)}this.collectorsRegistered=1}},stopCollectors:function(){this.collectorsRegistered&&(e.removeEventListener?(e.removeEventListener("mousemove",this.MouseEventCallBack,1),e.removeEventListener("load",this.LoadTimeCallBack,1)):e.detachEvent&&(e.detachEvent("onmousemove",this.MouseEventCallBack),e.detachEvent("onload",this.LoadTimeCallBack)),this.collectorsRegistered=0)},MouseEventCallBack:function(e){var r=(new Date).valueOf(),t=e.x||e.clientX||e.offsetX||0,n=e.y||e.clientY||e.offsetY||0;c([255&r,r>>8&255,r>>16&255,r>>24&255,255&t,t>>8&255,255&n,n>>8&255])},LoadTimeCallBack:function(){var e=(new Date).valueOf();c([255&e,e>>8&255,e>>16&255,e>>24&255])}};return{init:function(){if(s(),!a&&l)try{f.startCollectors()}catch(e){}},reseed:function(e){o.reseed(e)},read:function(e){if(!i)throw new Error("Entropy pool is not initialized.");var r=o.getBytes(e);return s(),r}}}(e)).init();var fe=ce.read(48);return J.init(fe),le}()}),function(e,r){"undefined"==typeof Promise&&(e.Promise=function(){var e=function(r,t){if(!(this instanceof e))throw new Error("use 'new' keyword with Promise constructor");var n=null,o=null,i=[],a=[],u=[],s=[];this.then=function(r,t){var c;return n?(c=r(n.result))&&c.then?c:e.resolve(c):o?(c=t?t(o.result):o.result)&&c.then?c:e.resolve(c):(i.push(r),t&&a.push(t),new e(function(e,r){s.push(e),u.push(r)}))},this["catch"]=function(r){var t;return o?(t=r(o.result))&&t.then?t:e.resolve(t):(a.push(r),new e(function(e,r){s.push(e),u.push(r)}))},r(function(e){var r,t;for(t=0;t0?e[0]:null}}else if("undefined"!=typeof self)return self.location.href;return null}(),n="undefined"!=typeof Worker,o="function"==typeof importScripts&&self instanceof WorkerGlobalScope,a=!1,u="undefined"!=typeof ArrayBuffer,s=function(){try{return Object.defineProperty({},"oncomplete",{}),!0}catch(e){return!1}}(),c=!1,l=function(e,r,t,n,o){if(s){var i={};n&&(i.get=n),o&&(i.set=o),Object.defineProperty(e,r,i)}else e[r]=t},f={},h=function(){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function r(r){for(r=r.replace(/-/g,"+").replace(/_/g,"/");r.length%4!=0;)r+="=";var t,n,o,i,a,u,s,c=[];for(r=r.replace(/[^A-Za-z0-9\+\/\=]/g,""),s=0;s>4,n=(15&i)<<4|(a=e.indexOf(r.charAt(s+2)))>>2,o=(3&a)<<6|(u=e.indexOf(r.charAt(s+3))),c.push(t),64!==a&&c.push(n),64!==u&&c.push(o);return c}function t(e){return Object.prototype.toString.call(e).slice(8,-1)}function n(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e]}function o(e){if(!e)return[];if(e.pop)return e;if("ArrayBuffer"===t(e)?e=new Uint8Array(e):e.BYTES_PER_ELEMENT>1&&(e=new Uint8Array(e.buffer)),1===e.length)return[e[0]];if(e.length<65536)return Array.apply(null,e);for(var r=new Array(e.length),n=0;n>2,l=(3&a)<<4|(u=p[y+1])>>4,f=(15&u)<<2|(s=p[y+2])>>6,h=63&s,isNaN(u)?f=h=64:isNaN(s)&&(h=64),g=g+e.charAt(c)+e.charAt(l)+e.charAt(f)+e.charAt(h);return n?g.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,""):g},fromBase64:r,checkParam:function(e,r,n){if(!e)throw new Error(n);if(r&&t(e)!==r)throw new Error(n);return!0},getObjectType:t,bytesToHexString:function(e,r){var t="";void 0===r&&(r=!1);for(var n=0;n>>6|192,r[n++]=63&o|128):o<55296||o>57343?(r[n++]=o>>>12|224,r[n++]=o>>>6&63|128,r[n++]=63&o|128):(o=1024*(o-55296)+(e.charCodeAt(++t)-56320)+65536,r[n++]=o>>>18|240,r[n++]=o>>>12&63|128,r[n++]=o>>>6&63|128,r[n++]=63&o|128)}return r},bytesToString:function(e){var r,t="";e=o(e);for(var n=0;n65535){var a=Math.floor((r-65536)/1024)+55296,u=(r-65536)%1024+56320;t+=String.fromCharCode(a,u)}else t+=String.fromCharCode(r)}return t},unpackData:function(e,t,n){var o,i=r(e),a=[];if(isNaN(t))return i;for(o=0;o=2;)r.push(parseInt(e.substring(0,2),16)),e=e.substring(2,e.length);return r},int32ToBytes:n,int32ArrayToBytes:function(e){for(var r=[],t=0;t255)return!1;return!0}}}(),y=(p={0:"CUSTOM",1:"BOOLEAN",2:"INTEGER",3:"BIT STRING",4:"OCTET STRING",5:"NULL",6:"OBJECT IDENTIFIER",16:"SEQUENCE",17:"SET",19:"PRINTABLE STRING",23:"UTCTime"},{parse:function e(r,t){t=!!t;var n,o,i,a=p[31&r[0]],u=r[1],s=0,c=!!(32&r[0]);if(128&u)for(s=0,u=0;s<(127&r[1]);s++)u=(u<<8)+r[2+s];if(i=2+s,void 0===a||u>r.length)return null;var l=c?[]:{};if(l.type=a,l.header=i,l.data=r.slice(0,u+i),c||t)for("BIT STRING"===l.type&&0===r[i]&&s++,n=r.slice(i,l.data.length);n.length>0&&null!==(o=e(n));)l.push(o),n=n.slice(o.data.length);return l},encode:function(e){throw new Error("not implemented")},toString:function(e){return function e(r,t){var n=new Array(t+1).join(" ")+r.type+" ("+r.length+") "+bytesToHexString(r.data).substring(0,16)+"\n";if(!r.children)return n;for(var o=0;o0;)t[n+o]=e[r+o]}function h(e){var r,t=0;for(r=0;r=0;c--)i+=a[s++]*(255&e[c]),a[s]===n&&(s=0,o[u++]=i,i=0);for(0!==i&&(o[u]=i);null==o[--t];)o[t]=0;return o}function g(r,t){if(void 0===t)if(r<=1)t=1;else{var o=Math.log(r)/Math.LN2;t=Math.ceil(o/e)}for(var i=[];r>0;)i.push(r%n),r=Math.floor(r/n);for(;i.length=0;r--)if(void 0!==e[r]&&0!==e[r])return r;return 0===e[0]?-1:0}function d(e,r){var t,n,o=0;for(n=0;n=e||o<0)throw new Error("bit count must be smaller than DIGIT_BITS and positive in shiftLeft");void 0===i&&(i=r.length);var a=e-o;n[i]=r[i-1]>>>e-o||n[i];for(var u=i-1;u>0;u--)n[u]=(r[u]<>>a)&t;n[0]=r[0]<>=e;for(u=s;u>=e;return o.length=a.length,0!==c&&(o[u]=c&t),c}function k(r,n,o){var i=n.length;if(r.length>=e;for(;a>=e;return u}function E(e,r,n){r="number"==typeof r?[r]:r;var o,a,u,s,c,l,f,h,y=e.length,g=r.length;for(o=0;o=0;v--)y=l*n+r[v],i[v]=y/g&t,l=y-i[v]*g&t;return i.length=b,m(i),a[0]=l,void(a.length=1)}var E=e-1-function(r){for(var t=0,n=0;n>>n&1)&n);return t}(o[k-1]),x=u||[];x.length=k,w(o,x,E,k);var S=s||[];for(S.length=b,w(r,S,E,b),S[b]=S[b]||0,i.length=b-k+1,a.length=k,v=b-k;v>=0;v--){for(c=Math.floor((S[v+k]*n+S[v+k-1])/x[k-1]),l=S[v+k]*n+S[v+k-1]-c*x[k-1];(c>=n||c*x[k-2]>l*n+S[v+k-2])&&(c-=1,(l+=x[k-1])>e;S[v+k]=S[v+k]+h&t}}for(d=0;d>>E|S[d+1]<0);v.subtract(n,d,o.temp2),s(S,n,o.temp2)}function u(e,r,t){var n,o,i,a,u;for(n=0;n>>=1)u===t&&(c[++s]=0,u=0),c[s]+=(1&n)<>>31,a=0;a0),v.subtract(r,c,f),s(u,r,f),m(r)},ctx:n}}return{DIGIT_BITS:e,DIGIT_NUM_BYTES:r,DIGIT_MASK:t,DIGIT_BASE:n,DIGIT_MAX:o,Zero:s,One:c,normalizeDigitArray:m,bytesToDigits:y,stringToDigits:function(e,r){e=e.replace(/^\s+|\s+$/g,"");var t=[0],n=[0];r=r||10;for(var o=0;o=r;)c[0]=c[0]*r,h=h.concat("0");for(t=0;tn&&0===u[0];)u.shift();return u},isZero:h,isEven:function(e){return 0==(1&e[0])},shiftRight:function(r,n,o,i){if(void 0===o)o=1;else if(o>=e||o<0)throw new Error("Invalid bit count for shiftRight");void 0===i&&(i=r.length);for(var a=i-1,u=e-o,s=0;s>>o)&t;n[a]=r[a]>>>o},shiftLeft:w,compareDigits:d,bitLength:function(e){for(var r=0,t=0;r=0&&0===t;){var o=1<=0)throw new Error("The number provided is not an element of this group");return m(r,this.m_digitWidth,!0),c(r,this)},createElementFromDigits:function(e){return v.normalizeDigitArray(e,this.m_digitWidth,!0),c(e,this)},equals:function(e){return 0===d(this.m_modulus,e.m_modulus)},add:function(r,n,o){var i,a=this.m_digitWidth,u=o.m_digits;v.add(r.m_digits,n.m_digits,u);var s=(d(u,this.m_modulus)>>>31)-1&t,c=0;for(i=0;i>=e;u.length=a},subtract:function(r,n,o){var i,a=this.m_digitWidth,u=o.m_digits,s=v.subtract(r.m_digits,n.m_digits,o.m_digits);if(-1===s)for(s=0,i=0;i>=e},multiply:function(e,r,t){return v.modMul(e.m_digits,r.m_digits,this.m_modulus,t.m_digits,u,s)},inverse:function(e,r){v.modInv(e.m_digits,this.m_modulus,r.m_digits)},modexp:function(e,r,t){if(t=t||c([],this),0===d(r,i))t.m_digits=g(1,this.m_digitWidth);else if(0===d(r,a)){for(var n=0;n0&&(n=r,o=e),S(n,o,void 0,void 0,t),m(t)},sequenceEqual:function(e,r){for(var t=e.length===r.length,n=0;n=0;){for(var o=0;o<8;){var i=1<>>=v.DIGIT_BITS;i<<=v.DIGIT_BITS-1,v.shiftRight(t,t),t[n-1]|=i}else v.shiftRight(r,t)}function T(e,r,t){o.montgomeryMultiply(e,r,t)}function I(e,r){o.montgomeryMultiply(e,e,r)}function K(e,r){var t=r.clone();if(R(t),!N(t))throw new Error("Invalid Parameter");var n=r.clone();q(n);var o,i=[r.clone()],a=n.clone(),u=n.clone();C(n,u),U(u);for(var s=1;s=0)throw new Error("The scalar k must be in the range 1 <= k < order.");if(r=r.slice(),1===t.curve.type){var a=void 0!==t.ta;a||L(t),function(e,r,t,o){if(!O(r))throw new Error("Invalid Parameter");var i=r.curve.rbits;o=void 0===o||o;var a,u,s=n<=8?5:6,c=Math.floor((i+(s-2))/(s-1));e=e.slice();var l=r.clone();L(l),o&&(G(l,l),G(l,l));var f=j(1<=0;a--){for(u=0;u>>31);A(r.curve.p,m.x,y);for(var b=0;b=0;g--){for(var p=0;p>>31),w=0;w=o&&(l=y(l))},finish:g,der:r,hashLen:a,maxMessageSize:4294967295}},M=function(){function e(e,t,n,o,i){var a,u,s,c,l=4294967295,f=n[0],h=n[1],y=n[2],g=n[3],p=n[4];for(u=0;u<16;u++)i[u]=r.bytesToInt32(e,64*t+4*u);for(a=16;a<80;a++)c=i[a-3]^i[a-8]^i[a-14]^i[a-16],i[a]=c<<1|c>>>31;for(u=0;u<80;u++)s=f<<5|f>>>27,s+=u>=60?h^y^g:u>=40?h&y^h&g^y&g:u>=20?h^y^g:h&y^~h&g,s+=p+o[u]+i[u],p=g,g=y,y=h<<30|h>>>2,h=f,f=s;return n[0]+=f&l,n[1]+=h&l,n[2]+=y&l,n[3]+=g&l,n[4]+=p&l,n}var r=h,t=r.unpackData,n=t("Z0UjAe/Nq4mYutz+EDJUdsPS4fA=",4,1),o=t("WoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroY8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdY",4,1),i=t("MCEwCQYFKw4DAhoFAAQU");return{sha1:function(){return A("SHA-1",i,n,o,64,e,160)}}}();void 0!==r&&(M.instances={},M.getInstance=function(e){return M.instances[e]||(M.instances[e]=M.sha1())},M.deleteInstance=function(e){M.instances[e]=null,delete M.instances[e]},M.hash=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?M.sha1.finish():M.sha1().computeHash(e.buffer);M.sha1.process(e.buffer)},r.register("digest","SHA-1",M.hash)),f["SHA-1"]=M.sha1;var D=function(){var e=h;function r(r,t,n,o,i){var a,u,s,c,l,f=n[0],h=n[1],y=n[2],g=n[3],p=n[4],d=n[5],v=n[6],m=n[7];for(u=0;u<16;u++)i[u]=e.bytesToInt32(r,64*t+4*u);for(a=16;a<64;a++)c=i[a-15],l=i[a-2],i[a]=((l>>>17|l<<15)^(l>>>19|l<<13)^l>>>10)+i[a-7]+((c>>>7|c<<25)^(c>>>18|c<<14)^c>>>3)+i[a-16],i[a]=4294967295&i[a];for(u=0;u<64;u++)g+=s=m+((p>>>6|p<<26)^(p>>>11|p<<21)^(p>>>25|p<<7))+(p&d^~p&v)+o[u]+i[u],s+=((f>>>2|f<<30)^(f>>>13|f<<19)^(f>>>22|f<<10))+(f&(h^y)^h&y),m=v,v=d,d=p,p=g,g=y,y=h,h=f,f=s;return n[0]=n[0]+f>>>0,n[1]=n[1]+h>>>0,n[2]=n[2]+y>>>0,n[3]=n[3]+g>>>0,n[4]=n[4]+p>>>0,n[5]=n[5]+d>>>0,n[6]=n[6]+v>>>0,n[7]=n[7]+m>>>0,n}var t,n,o,i,a,u=e.unpackData;return n=u("wQWe2DZ81QcwcN0X9w5ZOf/ACzFoWBURZPmPp776T6Q",4,1),o=u("agnmZ7tnroU8bvNypU/1OlEOUn+bBWiMH4PZq1vgzRk",4,1),t=u("QoovmHE3RJG1wPvP6bXbpTlWwltZ8RHxkj+CpKscXtXYB6qYEoNbASQxhb5VDH3Dcr5ddIDesf6b3AanwZvxdOSbacHvvkeGD8GdxiQMocwt6SxvSnSEqlywqdx2+YjamD5RUqgxxm2wAyfIv1l/x8bgC/PVp5FHBspjURQpKWcntwqFLhshOE0sbfxTOA0TZQpzVHZqCruBwskuknIshaK/6KGoGmZLwkuLcMdsUaPRkugZ1pkGJPQONYUQaqBwGaTBFh43bAgnSHdMNLC8tTkcDLNO2KpKW5zKT2gub/N0j4LueKVjb4TIeBSMxwIIkL7/+qRQbOu++aP3xnF48g",4,1),i=u("MC0wDQYJYIZIAWUDBAIEBQAEHA"),a=u("MDEwDQYJYIZIAWUDBAIBBQAEIA"),{sha224:function(){return A("SHA-224",i,n,t,64,r,224)},sha256:function(){return A("SHA-256",a,o,t,64,r,256)}}}();void 0!==r&&(D.instance224=D.instance224||D.sha224(),D.instance256=D.instance256||D.sha256(),D.instances={},D.getInstance224=function(e){return D.instances[e]||(D.instances[e]=D.sha224())},D.getInstance256=function(e){return D.instances[e]||(D.instances[e]=D.sha256())},D.deleteInstance=function(e){D.instances[e]=null,delete D.instances[e]},D.hash256=function(e){if("process"===e.operationSubType)return D.getInstance256(e.workerid).process(e.buffer),null;if("finish"===e.operationSubType){var r=D.getInstance256(e.workerid).finish();return D.deleteInstance(e.workerid),r}if("abort"!==e.operationSubType)return D.instance256.computeHash(e.buffer);D.deleteInstance(e.workerid)},D.hash224=function(e){if("process"!==e.operationSubType){if("finish"===e.operationSubType&&D.getInstance224(e.workerid).finish(),"abort"!==e.operationSubType)return D.instance224.computeHash(e.buffer);msrcryptoSha224.deleteInstance(e.workerid)}else D.getInstance224(e.workerid).process(e.buffer)},r.register("digest","SHA-224",D.hash224),r.register("digest","SHA-256",D.hash256)),f["SHA-224"]=D.sha224,f["SHA-256"]=D.sha256;var T=function(){function e(e,r,t,n,o){var i=r+n|0,a=i>>>0>>0;o[0]=e+t+a|0,o[1]=i}function r(r,t,n,o,i){var a,u,s,c,l,f,h,y,g,p=[],d=[],v=[],m=n[0],w=n[1],b=n[2],k=n[3],E=n[4],x=n[5],S=n[6],A=n[7],M=n[8],D=n[9],T=n[10],I=n[11],K=n[12],C=n[13],H=n[14],P=n[15];for(a=0;a<32;a++)g=128*t+4*a,i[a]=r.slice(g,g+4),i[a]=i[a][0]<<24|i[a][1]<<16|i[a][2]<<8|i[a][3];for(a=32;a<160;a+=2)s=((h=i[a-30])>>>1|(y=i[a-29])<<31)^(h>>>8|y<<24)^h>>>7,c=(y>>>1|h<<31)^(y>>>8|h<<24)^(y>>>7|h<<25),e(l=((h=i[a-4])>>>19|(y=i[a-3])<<13)^(y>>>29|h<<3)^h>>>6,f=(y>>>19|h<<13)^(h>>>29|y<<3)^(y>>>6|h<<26),i[a-14],i[a-13],p),e(s,c,p[0],p[1],p),e(i[a-32],i[a-31],p[0],p[1],p),i[a]=p[0],i[a+1]=p[1];for(u=0;u<160;u+=2)l=M&T^K&~M,f=D&I^C&~D,e(H,P,s=(M>>>14|D<<18)^(M>>>18|D<<14)^(D>>>9|M<<23),c=(D>>>14|M<<18)^(D>>>18|M<<14)^(M>>>9|D<<23),p),e(l,f,o[u],o[u+1],d),e(p[0],p[1],i[u],i[u+1],v),e(d[0],d[1],v[0],v[1],v),e(v[0],v[1],S,A,p),S=p[0],A=p[1],f=w&(k^x)^k&x,l=m&(b^E)^b&E,e(v[0],v[1],s=(m>>>28|w<<4)^(w>>>2|m<<30)^(w>>>7|m<<25),c=(w>>>28|m<<4)^(m>>>2|w<<30)^(m>>>7|w<<25),p),e(l,f,s=p[0],c=p[1],p),H=K,P=C,K=T,C=I,T=M,I=D,M=S,D=A,S=E,A=x,E=b,x=k,b=m,k=w,m=s=p[0],w=c=p[1];return e(n[0],n[1],m,w,p),n[0]=p[0],n[1]=p[1],e(n[2],n[3],b,k,p),n[2]=p[0],n[3]=p[1],e(n[4],n[5],E,x,p),n[4]=p[0],n[5]=p[1],e(n[6],n[7],S,A,p),n[6]=p[0],n[7]=p[1],e(n[8],n[9],M,D,p),n[8]=p[0],n[9]=p[1],e(n[10],n[11],T,I,p),n[10]=p[0],n[11]=p[1],e(n[12],n[13],K,C,p),n[12]=p[0],n[13]=p[1],e(n[14],n[15],H,P,p),n[14]=p[0],n[15]=p[1],n}var t,n,o,i,a,u,s,c=h.unpackData;return t=c("y7udXcEFnthimikqNnzVB5FZAVowcN0XFS/s2PcOWTlnMyZn/8ALMY60SodoWBUR2wwuDWT5j6dHtUgdvvpPpA==",4,1),n=c("agnmZ/O8yQi7Z66FhMqnOzxu83L+lPgrpU/1Ol8dNvFRDlJ/reaC0ZsFaIwrPmwfH4PZq/tBvWtb4M0ZE34heQ",4,1),o=c("QoovmNcoriJxN0SRI+9lzbXA+8/sTTsv6bXbpYGJ27w5VsJb80i1OFnxEfG2BdAZkj+CpK8ZT5urHF7V2m2BGNgHqpijAwJCEoNbAUVwb74kMYW+TuSyjFUMfcPV/7Ticr5ddPJ7iW+A3rH+OxaWsZvcBqclxxI1wZvxdM9pJpTkm2nBnvFK0u++R4Y4TyXjD8GdxouM1bUkDKHMd6ycZS3pLG9ZKwJ1SnSEqm6m5INcsKncvUH71Hb5iNqDEVO1mD5RUu5m36uoMcZtLbQyELADJ8iY+yE/v1l/x77vDuTG4AvzPaiPwtWnkUeTCqclBspjUeADgm8UKSlnCg5ucCe3CoVG0i/8LhshOFwmySZNLG38WsQq7VM4DROdlbPfZQpzVIuvY952agq7PHeyqIHCyS5H7a7mknIshRSCNTuiv+ihTPEDZKgaZku8QjABwkuLcND4l5HHbFGjBlS+MNGS6BnW71IY1pkGJFVlqRD0DjWFV3EgKhBqoHAyu9G4GaTBFrjS0MgeN2wIUUGrUydId0zfjuuZNLC8teGbSKg5HAyzxclaY07YqkrjQYrLW5zKT3dj43NoLm/z1rK4o3SPgu5d77L8eKVjb0MXL2CEyHgUofCrcozHAggaZDnskL7/+iNjHiikUGzr3oK96b75o/eyxnkVxnF48uNyUyvKJz7O6iZhnNGGuMchwMIH6tp91s3g6x71fU9/7m7ReAbwZ6pyF2+6CmN9xaLImKYRP5gEvvkNrhtxCzUTHEcbKNt39SMEfYQyyqt7QMckkzyevgoVyb68Qx1nxJwQDUxMxdS+yz5Ctll/KZz8ZX4qX8tvqzrW+uxsRBmMSkdYFw==",4,1),i=c("MEEwDQYJYIZIAWUDBAICBQAEMA"),a=c("MFEwDQYJYIZIAWUDBAIDBQAEQA"),u=c("MC0wDQYJYIZIAWUDBAIFBQAEHA"),s=c("MDEwDQYJYIZIAWUDBAIGBQAEIA"),{sha384:function(){return A("SHA-384",i,t,o,128,r,384)},sha512:function(){return A("SHA-512",a,n,o,128,r,512)},sha512_224:function(){return A("SHA-512.224",u,n,o,128,r,224)},sha512_256:function(){return A("SHA-512.256",s,n,o,128,r,256)}}}();void 0!==r&&(T.instances={},T.getInstance384=function(e){return T.instances[e]||(T.instances[e]=T.sha384())},T.getInstance512=function(e){return T.instances[e]||(T.instances[e]=T.sha512())},T.deleteInstance=function(e){T.instances[e]=null,delete T.instances[e]},T.hash384=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?T.sha384.finish():T.sha384().computeHash(e.buffer);T.sha384.process(e.buffer)},T.hash512=function(e){if("process"!==e.operationSubType)return"finish"===e.operationSubType?T.sha512.finish():T.sha512().computeHash(e.buffer);T.sha512.process(e.buffer)},r.register("digest","SHA-384",T.hash384),r.register("digest","SHA-512",T.hash512)),f["SHA-384"]=T.sha384,f["SHA-512"]=T.sha512;var I=function(e,r){var t,n,o,i,a,u={384:128,512:128}[r.name.replace(/SHA-/,"")]||64,s=e.length===u?e:e.length>u?l(r.computeHash(e),u):l(e,u);function c(e,r){for(var t=new Array(e),n=0;n6&&y%t==4&&f(r);var d=c(g(h,y-t),r);i=d,u=0,(o=h)[4*(a=y)]=i[4*u],o[4*a+1]=i[4*u+1],o[4*a+2]=i[4*u+2],o[4*a+3]=i[4*u+3],y+=1}return h}(e),{encrypt:function(e){var r,t=e;for(l(t,o,0),r=1;r<=n-1;r+=1)f(t),i(t),u(t),l(t,o,4*r*4);return f(t),i(t),l(t,o,4*n*4),t},decrypt:function(e){var r,t=e;for(l(t,o,4*n*4),r=n-1;r>=1;r-=1)a(t),y(t),l(t,o,4*r*4),s(t);return a(t),y(t),l(t,o,0),t},clear:function(){},keyLength:r,blockSize:128}}},j=j||{};j.pkcsv7=function(e){return{pad:function(r){var t=r[r.length-1>=0?r.length-1:0],n=t.length;if(n===e){var o,i=[];for(o=0;o>7-a%8&1)),n=0;n<16;n++)c[n]=c[n]^l[n]&t;t=255&-(1&l[15]),m(l),l[0]^=225&t}return c}function m(e){for(var r=e.length-1;r>0;r--)e[r]=(1&e[r-1])<<7|e[r]>>>1;return e[0]=e[0]>>>1,e}function w(e){for(var r=256,t=1;t<=4;t++)r=(r>>>8)+e[e.length-t],e[e.length-t]=255&r;return e}function b(r,t){var n,o=Math.ceil(t.length/16),i=[];a!==r&&(a=r.slice());for(var s=0;s>>24&255,e>>>16&255,e>>>8&255,255&e]}function E(){g=0,s=[],y=[],l=u.getVector(16),f=[],a=r=t=null}return{init:function(e,a,s){if(t=a||[],(n=isNaN(s)?128:s)%8!=0)throw new Error("DataError");if(12===(r=e).length)o=r.concat([0,0,0,1]);else{var f=16*Math.ceil(r.length/16)-r.length;o=p(c,r.concat(u.getVector(f+8)).concat(k(8*r.length))),l=u.getVector(16)}var h,y;i=w(o.slice()),p(c,(h=t,y=16*Math.ceil(t.length/16)-t.length,h.concat(u.getVector(y))))},encrypt:function(e){g=e.length;var r=b(i,e);p(c,r);var t=d(),a=b(o,t).slice(0,n/8);return E(),r.slice().concat(a)},decrypt:function(e,r){g=e.length;var t=b(i,e);p(c,e);var a=d(),s=b(o,a).slice(0,n/8);return E(),u.arraysEqual(s,r)?t:null},processEncrypt:function(e){var r=(s=s.concat(e)).slice(0,16*Math.floor(s.length/16));g+=r.length,s=s.slice(r.length);var t=b(a||i,r);y=y.concat(t),p(c,t)},processDecrypt:function(e){var r=(s=s.concat(e)).slice(0,16*Math.floor((s.length-n/8)/16));g+=r.length,s=s.slice(r.length);var t=b(a||i,r);y=y.concat(t),p(c,r)},finishEncrypt:function(){var e=b(a,s);y=y.concat(e),g+=s.length;var r=d(),t=b(o,r).slice(0,n/8),i=y.slice().concat(t);return E(),i},finishDecrypt:function(){var e=Math.floor(n/8),r=s.slice(-e);s=s.slice(0,s.length-e);var t=b(a,s);y=y.concat(t),g+=s.length;var i=d(),c=b(o,i).slice(0,n/8),l=y.slice();return E(),u.arraysEqual(c,r)?l:null}}};if(void 0!==r){var G={};V.encrypt=function(e){var r,t=e.workerid;if(G[t]||(G[t]=V(O.aes(e.keyData)),G[t].init(e.algorithm.iv,e.algorithm.additionalData,e.algorithm.tagLength)),"process"!==e.operationSubType)return"finish"===e.operationSubType?(r=G[t].finishEncrypt(),G[t]=null,r):(r=G[t].encrypt(e.buffer),G[t]=null,r);G[t].processEncrypt(e.buffer)},V.decrypt=function(e){var r,t=e.workerid;if(G[t]||(G[t]=V(O.aes(e.keyData)),G[t].init(e.algorithm.iv,e.algorithm.additionalData,e.algorithm.tagLength)),"process"!==e.operationSubType){if("finish"===e.operationSubType){if(r=G[t].finishDecrypt(),G[t]=null,null===r)throw new Error("OperationError");return r}var n=e.algorithm.tagLength?Math.floor(e.algorithm.tagLength/8):16,o=e.buffer.slice(0,e.buffer.length-n),i=e.buffer.slice(-n);if(r=G[t].decrypt(o,i),G[t]=null,null===r)throw new Error("OperationError");return r}G[t].processDecrypt(e.buffer)},V.generateKey=function(e){if(e.algorithm.length%8!=0)throw new Error;return{type:"keyGeneration",keyData:J.getBytes(Math.floor(e.algorithm.length/8)),keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:e.usages,type:"secret"}}},V.importKey=function(e){var r,t=8*e.keyData.length;if("jwk"===e.format)r=d.jwkToKey(e.keyData,e.algorithm,["k"]);else{if("raw"!==e.format)throw new Error("unsupported import format");if(128!==t&&192!==t&&256!==t)throw new Error("invalid key length (should be 128, 192, or 256 bits)");r={k:h.toArray(e.keyData)}}return{type:"keyImport",keyData:r.k,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||r.extractable,usages:e.usages,type:"secret"}}},V.exportKey=function(e){if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};if("raw"===e.format)return{type:"keyExport",keyHandle:e.keyData};throw new Error("unsupported export format")},r.register("importKey","AES-GCM",V.importKey),r.register("exportKey","AES-GCM",V.exportKey),r.register("generateKey","AES-GCM",V.generateKey),r.register("encrypt","AES-GCM",V.encrypt),r.register("decrypt","AES-GCM",V.decrypt)}function Z(){if(!(this instanceof Z))throw new Error("create MsrcryptoPrng object with new keyword");var e,r,t,n,o=!1,i=1,a=Math.pow(2,48);function u(e){var r;for(r=e.length-1;r>=0&&(e[r]+=1,e[r]>=256&&(e[r]=0),!e[r]);r-=1);}function s(){e=h.getVector(32),r=h.getVector(16),t=32,n=48,i=1}function c(e,r){if((r=r||[0]).length>n)throw new Error("Incorrect entropy or additionalEntropy length");r=r.concat(h.getVector(n-r.length)),e=e.concat(h.getVector((n-e.length%n)%n));for(var t=0;t=65536)throw new Error("too much random requested");if(i>a)throw new Error("Reseeding is required");if(o&&o.length>0){for(;o.length=0;)a=(u=a*f+n[i--])-(u/s|0)*s;r[o]=a}}function i(e,r){var t=e,n=[];v.subtract(t,[1],n);var o=function(e){var r,t=0,n=0;if(v.isZero(e))return 0;for(t=0;0===e[t];t++);for(n=0,r=2;e[t]%r==0;r*=2,n++);return t*v.DIGIT_BITS+n}(n),i=[];v.shiftRight(n,i,o);for(var u,s=function(e){var r=0,t=0,n=0;if(v.isZero(e))return 0;for(r=e.length-1;0===e[r];r--);for(n=1<<(t=v.DIGIT_BITS-1);t>0&&0==(e[r]&n);n>>>=1,t--);return r*v.DIGIT_BITS+t}(t),c=v.MontgomeryMultiplier(t),l=1;l<=r;l++){var f=!1;do{u=a(s)}while(v.compareDigits(u,n)>=0);var h=[];if(c.modExp(u,i,h,!0),0!==v.compareDigits(h,[1])&&0!==v.compareDigits(h,n)){for(var y=1;y>>24&255,i>>>16&255,i>>>8&255,255&i],o=t.computeHash(e.concat(n)),a=a.concat(o);return a.slice(0,r)},checkMessageVsMaxHash:function(e,r){if(e.length>(r.maxMessageSize||4294967295))throw new Error("message too long")}};(Q=Q||{}).oaep=function(e,r){var t=h,n=J,o=e.n.length;if(null===r)throw new Error("must supply hashFunction");return{pad:function(e,i){return function(e,i){var a,u,s,c,l,f,h,y,g;if(e.length>o-r.hashLen/8*2-2)throw new Error("Message too long.");return null==i&&(i=[]),a=r.computeHash(i),u=o-e.length-2*a.length-2,s=t.getVector(u),c=a.concat(s,[1],e),l=n.getBytes(a.length),f=X.mgf1(l,o-a.length-1,r),h=t.xorVectors(c,f),y=X.mgf1(h,a.length,r),g=t.xorVectors(l,y),e=[0].concat(g).concat(h).slice()}(e,i)},unpad:function(e,n){return function(e,n){var i,a,u,s,c,l,f,h,y=0,g=0===e[0];for(n||(n=[]),i=r.computeHash(n),a=e.slice(1,i.length+1),u=e.slice(i.length+1),s=X.mgf1(u,i.length,r),c=t.xorVectors(a,s),l=X.mgf1(c,o-i.length-1,r),h=(f=t.xorVectors(u,l)).slice(0,i.length),g=g&&t.arraysEqual(i,h),f=f.slice(i.length);!f[y++];);return{valid:g,data:f.slice(y)}}(e,n)}}},(Q=Q||{}).pkcs1Encrypt=function(e){var r=J,t=e.n.length;return{pad:function(e){return function(e){var n;if(e.length>t-11)throw new Error("message too long");return n=r.getNonZeroBytes(t-e.length-3),[0,2].concat(n,[0],e)}(e)},unpad:function(e){return function(e){var r,t=function(e){for(var r=0===e[0]&&2===e[1],t=2;t<10;t++)r=r&&!!e[t];return r}(e),n=0;for(r=1;r>>8-(8*u-a);for(var g=0;g0){var i=n;n=o,o=i}var a=[];v.multiply(n,o,a);var u=[];v.subtract(n,[1],u);var s=[];v.subtract(o,[1],s);var c=[];v.multiply(u,s,c);var l=[];v.gcd(t,c,l);var f=0===v.compareDigits(l,v.One)}while(!f);var h=[];v.modInv(t,c,h);var y=[];v.reduce(h,u,y);var g=[];v.reduce(h,s,g);var p=[];v.modInv(o,n,p);var d=v.digitsToBytes;return{privateKey:{n:d(a),e:d(t),d:d(h),p:d(n),q:d(o),dp:d(y),dq:d(g),qi:d(p)},publicKey:{n:d(a),e:d(t)}}},$.generateKeyPair=function(e){if(void 0===e.algorithm.modulusLength)throw new Error("missing modulusLength");var r,t=v.bytesToDigits;switch(e.algorithm.modulusLength){case 1024:case 2048:case 4096:r=$.genRsaKeyFromRandom(e.algorithm.modulusLength,e.algorithm.publicExponent);break;default:throw new Error("invalid modulusLength")}var n=r.privateKey;n.ctxp=new v.MontgomeryMultiplier(t(n.p)).ctx,n.ctxq=new v.MontgomeryMultiplier(t(n.q)).ctx;var o,i,a=e.algorithm.name;return a.slice(a.indexOf("-")+1).toUpperCase(),"RSASSA-PKCS1-V1_5"===a||"RSA-PSS"===a?(o=["verify"],i=["sign"]):(o=["encrypt"],i=["decrypt"]),{type:"keyGeneration",keyPair:{publicKey:{keyData:r.publicKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:o,type:"public"}},privateKey:{keyData:r.privateKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:i,type:"private"}}}}},r.register("sign","RSASSA-PKCS1-V1_5",$.sign),r.register("sign","RSA-PSS",$.sign),r.register("verify","RSASSA-PKCS1-V1_5",$.verify),r.register("verify","RSA-PSS",$.verify),r.register("encrypt","RSAES-PKCS1-V1_5",$.workerEncrypt),r.register("decrypt","RSAES-PKCS1-V1_5",$.workerDecrypt),r.register("encrypt","RSA-OAEP",$.workerEncrypt),r.register("decrypt","RSA-OAEP",$.workerDecrypt),r.register("importKey","RSA-OAEP",$.importKey),r.register("importKey","RSAES-PKCS1-V1_5",$.importKey),r.register("importKey","RSASSA-PKCS1-V1_5",$.importKey),r.register("importKey","RSA-PSS",$.importKey),r.register("exportKey","RSA-OAEP",$.exportKey),r.register("exportKey","RSAES-PKCS1-V1_5",$.exportKey),r.register("exportKey","RSASSA-PKCS1-V1_5",$.exportKey),r.register("exportKey","RSA-PSS",$.exportKey),r.register("generateKey","RSA-OAEP",$.generateKeyPair),r.register("generateKey","RSAES-PKCS1-V1_5",$.generateKeyPair),r.register("generateKey","RSASSA-PKCS1-V1_5",$.generateKeyPair),r.register("generateKey","RSA-PSS",$.generateKeyPair));var ee=function(e){var r=h;return{deriveKey:function(t,n,o){for(var i=Math.ceil(o/(e.hashLen/8)),a=1,u=t.concat(n),s=[],c=0;c>>24&255,n>>>16&255,n>>>8&255,255&n]),a=0;a255*r)throw new Error("The length provided for HKDF is too large.");for(0===u.length&&(u=h.getVector(r)),(n={workerid:0,keyHandle:{algorithm:o},keyData:u,buffer:i}).keyData=I.signHmac(n),t=0;t>>c;return(s=i?s.slice(0,Math.ceil(i/8)):s)[s.length-1]=s[s.length-1]&l,s},computePublicKey:function(e){n.generator.isInMontgomeryForm||o.convertToMontgomeryForm(n.generator);var i=n.allocatePointStorage();return o.convertToJacobianForm(i),o.convertToMontgomeryForm(i),o.scalarMultiply(r(e),n.generator,i),{x:t(i.x),y:t(i.y)}}}};void 0!==r&&(oe.deriveBits=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=e.keyData,n=e.additionalKeyData;return oe(r).deriveBits(t,n,e.length)},oe.deriveKey=function(e){throw new Error("not supported")},oe.generateKey=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=oe(r).generateKey();return{type:"keyPairGeneration",keyPair:{publicKey:{keyData:t.publicKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:[],type:"public"}},privateKey:{keyData:t.privateKey,keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:e.usages,type:"private"}}}}},oe.importKey=function(e){if("raw"===e.format){var r=e.keyData;if(4!==r[0])throw new Error("DataError");var t=~~((r.length-1)/2),n=e.algorithm.namedCurve.toUpperCase(),o=r.slice(1,t+1),i=r.slice(t+1);if(!1===m.validatePoint(n,o,i))throw new Error("DataError");return{type:"keyImport",keyData:{x:o,y:i},keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:"public"}}}if("jwk"===e.format){var a=d.jwkToKey(e.keyData,e.algorithm,["x","y","d","crv"]);if(a.d&&(!a.x||!a.y)){var u=m.createCurve(e.algorithm.namedCurve.toUpperCase()),s=oe(u).computePublicKey(a.d);a.x=s.x,a.y=s.y}if(!1===m.validatePoint(e.algorithm.namedCurve.toUpperCase(),a.x,a.y))throw new Error("DataError");return{type:"keyImport",keyData:a,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:a.d?"private":"public"}}}},oe.exportKey=function(e){if("raw"===e.format&&"public"===e.keyHandle.type)return{type:"keyExport",keyHandle:[4].concat(e.keyData.x,e.keyData.y)};if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};throw new Error("unsupported export format.")},r.register("importKey","ECDH",oe.importKey),r.register("exportKey","ECDH",oe.exportKey),r.register("generateKey","ECDH",oe.generateKey),r.register("deriveBits","ECDH",oe.deriveBits),r.register("deriveKey","ECDH",oe.deriveKey));var ie,ae=function(e){var r=v.bytesToDigits,t=v.digitsToBytes,n=new m.EllipticCurveOperatorFp(e),o=t(e.order).length,i=1===e.type;function a(r){var t=e.allocatePointStorage();return n.scalarMultiply(r,e.generator,t),{publicKey:t,privateKey:r}}function u(r){var t=[];return r||(r=J.getBytes(e.order.length*v.DIGIT_NUM_BYTES)),v.reduce(v.bytesToDigits(r),e.order,t),a(t)}function s(t){t.length>o&&(t.length=o);var n=r(t);if(i){var a=8-e.rbits%8;v.shiftRight(n,n,a)}return v.reduce(n,e.order,n),n}return{createKey:function(e){return a(r(e))},generateKey:u,sign:function(n,i,a){a||(a=u());var c=a.publicKey.x,l=a.privateKey,f=r(n.d),y=s(i.slice()),g=[],p=[];v.reduce(c,e.order,c),v.modMul(c,f,e.order,g),v.add(g,y,g),v.reduce(g,e.order,g),v.modInvCT(l,e.order,p),v.modMul(g,p,e.order,g);var d=h.padFront(t(c,!0,o),0,o),m=h.padFront(t(g,!0,o),0,o);return d.concat(m)},verify:function(t,o,a){var u=Math.floor(o.length/2),c=r(o.slice(0,u)),l=r(o.slice(u)),f=s(a.slice()),h=[],y=[],g=new m.EllipticCurvePointFp(e,!1,r(t.x),r(t.y),null,!1);v.modInv(l,e.order,l),v.modMul(f,l,e.order,h),v.modMul(c,l,e.order,y);var p=e.allocatePointStorage(),d=e.allocatePointStorage();return i?(v.add(h,h,h),v.add(h,h,h),v.reduce(h,e.order,h),n.scalarMultiply(h,e.generator,p,!1),n.scalarMultiply(y,g,d,!1),n.convertToExtendedProjective(p),n.convertToExtendedProjective(d),n.add(d,p,p),n.normalize(p)):(n.scalarMultiply(h,e.generator,p),n.scalarMultiply(y,g,d),n.convertToJacobianForm(p),n.convertToMontgomeryForm(p),n.convertToMontgomeryForm(d),n.mixedAdd(p,d,p),n.convertToAffineForm(p),n.convertToStandardForm(p)),!p.isInfinity&&(v.reduce(p.x,e.order,p.x),0===v.compareDigits(p.x,c))}}};void 0!==r&&(ae.sign=function(e){h.checkParam(e.algorithm.hash,"Object","algorithm.hash"),h.checkParam(e.algorithm.hash.name,"String","algorithm.hash.name"),h.checkParam(e.keyHandle.algorithm.namedCurve,"String","p.keyHandle.algorithm.namedCurve");var r=e.algorithm.hash.name,t=m.createCurve(e.keyHandle.algorithm.namedCurve.toUpperCase()),n=f[r.toUpperCase()]().computeHash(e.buffer);return ae(t).sign(e.keyData,n)},ae.verify=function(e){var r=e.algorithm.hash.name,t=m.createCurve(e.keyHandle.algorithm.namedCurve.toUpperCase()),n=f[r.toUpperCase()]().computeHash(e.buffer);return ae(t).verify(e.keyData,e.signature,n)},ae.generateKey=function(e){var r=m.createCurve(e.algorithm.namedCurve.toUpperCase()),t=ae(r).generateKey(),n=v.digitsToBytes;function o(e){return e}var i=o(n(t.publicKey.x)),a=o(n(t.publicKey.y)),u=o(n(t.privateKey));return{type:"keyPairGeneration",keyPair:{publicKey:{keyData:{x:i,y:a},keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:["verify"],type:"public"}},privateKey:{keyData:{x:i,y:a,d:u},keyHandle:{algorithm:e.algorithm,extractable:e.extractable,usages:["sign"],type:"private"}}}}},ae.importKey=function(e){if("raw"===e.format){var r=e.keyData;if(4!==r[0])throw new Error("DataError");var t=~~((r.length-1)/2),n=e.algorithm.namedCurve.toUpperCase(),o=r.slice(1,t+1),i=r.slice(t+1);if(!1===m.validatePoint(n,o,i))throw new Error("DataError");return{type:"keyImport",keyData:{x:o,y:i},keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:"public"}}}if("jwk"===e.format){var a=d.jwkToKey(e.keyData,e.algorithm,["x","y","d","crv"]);if(a.d&&(!a.x||!a.y)){var u=ae.curves[e.algorithm.namedCurve](),s=ae(u).computePublicKey(a.d);a.x=s.x,a.y=s.y}if(!1===m.validatePoint(e.algorithm.namedCurve.toUpperCase(),a.x,a.y))throw new Error("DataError");return{type:"keyImport",keyData:a,keyHandle:{algorithm:e.algorithm,extractable:e.extractable||a.extractable,usages:e.usages,type:a.d?"private":"public"}}}},ae.exportKey=function(e){if("raw"===e.format&&"public"===e.keyHandle.type)return{type:"keyExport",keyHandle:[4].concat(e.keyData.x,e.keyData.y)};if("jwk"===e.format)return{type:"keyExport",keyHandle:d.keyToJwk(e.keyHandle,e.keyData)};throw new Error("unsupported export format.")},r.register("sign","ECDSA",ae.sign),r.register("verify","ECDSA",ae.verify),r.register("generateKey","ECDSA",ae.generateKey),r.register("importKey","ECDSA",ae.importKey),r.register("exportKey","ECDSA",ae.exportKey));var ue=h;ie=function(){function e(){var e;return{postMessage:function(r){try{r.workerid=this.id,e=g.jsCryptoRunner({data:r})}catch(e){return void this.onerror({data:e,type:"error"})}this.onmessage({data:e})},onmessage:null,onerror:null,terminate:function(){}}}var o=function(e){return{process:function(r){return e.process(r)},finish:function(){return e.finish()},abort:function(){return e.abort()}}};function i(e){var r,t,n;return{dispatchEvent:function(o){"error"!==o.type?"process"!==o.data.type&&"finish"!==o.data.type?(this.result=e(o.data),t.apply(r,[this.result])):e(o.data.result,!0):n&&n.apply(r,[o])},promise:r=new Promise(function(e,r){t=e,n=r}),result:null}}function a(e){var r=[],t=i(function(e,t){var n;if(e=e&&(n=e,u&&n.pop?new Uint8Array(n).buffer:n),!t)return e;r.resolve(e)});return t.stream=e.algorithm.stream,r.add=function(e){var t,n,o=new Promise(function(e,r){t=e,n=r});return o.label=e,r.push({resolve:t,reject:n,promise:o}),o},r.resolve=function(e){var t=r.shift();t.resolve.apply(t.promise,[e])},t.process=function(t){return e.operationSubType="process",e.buffer=ue.toArray(t),l.continueJob(this,ue.clone(e)),r.add("process")},t.finish=function(){return e.operationSubType="finish",e.buffer=[],l.continueJob(this,ue.clone(e)),r.add("finish")},t.abort=function(){l.abortJob(this)},t.algorithm=e.algorithm||null,t.key=e.keyHandle||null,t}var s=[];s.add=function(e,r){s.push({keyHandle:e,keyData:r})},s.remove=function(e){for(var r=0;r=0;r-=1)i[r].isWebWorker===e&&(i[r].terminate(),i.splice(r,1))}(!c);for(var e=0;e0){var r,t=a.shift();if(k(t.operation,t.data),"process"===t.data.operationSubType){for(r=0;r=0;r--)t.operation===a[r].operation&&a.splice(r,1)}}else(function(){for(var e=0,r=0;ro&&p(e)}function w(r){var n;if("pending"===y)throw new Error("Creating new worker while workerstatus=pending");if("ready"===y)try{(n=new Worker(t)).postMessage({prngSeed:J.getBytes(48)}),n.isWebWorker=!0}catch(r){c=!1,y="failed",n.terminate(),(n=e()).isWebWorker=!1}else(n=e()).isWebWorker=!1;return n.operation=r,n.id=s++,n.busy=!1,n.onmessage=function(e){if(!0!==e.data.initialized){var r=n.operation;e.target||(e.target={data:n.data});for(var t=0;t=r)v(e,t);else{if(null===n&&(n=w(e)),null===n)throw v(e,t),new Error("could not create new worker");n.operation=e,n.busy=!0,t.workerid=n.id,E(n,t)}else v(e,t)}function k(e,r){var t=d(e);t?E(t,r):b(e,r)}function E(e,r){if(r.workerid=e.id,c)e.postMessage(r);else{var t=(o=r,function(){return e.postMessage(o)});n=t,l.push(n),f(h,0)}var n,o}return{runJob:b,continueJob:k,abortJob:function(e){var r=d(e);r&&p(r)},useWebWorkers:function(e){if("unavailable"!==y){if(!(!0===e&&"ready"===y||!1===e&&"available"===y)){if(!1===e&&"ready"===y)return c=!1,y="available",void ue.consoleLog("web workers disabled.");if("pending"!==y){y="pending";var r=new Worker(t);r.addEventListener("message",n,!1),r.addEventListener("error",n,!1),r.postMessage({prngSeed:J.getBytes(48)})}}}else ue.consoleLog("web workers not available in this browser.");function n(e){var t=!(!e.data||!0!==e.data.initialized);if(r.removeEventListener("message",n,!1),r.removeEventListener("error",n,!1),r.terminate(),y=t?"ready":"failed",c=t,ue.consoleLog("web worker initialization "+(t?"succeeded. Now using web workers.":"failed. running synchronously."+(e.message||""))),a.length>0){var o=a.shift();b(o.operation,o.data)}}}}}(),f=[{name:"algorithm",type:"Object",required:!0},{name:"keyHandle",type:"Object",required:!0},{name:"buffer",type:"Array",required:!1},{name:"signature",type:"Array",required:!0},{name:"format",type:"String",required:!0},{name:"keyData",type:"Object",required:!0},{name:"extractable",type:"Boolean",required:!1},{name:"usages",type:"Array",required:!1},{name:"derivedKeyType",type:"Object",required:!0},{name:"length",type:"Number",required:!1},{name:"extractable",type:"Boolean",required:!0},{name:"usages",type:"Array",required:!0},{name:"keyData",type:"Array",required:!0}],y={encrypt:[0,1,2],decrypt:[0,1,2],sign:[0,1,2],verify:[0,1,3,2],digest:[0,2],generateKey:[0,6,7],importKeyRaw:[4,12,0,10,11],importKeyJwk:[4,5,0,10,11],exportKey:[0,4,1,6,7],deriveKey:[0,1,8,6,7],deriveBits:[0,1,9],wrapKey:[1,1,0],unwrapKey:[2,0,1,6,7]};function p(e){var r=s.lookup(e);if(!r)throw new Error("key not found");return r}function d(e,t,n){var u=function(e,r){var t,n,o,i,a={operationType:e};for("importKey"!==e||"raw"!==r[0]&&"spki"!==r[0]||(e="importKeyRaw"),"importKey"===e&&"jwk"===r[0]&&(e="importKeyJwk"),t=y[e],i=0;i=n&&f.stopCollectors()}var l=e&&e.addEventListener||"undefined"!=typeof document&&document.attachEvent,f={startCollectors:function(){if(!this.collectorsRegistered){if(e.addEventListener)e.addEventListener("mousemove",this.MouseEventCallBack,!0),e.addEventListener("load",this.LoadTimeCallBack,!0);else{if(!document.attachEvent)throw new Error("Can't attach events for entropy collection");document.attachEvent("onmousemove",this.MouseEventCallBack),document.attachEvent("onload",this.LoadTimeCallBack)}this.collectorsRegistered=1}},stopCollectors:function(){this.collectorsRegistered&&(e.removeEventListener?(e.removeEventListener("mousemove",this.MouseEventCallBack,1),e.removeEventListener("load",this.LoadTimeCallBack,1)):e.detachEvent&&(e.detachEvent("onmousemove",this.MouseEventCallBack),e.detachEvent("onload",this.LoadTimeCallBack)),this.collectorsRegistered=0)},MouseEventCallBack:function(e){var r=(new Date).valueOf(),t=e.x||e.clientX||e.offsetX||0,n=e.y||e.clientY||e.offsetY||0;c([255&r,r>>8&255,r>>16&255,r>>24&255,255&t,t>>8&255,255&n,n>>8&255])},LoadTimeCallBack:function(){var e=(new Date).valueOf();c([255&e,e>>8&255,e>>16&255,e>>24&255])}};return{init:function(){if(s(),!a&&l)try{f.startCollectors()}catch(e){}},reseed:function(e){o.reseed(e)},read:function(e){if(!i)throw new Error("Entropy pool is not initialized.");var r=o.getBytes(e);return s(),r}}}(e)).init();var fe=ce.read(48);return J.init(fe),le}()}),function(e,r){"undefined"==typeof Promise&&(e.Promise=function(){var e=function(r,t){if(!(this instanceof e))throw new Error("use 'new' keyword with Promise constructor");var n=null,o=null,i=[],a=[],u=[],s=[];this.then=function(r,t){var c;return n?(c=r(n.result))&&c.then?c:e.resolve(c):o?(c=t?t(o.result):o.result)&&c.then?c:e.resolve(c):(i.push(r),t&&a.push(t),new e(function(e,r){s.push(e),u.push(r)}))},this["catch"]=function(r){var t;return o?(t=r(o.result))&&t.then?t:e.resolve(t):(a.push(r),new e(function(e,r){s.push(e),u.push(r)}))},r(function(e){var r,t;for(t=0;t