fox-send/assets/cryptofill.js

17 lines
99 KiB
JavaScript
Raw Permalink Normal View History

2018-03-29 05:03:46 +00:00
var liner=function(e){function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}var t={};return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},r.p="",r(r.s=16)}([function(e,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),function(e){function n(e){for(var r,t=e,n=/[^%](%\d+)/g,a=[];r=n.exec(t);)a.push({arg:r[1],index:r.index});for(var o=a.length-1;o>=0;o--){var i=a[o],s=i.arg.substring(1),c=i.index+1;t=t.substring(0,c)+arguments[+s]+t.substring(c+1+s.length)}return t=t.replace("%%","%")}function a(e){var r;r="string"==typeof e?{name:e}:e,p.checkAlgorithm(r);var t=e;return t.hash&&(t.hash=a(t.hash)),r}function o(e,r){if(!e)throw new s("Parameter '"+r+"' is required and cant be empty");if("undefined"!=typeof Buffer&&Buffer.isBuffer(e))return new Uint8Array(e);if(ArrayBuffer.isView(e)){var t=e.map(function(e){return e});return new Uint8Array(t.buffer)}if(e instanceof ArrayBuffer)return new Uint8Array(e);throw new s("Incoming parameter '"+r+"' has wrong data type. Must be ArrayBufferView or ArrayBuffer")}t.d(r,"WebCryptoError",function(){return s}),t.d(r,"AlgorithmError",function(){return c}),t.d(r,"CryptoKeyError",function(){return u}),t.d(r,"PrepareAlgorithm",function(){return a}),t.d(r,"PrepareData",function(){return o}),t.d(r,"BaseCrypto",function(){return p}),t.d(r,"AlgorithmNames",function(){return h}),t.d(r,"Base64Url",function(){return y}),t.d(r,"SubtleCrypto",function(){return x}),t.d(r,"Aes",function(){return A}),t.d(r,"AesAlgorithmError",function(){return m}),t.d(r,"AesWrapKey",function(){return w}),t.d(r,"AesEncrypt",function(){return v}),t.d(r,"AesECB",function(){return g}),t.d(r,"AesCBC",function(){return C}),t.d(r,"AesCTR",function(){return k}),t.d(r,"AesGCM",function(){return d}),t.d(r,"AesKW",function(){return b}),t.d(r,"RsaKeyGenParamsError",function(){return G}),t.d(r,"RsaHashedImportParamsError",function(){return M}),t.d(r,"Rsa",function(){return B}),t.d(r,"RsaSSA",function(){return T}),t.d(r,"RsaPSSParamsError",function(){return D}),t.d(r,"RsaPSS",function(){return j}),t.d(r,"RsaOAEPParamsError",function(){return W}),t.d(r,"RsaOAEP",function(){return H}),t.d(r,"EcKeyGenParamsError",function(){return U}),t.d(r,"Ec",function(){return _}),t.d(r,"EcAlgorithmError",function(){return K}),t.d(r,"EcDSA",function(){return S}),t.d(r,"EcDH",function(){return O}),t.d(r,"ShaAlgorithms",function(){return E}),t.d(r,"Sha",function(){return P});var i=t(8),s=function(e){function r(r){for(var t=[],a=1;a<arguments.length;a++)t[a-1]=arguments[a];var o=e.call(this)||this;o.code=0,o.message=n.apply(void 0,[r].concat(t));var i=new Error(o.message);return i.name=o.constructor.name,o.stack=i.stack,o}return Object(i.a)(r,e),r.NOT_SUPPORTED="Method is not supported",r}(Error),c=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=1,r}return Object(i.a)(r,e),r.PARAM_REQUIRED="Algorithm hasn't got required paramter '%1'",r.PARAM_WRONG_TYPE="Algorithm has got wrong type for paramter '%1'. Must be %2",r.PARAM_WRONG_VALUE="Algorithm has got wrong value for paramter '%1'. Must be %2",r.WRONG_ALG_NAME="Algorithm has got wrong name '%1'. Must be '%2'",r.UNSUPPORTED_ALGORITHM="Algorithm '%1' is not supported",r.WRONG_USAGE="Algorithm doesn't support key usage '%1'",r}(s),u=function(e){function r(){var r=null!==e&&e.apply(this,arguments)||this;return r.code=3,r}return Object(i.a)(r,e),r.EMPTY_KEY="CryptoKey is empty",r.WRONG_KEY_ALG="CryptoKey has wrong algorithm '%1'. Must be '%2'",r.WRONG_KEY_TYPE="CryptoKey has wrong type '%1'. Must be '%2'",r.WRONG_KEY_USAGE="CryptoKey has wrong key usage. Must be '%1'",r.NOT_EXTRACTABLE="CryptoKey is not extractable",r.WRONG_FORMAT="CryptoKey has '%1' type. It can be used with '%2' format",r.UNKNOWN_FORMAT="Unknown format in use '%1'. Must be
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
2018-03-29 05:03:46 +00:00
var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};Object.assign},function(e,r){e.exports=require("crypto")},function(e,r,t){"use strict";function n(e,r){return Promise.resolve().then(function(){if(e.key)return e;if(e.extractable){return(new A.Crypto).subtle.exportKey("jwk",e).then(function(t){var n=o(e);return n&&(n=w.assign(n,e.algorithm)),r.importKey("jwk",t,n,!0,e.usages)})}throw new m.LinerError("'key' is Native CryptoKey. It can't be converted to JS CryptoKey")})}function a(e,r){w.BrowserInfo().name!==w.Browser.IE&&w.BrowserInfo().name!==w.Browser.Edge&&w.BrowserInfo().name!==w.Browser.Safari||!/^rsa/i.test(e.name)||(r.privateKey?(b.push({hash:e.hash,key:r.privateKey}),b.push({hash:e.hash,key:r.publicKey})):b.push({hash:e.hash,key:r}))}function o(e){var r=null;return b.some(function(t){return t.key===e&&(r=w.assign({},e.algorithm,{hash:t.hash}),!0)}),r}function i(e,r){var t=[];e.privateKey?(t.push(e.privateKey),t.push(e.publicKey)):t.push(e),t.forEach(function(e){"keyUsage"in e&&(e.usages=e.keyUsage||[],e.usages.length||(["verify","encrypt","wrapKey"].forEach(function(t){r.indexOf(t)>-1&&("public"===e.type||"secret"===e.type)&&e.usages.push(t)}),["sign","decrypt","unwrapKey","deriveKey","deriveBits"].forEach(function(t){r.indexOf(t)>-1&&("private"===e.type||"secret"===e.type)&&e.usages.push(t)})))})}function s(e,r,t){if(r&&w.BrowserInfo().name===w.Browser.IE){"extractable"in e&&(e.ext=e.extractable,delete e.extractable);var n=null;switch(r.name.toUpperCase()){case h.AlgorithmNames.AesECB.toUpperCase():case h.AlgorithmNames.AesCBC.toUpperCase():case h.AlgorithmNames.AesGCM.toUpperCase():n=v.AesCrypto;break;default:throw new m.LinerError(m.LinerError.UNSUPPORTED_ALGORITHM,r.name.toUpperCase())}n&&!e.alg&&(e.alg=n.alg2jwk(r)),"key_ops"in e||(e.key_ops=t)}}function c(e){w.BrowserInfo().name===w.Browser.IE&&("ext"in e&&(e.extractable=e.ext,delete e.ext),delete e.key_ops,delete e.alg)}function u(e){var r=/AppleWebKit\/(\d+)/.exec(self.navigator.userAgent);return e.toUpperCase()===h.AlgorithmNames.RsaOAEP&&r&&parseInt(r[1],10)<604}var p=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}}();Object.defineProperty(r,"__esModule",{value:!0});var h=t(0),f=t(0),y=t(0),l=t(3),A=t(2),m=t(1),w=t(5),v=t(11),g=t(12),C=t(13),k=t(14),d=t(15),b=[],E=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return p(r,e),r.prototype.generateKey=function(r,t,n){var o,s=this,c=arguments;return e.prototype.generateKey.apply(this,c).then(function(e){if(o=y.PrepareAlgorithm(r),!(w.BrowserInfo().name===w.Browser.Edge&&o.name.toUpperCase()===h.AlgorithmNames.AesGCM||u(o.name))&&l.nativeSubtle)try{return l.nativeSubtle.generateKey.apply(l.nativeSubtle,c).catch(function(e){w.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e&&e.message||"Unknown message")})}catch(e){w.warn("WebCrypto: native generateKey for "+o.name+" doesn't work.",e&&e.message||"Unknown message")}}).then(function(e){if(e){var c=Promise.resolve(e);if(w.BrowserInfo().name===w.Browser.Safari&&(o.name.toUpperCase()===h.AlgorithmNames.EcDH.toUpperCase()||o.name.toUpperCase()===h.AlgorithmNames.EcDSA.toUpperCase())){var u=e.publicKey;c=c.then(function(){return s.exportKey("jwk",u).then(function(a){return s.exportKey("spki",u).then(function(o){for(var i=h.Base64Url.decode(a.x),c=h.Base64Url.decode(a.y),u=i.length+c.length,p=new Uint8Array(o),f=0;f<u;f++){var y=p[p.length-f-1],l=void 0;if(l=f<c.length?c[c.length-f-1]:i[i.length+c.length-f-1],y!==l)return w.warn("WebCrypto: EC key has wrong public key JWK. Key pair will be recreated"),s.generateKey(r,t,n)}return e})})})}return c.then(function(e){return i(e,n),a(o,e),e})}var p;switch(o.name.toLowerCase()){case h.AlgorithmNames.AesECB.toLowerC
/*! asmCrypto v0.22.0, (c) 2018 asmCrypto.js, opensource.org/licenses/MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.asmCrypto={})}(this,function(t){"use strict";var e=function(){var t,e,r=!1;function s(r,s){var i=t[(e[r]+e[s])%255];return 0!==r&&0!==s||(i=0),i}var i,n,a,h;function o(){function o(r){var s,i,n;for(i=n=function(r){var s=t[255-e[r]];return 0===r&&(s=0),s}(r),s=0;s<4;s++)n^=i=255&(i<<1|i>>>7);return n^=99}r||function(){t=[],e=[];var s,i,n=1;for(s=0;s<255;s++)t[s]=n,i=128&n,n<<=1,n&=255,128===i&&(n^=27),n^=t[s],e[t[s]]=s;t[255]=t[0],e[0]=0,r=!0}(),i=[],n=[],a=[[],[],[],[]],h=[[],[],[],[]];for(var c=0;c<256;c++){var u=o(c);i[c]=u,n[u]=c,a[0][c]=s(2,u)<<24|u<<16|u<<8|s(3,u),h[0][u]=s(14,c)<<24|s(9,c)<<16|s(13,c)<<8|s(11,c);for(var f=1;f<4;f++)a[f][c]=a[f-1][c]>>>8|a[f-1][c]<<24,h[f][u]=h[f-1][u]>>>8|h[f-1][u]<<24}}var c=function(t,e){o();var r=new Uint32Array(e);r.set(i,512),r.set(n,768);for(var s=0;s<4;s++)r.set(a[s],4096+1024*s>>2),r.set(h[s],8192+1024*s>>2);var c=function(t,e,r){"use asm";var s=0,i=0,n=0,a=0,h=0,o=0,c=0,u=0,f=0,l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0,x=0,E=0,g=0,m=0;var b=new t.Uint32Array(r),S=new t.Uint8Array(r);function C(t,e,r,h,o,c,u,f){t=t|0;e=e|0;r=r|0;h=h|0;o=o|0;c=c|0;u=u|0;f=f|0;var l=0,p=0,w=0,y=0,_=0,d=0,A=0,v=0;l=r|0x400,p=r|0x800,w=r|0xc00;o=o^b[(t|0)>>2],c=c^b[(t|4)>>2],u=u^b[(t|8)>>2],f=f^b[(t|12)>>2];for(v=16;(v|0)<=h<<4;v=v+16|0){y=b[(r|o>>22&1020)>>2]^b[(l|c>>14&1020)>>2]^b[(p|u>>6&1020)>>2]^b[(w|f<<2&1020)>>2]^b[(t|v|0)>>2],_=b[(r|c>>22&1020)>>2]^b[(l|u>>14&1020)>>2]^b[(p|f>>6&1020)>>2]^b[(w|o<<2&1020)>>2]^b[(t|v|4)>>2],d=b[(r|u>>22&1020)>>2]^b[(l|f>>14&1020)>>2]^b[(p|o>>6&1020)>>2]^b[(w|c<<2&1020)>>2]^b[(t|v|8)>>2],A=b[(r|f>>22&1020)>>2]^b[(l|o>>14&1020)>>2]^b[(p|c>>6&1020)>>2]^b[(w|u<<2&1020)>>2]^b[(t|v|12)>>2];o=y,c=_,u=d,f=A}s=b[(e|o>>22&1020)>>2]<<24^b[(e|c>>14&1020)>>2]<<16^b[(e|u>>6&1020)>>2]<<8^b[(e|f<<2&1020)>>2]^b[(t|v|0)>>2],i=b[(e|c>>22&1020)>>2]<<24^b[(e|u>>14&1020)>>2]<<16^b[(e|f>>6&1020)>>2]<<8^b[(e|o<<2&1020)>>2]^b[(t|v|4)>>2],n=b[(e|u>>22&1020)>>2]<<24^b[(e|f>>14&1020)>>2]<<16^b[(e|o>>6&1020)>>2]<<8^b[(e|c<<2&1020)>>2]^b[(t|v|8)>>2],a=b[(e|f>>22&1020)>>2]<<24^b[(e|o>>14&1020)>>2]<<16^b[(e|c>>6&1020)>>2]<<8^b[(e|u<<2&1020)>>2]^b[(t|v|12)>>2]}function M(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;C(0x0000,0x0800,0x1000,m,t,e,r,s)}function U(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;var n=0;C(0x0400,0x0c00,0x2000,m,t,s,r,e);n=i,i=a,a=n}function H(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h^t,o^e,c^r,u^f);h=s,o=i,c=n,u=a}function T(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;var l=0;C(0x0400,0x0c00,0x2000,m,t,f,r,e);l=i,i=a,a=l;s=s^h,i=i^o,n=n^c,a=a^u;h=t,o=e,c=r,u=f}function D(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);h=s=s^t,o=i=i^e,c=n=n^r,u=a=a^f}function k(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);s=s^t,i=i^e,n=n^r,a=a^f;h=t,o=e,c=r,u=f}function G(t,e,r,f){t=t|0;e=e|0;r=r|0;f=f|0;C(0x0000,0x0800,0x1000,m,h,o,c,u);h=s,o=i,c=n,u=a;s=s^t,i=i^e,n=n^r,a=a^f}function I(t,e,r,h){t=t|0;e=e|0;r=r|0;h=h|0;C(0x0000,0x0800,0x1000,m,f,l,p,w);w=~A&w|A&w+1;p=~d&p|d&p+((w|0)==0);l=~_&l|_&l+((p|0)==0);f=~y&f|y&f+((l|0)==0);s=s^t;i=i^e;n=n^r;a=a^h}function Z(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;var i=0,n=0,a=0,f=0,l=0,p=0,w=0,y=0,_=0,d=0;t=t^h,e=e^o,r=r^c,s=s^u;i=v|0,n=x|0,a=E|0,f=g|0;for(;(_|0)<128;_=_+1|0){if(i>>>31){l=l^t,p=p^e,w=w^r,y=y^s}i=i<<1|n>>>31,n=n<<1|a>>>31,a=a<<1|f>>>31,f=f<<1;d=s&1;s=s>>>1|r<<31,r=r>>>1|e<<31,e=e>>>1|t<<31,t=t>>>1;if(d)t=t^0xe1000000}h=l,o=p,c=w,u=y}function P(t){t=t|0;m=t}function B(t,e,r,h){t=t|0;e=e|0;r=r|0;h=h|0;s=t,i=e,n=r,a=h}function z(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;h=t,o=e,c=r,u=s}function O(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;f=t,l=e,p=r,w=s}function q(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;y=t,_=e,d=r,A=s}function L(t,e,r,s){t=t|0;e=e|0;r=r|0;s=s|0;w=~A&w|A&s,p=~d&p|d&r,l=~_&l|_&e,f=~y&f|y&t}function R(t){t=t|0;if(t&15)return-1;S[t|0]=s>>>24,S[t|1]=s>>>16&255,S[t|2]=s>>>8&255,S[t|3]=s&255,S[t|4]=i>>>24,S[t|5]=i>>>16&255,S[t|6]=i>>>8&255,S[t|7]=i&255,S[t|8]=n>>>24,S[t|9]=n>>>16&255,S[t|10]