Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cryptography/aes

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cryptography/aes - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

21

dist/cjs/aes.js

@@ -284,2 +284,3 @@ 'use strict';

if (blockSize === void 0) { blockSize = 16; }
this.offset = 0;
this.key = getWords(key);

@@ -299,12 +300,15 @@ this.counter = getWords(counter);

var cipherText = buf || new Uint32Array(text.length);
var offset = this.offset;
for (var i = 0; i < text.length; i += this.blockSize) {
var x = this.cipher.encrypt(this.counter);
for (var j = i, k = 0; j < text.length && k < this.blockSize; j++, k++)
for (var j = i, k = offset; j < text.length && k < this.blockSize; j++, k++)
cipherText[j] = x[k] ^ text[j];
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
if (text.length - i >= this.blockSize)
this.incrementCounter();
if (offset) {
i -= offset;
offset = 0;
}
}
this.offset = (this.offset + (text.length % 4)) % 4;
return cipherText;

@@ -318,2 +322,9 @@ };

};
AES_IGE.prototype.incrementCounter = function () {
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
}
};
return AES_IGE;

@@ -320,0 +331,0 @@ }());

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=new Uint8Array(256),t=new Uint8Array(256),r=new Uint32Array(256),n=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),s=new Uint32Array(256),y=new Uint32Array(256);function a(e){if(e instanceof Uint32Array)return e;if("string"==typeof e){if(e.length%4!=0)for(var t=e.length%4;t<=4;t++)e+="\0x00";var r=new Uint32Array(e.length/4);for(t=0;t<e.length;t+=4)r[t/4]=(i=t,(n=e).charCodeAt(i)<<24^n.charCodeAt(i+1)<<16^n.charCodeAt(i+2)<<8^n.charCodeAt(i+3));return r}var n,i;if(e instanceof Uint8Array){for(r=new Uint32Array(e.length/4),t=0;t<e.length;t+=4)r[t/4]=e[t]<<24^e[t+1]<<16^e[t+2]<<8^e[t+3];return r}throw new Error("Unable to create 32-bit words")}function l(e,t,r){void 0===r&&(r=e);for(var n=0;n<e.length;n++)r[n]=e[n]^t[n]}!function(){for(var a,l,f,u,g,v=new Uint8Array(256),p=new Uint8Array(256),w=0,A=0,d=0;d<256;d++)v[d]=d<<1^283*(d>>7),p[v[d]^d]=d;for(;!e[w];w^=a||1)f=(f=A^A<<1^A<<2^A<<3^A<<4)>>8^255&f^99,e[w]=f,t[f]=w,g=16843009*v[l=v[a=v[w]]]^65537*l^257*a^16843008*w,u=257*v[f]^16843008*f,r[w]=u=u<<24^u>>>8,n[w]=u=u<<24^u>>>8,i[w]=u=u<<24^u>>>8,h[w]=u=u<<24^u>>>8,o[f]=g=g<<24^g>>>8,c[f]=g=g<<24^g>>>8,s[f]=g=g<<24^g>>>8,y[f]=g=g<<24^g>>>8,A=p[A]||1}();var f=function(){function l(t){var r=a(t);if(4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*r.length+28),this.decKey=new Uint32Array(4*r.length+28),this.encKey.set(r);for(var n,i=1,h=r.length;h<4*r.length+28;h++)n=this.encKey[h-1],(h%r.length==0||8===r.length&&h%r.length==4)&&(n=e[n>>>24]<<24^e[n>>16&255]<<16^e[n>>8&255]<<8^e[255&n],h%r.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-r.length]^n;for(var l=0;h;l++,h--)n=this.encKey[3&l?h:h-4],this.decKey[l]=h<=4||l<4?n:o[e[n>>>24]]^c[e[n>>16&255]]^s[e[n>>8&255]]^y[e[255&n]]}return l.prototype.encrypt=function(t){for(var o,c,s,y=a(t),l=new Uint32Array(4),f=y[0]^this.encKey[0],u=y[1]^this.encKey[1],g=y[2]^this.encKey[2],v=y[3]^this.encKey[3],p=this.encKey.length/4-2,w=4,A=0;A<p;A++)o=r[f>>>24]^n[u>>16&255]^i[g>>8&255]^h[255&v]^this.encKey[w],c=r[u>>>24]^n[g>>16&255]^i[v>>8&255]^h[255&f]^this.encKey[w+1],s=r[g>>>24]^n[v>>16&255]^i[f>>8&255]^h[255&u]^this.encKey[w+2],v=r[v>>>24]^n[f>>16&255]^i[u>>8&255]^h[255&g]^this.encKey[w+3],f=o,u=c,g=s,w+=4;for(A=0;A<4;A++)l[A]=e[f>>>24]<<24^e[u>>16&255]<<16^e[g>>8&255]<<8^e[255&v]^this.encKey[w++],o=f,f=u,u=g,g=v,v=o;return l},l.prototype.decrypt=function(e){for(var r,n,i,h=a(e),l=new Uint32Array(4),f=h[0]^this.decKey[0],u=h[3]^this.decKey[1],g=h[2]^this.decKey[2],v=h[1]^this.decKey[3],p=this.decKey.length/4-2,w=4,A=0;A<p;A++)r=o[f>>>24]^c[u>>16&255]^s[g>>8&255]^y[255&v]^this.decKey[w],n=o[u>>>24]^c[g>>16&255]^s[v>>8&255]^y[255&f]^this.decKey[w+1],i=o[g>>>24]^c[v>>16&255]^s[f>>8&255]^y[255&u]^this.decKey[w+2],v=o[v>>>24]^c[f>>16&255]^s[u>>8&255]^y[255&g]^this.decKey[w+3],f=r,u=n,g=i,w+=4;for(A=0;A<4;A++)l[3&-A]=t[f>>>24]<<24^t[u>>16&255]<<16^t[g>>8&255]<<8^t[255&v]^this.decKey[w++],r=f,f=u,u=g,g=v,v=r;return l},l}(),u=function(){function e(e,t,r){void 0===r&&(r=16),this.key=a(e),this.iv=a(t),this.cipher=new f(e),this.blockSize=r/4}return e.prototype.encrypt=function(e,t){for(var r=a(e),n=t||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<r.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,h,o);var y=this.cipher.encrypt(o);l(y,i),i=s,h=y;for(var f=c,u=0;f<r.length&&u<4;f++,u++)n[f]=y[u]}return n},e.prototype.decrypt=function(e,t){for(var r=a(e),n=t||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<n.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,i,o);var y=this.cipher.decrypt(o);l(y,h),h=s,i=y;for(var f=c,u=0;f<n.length&&u<4;f++,u++)n[f]=y[u]}return n},e}(),g=function(){function e(e,t,r){if(void 0===r&&(r=16),this.key=a(e),this.counter=a(t),this.cipher=new f(e),this.blockSize=r/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return e.prototype.encrypt=function(e,t){for(var r=a(e),n=t||new Uint32Array(r.length),i=0;i<r.length;i+=this.blockSize){for(var h=this.cipher.encrypt(this.counter),o=i,c=0;o<r.length&&c<this.blockSize;o++,c++)n[o]=h[c]^r[o];for(var s=this.counter.length-1;s>=0&&!(++this.counter[s]<4294967295);s--);}return n},e.prototype.decrypt=function(e,t){return this.encrypt(e,t)},e}();exports.CTR=g,exports.IGE=u,exports.default=f;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=new Uint8Array(256),e=new Uint8Array(256),r=new Uint32Array(256),n=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),s=new Uint32Array(256),c=new Uint32Array(256),y=new Uint32Array(256);function a(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]=(i=e,(n=t).charCodeAt(i)<<24^n.charCodeAt(i+1)<<16^n.charCodeAt(i+2)<<8^n.charCodeAt(i+3));return r}var n,i;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 l(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 a,l,f,u,g,p=new Uint8Array(256),v=new Uint8Array(256),w=0,A=0,d=0;d<256;d++)p[d]=d<<1^283*(d>>7),v[p[d]^d]=d;for(;!t[w];w^=a||1)f=(f=A^A<<1^A<<2^A<<3^A<<4)>>8^255&f^99,t[w]=f,e[f]=w,g=16843009*p[l=p[a=p[w]]]^65537*l^257*a^16843008*w,u=257*p[f]^16843008*f,r[w]=u=u<<24^u>>>8,n[w]=u=u<<24^u>>>8,i[w]=u=u<<24^u>>>8,h[w]=u=u<<24^u>>>8,o[f]=g=g<<24^g>>>8,s[f]=g=g<<24^g>>>8,c[f]=g=g<<24^g>>>8,y[f]=g=g<<24^g>>>8,A=v[A]||1}();var f=function(){function l(e){var r=a(e);if(4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*r.length+28),this.decKey=new Uint32Array(4*r.length+28),this.encKey.set(r);for(var n,i=1,h=r.length;h<4*r.length+28;h++)n=this.encKey[h-1],(h%r.length==0||8===r.length&&h%r.length==4)&&(n=t[n>>>24]<<24^t[n>>16&255]<<16^t[n>>8&255]<<8^t[255&n],h%r.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-r.length]^n;for(var l=0;h;l++,h--)n=this.encKey[3&l?h:h-4],this.decKey[l]=h<=4||l<4?n:o[t[n>>>24]]^s[t[n>>16&255]]^c[t[n>>8&255]]^y[t[255&n]]}return l.prototype.encrypt=function(e){for(var o,s,c,y=a(e),l=new Uint32Array(4),f=y[0]^this.encKey[0],u=y[1]^this.encKey[1],g=y[2]^this.encKey[2],p=y[3]^this.encKey[3],v=this.encKey.length/4-2,w=4,A=0;A<v;A++)o=r[f>>>24]^n[u>>16&255]^i[g>>8&255]^h[255&p]^this.encKey[w],s=r[u>>>24]^n[g>>16&255]^i[p>>8&255]^h[255&f]^this.encKey[w+1],c=r[g>>>24]^n[p>>16&255]^i[f>>8&255]^h[255&u]^this.encKey[w+2],p=r[p>>>24]^n[f>>16&255]^i[u>>8&255]^h[255&g]^this.encKey[w+3],f=o,u=s,g=c,w+=4;for(A=0;A<4;A++)l[A]=t[f>>>24]<<24^t[u>>16&255]<<16^t[g>>8&255]<<8^t[255&p]^this.encKey[w++],o=f,f=u,u=g,g=p,p=o;return l},l.prototype.decrypt=function(t){for(var r,n,i,h=a(t),l=new Uint32Array(4),f=h[0]^this.decKey[0],u=h[3]^this.decKey[1],g=h[2]^this.decKey[2],p=h[1]^this.decKey[3],v=this.decKey.length/4-2,w=4,A=0;A<v;A++)r=o[f>>>24]^s[u>>16&255]^c[g>>8&255]^y[255&p]^this.decKey[w],n=o[u>>>24]^s[g>>16&255]^c[p>>8&255]^y[255&f]^this.decKey[w+1],i=o[g>>>24]^s[p>>16&255]^c[f>>8&255]^y[255&u]^this.decKey[w+2],p=o[p>>>24]^s[f>>16&255]^c[u>>8&255]^y[255&g]^this.decKey[w+3],f=r,u=n,g=i,w+=4;for(A=0;A<4;A++)l[3&-A]=e[f>>>24]<<24^e[u>>16&255]<<16^e[g>>8&255]<<8^e[255&p]^this.decKey[w++],r=f,f=u,u=g,g=p,p=r;return l},l}(),u=function(){function t(t,e,r){void 0===r&&(r=16),this.key=a(t),this.iv=a(e),this.cipher=new f(t),this.blockSize=r/4}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),s=0;s<r.length;s+=this.blockSize){var c=r.subarray(s,s+this.blockSize);l(c,h,o);var y=this.cipher.encrypt(o);l(y,i),i=c,h=y;for(var f=s,u=0;f<r.length&&u<4;f++,u++)n[f]=y[u]}return n},t.prototype.decrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),s=0;s<n.length;s+=this.blockSize){var c=r.subarray(s,s+this.blockSize);l(c,i,o);var y=this.cipher.decrypt(o);l(y,h),h=c,i=y;for(var f=s,u=0;f<n.length&&u<4;f++,u++)n[f]=y[u]}return n},t}(),g=function(){function t(t,e,r){if(void 0===r&&(r=16),this.offset=0,this.key=a(t),this.counter=a(e),this.cipher=new f(t),this.blockSize=r/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.offset,h=0;h<r.length;h+=this.blockSize){for(var o=this.cipher.encrypt(this.counter),s=h,c=i;s<r.length&&c<this.blockSize;s++,c++)n[s]=o[c]^r[s];r.length-h>=this.blockSize&&this.incrementCounter(),i&&(h-=i,i=0)}return this.offset=(this.offset+r.length%4)%4,n},t.prototype.decrypt=function(t,e){return this.encrypt(t,e)},t.prototype.incrementCounter=function(){for(var t=this.counter.length-1;t>=0&&!(++this.counter[t]<4294967295);t--);},t}();exports.CTR=g,exports.IGE=u,exports.default=f;

@@ -280,2 +280,3 @@ var S = new Uint8Array(256);

if (blockSize === void 0) { blockSize = 16; }
this.offset = 0;
this.key = getWords(key);

@@ -295,12 +296,15 @@ this.counter = getWords(counter);

var cipherText = buf || new Uint32Array(text.length);
var offset = this.offset;
for (var i = 0; i < text.length; i += this.blockSize) {
var x = this.cipher.encrypt(this.counter);
for (var j = i, k = 0; j < text.length && k < this.blockSize; j++, k++)
for (var j = i, k = offset; j < text.length && k < this.blockSize; j++, k++)
cipherText[j] = x[k] ^ text[j];
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
if (text.length - i >= this.blockSize)
this.incrementCounter();
if (offset) {
i -= offset;
offset = 0;
}
}
this.offset = (this.offset + (text.length % 4)) % 4;
return cipherText;

@@ -314,2 +318,9 @@ };

};
AES_IGE.prototype.incrementCounter = function () {
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
}
};
return AES_IGE;

@@ -316,0 +327,0 @@ }());

@@ -1,1 +0,1 @@

var t=new Uint8Array(256),e=new Uint8Array(256),r=new Uint32Array(256),n=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),y=new Uint32Array(256),s=new Uint32Array(256);function a(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]=(i=e,(n=t).charCodeAt(i)<<24^n.charCodeAt(i+1)<<16^n.charCodeAt(i+2)<<8^n.charCodeAt(i+3));return r}var n,i;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 l(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 a,l,f,u,g,v=new Uint8Array(256),w=new Uint8Array(256),p=0,A=0,K=0;K<256;K++)v[K]=K<<1^283*(K>>7),w[v[K]^K]=K;for(;!t[p];p^=a||1)f=(f=A^A<<1^A<<2^A<<3^A<<4)>>8^255&f^99,t[p]=f,e[f]=p,g=16843009*v[l=v[a=v[p]]]^65537*l^257*a^16843008*p,u=257*v[f]^16843008*f,r[p]=u=u<<24^u>>>8,n[p]=u=u<<24^u>>>8,i[p]=u=u<<24^u>>>8,h[p]=u=u<<24^u>>>8,o[f]=g=g<<24^g>>>8,c[f]=g=g<<24^g>>>8,y[f]=g=g<<24^g>>>8,s[f]=g=g<<24^g>>>8,A=w[A]||1}();var f=function(){function l(e){var r=a(e);if(4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*r.length+28),this.decKey=new Uint32Array(4*r.length+28),this.encKey.set(r);for(var n,i=1,h=r.length;h<4*r.length+28;h++)n=this.encKey[h-1],(h%r.length==0||8===r.length&&h%r.length==4)&&(n=t[n>>>24]<<24^t[n>>16&255]<<16^t[n>>8&255]<<8^t[255&n],h%r.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-r.length]^n;for(var l=0;h;l++,h--)n=this.encKey[3&l?h:h-4],this.decKey[l]=h<=4||l<4?n:o[t[n>>>24]]^c[t[n>>16&255]]^y[t[n>>8&255]]^s[t[255&n]]}return l.prototype.encrypt=function(e){for(var o,c,y,s=a(e),l=new Uint32Array(4),f=s[0]^this.encKey[0],u=s[1]^this.encKey[1],g=s[2]^this.encKey[2],v=s[3]^this.encKey[3],w=this.encKey.length/4-2,p=4,A=0;A<w;A++)o=r[f>>>24]^n[u>>16&255]^i[g>>8&255]^h[255&v]^this.encKey[p],c=r[u>>>24]^n[g>>16&255]^i[v>>8&255]^h[255&f]^this.encKey[p+1],y=r[g>>>24]^n[v>>16&255]^i[f>>8&255]^h[255&u]^this.encKey[p+2],v=r[v>>>24]^n[f>>16&255]^i[u>>8&255]^h[255&g]^this.encKey[p+3],f=o,u=c,g=y,p+=4;for(A=0;A<4;A++)l[A]=t[f>>>24]<<24^t[u>>16&255]<<16^t[g>>8&255]<<8^t[255&v]^this.encKey[p++],o=f,f=u,u=g,g=v,v=o;return l},l.prototype.decrypt=function(t){for(var r,n,i,h=a(t),l=new Uint32Array(4),f=h[0]^this.decKey[0],u=h[3]^this.decKey[1],g=h[2]^this.decKey[2],v=h[1]^this.decKey[3],w=this.decKey.length/4-2,p=4,A=0;A<w;A++)r=o[f>>>24]^c[u>>16&255]^y[g>>8&255]^s[255&v]^this.decKey[p],n=o[u>>>24]^c[g>>16&255]^y[v>>8&255]^s[255&f]^this.decKey[p+1],i=o[g>>>24]^c[v>>16&255]^y[f>>8&255]^s[255&u]^this.decKey[p+2],v=o[v>>>24]^c[f>>16&255]^y[u>>8&255]^s[255&g]^this.decKey[p+3],f=r,u=n,g=i,p+=4;for(A=0;A<4;A++)l[3&-A]=e[f>>>24]<<24^e[u>>16&255]<<16^e[g>>8&255]<<8^e[255&v]^this.decKey[p++],r=f,f=u,u=g,g=v,v=r;return l},l}(),u=function(){function t(t,e,r){void 0===r&&(r=16),this.key=a(t),this.iv=a(e),this.cipher=new f(t),this.blockSize=r/4}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<r.length;c+=this.blockSize){var y=r.subarray(c,c+this.blockSize);l(y,h,o);var s=this.cipher.encrypt(o);l(s,i),i=y,h=s;for(var f=c,u=0;f<r.length&&u<4;f++,u++)n[f]=s[u]}return n},t.prototype.decrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<n.length;c+=this.blockSize){var y=r.subarray(c,c+this.blockSize);l(y,i,o);var s=this.cipher.decrypt(o);l(s,h),h=y,i=s;for(var f=c,u=0;f<n.length&&u<4;f++,u++)n[f]=s[u]}return n},t}(),g=function(){function t(t,e,r){if(void 0===r&&(r=16),this.key=a(t),this.counter=a(e),this.cipher=new f(t),this.blockSize=r/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=0;i<r.length;i+=this.blockSize){for(var h=this.cipher.encrypt(this.counter),o=i,c=0;o<r.length&&c<this.blockSize;o++,c++)n[o]=h[c]^r[o];for(var y=this.counter.length-1;y>=0&&!(++this.counter[y]<4294967295);y--);}return n},t.prototype.decrypt=function(t,e){return this.encrypt(t,e)},t}();export default f;export{g as CTR,u as IGE};
var t=new Uint8Array(256),e=new Uint8Array(256),r=new Uint32Array(256),n=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),s=new Uint32Array(256),y=new Uint32Array(256);function a(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]=(i=e,(n=t).charCodeAt(i)<<24^n.charCodeAt(i+1)<<16^n.charCodeAt(i+2)<<8^n.charCodeAt(i+3));return r}var n,i;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 l(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 a,l,f,u,g,v=new Uint8Array(256),p=new Uint8Array(256),w=0,A=0,K=0;K<256;K++)v[K]=K<<1^283*(K>>7),p[v[K]^K]=K;for(;!t[w];w^=a||1)f=(f=A^A<<1^A<<2^A<<3^A<<4)>>8^255&f^99,t[w]=f,e[f]=w,g=16843009*v[l=v[a=v[w]]]^65537*l^257*a^16843008*w,u=257*v[f]^16843008*f,r[w]=u=u<<24^u>>>8,n[w]=u=u<<24^u>>>8,i[w]=u=u<<24^u>>>8,h[w]=u=u<<24^u>>>8,o[f]=g=g<<24^g>>>8,c[f]=g=g<<24^g>>>8,s[f]=g=g<<24^g>>>8,y[f]=g=g<<24^g>>>8,A=p[A]||1}();var f=function(){function l(e){var r=a(e);if(4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*r.length+28),this.decKey=new Uint32Array(4*r.length+28),this.encKey.set(r);for(var n,i=1,h=r.length;h<4*r.length+28;h++)n=this.encKey[h-1],(h%r.length==0||8===r.length&&h%r.length==4)&&(n=t[n>>>24]<<24^t[n>>16&255]<<16^t[n>>8&255]<<8^t[255&n],h%r.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-r.length]^n;for(var l=0;h;l++,h--)n=this.encKey[3&l?h:h-4],this.decKey[l]=h<=4||l<4?n:o[t[n>>>24]]^c[t[n>>16&255]]^s[t[n>>8&255]]^y[t[255&n]]}return l.prototype.encrypt=function(e){for(var o,c,s,y=a(e),l=new Uint32Array(4),f=y[0]^this.encKey[0],u=y[1]^this.encKey[1],g=y[2]^this.encKey[2],v=y[3]^this.encKey[3],p=this.encKey.length/4-2,w=4,A=0;A<p;A++)o=r[f>>>24]^n[u>>16&255]^i[g>>8&255]^h[255&v]^this.encKey[w],c=r[u>>>24]^n[g>>16&255]^i[v>>8&255]^h[255&f]^this.encKey[w+1],s=r[g>>>24]^n[v>>16&255]^i[f>>8&255]^h[255&u]^this.encKey[w+2],v=r[v>>>24]^n[f>>16&255]^i[u>>8&255]^h[255&g]^this.encKey[w+3],f=o,u=c,g=s,w+=4;for(A=0;A<4;A++)l[A]=t[f>>>24]<<24^t[u>>16&255]<<16^t[g>>8&255]<<8^t[255&v]^this.encKey[w++],o=f,f=u,u=g,g=v,v=o;return l},l.prototype.decrypt=function(t){for(var r,n,i,h=a(t),l=new Uint32Array(4),f=h[0]^this.decKey[0],u=h[3]^this.decKey[1],g=h[2]^this.decKey[2],v=h[1]^this.decKey[3],p=this.decKey.length/4-2,w=4,A=0;A<p;A++)r=o[f>>>24]^c[u>>16&255]^s[g>>8&255]^y[255&v]^this.decKey[w],n=o[u>>>24]^c[g>>16&255]^s[v>>8&255]^y[255&f]^this.decKey[w+1],i=o[g>>>24]^c[v>>16&255]^s[f>>8&255]^y[255&u]^this.decKey[w+2],v=o[v>>>24]^c[f>>16&255]^s[u>>8&255]^y[255&g]^this.decKey[w+3],f=r,u=n,g=i,w+=4;for(A=0;A<4;A++)l[3&-A]=e[f>>>24]<<24^e[u>>16&255]<<16^e[g>>8&255]<<8^e[255&v]^this.decKey[w++],r=f,f=u,u=g,g=v,v=r;return l},l}(),u=function(){function t(t,e,r){void 0===r&&(r=16),this.key=a(t),this.iv=a(e),this.cipher=new f(t),this.blockSize=r/4}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<r.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,h,o);var y=this.cipher.encrypt(o);l(y,i),i=s,h=y;for(var f=c,u=0;f<r.length&&u<4;f++,u++)n[f]=y[u]}return n},t.prototype.decrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<n.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,i,o);var y=this.cipher.decrypt(o);l(y,h),h=s,i=y;for(var f=c,u=0;f<n.length&&u<4;f++,u++)n[f]=y[u]}return n},t}(),g=function(){function t(t,e,r){if(void 0===r&&(r=16),this.offset=0,this.key=a(t),this.counter=a(e),this.cipher=new f(t),this.blockSize=r/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return t.prototype.encrypt=function(t,e){for(var r=a(t),n=e||new Uint32Array(r.length),i=this.offset,h=0;h<r.length;h+=this.blockSize){for(var o=this.cipher.encrypt(this.counter),c=h,s=i;c<r.length&&s<this.blockSize;c++,s++)n[c]=o[s]^r[c];r.length-h>=this.blockSize&&this.incrementCounter(),i&&(h-=i,i=0)}return this.offset=(this.offset+r.length%4)%4,n},t.prototype.decrypt=function(t,e){return this.encrypt(t,e)},t.prototype.incrementCounter=function(){for(var t=this.counter.length-1;t>=0&&!(++this.counter[t]<4294967295);t--);},t}();export default f;export{g as CTR,u as IGE};

@@ -272,2 +272,3 @@ import { s2i } from '@cryptography/utils';

if (blockSize === void 0) { blockSize = 16; }
this.offset = 0;
this.key = getWords(key);

@@ -287,12 +288,15 @@ this.counter = getWords(counter);

var cipherText = buf || new Uint32Array(text.length);
var offset = this.offset;
for (var i = 0; i < text.length; i += this.blockSize) {
var x = this.cipher.encrypt(this.counter);
for (var j = i, k = 0; j < text.length && k < this.blockSize; j++, k++)
for (var j = i, k = offset; j < text.length && k < this.blockSize; j++, k++)
cipherText[j] = x[k] ^ text[j];
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
if (text.length - i >= this.blockSize)
this.incrementCounter();
if (offset) {
i -= offset;
offset = 0;
}
}
this.offset = (this.offset + (text.length % 4)) % 4;
return cipherText;

@@ -306,2 +310,9 @@ };

};
AES_IGE.prototype.incrementCounter = function () {
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
}
};
return AES_IGE;

@@ -308,0 +319,0 @@ }());

@@ -10,2 +10,3 @@ import AES from '../aes';

blockSize: number;
offset: number;
constructor(key: string | Uint32Array | Uint8Array, counter: string | Uint32Array | Uint8Array, blockSize?: number);

@@ -20,2 +21,3 @@ /**

decrypt(message: string | Uint32Array | Uint8Array, buf?: Uint32Array): Uint32Array;
incrementCounter(): void;
}

@@ -286,2 +286,3 @@ (function (global, factory) {

if (blockSize === void 0) { blockSize = 16; }
this.offset = 0;
this.key = getWords(key);

@@ -301,12 +302,15 @@ this.counter = getWords(counter);

var cipherText = buf || new Uint32Array(text.length);
var offset = this.offset;
for (var i = 0; i < text.length; i += this.blockSize) {
var x = this.cipher.encrypt(this.counter);
for (var j = i, k = 0; j < text.length && k < this.blockSize; j++, k++)
for (var j = i, k = offset; j < text.length && k < this.blockSize; j++, k++)
cipherText[j] = x[k] ^ text[j];
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
if (text.length - i >= this.blockSize)
this.incrementCounter();
if (offset) {
i -= offset;
offset = 0;
}
}
this.offset = (this.offset + (text.length % 4)) % 4;
return cipherText;

@@ -320,2 +324,9 @@ };

};
AES_IGE.prototype.incrementCounter = function () {
// increment counter
for (var carry = this.counter.length - 1; carry >= 0; carry--) {
if (++this.counter[carry] < 0xFFFFFFFF)
break; // If overflowing, it'll be 0 and we'll have to continue propagating the carry
}
};
return AES_IGE;

@@ -322,0 +333,0 @@ }());

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).aes={})}(this,(function(e){"use strict";var t=new Uint8Array(256),r=new Uint8Array(256),n=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),s=new Uint32Array(256),y=new Uint32Array(256),a=new Uint32Array(256);function f(e){if(e instanceof Uint32Array)return e;if("string"==typeof e){if(e.length%4!=0)for(var t=e.length%4;t<=4;t++)e+="\0x00";var r=new Uint32Array(e.length/4);for(t=0;t<e.length;t+=4)r[t/4]=(i=t,(n=e).charCodeAt(i)<<24^n.charCodeAt(i+1)<<16^n.charCodeAt(i+2)<<8^n.charCodeAt(i+3));return r}var n,i;if(e instanceof Uint8Array){for(r=new Uint32Array(e.length/4),t=0;t<e.length;t+=4)r[t/4]=e[t]<<24^e[t+1]<<16^e[t+2]<<8^e[t+3];return r}throw new Error("Unable to create 32-bit words")}function l(e,t,r){void 0===r&&(r=e);for(var n=0;n<e.length;n++)r[n]=e[n]^t[n]}!function(){for(var e,f,l,u,d,g=new Uint8Array(256),p=new Uint8Array(256),v=0,w=0,A=0;A<256;A++)g[A]=A<<1^283*(A>>7),p[g[A]^A]=A;for(;!t[v];v^=e||1)l=(l=w^w<<1^w<<2^w<<3^w<<4)>>8^255&l^99,t[v]=l,r[l]=v,d=16843009*g[f=g[e=g[v]]]^65537*f^257*e^16843008*v,u=257*g[l]^16843008*l,n[v]=u=u<<24^u>>>8,i[v]=u=u<<24^u>>>8,h[v]=u=u<<24^u>>>8,o[v]=u=u<<24^u>>>8,c[l]=d=d<<24^d>>>8,s[l]=d=d<<24^d>>>8,y[l]=d=d<<24^d>>>8,a[l]=d=d<<24^d>>>8,w=p[w]||1}();var u=function(){function e(e){var r=f(e);if(4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*r.length+28),this.decKey=new Uint32Array(4*r.length+28),this.encKey.set(r);for(var n,i=1,h=r.length;h<4*r.length+28;h++)n=this.encKey[h-1],(h%r.length==0||8===r.length&&h%r.length==4)&&(n=t[n>>>24]<<24^t[n>>16&255]<<16^t[n>>8&255]<<8^t[255&n],h%r.length==0&&(n=n<<8^n>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-r.length]^n;for(var o=0;h;o++,h--)n=this.encKey[3&o?h:h-4],this.decKey[o]=h<=4||o<4?n:c[t[n>>>24]]^s[t[n>>16&255]]^y[t[n>>8&255]]^a[t[255&n]]}return e.prototype.encrypt=function(e){for(var r,c,s,y=f(e),a=new Uint32Array(4),l=y[0]^this.encKey[0],u=y[1]^this.encKey[1],d=y[2]^this.encKey[2],g=y[3]^this.encKey[3],p=this.encKey.length/4-2,v=4,w=0;w<p;w++)r=n[l>>>24]^i[u>>16&255]^h[d>>8&255]^o[255&g]^this.encKey[v],c=n[u>>>24]^i[d>>16&255]^h[g>>8&255]^o[255&l]^this.encKey[v+1],s=n[d>>>24]^i[g>>16&255]^h[l>>8&255]^o[255&u]^this.encKey[v+2],g=n[g>>>24]^i[l>>16&255]^h[u>>8&255]^o[255&d]^this.encKey[v+3],l=r,u=c,d=s,v+=4;for(w=0;w<4;w++)a[w]=t[l>>>24]<<24^t[u>>16&255]<<16^t[d>>8&255]<<8^t[255&g]^this.encKey[v++],r=l,l=u,u=d,d=g,g=r;return a},e.prototype.decrypt=function(e){for(var t,n,i,h=f(e),o=new Uint32Array(4),l=h[0]^this.decKey[0],u=h[3]^this.decKey[1],d=h[2]^this.decKey[2],g=h[1]^this.decKey[3],p=this.decKey.length/4-2,v=4,w=0;w<p;w++)t=c[l>>>24]^s[u>>16&255]^y[d>>8&255]^a[255&g]^this.decKey[v],n=c[u>>>24]^s[d>>16&255]^y[g>>8&255]^a[255&l]^this.decKey[v+1],i=c[d>>>24]^s[g>>16&255]^y[l>>8&255]^a[255&u]^this.decKey[v+2],g=c[g>>>24]^s[l>>16&255]^y[u>>8&255]^a[255&d]^this.decKey[v+3],l=t,u=n,d=i,v+=4;for(w=0;w<4;w++)o[3&-w]=r[l>>>24]<<24^r[u>>16&255]<<16^r[d>>8&255]<<8^r[255&g]^this.decKey[v++],t=l,l=u,u=d,d=g,g=t;return o},e}(),d=function(){function e(e,t,r){void 0===r&&(r=16),this.key=f(e),this.iv=f(t),this.cipher=new u(e),this.blockSize=r/4}return e.prototype.encrypt=function(e,t){for(var r=f(e),n=t||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<r.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,h,o);var y=this.cipher.encrypt(o);l(y,i),i=s,h=y;for(var a=c,u=0;a<r.length&&u<4;a++,u++)n[a]=y[u]}return n},e.prototype.decrypt=function(e,t){for(var r=f(e),n=t||new Uint32Array(r.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<n.length;c+=this.blockSize){var s=r.subarray(c,c+this.blockSize);l(s,i,o);var y=this.cipher.decrypt(o);l(y,h),h=s,i=y;for(var a=c,u=0;a<n.length&&u<4;a++,u++)n[a]=y[u]}return n},e}(),g=function(){function e(e,t,r){if(void 0===r&&(r=16),this.key=f(e),this.counter=f(t),this.cipher=new u(e),this.blockSize=r/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return e.prototype.encrypt=function(e,t){for(var r=f(e),n=t||new Uint32Array(r.length),i=0;i<r.length;i+=this.blockSize){for(var h=this.cipher.encrypt(this.counter),o=i,c=0;o<r.length&&c<this.blockSize;o++,c++)n[o]=h[c]^r[o];for(var s=this.counter.length-1;s>=0&&!(++this.counter[s]<4294967295);s--);}return n},e.prototype.decrypt=function(e,t){return this.encrypt(e,t)},e}();e.CTR=g,e.IGE=d,e.default=u,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).aes={})}(this,(function(e){"use strict";var t=new Uint8Array(256),n=new Uint8Array(256),r=new Uint32Array(256),i=new Uint32Array(256),h=new Uint32Array(256),o=new Uint32Array(256),c=new Uint32Array(256),s=new Uint32Array(256),y=new Uint32Array(256),a=new Uint32Array(256);function f(e){if(e instanceof Uint32Array)return e;if("string"==typeof e){if(e.length%4!=0)for(var t=e.length%4;t<=4;t++)e+="\0x00";var n=new Uint32Array(e.length/4);for(t=0;t<e.length;t+=4)n[t/4]=(i=t,(r=e).charCodeAt(i)<<24^r.charCodeAt(i+1)<<16^r.charCodeAt(i+2)<<8^r.charCodeAt(i+3));return n}var r,i;if(e instanceof Uint8Array){for(n=new Uint32Array(e.length/4),t=0;t<e.length;t+=4)n[t/4]=e[t]<<24^e[t+1]<<16^e[t+2]<<8^e[t+3];return n}throw new Error("Unable to create 32-bit words")}function l(e,t,n){void 0===n&&(n=e);for(var r=0;r<e.length;r++)n[r]=e[r]^t[r]}!function(){for(var e,f,l,u,g,p=new Uint8Array(256),d=new Uint8Array(256),v=0,w=0,A=0;A<256;A++)p[A]=A<<1^283*(A>>7),d[p[A]^A]=A;for(;!t[v];v^=e||1)l=(l=w^w<<1^w<<2^w<<3^w<<4)>>8^255&l^99,t[v]=l,n[l]=v,g=16843009*p[f=p[e=p[v]]]^65537*f^257*e^16843008*v,u=257*p[l]^16843008*l,r[v]=u=u<<24^u>>>8,i[v]=u=u<<24^u>>>8,h[v]=u=u<<24^u>>>8,o[v]=u=u<<24^u>>>8,c[l]=g=g<<24^g>>>8,s[l]=g=g<<24^g>>>8,y[l]=g=g<<24^g>>>8,a[l]=g=g<<24^g>>>8,w=d[w]||1}();var u=function(){function e(e){var n=f(e);if(4!==n.length&&6!==n.length&&8!==n.length)throw new Error("Invalid key size");this.encKey=new Uint32Array(4*n.length+28),this.decKey=new Uint32Array(4*n.length+28),this.encKey.set(n);for(var r,i=1,h=n.length;h<4*n.length+28;h++)r=this.encKey[h-1],(h%n.length==0||8===n.length&&h%n.length==4)&&(r=t[r>>>24]<<24^t[r>>16&255]<<16^t[r>>8&255]<<8^t[255&r],h%n.length==0&&(r=r<<8^r>>>24^i<<24,i=i<<1^283*(i>>7))),this.encKey[h]=this.encKey[h-n.length]^r;for(var o=0;h;o++,h--)r=this.encKey[3&o?h:h-4],this.decKey[o]=h<=4||o<4?r:c[t[r>>>24]]^s[t[r>>16&255]]^y[t[r>>8&255]]^a[t[255&r]]}return e.prototype.encrypt=function(e){for(var n,c,s,y=f(e),a=new Uint32Array(4),l=y[0]^this.encKey[0],u=y[1]^this.encKey[1],g=y[2]^this.encKey[2],p=y[3]^this.encKey[3],d=this.encKey.length/4-2,v=4,w=0;w<d;w++)n=r[l>>>24]^i[u>>16&255]^h[g>>8&255]^o[255&p]^this.encKey[v],c=r[u>>>24]^i[g>>16&255]^h[p>>8&255]^o[255&l]^this.encKey[v+1],s=r[g>>>24]^i[p>>16&255]^h[l>>8&255]^o[255&u]^this.encKey[v+2],p=r[p>>>24]^i[l>>16&255]^h[u>>8&255]^o[255&g]^this.encKey[v+3],l=n,u=c,g=s,v+=4;for(w=0;w<4;w++)a[w]=t[l>>>24]<<24^t[u>>16&255]<<16^t[g>>8&255]<<8^t[255&p]^this.encKey[v++],n=l,l=u,u=g,g=p,p=n;return a},e.prototype.decrypt=function(e){for(var t,r,i,h=f(e),o=new Uint32Array(4),l=h[0]^this.decKey[0],u=h[3]^this.decKey[1],g=h[2]^this.decKey[2],p=h[1]^this.decKey[3],d=this.decKey.length/4-2,v=4,w=0;w<d;w++)t=c[l>>>24]^s[u>>16&255]^y[g>>8&255]^a[255&p]^this.decKey[v],r=c[u>>>24]^s[g>>16&255]^y[p>>8&255]^a[255&l]^this.decKey[v+1],i=c[g>>>24]^s[p>>16&255]^y[l>>8&255]^a[255&u]^this.decKey[v+2],p=c[p>>>24]^s[l>>16&255]^y[u>>8&255]^a[255&g]^this.decKey[v+3],l=t,u=r,g=i,v+=4;for(w=0;w<4;w++)o[3&-w]=n[l>>>24]<<24^n[u>>16&255]<<16^n[g>>8&255]<<8^n[255&p]^this.decKey[v++],t=l,l=u,u=g,g=p,p=t;return o},e}(),g=function(){function e(e,t,n){void 0===n&&(n=16),this.key=f(e),this.iv=f(t),this.cipher=new u(e),this.blockSize=n/4}return e.prototype.encrypt=function(e,t){for(var n=f(e),r=t||new Uint32Array(n.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<n.length;c+=this.blockSize){var s=n.subarray(c,c+this.blockSize);l(s,h,o);var y=this.cipher.encrypt(o);l(y,i),i=s,h=y;for(var a=c,u=0;a<n.length&&u<4;a++,u++)r[a]=y[u]}return r},e.prototype.decrypt=function(e,t){for(var n=f(e),r=t||new Uint32Array(n.length),i=this.iv.subarray(this.blockSize,this.iv.length),h=this.iv.subarray(0,this.blockSize),o=new Uint32Array(this.blockSize),c=0;c<r.length;c+=this.blockSize){var s=n.subarray(c,c+this.blockSize);l(s,i,o);var y=this.cipher.decrypt(o);l(y,h),h=s,i=y;for(var a=c,u=0;a<r.length&&u<4;a++,u++)r[a]=y[u]}return r},e}(),p=function(){function e(e,t,n){if(void 0===n&&(n=16),this.offset=0,this.key=f(e),this.counter=f(t),this.cipher=new u(e),this.blockSize=n/4,4!==this.counter.length)throw new Error("AES-CTR mode counter must be 16 bytes length")}return e.prototype.encrypt=function(e,t){for(var n=f(e),r=t||new Uint32Array(n.length),i=this.offset,h=0;h<n.length;h+=this.blockSize){for(var o=this.cipher.encrypt(this.counter),c=h,s=i;c<n.length&&s<this.blockSize;c++,s++)r[c]=o[s]^n[c];n.length-h>=this.blockSize&&this.incrementCounter(),i&&(h-=i,i=0)}return this.offset=(this.offset+n.length%4)%4,r},e.prototype.decrypt=function(e,t){return this.encrypt(e,t)},e.prototype.incrementCounter=function(){for(var e=this.counter.length-1;e>=0&&!(++this.counter[e]<4294967295);e--);},e}();e.CTR=p,e.IGE=g,e.default=u,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "@cryptography/aes",
"description": "High-performance synchronous AES implementation for JavaScript",
"version": "0.1.0",
"version": "0.1.1",
"author": "Konstantin Darutkin",

@@ -45,2 +45,2 @@ "scripts": {

"license": "GPL-3.0-or-later"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc