forked from kevlened/msrCrypto
-
Notifications
You must be signed in to change notification settings - Fork 7
/
msrcrypto.aes.min.js
executable file
·18 lines (18 loc) · 28.3 KB
/
msrcrypto.aes.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//*******************************************************************************
//
// Copyright 2018 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.5.6",msrCrypto=msrCrypto||function(){"use strict";function y(){function h(n){for(var t=n.length-1;t>=0;t-=1)if(n[t]+=1,n[t]>=256&&(n[t]=0),n[t])break}function c(){r=n.getVector(32);i=n.getVector(16);e=32;t=48;u=1}function l(i,r){var f,e;if(r=r||[0],r.length>t)throw new Error("Incorrect entropy or additionalEntropy length");for(r=r.concat(n.getVector(t-r.length)),i=i.concat(n.getVector((t-i.length%t)%t)),f=0;f<i.length;f+=t)e=n.xorVectors(i.slice(f,f+t),r),o(e);u=1}function o(u){for(var f=[],l=new s.aes(r),o,c;f.length<t;)h(i),o=i.slice(0,16),c=l.encrypt(o),f=f.concat(c);f=n.xorVectors(f,u);r=f.slice(0,e);i=f.slice(e)}function a(f,e){var c,l,a,y;if(f>=65536)throw new Error("too much random requested");if(u>v)throw new Error("Reseeding is required");if(e&&e.length>0){while(e.length<t)e=e.concat(n.getVector(t-e.length));o(e)}else e=n.getVector(t);for(c=[],l=new s.aes(r);c.length<f;)h(i),a=i.slice(0,i.length),y=l.encrypt(a),c=c.concat(y);return c=c.slice(0,f),o(e),u+=1,c}if(!(this instanceof y))throw new Error("create MsrcryptoPrng object with new keyword");var f=!1,r,i,e,t,u=1,v=16777216;return c(),{reseed:l,init:function(n,i){if(n.length<t)throw new Error("Initial entropy length too short");c();l(n,i);f=!0},getBytes:function(n,t){if(!f)throw new Error("can't get randomness before initialization");return a(n,t)},getNonZeroBytes:function(n,t){var r,u,i;if(!f)throw new Error("can't get randomness before initialization");for(r=[];r.length<n;)for(u=a(n,t),i=0;i<u.length;i+=1)u[i]!==0&&r.push(u[i]);return r.slice(0,n)}}}function rt(){function s(){for(var s=[],c,l,v,a,y,h=0;h<e;h+=1)s[h]=Math.floor(Math.random()*256);for(c=window.crypto||window.msCrypto,c&&typeof c.getRandomValues=="function"&&window.Uint8Array&&(l=new window.Uint8Array(e),c.getRandomValues(l),s=s.concat(Array.apply(null,l)),u=!0),v=new XMLHttpRequest,h=0;h<o.length;h+=1)try{a=v.getResponseHeader(o[h]);a&&(y=n.stringToBytes(a),s=s.concat(y))}catch(p){}u||(s=s.concat(t.splice(0,t.length)),f.startCollectors());r?i.reseed(s):i.init(s);r=!0}function h(n){for(var i=0;i<n.length;++i)t.push(n[i]);t.length>=c&&f.stopCollectors()}var e=48,t=[],c=128,l=0,i=new y,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){i.reseed(n)},read:function(n){if(!r)throw new Error("Entropy pool is not initialized.");var t=i.getBytes(n);return s(),t}}}var t={},a,v,r,s,l,u,i,o,p,h,f,k;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 w=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}(),nt=!1,b=typeof Worker!="undefined",c=typeof importScripts!="undefined",tt=typeof Uint8Array!="undefined",it=function(){try{return Object.defineProperty({},"oncomplete",{}),!0}catch(n){return!1}}(),e=b,ut=function(n,t,i,r,u){if(!it){n[t]=i;return}var f={};r&&(f.get=r);u&&(f.set=u);Object.defineProperty(n,t,f)},d={},n=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<t.length;u+=3)h=t.charCodeAt(u),e=t.charCodeAt(u+1),o=t.charCodeAt(u+2),l=h>>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<t.length;i+=4)c=n.indexOf(t.charAt(i)),f=n.indexOf(t.charAt(i+1)),u=n.indexOf(t.charAt(i+2)),e=n.indexOf(t.charAt(i+3)),o=c<<2|f>>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<n.length;i++)t&&i%4==0&&i!==0&&(r+="-"),u=n[i].toString(16).toUpperCase(),u.length===1&&(r+="0"),r+=u;return r}function s(n,t){return t=t||0,n[t]<<24|n[t+1]<<16|n[t+2]<<8|n[t+3]}function h(n){for(var i=new Array(n.length),t=0;t<i.length;t++)i[t]=n.charCodeAt(t);return i}function c(n){n=n.replace(/\-/g,"");for(var t=[];n.length>=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<e.length;u+=i)f.push(e.slice(u,u+i));if(r)for(u=0;u<f.length;u++)f[u]=(f[u][0]<<24)+(f[u][1]<<16)+(f[u][2]<<8)+f[u][3];return f}function u(n){return[n>>>24&255,n>>>16&255,n>>>8&255,n&255]}function v(n){for(var t=[],i=0;i<n.length;i++)t=t.concat(u(n[i]));return t}function y(n,t){for(var r=Math.min(n.length,t.length),u=new Array(r),i=0;i<r;i+=1)u[i]=n[i]^t[i];return u}function p(n,t){var r,i;for(t||(t=0),r=new Array(n),i=0;i<n;i+=1)r[i]=t;return r}function w(n){return n?n.pop?n:(n.isView&&(n=Uint8Array(n)),n.length===1?[n[0]]:Array.apply(null,n)):[]}function b(n,t,i){while(n.length<i)n.push(t);return n}function k(n,t,i){while(n.length<i)n.unshift(t);return n}function d(n,t){var r=!0,i;for(n.length!==t.length&&(r=!1),i=0;i<n.length;i++)n[i]!==t[i]&&(r=!1);return r}function g(n){var t,i;if(r(n)!=="Array")return!1;for(i=0;i<n.length;i++)if(t=n[i],isNaN(t)||t<0||t>255)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}}(),g=function(){function n(n){return c&&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}}}();return c&&(self.onmessage=function(n){if(n.data.prngSeed){var t=n.data.prngSeed;o.init(t);return}g.jsCryptoRunner(n)}),a=function(){function r(n){for(var t=[],i=0;i<n.length;i++)t[i]=n.charCodeAt(i);return t[t.length-1]===0&&t.pop(),t}function i(n){var t=n.algorithm.name.slice(0,3).toLowerCase();return t==="rsa"?"RSA":t==="ecd"?"EC":"oct"}function f(n,r){var f={},e;if(f.kty=i(n),f.ext=n.extractable,f.alg=u[n.algorithm.name.toLowerCase()](n.algorithm),f.key_ops=n.keyUsage,r.pop)f.k=t.toBase64(r,!0);else for(e in r)r[e].pop&&(f[e]=t.toBase64(r[e],!0));return n.algorithm.namedCurve&&(f.crv=n.algorithm.namedCurve),f}function e(n,u){var f={},e,o;if(f.kty=i(n),f.extractable=n.extractable,u.pop)f.k=t.toBase64(u,!0);else for(e in u)u[e].pop&&(f[e]=t.toBase64(u[e],!0));return n.algorithm.namedCurve&&(f.crv=n.algorithm.namedCurve),o=JSON.stringify(f,null,"\t"),r(o)}function o(n,i,r){for(var e,f=JSON.parse(JSON.stringify(n)),u=0;u<r.length;u+=1)e=f[r[u]],e&&(f[r[u]]=t.base64ToBytes(e));return f}var t=n,u={hmac:function(n){return"HS"+n.hash.name.substring(n.hash.name.indexOf("-")+1)},"aes-cbc":function(n){return"A"+n.length.toString()+"CBC"},"aes-gcm":function(n){return"A"+n.length.toString()+"GCM"},"rsaes-pkcs1-v1_5":function(){return"RSA1_5"},"rsassa-pkcs1-v1_5":function(n){return"RS"+n.hash.name.substring(n.hash.name.indexOf("-")+1)},"rsa-oaep":function(n){return"RS-OAEP-"+n.hash.name.substring(n.hash.name.indexOf("-")+1)},"rsa-pss":function(n){return"PS"+n.hash.name.substring(n.hash.name.indexOf("-")+1)},ecdsa:function(n){return"EC-"+n.namedCurve.substring(n.namedCurve.indexOf("-")+1)}};return{keyToJwkOld:e,keyToJwk:f,jwkToKey:o}}(),v=function(t,i,r,u,f,e,o){function l(n){for(var t=Math.floor(n.length/f),i=0;i<t;i++)e(n,i,h,u,y);return c+=t,n.slice(t*f)}function p(){for(var n=[],t=0;t<h.length;t++)n=n.concat(a.int32ToBytes(h[t]));return n.length=o/8,n}function w(n){var t=f-n.length%f,i,r;return t<=f/8&&(t+=f),i=a.getVector(t),i[0]=128,r=(n.length+c*f)*8,i[t-4]=r>>>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=n,h=r.slice(),y=new Array(f),s=[],c=0;return{name:t,computeHash:b,process:k,finish:v,der:i,hashLen:o,maxMessageSize:4294967295}},r=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=n,i,f,e,o,s,t=r.unpackData;return f=t("wQWe2DZ81QcwcN0X9w5ZOf/ACzFoWBURZPmPp776T6Q",4,1),e=t("agnmZ7tnroU8bvNypU/1OlEOUn+bBWiMH4PZq1vgzRk",4,1),i=t("QoovmHE3RJG1wPvP6bXbpTlWwltZ8RHxkj+CpKscXtXYB6qYEoNbASQxhb5VDH3Dcr5ddIDesf6b3AanwZvxdOSbacHvvkeGD8GdxiQMocwt6SxvSnSEqlywqdx2+YjamD5RUqgxxm2wAyfIv1l/x8bgC/PVp5FHBspjURQpKWcntwqFLhshOE0sbfxTOA0TZQpzVHZqCruBwskuknIshaK/6KGoGmZLwkuLcMdsUaPRkugZ1pkGJPQONYUQaqBwGaTBFh43bAgnSHdMNLC8tTkcDLNO2KpKW5zKT2gub/N0j4LueKVjb4TIeBSMxwIIkL7/+qRQbOu++aP3xnF48g",4,1),o=t("MC0wDQYJYIZIAWUDBAIEBQAEHA"),s=t("MDEwDQYJYIZIAWUDBAIBBQAEIA"),{sha224:v("SHA-224",o,f,i,64,u,224),sha256:v("SHA-256",s,e,i,64,u,256)}}(),typeof t!="undefined"&&(r.hash256=function(n){if(n.operationSubType==="process"){r.sha256.process(n.buffer);return}return n.operationSubType==="finish"?r.sha256.finish():r.sha256.computeHash(n.buffer)},r.hash224=function(n){if(n.operationSubType==="process"){r.sha224.process(n.buffer);return}return n.operationSubType==="finish"?r.sha224.finish():r.sha224.computeHash(n.buffer)},t.register("digest","sha-224",r.hash224),t.register("digest","sha-256",r.hash256)),d["sha-224"]=r.sha224,d["sha-256"]=r.sha256,s=function(){var o,t,i,r,u,f,e,s,h,c;return{aes:function(l){var d,b,a,p,v,y;o||(o=n.unpackData("AAIEBggKDA4QEhQWGBocHiAiJCYoKiwuMDI0Njg6PD5AQkRGSEpMTlBSVFZYWlxeYGJkZmhqbG5wcnR2eHp8foCChIaIioyOkJKUlpianJ6goqSmqKqsrrCytLa4ury+wMLExsjKzM7Q0tTW2Nrc3uDi5Obo6uzu8PL09vj6/P4bGR8dExEXFQsJDw0DAQcFOzk/PTMxNzUrKS8tIyEnJVtZX11TUVdVS0lPTUNBR0V7eX99c3F3dWtpb21jYWdlm5mfnZORl5WLiY+Ng4GHhbu5v72zsbe1q6mvraOhp6Xb2d/d09HX1cvJz83DwcfF+/n//fPx9/Xr6e/t4+Hn5QADBgUMDwoJGBseHRQXEhEwMzY1PD86OSgrLi0kJyIhYGNmZWxvaml4e359dHdycVBTVlVcX1pZSEtOTURHQkHAw8bFzM/Kydjb3t3U19LR8PP29fz/+vno6+7t5Ofi4aCjpqWsr6qpuLu+vbS3srGQk5aVnJ+amYiLjo2Eh4KBm5idnpeUkZKDgIWGj4yJiquora6npKGis7C1tr+8ubr7+P3+9/Tx8uPg5ebv7Onqy8jNzsfEwcLT0NXW39zZ2ltYXV5XVFFSQ0BFRk9MSUpraG1uZ2RhYnNwdXZ/fHl6Ozg9Pjc0MTIjICUmLywpKgsIDQ4HBAECExAVFh8cGRoADhwSODYkKnB+bGJIRlRa4O788tjWxMqQnoyCqKa0utvVx8nj7f/xq6W3uZOdj4E7NScpAw0fE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06MuNAQIECBAgQIAbNmzYq02aL168Y8aXNWrUs33678WROXLk071hwp8lSpQzZsyDHTp06MuNAQIECBAgQIAbNmzYq02aL168Y8aXNWrUs33678WROXLk071hwp8lSpQzZsyDHTp06MuN",256,!1),t=o[0],i=o[1],r=o[2],u=o[3],f=o[4],e=o[5],s=o[6],h=o[7],c=o[8]);d=128;p=4;switch(l.length*8){case 128:b=128;a=4;v=10;break;case 192:b=192;a=6;v=12;break;case 256:b=256;a=8;v=14;break;default:throw new Error("Unsupported keyLength");}var g=function(n){var t=n[1];n[1]=n[5];n[5]=n[9];n[9]=n[13];n[13]=t;t=n[2];n[2]=n[10];n[10]=t;t=n[6];n[6]=n[14];n[14]=t;t=n[15];n[15]=n[11];n[11]=n[7];n[7]=n[3];n[3]=t},nt=function(n){var t=n[13];n[13]=n[9];n[9]=n[5];n[5]=n[1];n[1]=t;t=n[10];n[10]=n[2];n[2]=t;t=n[14];n[14]=n[6];n[6]=t;t=n[3];n[3]=n[7];n[7]=n[11];n[11]=n[15];n[15]=t},ut=function(n){var r=n[0],u=n[1],f=n[2],e=n[3],o=n[4],s=n[5],h=n[6],c=n[7],l=n[8],a=n[9],v=n[10],y=n[11],p=n[12],w=n[13],b=n[14],k=n[15];n[0]=t[r]^i[u]^f^e;n[1]=r^t[u]^i[f]^e;n[2]=r^u^t[f]^i[e];n[3]=i[r]^u^f^t[e];n[4]=t[o]^i[s]^h^c;n[5]=o^t[s]^i[h]^c;n[6]=o^s^t[h]^i[c];n[7]=i[o]^s^h^t[c];n[8]=t[l]^i[a]^v^y;n[9]=l^t[a]^i[v]^y;n[10]=l^a^t[v]^i[y];n[11]=i[l]^a^v^t[y];n[12]=t[p]^i[w]^b^k;n[13]=p^t[w]^i[b]^k;n[14]=p^w^t[b]^i[k];n[15]=i[p]^w^b^t[k]},ft=function(n){var t=n[0],i=n[1],o=n[2],s=n[3],h=n[4],c=n[5],l=n[6],a=n[7],v=n[8],y=n[9],p=n[10],w=n[11],b=n[12],k=n[13],d=n[14],g=n[15];n[0]=r[t]^f[i]^u[o]^e[s];n[1]=e[t]^r[i]^f[o]^u[s];n[2]=u[t]^e[i]^r[o]^f[s];n[3]=f[t]^u[i]^e[o]^r[s];n[4]=r[h]^f[c]^u[l]^e[a];n[5]=e[h]^r[c]^f[l]^u[a];n[6]=u[h]^e[c]^r[l]^f[a];n[7]=f[h]^u[c]^e[l]^r[a];n[8]=r[v]^f[y]^u[p]^e[w];n[9]=e[v]^r[y]^f[p]^u[w];n[10]=u[v]^e[y]^r[p]^f[w];n[11]=f[v]^u[y]^e[p]^r[w];n[12]=r[b]^f[k]^u[d]^e[g];n[13]=e[b]^r[k]^f[d]^u[g];n[14]=u[b]^e[k]^r[d]^f[g];n[15]=f[b]^u[k]^e[d]^r[g]},tt=function(n,t){return[n[0]^t[0],n[1]^t[1],n[2]^t[2],n[3]^t[3]]},w=function(n,t,i){for(var r=0;r<n.length;r+=1)n[r]^=t[r+i]},et=function(n){var t=n[0];n[0]=n[1];n[1]=n[2];n[2]=n[3];n[3]=t},k=function(n){for(var t=0;t<n.length;t+=1)n[t]=s[n[t]]},it=function(n){for(var t=0;t<n.length;t+=1)n[t]=h[n[t]]},rt=function(n,t){return[n[4*t],n[4*t+1],n[4*t+2],n[4*t+3]]},ot=function(n,t,i,r){n[4*i]=t[4*r];n[4*i+1]=t[4*r+1];n[4*i+2]=t[4*r+2];n[4*i+3]=t[4*r+3]},st=function(n){for(var i,r=[],t=0,u,f,e;t<4*a;)r.push(n[t++]);for(t=a;t<p*(v+1);)i=rt(r,t-1),t%a==0?(u=t/a,f=[c[u],0,0,0],et(i),k(i),i=tt(i,f)):a>6&&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}}}}(),l=l||{},l.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;u<n;u+=1)r.push(n);t.push(r)}else for(e=n-f&255;i.length!==n;)i.push(e)}function i(t){var i=!0,u,f,r,e,o,s;for(t.length%n!=0&&(i=!1),u=t.slice(-n),f=u[u.length-1],r=0;r<n;r++)e=n-r<=f,o=u[r]===f,i=(e?o:!0)&&i;return s=i?f:0,t.length-=s,i}return{pad:t,unpad:i}},u=function(t){function s(n){var f=[],r,t;for(i=i.concat(n),r=Math.floor(i.length/u),t=0;t<r;t++)f.push(i.slice(t*u,(t+1)*u));return i=i.slice(r*u),f}function h(i){for(var u=[],e,r=0;r<i.length;r++)e=n.xorVectors(f,i[r]),u.push(t.encrypt(e)),f=u[r];return u}function a(i){for(var u=[],e,o,r=0;r<i.length;r+=1)e=i[r].slice(0,i[r].length),o=t.decrypt(e),u.push(n.xorVectors(f,o)),f=i[r];return u}function c(){i=[];r=[];f=null}var u=t.blockSize/8,o=l.pkcsv7(u),e=function(n){for(var u=[],i,r,t=0;t<n.length;t+=1)for(r=n[t],i=0;i<r.length;i+=1)u.push(r[i]);return u},i=[],r=[],f;return{init:function(n){if(n.length!==u)throw new Error("Invalid iv size");f=n.slice()},encrypt:function(n){return this.processEncrypt(n),this.finishEncrypt()},processEncrypt:function(n){var t=h(s(n));r=r.concat(e(t));return},finishEncrypt:function(){var n=i.length===1?[[i[0]]]:[i],t;return o.pad(n),t=r.concat(e(h(n))),c(),t},decrypt:function(n){return this.processDecrypt(n),this.finishDecrypt()},processDecrypt:function(n){var t=a(s(n));r=r.concat(e(t));return},finishDecrypt:function(){var n=r,t=o.unpad(n);return c(),n}}},i=null,typeof t!="undefined"&&(u.workerEncrypt=function(n){var t;if(i||(i=u(s.aes(n.keyData)),i.init(n.algorithm.iv)),n.operationSubType==="process"){i.processEncrypt(n.buffer);return}return n.operationSubType==="finish"?(t=i.finishEncrypt(),i=null,t):(t=i.encrypt(n.buffer),i=null,t)},u.workerDecrypt=function(n){var t;if(i||(i=u(s.aes(n.keyData)),i.init(n.algorithm.iv)),n.operationSubType==="process"){i.processDecrypt(n.buffer);return}return n.operationSubType==="finish"?(t=i.finishDecrypt(),i=null,t):(t=i.decrypt(n.buffer),i=null,t)},u.generateKey=function(n){if(n.algorithm.length%8!=0)throw new Error;return{type:"keyGeneration",keyData:o.getBytes(Math.floor(n.algorithm.length/8)),keyHandle:{algorithm:n.algorithm,extractable:n.extractable,keyUsage:null||n.keyUsage,type:"secret"}}},u.importKey=function(n){var t=a.jwkToKey(n.keyData,n.algorithm,["k"]);return n.algorithm.length=t.k.length*8,{type:"keyImport",keyData:t.k,keyHandle:{algorithm:n.algorithm,extractable:n.extractable||t.extractable,keyUsage:null||n.keyUsage,type:"secret"}}},u.exportKey=function(n){var t=a.keyToJwk(n.keyHandle,n.keyData);return{type:"keyExport",keyHandle:t}},t.register("importKey","aes-cbc",u.importKey),t.register("exportKey","aes-cbc",u.exportKey),t.register("generateKey","aes-cbc",u.generateKey),t.register("encrypt","aes-cbc",u.workerEncrypt),t.register("decrypt","aes-cbc",u.workerDecrypt)),o=new y,c||(p=function(){function l(){function t(t){try{n=g.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 c(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 p(){function n(n){switch(n.type){case"keyGeneration":case"keyImport":case"keyDerive":return i.add(n.keyHandle,n.keyData),n.keyHandle;case"keyExport":return n.keyHandle;case"keyPairGeneration":return i.add(n.keyPair.publicKey.keyHandle,n.keyPair.publicKey.keyData),i.add(n.keyPair.privateKey.keyHandle,n.keyPair.privateKey.keyData),{publicKey:n.keyPair.publicKey.keyHandle,privateKey:n.keyPair.privateKey.keyHandle};default:throw new Error("Unknown key operation");}return}return c(n)}function d(n){function i(n){return nt(n)}var t=c(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 nt(n){return tt&&n.pop?new Uint8Array(n).buffer:n}function y(n,i){if(!t.exists(n,i))throw new Error("unsupported algorithm");}function s(n){var t=i.lookup(n);if(!t)throw new Error("key not found");return t}function k(t,i){for(var f,r,e={operationType:t},s=v[t],o=0;o<s.length;o+=1){if(f=a[s[o]],r=i[o],!r)if(f.required)throw new Error(f.name);else continue;if(r.subarray&&(r=u.toArray(r)),u.getObjectType(r)=="ArrayBuffer"&&(r=u.toArray(r)),n.getObjectType(r)!==f.type)throw new Error(f.name);f.name==="algorithm"&&(r.name=r.name.toLowerCase(),r.iv&&(r.iv=u.toArray(r.iv)),r.salt&&(r.salt=u.toArray(r.salt)),r.additionalData&&(r.additionalData=u.toArray(r.additionalData)),r.hash&&!r.hash.name&&n.getObjectType(r.hash)==="String"&&(r.hash={name:r.hash}));e.hasOwnProperty(f.name)?e[f.name+"1"]=r:e[f.name]=r}return e}function r(n,t,i){var r=k(n,t),u;return y(n,r.algorithm.name),r.keyHandle&&(r.keyData=s(r.keyHandle)),r.keyHandle1&&(r.keyData1=s(r.keyHandle1)),r.algorithm&&r.algorithm.public&&(r.additionalKeyData=s(r.algorithm.public)),u=i?p(r):d(r),(i||r.buffer||n==="deriveBits"||n==="wrapKey")&&f.runJob(u,r),u.promise}var i,f,u,a,v,h;return window.Promise||(window.Promise=function(n){function s(n){for(var f,u=0;u<r.length;u++)f=r[u](n),f&&f.then?f.then(t[u],e[u]):t[u]&&t[u](f);i={result:n};return}var o;if(!(this instanceof Promise))throw new Error("use 'new' keyword with Promise constructor");var u=null,i=null,f=[],r=[],e=[],t=[];this.then=function(n,o){var s;return u?(s=n(u.result),s&&s.then)?s:Promise.resolve(s):i?(s=o?o(i.result):i.result,s&&s.then)?s:Promise.resolve(s):(f.push(n),o&&r.push(o),new Promise(function(n,i){t.push(n);e.push(i)}))};this["catch"]=function(n){var u;return i?(u=n(i.result),u&&u.then)?u:Promise.resolve(u):(r.push(n),new Promise(function(n,i){t.push(n);e.push(i)}))};o=function(n){for(var r,i=0;i<f.length;i++)r=f[i](n),r&&r.then?r.then(t[i]):t[i]&&t[i](r);u={result:n};return};n(o,s);return},window.Promise.all=function(n){function r(r,u){return function(f){t[r]=f;++i==n.length&&u(t)}}var t=[],i=0;return new Promise(function(t,i){for(var u=0;u<n.length;u++)n[u].then(r(u,t)),n[u]["catch"](function(n){i(n)})})},window.Promise.race=function(n){function i(n){return function(i){t||(t=!0,n(i))}}var t=!1;return new Promise(function(t,r){for(var u=0;u<n.length;u++)n[u].then(i(t),i(r))})},window.Promise.reject=function(n){return new Promise(function(t,i){i(n)})},window.Promise.resolve=function(n){return new Promise(function(t){t(n)})}),i=[],i.add=function(n,t){i.push({keyHandle:n,keyData:t})},i.remove=function(n){for(var t=0;t<i.length;t++)if(i[t].keyHandle===n){i=i.splice(t,1);return}},i.lookup=function(n){for(var t=0;t<i.length;t++)if(i[t].keyHandle===n)return i[t].keyData;return null},f=function(){function k(){d(!e);for(var t=0;t<n.length;t++)if(!n[t].busy)return n[t];return null}function d(t){for(var i=n.length-1;i>=0;i-=1)n[i].isWebWorker===t&&(n[i].terminate(),n.splice(i,1))}function g(){for(var i=0,t=0;t<n.length;t++)n[t].busy||(i+=1);return i}function nt(t){n.push(t)}function r(t){for(var i=0;i<n.length;i++)if(n[i]===t){t.terminate();n.splice(i,1);return}}function u(t){for(var i=0;i<n.length;i++)if(n[i].operation===t)return n[i];return null}function f(n,i){t.push({operation:n,data:i,id:p++})}function s(n){if(n.busy=!1,n.operation=null,e)if(t.length>0){var i=t.shift();a(i.operation,i.data)}else g()>y&&r(n)}function tt(n){var r;if(e)try{r=new Worker(w);r.postMessage({prngSeed:o.getBytes(48)});r.isWebWorker=!0}catch(u){e=!1;h.forceSync=!0;r=l();r.isWebWorker=!1}else r=l(),r.isWebWorker=!1;return r.operation=n,r.busy=!1,r.onmessage=function(n){for(var e,f=r.operation,u=0;u<t.length;u++)if(t[u].operation===r.operation){e=t[u];t.splice(u,1);i(r,e.data);return}f&&n.data.type!=="process"&&(s(r),f.dispatchEvent(n))},r.onerror=function(n){var t=r.operation;s(r);t.dispatchEvent(n)},nt(r),r}function it(n){var t=u(n);t&&r(t)}function c(t,r){var u=null;if(e=b&&!h.forceSync,u=k(),e&&u===null&&n.length>=v){f(t,r);return}if(u===null&&(u=tt(t)),u===null){f(t,r);throw new Error("could not create new worker");}u.operation=t;u.busy=!0;i(u,r)}function a(n,t){var r=u(n);if(r){i(r,t);return}c(n,t)}function i(n,t){if(e)n.data=t,n.postMessage(t);else var i=function(t){return function(){return n.postMessage(t)}}(t),r=setTimeout(i,0);return}var v=12,y=2,n=[],t=[],p=0;return{runJob:c,continueJob:a,abortJob:it}}(),u=n,a=[{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}],v={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]},h={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)}}}()),h={subtle:p,getRandomValues:function(n){for(var i=o.getBytes(n.length),t=0;t<n.length;t+=1)n[t]=i[t];return n},initPrng:function(n){var t=Object.prototype.toString.call(n);if(t!=="[object Array]"&&t!=="[object Uint8Array]")throw new Error("entropyData must be a Array or Uint8Array");f&&f.reseed(n);o.reseed(f.read(48));nt=!0},toBase64:function(t){return n.toBase64(t,!1)},base64ToString:function(t){return n.base64ToString(t)},url:w},typeof cryptoMath!="undefined"&&(h.cryptoMath=cryptoMath),typeof testInterface!="undefined"&&(h.testInterface=testInterface),c||(f=f||new rt,f.init(),k=f.read(48),o.init(k)),h}();