mirror of
https://github.com/danog/telegram-tt.git
synced 2024-12-15 02:37:17 +01:00
3 lines
68 KiB
JavaScript
3 lines
68 KiB
JavaScript
|
/*! For license information please see 313.8a2407b28699bf5c67c8.js.LICENSE.txt */
|
||
|
(self.webpackChunktelegram_t=self.webpackChunktelegram_t||[]).push([[313],{8136:(t,e,r)=>{"use strict";r.r(e),r.d(e,{default:()=>w,CTR:()=>d,IGE:()=>v});var n=new Uint8Array(256),o=new Uint8Array(256),i=new Uint32Array(256),u=new Uint32Array(256),s=new Uint32Array(256),a=new Uint32Array(256),f=new Uint32Array(256),c=new Uint32Array(256),p=new Uint32Array(256),l=new Uint32Array(256);function h(t){if(t instanceof Uint32Array)return t;if("string"==typeof t){if(t.length%4!=0)for(var e=t.length%4;e<=4;e++)t+="\0x00";var r=new Uint32Array(t.length/4);for(e=0;e<t.length;e+=4)r[e/4]=(o=e,(n=t).charCodeAt(o)<<24^n.charCodeAt(o+1)<<16^n.charCodeAt(o+2)<<8^n.charCodeAt(o+3));return r}var n,o;if(t instanceof Uint8Array){for(r=new Uint32Array(t.length/4),e=0;e<t.length;e+=4)r[e/4]=t[e]<<24^t[e+1]<<16^t[e+2]<<8^t[e+3];return r}throw new Error("Unable to create 32-bit words")}function y(t,e,r){void 0===r&&(r=t);for(var n=0;n<t.length;n++)r[n]=t[n]^e[n]}!function(){for(var t,e,r,h,y,g=new Uint8Array(256),v=new Uint8Array(256),d=0,w=0,b=0;b<256;b++)g[b]=b<<1^283*(b>>7),v[g[b]^b]=b;for(;!n[d];d^=t||1)r=(r=w^w<<1^w<<2^w<<3^w<<4)>>8^255&r^99,n[d]=r,o[r]=d,y=16843009*g[e=g[t=g[d]]]^65537*e^257*t^16843008*d,h=257*g[r]^16843008*r,i[d]=h=h<<24^h>>>8,u[d]=h=h<<24^h>>>8,s[d]=h=h<<24^h>>>8,a[d]=h=h<<24^h>>>8,f[r]=y=y<<24^y>>>8,c[r]=y=y<<24^y>>>8,p[r]=y=y<<24^y>>>8,l[r]=y=y<<24^y>>>8,w=v[w]||1}();var g=function(){function t(t){var e=h(t);if(4!==e.length&&6!==e.length&&8!==e.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*e.length+28),this.decKey=new Uint32Array(4*e.length+28),this.encKey.set(e);for(var r,o=1,i=e.length;i<4*e.length+28;i++)r=this.encKey[i-1],(i%e.length==0||8===e.length&&i%e.length==4)&&(r=n[r>>>24]<<24^n[r>>16&255]<<16^n[r>>8&255]<<8^n[255&r],i%e.length==0&&(r=r<<8^r>>>24^o<<24,o=o<<1^283*(o>>7))),this.encKey[i]=this.encKey[i-e.length]^r;for(var u=0;i;u++,i--)r=this.encKey[3&u?i:i-4],this.decKey[u]=i<=4||u<4?r:f[n[r>>>24]]^c[n[r>>16&255]]^p[n[r>>8&255]]^l[n[255&r]]}return t.prototype.encrypt=function(t){for(var e,r,o,f=h(t),c=new Uint32Array(4),p=f[0]^this.encKey[0],l=f[1]^this.encKey[1],y=f[2]^this.encKey[2],g=f[3]^this.encKey[3],v=this.encKey.length/4-2,d=4,w=0;w<v;w++)e=i[p>>>24]^u[l>>16&255]^s[y>>8&255]^a[255&g]^this.encKey[d],r=i[l>>>24]^u[y>>16&255]^s[g>>8&255]^a[255&p]^this.encKey[d+1],o=i[y>>>24]^u[g>>16&255]^s[p>>8&255]^a[255&l]^this.encKey[d+2],g=i[g>>>24]^u[p>>16&255]^s[l>>8&255]^a[255&y]^this.encKey[d+3],p=e,l=r,y=o,d+=4;for(w=0;w<4;w++)c[w]=n[p>>>24]<<24^n[l>>16&255]<<16^n[y>>8&255]<<8^n[255&g]^this.encKey[d++],e=p,p=l,l=y,y=g,g=e;return c},t.prototype.decrypt=function(t){for(var e,r,n,i=h(t),u=new Uint32Array(4),s=i[0]^this.decKey[0],a=i[3]^this.decKey[1],y=i[2]^this.decKey[2],g=i[1]^this.decKey[3],v=this.decKey.length/4-2,d=4,w=0;w<v;w++)e=f[s>>>24]^c[a>>16&255]^p[y>>8&255]^l[255&g]^this.decKey[d],r=f[a>>>24]^c[y>>16&255]^p[g>>8&255]^l[255&s]^this.decKey[d+1],n=f[y>>>24]^c[g>>16&255]^p[s>>8&255]^l[255&a]^this.decKey[d+2],g=f[g>>>24]^c[s>>16&255]^p[a>>8&255]^l[255&y]^this.decKey[d+3],s=e,a=r,y=n,d+=4;for(w=0;w<4;w++)u[3&-w]=o[s>>>24]<<24^o[a>>16&255]<<16^o[y>>8&255]<<8^o[255&g]^this.decKey[d++],e=s,s=a,a=y,y=g,g=e;return u},t}(),v=function(){function t(t,e,r){void 0===r&&(r=16),this.key=h(t),this.iv=h(e),this.cipher=new g(t),this.blockSize=r/4}return t.prototype.encrypt=function(t,e){for(var r=h(t),n=e||new Uint32Array(r.length),o=this.iv.subarray(this.blockSize,this.iv.length),i=this.iv.subarray(0,this.blockSize),u=new Uint32Array(this.blockSize),s=0;s<r.length;s+=this.blockSize){var a=r.subarray(s,s+this.blockSize);y(a,i,u);var f=this.cipher.encrypt(u);y(f,o),o=a,i=f;for(var c=s,p=0;c<r.length&&p<4;c++,p++)n[c]=f[p]}return n},t.prototype.decrypt=function(t,e){for(var r=h(t),n=e||new Uint32Array(r.length),o=this.iv.subarray(this.blockSize,this.iv.length),i=this.iv.subarray(0,this.blockSize),u=new Uint32Array(this.blockSize),s=0;s<n.length;s+=this.blockSize){var a=r.subarray(s,s+this.blockSize);y(a,o,u);var f=this.cipher.decrypt(u);y(f,i),i=a,o=f;for(var c=s,p=0;c<n.length&&p<4;c++,p++)n[c]=f
|
||
|
//# sourceMappingURL=313.8a2407b28699bf5c67c8.js.map
|