//******************************************************************************* // // Copyright 2014 Microsoft // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //******************************************************************************* var msrCryptoVersion="1.4",msrCrypto=msrCrypto||function(){"use strict";function gt(){function f(n){var t,i=null;if(arguments.length&&typeof arguments[0]!="number"){if(typeof arguments[0]=="object")for(i=new Array(n.length),t=0;t=t;)o[0]=o[0]*t,c=c.concat("0");for(f=0;f=0;){for(t=0;t<8;){var e=1<>>1,u=t;u-->0;){if((n&i)===i)break;i=i>>>1}return u}function lt(n){for(var r=0,t=0,i,u;r=0&&t===0;)u=1<0)i[r+u]=n[t+u]}function w(n){for(var t=0;t=0;u--)t=t+v[f++]*(n[u]&255),v[f]===r&&(f=0,i[e++]=t,t=0);return t!==0&&(i[e]=t),i}function pt(n,t,i){var u,f,e,r=[0];for(typeof t=="undefined"&&(t=!0),u=0;ui&&r[0]===0)r.shift();return r}function l(n,i){var f,u;for(typeof i=="undefined"&&(n<=1?i=1:(f=Math.log(n)/Math.LN2,i=Math.ceil(f/t))),u=[];n>0;)u.push(n%r),n=Math.floor(n/r);while(u.length=0;t--)if(n[t]!==undefined&&n[t]!==0)return t;return n[0]===0?-1:0}function o(n,t){var i=0,r=c(n)+1,u=c(t)+1;if(r>u)i=1;else if(u>r)i=-1;else while(r-->0&&i===0)i=n[r]-t[r];return i}function u(n,t,i){var r=c(n);if(n.length=t||r+1,i)while(++r=t||u<0)throw new Error("Invalid bit count for shiftRight");for(f===undefined&&(f=n.length),o=f-1,s=t-u,e=0;e>>u)&i;r[o]=n[o]>>>u}function g(n,r,u,f){var o,e;if(u===undefined)u=1;else if(u>=t||u<0)throw new Error("bit count must be smaller than DIGIT_BITS and positive in shiftLeft");for(f===undefined&&(f=n.length),o=t-u,r[f]=n[f-1]>>>t-u||r[f],e=f-1;e>0;e--)r[e]=(n[e]<>>o)&i;r[0]=n[0]<>t;for(e=h;e>t;return u.length=o.length,f!==0&&(u[e]=f&i),f}function rt(n,r,u){var o=r.length,e,f;if(n.length>t;while(e>t;return f}function a(n,t,u){for(var s=typeof t=="number"?[t]:t,h=Math.max(n.length,s.length),e,o,f=0;f=0;v--)rt=k*r+n[v],o[v]=rt/w&i,k=rt-o[v]*w&i;o.length=b;u(o);s[0]=k;s.length=1;return}for(ut=t-1-it(f[a-1]),d=h||[],d.length=a,g(f,d,ut,a),y=l||[],y.length=b,g(n,y,ut,b),y[b]=y[b]||0,o.length=b-a+1,s.length=a,v=b-a;v>=0;v--){for(nt=Math.floor((y[v+a]*r+y[v+a-1])/d[a-1]),k=y[v+a]*r+y[v+a-1]-nt*d[a-1];;)if(!(nt>=r)&&!(nt*d[a-2]>k*r+y[v+a-2])||(nt=nt-1,k=k+d[a-1],!(k>t;y[v+a]=y[v+a]+tt&i}}for(p=0;p>>ut|y[p+1]<0&&(r=t,f=n),ft(r,f,undefined,undefined,i),u(i)}function dt(n,t,i){var r=new Array(t.length),s=new Array(t.length),f=new Array(t.length),h=ft(n,t,s,r,f);return i=i||[],o(f,p)!==0?(i[0]=NaN,i.length=1):((h&1)==1?rt(t,r,i):(e(r,0,i,0,r.length),i.length=r.length),u(i)),i}function gt(n,t,i,r){if(r=r||[],o(t,k)===0)r[0]=1;else if(o(t,p)===0)e(n,0,r,0,n.length),r.length=n.length;else{var f=new nt(i);u(n,f.s,!0);f.modExp(n,t,r);r.length=i.length}return r}function nt(n){function et(n){for(var f=1,r=2,u=3,e=u&n,o=2;o<=t;o+=1)r>t),v[o]=c&i;for(c=(l&i)+(c>>t),c=(l>>>t)+(c>>t),o=0;o>>t-s,l,a,y,d,o=r.length-1;o>0&&r[o]===0;o--);for(l=o*t+it(r[o])+1,l=l+(s-l%s),a=l%t-s,a<0&&(a+=t),y=b<0;)this.montgomeryMultiply(p,p,w),this.montgomeryMultiply(w,w,k),d=(r[Math.floor((l-1)/t)]&y)>>>a,this.montgomeryMultiply(k,h[d],p),l=l-s,a=a-s,y=y>>>s,y===0&&(y=b<=0)throw new Error("The number provided is not an element of this group");return u(i,this.m_digitWidth,!0),s(i,this)}function b(n){var t=l(n,this.m_digitWidth);return s(t,this)}function k(t){return n.normalizeDigitArray(t,this.m_digitWidth,!0),s(t,this)}function g(n){return o(this.m_modulus,n.m_modulus)===0}function tt(r,u,f){var e,c=this.m_digitWidth,h=f.m_digits,l,s;for(n.add(r.m_digits,u.m_digits,h),l=o(h,this.m_modulus)>=0?i:0,s=0,e=0;e>t;h.length=c}function it(r,u,f){var e,h=this.m_digitWidth,s=f.m_digits,o=n.subtract(r.m_digits,u.m_digits,f.m_digits);if(o===-1)for(o=0,e=0;e>t}function rt(t,i){n.modInv(t.m_digits,this.m_modulus,i.m_digits)}function ut(t,i,r){return n.modMul(t.m_digits,i.m_digits,this.m_modulus,r.m_digits,v,y)}function ft(n,t,i){if(i=i||s([],this),o(t,c)===0)i.m_digits=l(1,this.m_digitWidth);else if(o(t,a)===0){for(var r=0;r>>n.DIGIT_BITS;u=u<=0)throw new Error("The scalar k must be in the range 1 <= k < order.");if(t=t.slice(),r.curve.type===1)e=typeof r.ta!="undefined",e||lt(r),li(t,r,u,f),e||rt(r);else{var o=r.isInMontgomeryForm,s=u.isInMontgomeryForm,h=u.isAffine;o||ht(r);s||ht(u);si(t,r,u);h&&it(u);o||nt(r);s||nt(u)}return}function si(t,i,r){var w=i.clone(),c,o,u,p,h;if(nt(w),!gt(w))throw new Error("Invalid Parameters.");for(c=t[0]&1,o=[],e(i.curve.order,t,o),u=0;u=0;u--){for(p=0;p=0;o--){for(v=0;v=0;t-=1)if(n[t]+=1,n[t]>=256&&(n[t]=0),n[t])break}function h(){r=i.getVector(32);t=i.getVector(16);e=32;n=48;u=1}function c(t,r){var f,e;if(r=r||[0],r.length>n)throw new Error("Incorrect entropy or additionalEntropy length");for(r=r.concat(i.getVector(n-r.length)),t=t.concat(i.getVector((n-t.length%n)%n)),f=0;f=65536)throw new Error("too much random requested");if(u>a)throw new Error("Reseeding is required");if(e&&e.length>0){while(e.length=c&&f.stopCollectors()}var e=48,n=[],c=128,l=0,t=new at,r=!1,u=!1,o=["Cookie","RedirectUri","ETag","x-ms-client-antiforgery-id","x-ms-client-request-id","x-ms-client-session-id","SubscriptionPool"],f=function(){return{startCollectors:function(){if(!this.collectorsRegistered){if(window.addEventListener)window.addEventListener("mousemove",this.MouseEventCallBack,!0),window.addEventListener("load",this.LoadTimeCallBack,!0);else if(document.attachEvent)document.attachEvent("onmousemove",this.MouseEventCallBack),document.attachEvent("onload",this.LoadTimeCallBack);else throw new Error("Can't attach events for entropy collection");this.collectorsRegistered=1}},stopCollectors:function(){this.collectorsRegistered&&(window.removeEventListener?(window.removeEventListener("mousemove",this.MouseEventCallBack,1),window.removeEventListener("load",this.LoadTimeCallBack,1)):window.detachEvent&&(window.detachEvent("onmousemove",this.MouseEventCallBack),window.detachEvent("onload",this.LoadTimeCallBack)),this.collectorsRegistered=0)},MouseEventCallBack:function(n){var t=(new Date).valueOf(),i=n.x||n.clientX||n.offsetX||0,r=n.y||n.clientY||n.offsetY||0,u=[t&255,t>>8&255,t>>16&255,t>>24&255,i&255,i>>8&255,r&255,r>>8&255];h(u)},LoadTimeCallBack:function(){var n=(new Date).valueOf(),t=[n&255,n>>8&255,n>>16&255,n>>24&255];h(t)}}}();return{init:function(){if(s(),!u&&!l)try{f.startCollectors()}catch(n){}},reseed:function(n){t.reseed(n)},read:function(n){if(!r)throw new Error("Entropy pool is not initialized.");var i=t.getBytes(n);return s(),i}}}var t={},c,n,vt,g,d,l,a,f,k,ht,w,e,v,h,s,p,r,nt,tt,b,ft,o,wt,lt,st,ut,kt;t.register=function(n,i,r){t[n]||(t[n]={});var u=t[n];u[i]||(u[i]=r)};t.exists=function(n,i){return t[n]?t[n][i]?!0:!1:!1};var yt=function(){if(typeof document!="undefined")try{throw new Error;}catch(t){if(t.stack){var n=/\w+:\/\/(.+?\/)*.+\.js/.exec(t.stack);return n&&n.length>0?n[0]:null}}else if(typeof self!="undefined")return self.location.href;return null}(),ui=!1,bt=typeof Worker!="undefined",ct=typeof importScripts!="undefined",fi=typeof Uint8Array!="undefined",ot=function(){try{return Object.defineProperty({},"oncomplete",{}),!0}catch(n){return!1}}(),it=bt,rt=function(n,t,i,r,u){if(!ot){n[t]=i;return}var f={};r&&(f.get=r);u&&(f.set=u);Object.defineProperty(n,t,f)},y={},i=function(){function f(t,r){var f="",h,e,o,l,a,c,s,u;if(r||(r=!1),(t.pop||t.subarray)&&(t=String.fromCharCode.apply(null,t)),i)f=btoa(t);else for(u=0;u>2,a=(h&3)<<4|e>>4,c=(e&15)<<2|o>>6,s=o&63,isNaN(e)?c=s=64:isNaN(o)&&(s=64),f=f+n.charAt(l)+n.charAt(a)+n.charAt(c)+n.charAt(s);return r?f.replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,""):f}function e(n){if(i){for(n=n.replace(/-/g,"+").replace(/_/g,"/");n.length%4!=0;)n+="=";return atob(n)}return String.fromCharCode.apply(null,t(n))}function t(t){for(t=t.replace(/-/g,"+").replace(/_/g,"/");t.length%4!=0;)t+="=";var r=[],o,s,h,c,f,u,e,i;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),i=0;i>4,s=(f&15)<<4|u>>2,h=(u&3)<<6|e,r.push(o),u!==64&&r.push(s),e!==64&&r.push(h);return r}function r(n){return Object.prototype.toString.call(n).slice(8,-1)}function o(n,t){var r="",i,u;for(typeof t=="undefined"&&(t=!1),i=0;i=2;)t.push(parseInt(n.substring(0,2),16)),n=n.substring(2,n.length);return t}function l(n){var i={};for(var t in n)n.hasOwnProperty(t)&&(i[t]=n[t]);return i}function a(n,i,r){var e=t(n),f=[],u;if(isNaN(i))return e;for(u=0;u>>24&255,n>>>16&255,n>>>8&255,n&255]}function v(n){for(var t=[],i=0;i255)return!1;return!0}var n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",i=typeof btoa!="undefined";return{toBase64:f,base64ToString:e,base64ToBytes:t,getObjectType:r,bytesToHexString:o,bytesToInt32:s,stringToBytes:h,unpackData:a,hexToBytesArray:c,int32ToBytes:u,int32ArrayToBytes:v,toArray:w,arraysEqual:d,clone:l,xorVectors:y,padEnd:b,padFront:k,getVector:p,verifyByteArray:g}}(),pt=function(){function n(n){return ct&&self.postMessage(n),n}return{jsCryptoRunner:function(i){var e=i.data.operationType,u,f,r;if(!t.exists(e,i.data.algorithm.name))throw new Error("unregistered algorithm.");return f=t[e][i.data.algorithm.name],r=i.data,r.operationSubType==="process"?(f(r),u=n({type:"process"})):u=n(f(r)),u}}}();ct&&(self.onmessage=function(n){if(n.data.prngSeed){var t=n.data.prngSeed;s.init(t);return}pt.jsCryptoRunner(n)});c=function(){function r(n){for(var t=[],i=0;i>>24&255,i[t-3]=r>>>16&255,i[t-2]=r>>>8&255,i[t-1]=r&255,n.concat(i)}function b(n){return s=l(n),v()}function k(n){s=s.concat(n);s.length>=f&&(s=l(s));return}function v(){if(l(w(s)).length!==0)throw new Error("buffer.length !== 0");var n=p();return s=[],h=r.slice(),c=0,n}var a=i,h=r.slice(),y=new Array(f),s=[],c=0;return{name:n,computeHash:b,process:k,finish:v,der:t,hashLen:o,maxMessageSize:4294967295}};d=function(){function r(n,i,r,u,f){for(var s,v,y,l=4294967295,a=r[0],o=r[1],h=r[2],c=r[3],p=r[4],e=0;e<16;e++)f[e]=t.bytesToInt32(n,i*64+e*4);for(s=16;s<80;s++)y=f[s-3]^f[s-8]^f[s-14]^f[s-16],f[s]=y<<1|y>>>31;for(e=0;e<80;e++)v=a<<5|a>>>27,v+=e>=60?o^h^c:e>=40?o&h^o&c^h&c:e>=20?o^h^c:o&h^~o&c,v+=p+u[e]+f[e],p=c,c=h,h=o<<30|o>>>2,o=a,a=v;return r[0]+=a&l,r[1]+=o&l,r[2]+=h&l,r[3]+=c&l,r[4]+=p&l,r}var t=i,n=t.unpackData,u=n("Z0UjAe/Nq4mYutz+EDJUdsPS4fA=",4,1),f=n("WoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlagnmZWoJ5mVqCeZlu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroW7Z66Fu2euhbtnroY8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcjxu83I8bvNyPG7zcymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdbKYsHWymLB1spiwdY",4,1),e=n("MCEwCQYFKw4DAhoFAAQU");return{sha1:g("SHA-1",e,u,f,64,r,160)}}();typeof t!="undefined"&&(d.hash=function(n){if(n.operationSubType==="process"){d.sha1.process(n.buffer);return}return n.operationSubType==="finish"?d.sha1.finish():d.sha1.computeHash(n.buffer)},t.register("digest","sha-1",d.hash));y["sha-1"]=d.sha1;l=function(){function u(n,t,i,u,f){for(var o,p,l,a,c=4294967295,h=i[0],v=i[1],y=i[2],w=i[3],e=i[4],b=i[5],k=i[6],d=i[7],s=0;s<16;s++)f[s]=r.bytesToInt32(n,t*64+s*4);for(o=16;o<64;o++)l=f[o-15],a=f[o-2],f[o]=((a>>>17|a<<15)^(a>>>19|a<<13)^a>>>10)+f[o-7]+((l>>>7|l<<25)^(l>>>18|l<<14)^l>>>3)+f[o-16],f[o]=f[o]&c;for(s=0;s<64;s++)p=d+((e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7))+(e&b^~e&k)+u[s]+f[s],w+=p,p+=((h>>>2|h<<30)^(h>>>13|h<<19)^(h>>>22|h<<10))+(h&(v^y)^v&y),d=k,k=b,b=e,e=w,w=y,y=v,v=h,h=p;return i[0]+=h&c,i[1]+=v&c,i[2]+=y&c,i[3]+=w&c,i[4]+=e&c,i[5]+=b&c,i[6]+=k&c,i[7]+=d&c,i}var r=i,t,f,e,o,s,n=r.unpackData;return f=n("wQWe2DZ81QcwcN0X9w5ZOf/ACzFoWBURZPmPp776T6Q",4,1),e=n("agnmZ7tnroU8bvNypU/1OlEOUn+bBWiMH4PZq1vgzRk",4,1),t=n("QoovmHE3RJG1wPvP6bXbpTlWwltZ8RHxkj+CpKscXtXYB6qYEoNbASQxhb5VDH3Dcr5ddIDesf6b3AanwZvxdOSbacHvvkeGD8GdxiQMocwt6SxvSnSEqlywqdx2+YjamD5RUqgxxm2wAyfIv1l/x8bgC/PVp5FHBspjURQpKWcntwqFLhshOE0sbfxTOA0TZQpzVHZqCruBwskuknIshaK/6KGoGmZLwkuLcMdsUaPRkugZ1pkGJPQONYUQaqBwGaTBFh43bAgnSHdMNLC8tTkcDLNO2KpKW5zKT2gub/N0j4LueKVjb4TIeBSMxwIIkL7/+qRQbOu++aP3xnF48g",4,1),o=n("MC0wDQYJYIZIAWUDBAIEBQAEHA"),s=n("MDEwDQYJYIZIAWUDBAIBBQAEIA"),{sha224:g("SHA-224",o,f,t,64,u,224),sha256:g("SHA-256",s,e,t,64,u,256)}}();typeof t!="undefined"&&(l.hash256=function(n){if(n.operationSubType==="process"){l.sha256.process(n.buffer);return}return n.operationSubType==="finish"?l.sha256.finish():l.sha256.computeHash(n.buffer)},l.hash224=function(n){if(n.operationSubType==="process"){l.sha224.process(n.buffer);return}return n.operationSubType==="finish"?l.sha224.finish():l.sha224.computeHash(n.buffer)},t.register("digest","sha-224",l.hash224),t.register("digest","sha-256",l.hash256));y["sha-224"]=l.sha224;y["sha-256"]=l.sha256;a=function(){function n(n,t,i,r,u){var f=t+r|0,e=f>>>0>>0;u[0]=n+i+e|0;u[1]=f;return}function u(t,i,r,u,f){for(var b,a,v,k,d,s,h,e=[],ht=[],w=[],ct,y=r[0],p=r[1],g=r[2],nt=r[3],tt=r[4],it=r[5],rt=r[6],ut=r[7],c=r[8],l=r[9],ft=r[10],et=r[11],ot=r[12],st=r[13],lt=r[14],at=r[15],o=0;o<32;o++)ct=i*128+o*4,f[o]=t.slice(ct,ct+4),f[o]=f[o][0]<<24|f[o][1]<<16|f[o][2]<<8|f[o][3];for(o=32;o<160;o+=2)s=f[o-30],h=f[o-29],a=(s>>>1|h<<31)^(s>>>8|h<<24)^s>>>7,v=(h>>>1|s<<31)^(h>>>8|s<<24)^(h>>>7|s<<25),s=f[o-4],h=f[o-3],k=(s>>>19|h<<13)^(h>>>29|s<<3)^s>>>6,d=(h>>>19|s<<13)^(s>>>29|h<<3)^(h>>>6|s<<26),n(k,d,f[o-14],f[o-13],e),n(a,v,e[0],e[1],e),n(f[o-32],f[o-31],e[0],e[1],e),f[o]=e[0],f[o+1]=e[1];for(b=0;b<160;b+=2)a=(c>>>14|l<<18)^(c>>>18|l<<14)^(l>>>9|c<<23),v=(l>>>14|c<<18)^(l>>>18|c<<14)^(c>>>9|l<<23),k=c&ft^ot&~c,d=l&et^st&~l,n(lt,at,a,v,e),n(k,d,u[b],u[b+1],ht),n(e[0],e[1],f[b],f[b+1],w),n(ht[0],ht[1],w[0],w[1],w),n(w[0],w[1],rt,ut,e),rt=e[0],ut=e[1],v=(p>>>28|y<<4)^(y>>>2|p<<30)^(y>>>7|p<<25),a=(y>>>28|p<<4)^(p>>>2|y<<30)^(p>>>7|y<<25),d=p&(nt^it)^nt&it,k=y&(g^tt)^g&tt,n(w[0],w[1],a,v,e),a=e[0],v=e[1],n(k,d,a,v,e),a=e[0],v=e[1],lt=ot,at=st,ot=ft,st=et,ft=c,et=l,c=rt,l=ut,rt=tt,ut=it,tt=g,it=nt,g=y,nt=p,y=a,p=v;return n(r[0],r[1],y,p,e),r[0]=e[0],r[1]=e[1],n(r[2],r[3],g,nt,e),r[2]=e[0],r[3]=e[1],n(r[4],r[5],tt,it,e),r[4]=e[0],r[5]=e[1],n(r[6],r[7],rt,ut,e),r[6]=e[0],r[7]=e[1],n(r[8],r[9],c,l,e),r[8]=e[0],r[9]=e[1],n(r[10],r[11],ft,et,e),r[10]=e[0],r[11]=e[1],n(r[12],r[13],ot,st,e),r[12]=e[0],r[13]=e[1],n(r[14],r[15],lt,at,e),r[14]=e[0],r[15]=e[1],r}var l=i,e,f,r,o,s,h,c,t=l.unpackData;return e=t("y7udXcEFnthimikqNnzVB5FZAVowcN0XFS/s2PcOWTlnMyZn/8ALMY60SodoWBUR2wwuDWT5j6dHtUgdvvpPpA==",4,1),f=t("agnmZ/O8yQi7Z66FhMqnOzxu83L+lPgrpU/1Ol8dNvFRDlJ/reaC0ZsFaIwrPmwfH4PZq/tBvWtb4M0ZE34heQ",4,1),r=t("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),o=t("MEEwDQYJYIZIAWUDBAICBQAEMA"),s=t("MFEwDQYJYIZIAWUDBAIDBQAEQA"),h=t("MC0wDQYJYIZIAWUDBAIFBQAEHA"),c=t("MDEwDQYJYIZIAWUDBAIGBQAEIA"),{sha384:g("SHA-384",o,e,r,128,u,384),sha512:g("SHA-512",s,f,r,128,u,512),sha512_224:g("SHA-512.224",h,f,r,128,u,224),sha512_256:g("SHA-512.256",c,f,r,128,u,256)}}();typeof t!="undefined"&&(a.hash384=function(n){if(n.operationSubType==="process"){a.sha384.process(n.buffer);return}return n.operationSubType==="finish"?a.sha384.finish():a.sha384.computeHash(n.buffer)},a.hash512=function(n){if(n.operationSubType==="process"){a.sha512.process(n.buffer);return}return n.operationSubType==="finish"?a.sha512.finish():a.sha512.computeHash(n.buffer)},t.register("digest","sha-384",a.hash384),t.register("digest","sha-512",a.hash512));y["sha-384"]=a.sha384;y["sha-512"]=a.sha512;f=function(){function v(n,t){for(var r=new Array(n),i=0;it?y(n.computeHash(i),t):y(i,t)}function h(i){var f,e,u;if(r)n.process(i);else{for(o=new Array(t),s=new Array(t),u=0;u6&&t%a==4&&k(i),e=tt(rt(r,t-a),i),ot(r,e,t,0),t+=1;return r};return y=st(l),{encrypt:function(n){var t=n,i;for(w(t,y,0),i=1;i<=v-1;i+=1)k(t),g(t),ut(t),w(t,y,4*i*p);return k(t),g(t),w(t,y,4*v*p),t},decrypt:function(n){var t=n,i;for(w(t,y,4*v*p),i=v-1;i>=1;i-=1)nt(t),it(t),w(t,y,4*i*p),ft(t);return nt(t),it(t),w(t,y,0),t},clear:function(){},keyLength:b,blockSize:d}}}}();ht=ht||{};ht.pkcsv7=function(n){function t(t){var o=t.length-1>=0?t.length-1:0,i=t[o],f=i.length,s=f===n,r,u,e;if(s){for(r=[],u=0;u0;t--)n[t]=(n[t-1]&1)<<7|n[t]>>>1;return n[0]=n[0]>>>1,n}function it(n,t){var i=Math.floor(t/8);return n[i]>>7-t%8&1}function nt(n){for(var i=256,t=1;t<=4;t++)i=(i>>>8)+n[n.length-t],n[n.length-t]=i&255;return n}function o(t,i){var h=Math.ceil(i.length/16),o,e=[],u,s;for(f!==t&&(f=t.slice()),u=0;u>>24&255,n>>>16&255,n>>>8&255,n&255]}function rt(n){var t=16*Math.ceil(v.length/16)-v.length;return n.concat(r.getVector(t))}function b(){e=0;t=[];u=[];p=r.getVector(16);k=[];f=s=v=null}function ut(n,t,i){if(v=t||[],h=isNaN(i)?128:i,h%8!=0)throw new Error("DataError");if(s=n,s.length===12)c=s.concat([0,0,0,1]);else{var u=16*Math.ceil(s.length/16)-s.length;c=a(l,s.concat(r.getVector(u+8)).concat(d(s.length*8)));p=r.getVector(16)}y=nt(c.slice());a(l,rt(v))}function ft(n){var t,i,r;return e=n.length,t=o(y,n),a(l,t),i=w(),r=o(c,i).slice(0,h/8),b(),t.slice().concat(r)}function et(n,t){var i,u,f;return e=n.length,i=o(y,n),a(l,n),u=w(),f=o(c,u).slice(0,h/8),b(),r.arraysEqual(f,t)?i:null}function ot(n){var i,r;t=t.concat(n);i=t.slice(0,Math.floor(t.length/16)*16);e+=i.length;t=t.slice(i.length);r=o(f||y,i);u=u.concat(r);a(l,r)}function st(n){var i,r;t=t.concat(n);i=t.slice(0,Math.floor((t.length-h/8)/16)*16);e+=i.length;t=t.slice(i.length);r=o(f||y,i);u=u.concat(r);a(l,i)}function ht(){var n=o(f,t);u=u.concat(n);e+=t.length;var i=w(),r=o(c,i).slice(0,h/8),s=u.slice().concat(r);return b(),s}function ct(){var n=Math.floor(h/8),s=t.slice(-n),i;t=t.slice(0,t.length-n);i=o(f,t);u=u.concat(i);e+=t.length;var l=w(),a=o(c,l).slice(0,h/8),v=u.slice();if(b(),r.arraysEqual(a,s))return v;throw new Error("OperationError");}var r=i,t=[],s,v,h,c,y,l=n.encrypt(r.getVector(16)),p=r.getVector(16),k=[],u=[],f,e=0;return{init:ut,encrypt:ft,decrypt:et,processEncrypt:ot,processDecrypt:st,finishEncrypt:ht,finishDecrypt:ct}};typeof t!="undefined"&&(v.encrypt=function(n){var t;if(h||(h=v(k.aes(n.keyData)),h.init(n.algorithm.iv,n.algorithm.additionalData,n.algorithm.tagLength)),n.operationSubType==="process"){h.processEncrypt(n.buffer);return}return n.operationSubType==="finish"?(t=h.finishEncrypt(),h=null,t):(t=h.encrypt(n.buffer),h=null,t)},v.decrypt=function(n){var t;if(h||(h=v(k.aes(n.keyData)),h.init(n.algorithm.iv,n.algorithm.additionalData,n.algorithm.tagLength)),n.operationSubType==="process"){h.processDecrypt(n.buffer);return}if(n.operationSubType==="finish")return t=h.finishDecrypt(),h=null,t;var i=Math.floor(n.algorithm.tagLength/8),r=n.buffer.slice(0,n.buffer.length-i),u=n.buffer.slice(-i);return t=h.decrypt(r,u),h=null,t},v.generateKey=function(n){if(n.algorithm.length%8!=0)throw new Error;return{type:"keyGeneration",keyData:s.getBytes(Math.floor(n.algorithm.length/8)),keyHandle:{algorithm:n.algorithm,extractable:n.extractable,keyUsage:null||n.keyUsage,type:"secret"}}},v.importKey=function(n){var t=c.jwkToKey(n.keyData,n.algorithm,["k"]);return{type:"keyImport",keyData:t.k,keyHandle:{algorithm:n.algorithm,extractable:n.extractable||t.extractable,keyUsage:null||n.keyUsage,type:"secret"}}},v.exportKey=function(n){var t=c.keyToJwk(n.keyHandle,n.keyData);return{type:"keyExport",keyHandle:t}},t.register("importKey","aes-gcm",v.importKey),t.register("exportKey","aes-gcm",v.exportKey),t.register("generateKey","aes-gcm",v.generateKey),t.register("encrypt","aes-gcm",v.encrypt),t.register("decrypt","aes-gcm",v.decrypt));s=new at;var ni=function(t){function r(t){var i=n.digitsToBytes(t);return f.padFront(i,0,s),i}function u(t,i,r){var f=n.bytesToDigits(i),u=n.IntegerGroup(r),e=u.createElementFromBytes(t),o=u.modexp(e,f);return o.m_digits}function h(n){var i=u(n,t.d,t.n);return r(i)}function c(i){var l=t.p,a=t.q,v=t.dp,y=t.dq,p=t.qi,f=n.bytesToDigits(l),o=n.bytesToDigits(a),u=new Array(f.length+o.length),s=new Array(f.length+1),h=new Array(o.length+1),e=n.bytesToDigits(i),c;return n.reduce(e,f,u),n.modExp(u,n.bytesToDigits(v),f,s),n.reduce(e,o,u),n.modExp(u,n.bytesToDigits(y),o,h),c=n.subtract(s,h,u),c!==0&&n.subtract(h,s,u),n.modMul(u,n.bytesToDigits(p),f,e),c!==0&&n.subtract(f,e,e),n.multiply(e,o,u),n.add(h,u,s),r(s)}var f=i,e=t.hasOwnProperty("n")&&t.hasOwnProperty("d"),o=t.hasOwnProperty("p")&&t.hasOwnProperty("q"),s=t.n.length;return{encrypt:function(n){return r(u(n,t.e,t.n))},decrypt:function(n){if(o)return c(n);if(e)return h(n);throw new Error("missing private key");}}},et={mgf1:function(n,t,i){for(var u=[],f,e,o=i.hashLen/8,r=0;r<=Math.floor(t/o);r+=1)f=[r>>>24&255,r>>>16&255,r>>>8&255,r&255],e=i.computeHash(n.concat(f)),u=u.concat(e);return u.slice(0,t)},checkMessageVsMaxHash:function(n,t){if(n.length>(t.maxMessageSize||4294967295))throw new Error("message too long");return}},p=p||{};return p.oaep=function(n,t){function e(n,i){var e,c,l,a,o,v,s,y,p,h;if(n.length>u-t.hashLen/4-2)throw new Error("Message too long.");return i||(i=[]),e=t.computeHash(i),c=u-n.length-2*e.length-2,l=r.getVector(c),a=e.concat(l,[1],n),o=f.getBytes(e.length),v=et.mgf1(o,u-e.length-1,t),s=r.xorVectors(a,v),y=et.mgf1(s,e.length,t),p=r.xorVectors(o,y),h=[0].concat(p).concat(s),n=h.slice(),h}function o(n,i){var f,s,o,h,c,l,e,a,v;if(i||(i=[]),f=t.computeHash(i),n[0]!==0)throw new Error("Encryption Error");if(s=n.slice(1,f.length+1),o=n.slice(f.length+1),h=et.mgf1(o,f.length,t),c=r.xorVectors(s,h),l=et.mgf1(c,u-f.length-1,t),e=r.xorVectors(o,l),a=e.slice(0,f.length),!r.arraysEqual(f,a))throw new Error("Encryption Error");return e=e.slice(f.length),v=e.indexOf(1),e.slice(v+1)}var r=i,f=s,u=n.n.length;if(t===null)throw new Error("must supply hashFunction");return{pad:function(n,t){return e(n,t)},unpad:function(n,t){return o(n,t)}}},p=p||{},p.pkcs1Encrypt=function(n){function r(n){var r;if(n.length>t-11)throw new Error("message too long");return r=i.getNonZeroBytes(t-n.length-3),[0,2].concat(r,[0],n)}function u(n){for(var t=1;t>>8-(8*o-l),h=0;hf&&(i.length=f),u=r(i),o&&(e=8-t.rbits%8,n.shiftRight(u,u,e)),n.reduce(u,t.order,u),u}function v(i,u,o){o||(o=c());var h=o.publicKey.x,v=o.privateKey,y=r(i.d),p=l(u.slice()),s=[],a=[];return n.reduce(h,t.order,h),n.modMul(h,y,t.order,s),n.add(s,p,s),n.reduce(s,t.order,s),n.modInv(v,t.order,a),n.modMul(s,a,t.order,s),e(h,!0,f).concat(e(s,!0,f))}function y(f,e,s){var p=Math.floor(e.length/2),w=r(e.slice(0,p)),v=r(e.slice(p)),k=l(s.slice()),c=[],y=[],b=new u.EllipticCurvePointFp(t,!1,r(f.x),r(f.y),null,!1),h,a;return(n.modInv(v,t.order,v),n.modMul(k,v,t.order,c),n.modMul(w,v,t.order,y),h=t.allocatePointStorage(),a=t.allocatePointStorage(),o?(n.add(c,c,c),n.add(c,c,c),n.reduce(c,t.order,c),i.scalarMultiply(c,t.generator,h,!1),i.scalarMultiply(y,b,a,!1),i.convertToExtendedProjective(h),i.convertToExtendedProjective(a),i.add(a,h,h),i.normalize(h)):(i.scalarMultiply(c,t.generator,h),i.scalarMultiply(y,b,a),i.convertToJacobianForm(h),i.convertToMontgomeryForm(h),i.convertToMontgomeryForm(a),i.mixedAdd(h,a,h),i.convertToAffineForm(h),i.convertToStandardForm(h)),h.isInfinity)?!1:(n.reduce(h.x,t.order,h.x),n.compareDigits(h.x,w)===0)}var r=n.bytesToDigits,e=n.digitsToBytes,i=new u.EllipticCurveOperatorFp(t),f=e(t.order).length,o=t.type===1;return{createKey:a,generateKey:c,sign:v,verify:y}},typeof t!="undefined"&&(o.sign=function(n){var t=n.algorithm.hash.name,i=u.createCurve(n.algorithm.namedCurve.toUpperCase()),r=y[t.toLowerCase()],f=r.computeHash(n.buffer),e=o(i);return e.sign(n.keyData,f)},o.verify=function(n){var t=n.algorithm.hash.name,i=u.createCurve(n.algorithm.namedCurve.toUpperCase()),r=y[t.toLowerCase()],f=r.computeHash(n.buffer),e=o(i);return e.verify(n.keyData,n.signature,f)},o.generateKey=function(t){function e(n){return i.padFront(n,0,Math.ceil(n.length/8)*8)}var c=u.createCurve(t.algorithm.namedCurve.toUpperCase()),l=o(c),r=l.generateKey(),f=n.digitsToBytes,s=e(f(r.publicKey.x)),h=e(f(r.publicKey.y)),a=e(f(r.privateKey));return{type:"keyPairGeneration",keyPair:{publicKey:{keyData:{x:s,y:h},keyHandle:{algorithm:t.algorithm,extractable:t.extractable,keyUsage:null||t.keyUsage,type:"public"}},privateKey:{keyData:{x:s,y:h,d:a},keyHandle:{algorithm:t.algorithm,extractable:t.extractable,keyUsage:null||t.keyUsage,type:"private"}}}}},o.importKey=function(n){var t=c.jwkToKey(n.keyData,n.algorithm,["x","y","d","crv"]);if(t.d&&(!t.x||!t.y)){var r=o.curves[n.algorithm.namedCurve](),u=o(r),i=u.computePublicKey(t.d);t.x=i.x;t.y=i.y}return{type:"keyImport",keyData:t,keyHandle:{algorithm:n.algorithm,extractable:n.extractable||t.extractable,keyUsage:null||n.keyUsage,type:t.d?"private":"public"}}},o.exportKey=function(n){var t=c.keyToJwk(n.keyHandle,n.keyData);return{type:"keyExport",keyHandle:t}},t.register("sign","ecdsa",o.sign),t.register("verify","ecdsa",o.verify),t.register("generateKey","ecdsa",o.generateKey),t.register("importKey","ecdsa",o.importKey),t.register("exportKey","ecdsa",o.exportKey)),ct||(wt=function(){function c(){function t(t){try{n=pt.jsCryptoRunner({data:t})}catch(i){this.onerror({data:i.description,type:"error"});return}if(!t.operationSubType||t.operationSubType!=="process")this.onmessage({data:n})}var n;return{postMessage:t,onmessage:null,onerror:null,terminate:function(){}}}function h(n){function u(u){if(u.type==="error"){i&&i.apply(t,[u.message?u.message:u]);return}this.result=n(u.data);r.apply(t,[this.result]);return}var t,r,i;return t=new Promise(function(n,t){r=n;i=t}),{dispatchEvent:u,promise:t,result:null}}function y(){function t(t){switch(t.type){case"keyGeneration":case"keyImport":case"keyDerive":return n.add(t.keyHandle,t.keyData),t.keyHandle;case"keyExport":return t.keyHandle;case"keyPairGeneration":return n.add(t.keyPair.publicKey.keyHandle,t.keyPair.publicKey.keyData),n.add(t.keyPair.privateKey.keyHandle,t.keyPair.privateKey.keyData),{publicKey:t.keyPair.publicKey.keyHandle,privateKey:t.keyPair.privateKey.keyHandle};default:throw new Error("Unknown key operation");}return}return h(t)}function w(n){function i(n){return b(n)}var t=h(i);return t.process=function(t){n.operationSubType="process";n.buffer=u.toArray(t);f.continueJob(this,u.clone(n))},t.finish=function(){n.operationSubType="finish";n.buffer=[];f.continueJob(this,u.clone(n))},t.abort=function(){f.abortJob(this)},t.onabort=null,t.onprogress=null,t.algorithm=n.algorithm||null,t.key=n.keyHandle||null,t}function b(n){return fi&&n.pop?new Uint8Array(n).buffer:n}function v(n,i){if(!t.exists(n,i))throw new Error("unsupported algorithm");}function e(t){var i=n.lookup(t);if(!i)throw new Error("key not found");return i}function p(n,t){for(var f,r,e={operationType:n},s=a[n],o=0;o=0;i-=1)n[i].isWebWorker===t&&(n[i].terminate(),n.splice(i,1))}function b(){for(var i=0,t=0;t0){var i=t.shift();l(i.operation,i.data)}else b()>v&&r(n)}function d(n){var r;if(it)try{r=new Worker(yt);r.postMessage({prngSeed:s.getBytes(48)});r.isWebWorker=!0}catch(u){it=!1;o.forceSync=!0;r=c();r.isWebWorker=!1}else r=c(),r.isWebWorker=!1;return r.operation=n,r.busy=!1,r.onmessage=function(n){for(var o,f=r.operation,u=0;u=a){f(t,r);return}if(u===null&&(u=d(t)),u===null){f(t,r);throw new Error("could not create new worker");}u.operation=t;u.busy=!0;i(u,r)}function l(n,t){var r=u(n);if(r){i(r,t);return}h(n,t)}function i(n,t){if(it)n.data=t,n.postMessage(t);else var i=function(t){return function(){return n.postMessage(t)}}(t),r=setTimeout(i,0);return}var a=12,v=2,n=[],t=[],y=0;return{runJob:h,continueJob:l,abortJob:g}}(),u=i,l=[{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:"keyUsage",type:"Array",required:!1},{name:"derivedKeyType",type:"Object",required:!0},{name:"length",type:"Number",required:!1},{name:"extractable",type:"Boolean",required:!0},{name:"keyUsage",type:"Array",required:!0}],a={encrypt:[0,1,2],decrypt:[0,1,2],sign:[0,1,2],verify:[0,1,3,2],digest:[0,2],generateKey:[0,6,7],importKey:[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]},o={encrypt:function(){return r("encrypt",arguments,0)},decrypt:function(){return r("decrypt",arguments,0)},sign:function(){return r("sign",arguments,0)},verify:function(){return r("verify",arguments,0)},digest:function(){return r("digest",arguments,0)},generateKey:function(){return r("generateKey",arguments,1)},deriveKey:function(){return r("deriveKey",arguments,1)},deriveBits:function(){return r("deriveBits",arguments,0)},importKey:function(){return r("importKey",arguments,1)},exportKey:function(n,t){return r("exportKey",[t.algorithm,n,t],1)},wrapKey:function(){return r("wrapKey",arguments,0)},unwrapKey:function(){return r("unwrapKey",arguments,1)}}}()),lt=function(){function t(t){var w=r(t.keyData1,t.keyHandle1.algorithm.name,y["sha-1"]),u=128,b=c.keyToJwkOld(t.keyHandle,t.keyData),d={alg:t.keyHandle1.algorithm.name.toUpperCase(),enc:"A128GCM"},f=n.toBase64(JSON.stringify(d),!0),e=s.getBytes(32),g=w.encrypt(e),o=n.toBase64(g,!0),h=s.getBytes(12),l=n.toBase64(h,!0),nt=f.concat(".",o,".",l),a=v(k.aes(e));a.init(h,n.stringToBytes(nt),u);var i=a.encrypt(b),p=i.slice(-(u/8)),tt=n.toBase64(p,!0),it=n.toBase64(i.slice(0,i.length-p.length),!0),rt={recipients:[{header:f,encrypted_key:o,integrity_value:tt}],initialization_vector:l,ciphertext:it};return n.stringToBytes(JSON.stringify(rt))}function u(t){var u=n.base64ToBytes,i=JSON.parse(String.fromCharCode.apply(null,t.buffer)),g=n.base64ToString(i.recipients[0].header),s=u(i.recipients[0].encrypted_key),h=u(i.recipients[0].integrity_value),l=u(i.initialization_vector),a=u(i.ciphertext),p=y["sha-1"],w=r(t.keyData,t.keyHandle.algorithm.name,p),b=w.decrypt(s),d=i.recipients[0].header.concat(".",i.recipients[0].encrypted_key,".",i.initialization_vector),e=v(k.aes(b)),o,f;return e.init(l,n.stringToBytes(d),128),o=e.decrypt(a,h),f=c.jwkToKey(o,t.algorithm,["k"]),{type:"keyImport",keyData:f.k,keyHandle:{algorithm:{name:t.algorithm.name},extractable:t.extractable||f.extractable,keyUsage:t.keyUsage,type:"secret"}}}var n=i;return{wrapKey:t,unwrapKey:u}}(),typeof t!="undefined"&&(t.register("wrapKey","aes-gcm",lt.wrapKey),t.register("unwrapKey","aes-cbc",lt.unwrapKey)),st={subtle:wt,getRandomValues:function(n){for(var i=s.getBytes(n.length),t=0;t