Socket
Socket
Sign inDemoInstall

asmcrypto.js

Package Overview
Dependencies
Maintainers
3
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asmcrypto.js - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

27

dist_es5/aes/aes.js

@@ -14,3 +14,2 @@ import { AES_asm } from './aes.asm';

// The AES object state
this.result = null;
this.pos = 0;

@@ -69,6 +68,5 @@ this.len = 0;

}
this.result = result;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -99,14 +97,10 @@ AES.prototype.AES_Encrypt_finish = function () {

}
if (!this.result)
throw new Error('There is no result');
var result = new Uint8Array(this.result.length + rlen);
result.set(this.result, 0);
var result = new Uint8Array(rlen);
if (len)
asm.cipher(amode, hpos + pos, len);
if (rlen)
result.set(heap.subarray(pos, pos + rlen), this.result.length);
this.result = result;
result.set(heap.subarray(pos, pos + rlen));
this.pos = 0;
this.len = 0;
return this;
return result;
};

@@ -151,6 +145,5 @@ AES.prototype.AES_Decrypt_process = function (data) {

}
this.result = result;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -187,13 +180,9 @@ AES.prototype.AES_Decrypt_finish = function () {

}
if (!this.result)
throw new Error('There is no result');
var result = new Uint8Array(rlen + this.result.length);
result.set(this.result, 0);
var result = new Uint8Array(rlen);
if (rlen > 0) {
result.set(heap.subarray(pos, pos + rlen), this.result.length);
result.set(heap.subarray(pos, pos + rlen));
}
this.result = result;
this.pos = 0;
this.len = 0;
return this;
return result;
};

@@ -200,0 +189,0 @@ return AES;

@@ -12,2 +12,3 @@ var __extends = (this && this.__extends) || (function () {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
var AES_CBC = /** @class */ (function (_super) {

@@ -21,15 +22,17 @@ __extends(AES_CBC, _super);

if (padding === void 0) { padding = true; }
return new AES_CBC(key, iv, padding).encrypt(data).result;
return new AES_CBC(key, iv, padding).encrypt(data);
};
AES_CBC.decrypt = function (data, key, padding, iv) {
if (padding === void 0) { padding = true; }
return new AES_CBC(key, iv, padding).decrypt(data).result;
return new AES_CBC(key, iv, padding).decrypt(data);
};
AES_CBC.prototype.encrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};
AES_CBC.prototype.decrypt = function (data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
var r1 = this.AES_Decrypt_process(data);
var r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
};

@@ -36,0 +39,0 @@ return AES_CBC;

@@ -65,12 +65,12 @@ /**

if (tagsize === void 0) { tagsize = 16; }
return new AES_CCM(key, nonce, adata, tagsize, clear.length).encrypt(clear).result;
return new AES_CCM(key, nonce, adata, tagsize, clear.length).encrypt(clear);
};
AES_CCM.decrypt = function (cipher, key, nonce, adata, tagsize) {
if (tagsize === void 0) { tagsize = 16; }
return new AES_CCM(key, nonce, adata, tagsize, cipher.length - tagsize).decrypt(cipher).result;
return new AES_CCM(key, nonce, adata, tagsize, cipher.length - tagsize).decrypt(cipher);
};
AES_CCM.prototype.encrypt = function (data) {
this.dataLength = data.length || 0;
var result1 = this.AES_CCM_Encrypt_process(data).result;
var result2 = this.AES_CCM_Encrypt_finish().result;
var result1 = this.AES_CCM_Encrypt_process(data);
var result2 = this.AES_CCM_Encrypt_finish();
var result = new Uint8Array(result1.length + result2.length);

@@ -81,9 +81,8 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
};
AES_CCM.prototype.decrypt = function (data) {
this.dataLength = data.length || 0;
var result1 = this.AES_CCM_Decrypt_process(data).result;
var result2 = this.AES_CCM_Decrypt_finish().result;
var result1 = this.AES_CCM_Decrypt_process(data);
var result2 = this.AES_CCM_Decrypt_finish();
var result = new Uint8Array(result1.length + result2.length);

@@ -94,4 +93,3 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
};

@@ -182,7 +180,6 @@ AES_CCM.prototype.AES_CCM_calculate_iv = function () {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -207,7 +204,6 @@ AES_CCM.prototype.AES_CCM_Encrypt_finish = function () {

result.set(heap.subarray(0, tagSize), len);
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
};

@@ -247,7 +243,6 @@ AES_CCM.prototype.AES_CCM_Decrypt_process = function (data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -279,7 +274,6 @@ AES_CCM.prototype.AES_CCM_Decrypt_finish = function () {

throw new SecurityError('data integrity check failed');
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
};

@@ -286,0 +280,0 @@ AES_CCM.prototype.AES_CTR_set_options = function (nonce, counter, size) {

@@ -12,2 +12,3 @@ var __extends = (this && this.__extends) || (function () {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
var AES_CFB = /** @class */ (function (_super) {

@@ -21,14 +22,16 @@ __extends(AES_CFB, _super);

AES_CFB.encrypt = function (data, key, iv) {
return new AES_CFB(key, iv).encrypt(data).result;
return new AES_CFB(key, iv).encrypt(data);
};
AES_CFB.decrypt = function (data, key, iv) {
return new AES_CFB(key, iv).decrypt(data).result;
return new AES_CFB(key, iv).decrypt(data);
};
AES_CFB.prototype.encrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};
AES_CFB.prototype.decrypt = function (data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
var r1 = this.AES_Decrypt_process(data);
var r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
};

@@ -35,0 +38,0 @@ return AES_CFB;

@@ -13,3 +13,3 @@ import { AES_ECB } from './ecb';

this.bufferLength = 0;
this.k = new AES_ECB(key).encrypt(new Uint8Array(16)).result;
this.k = new AES_ECB(key).encrypt(new Uint8Array(16));
mul2(this.k);

@@ -48,3 +48,3 @@ this.cbc = new AES_CBC(key, new Uint8Array(16), false);

}
this.result = this.cbc.encrypt(this.buffer).result;
this.result = this.cbc.encrypt(this.buffer);
return this;

@@ -51,0 +51,0 @@ };

@@ -13,2 +13,3 @@ var __extends = (this && this.__extends) || (function () {

import { IllegalArgumentError } from '../other/errors';
import { joinBytes } from '../other/utils';
var AES_CTR = /** @class */ (function (_super) {

@@ -23,14 +24,16 @@ __extends(AES_CTR, _super);

AES_CTR.encrypt = function (data, key, nonce) {
return new AES_CTR(key, nonce).encrypt(data).result;
return new AES_CTR(key, nonce).encrypt(data);
};
AES_CTR.decrypt = function (data, key, nonce) {
return new AES_CTR(key, nonce).encrypt(data).result;
return new AES_CTR(key, nonce).encrypt(data);
};
AES_CTR.prototype.encrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};
AES_CTR.prototype.decrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};

@@ -37,0 +40,0 @@ AES_CTR.prototype.AES_CTR_set_options = function (nonce, counter, size) {

@@ -12,2 +12,3 @@ var __extends = (this && this.__extends) || (function () {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
var AES_ECB = /** @class */ (function (_super) {

@@ -21,15 +22,17 @@ __extends(AES_ECB, _super);

if (padding === void 0) { padding = false; }
return new AES_ECB(key, padding).encrypt(data).result;
return new AES_ECB(key, padding).encrypt(data);
};
AES_ECB.decrypt = function (data, key, padding) {
if (padding === void 0) { padding = false; }
return new AES_ECB(key, padding).decrypt(data).result;
return new AES_ECB(key, padding).decrypt(data);
};
AES_ECB.prototype.encrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};
AES_ECB.prototype.decrypt = function (data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
var r1 = this.AES_Decrypt_process(data);
var r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
};

@@ -36,0 +39,0 @@ return AES_ECB;

@@ -85,6 +85,6 @@ var __extends = (this && this.__extends) || (function () {

AES_GCM.encrypt = function (cleartext, key, nonce, adata, tagsize) {
return new AES_GCM(key, nonce, adata, tagsize).encrypt(cleartext).result;
return new AES_GCM(key, nonce, adata, tagsize).encrypt(cleartext);
};
AES_GCM.decrypt = function (ciphertext, key, nonce, adata, tagsize) {
return new AES_GCM(key, nonce, adata, tagsize).decrypt(ciphertext).result;
return new AES_GCM(key, nonce, adata, tagsize).decrypt(ciphertext);
};

@@ -131,7 +131,6 @@ AES_GCM.prototype.encrypt = function (data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -175,7 +174,6 @@ AES_GCM.prototype.AES_GCM_Encrypt_finish = function () {

result.set(heap.subarray(0, tagSize), len);
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
};

@@ -215,7 +213,6 @@ AES_GCM.prototype.AES_GCM_Decrypt_process = function (data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
};

@@ -267,11 +264,10 @@ AES_GCM.prototype.AES_GCM_Decrypt_finish = function () {

throw new SecurityError('data integrity check failed');
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
};
AES_GCM.prototype.AES_GCM_decrypt = function (data) {
var result1 = this.AES_GCM_Decrypt_process(data).result;
var result2 = this.AES_GCM_Decrypt_finish().result;
var result1 = this.AES_GCM_Decrypt_process(data);
var result2 = this.AES_GCM_Decrypt_finish();
var result = new Uint8Array(result1.length + result2.length);

@@ -282,8 +278,7 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
};
AES_GCM.prototype.AES_GCM_encrypt = function (data) {
var result1 = this.AES_GCM_Encrypt_process(data).result;
var result2 = this.AES_GCM_Encrypt_finish().result;
var result1 = this.AES_GCM_Encrypt_process(data);
var result2 = this.AES_GCM_Encrypt_finish();
var result = new Uint8Array(result1.length + result2.length);

@@ -294,4 +289,3 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
};

@@ -298,0 +292,0 @@ AES_GCM.prototype._gcm_mac_process = function (data) {

@@ -12,2 +12,3 @@ var __extends = (this && this.__extends) || (function () {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
var AES_OFB = /** @class */ (function (_super) {

@@ -19,14 +20,16 @@ __extends(AES_OFB, _super);

AES_OFB.encrypt = function (data, key, iv) {
return new AES_OFB(key, iv).encrypt(data).result;
return new AES_OFB(key, iv).encrypt(data);
};
AES_OFB.decrypt = function (data, key, iv) {
return new AES_OFB(key, iv).decrypt(data).result;
return new AES_OFB(key, iv).decrypt(data);
};
AES_OFB.prototype.encrypt = function (data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
var r1 = this.AES_Encrypt_process(data);
var r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
};
AES_OFB.prototype.decrypt = function (data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
var r1 = this.AES_Decrypt_process(data);
var r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
};

@@ -33,0 +36,0 @@ return AES_OFB;

@@ -145,1 +145,15 @@ var local_atob = typeof atob === 'undefined' ? function (str) { return Buffer.from(str, 'base64').toString('binary'); } : atob;

}
export function joinBytes() {
var arg = [];
for (var _i = 0; _i < arguments.length; _i++) {
arg[_i] = arguments[_i];
}
var totalLenght = arg.reduce(function (sum, curr) { return sum + curr.length; }, 0);
var ret = new Uint8Array(totalLenght);
var cursor = 0;
for (var i = 0; i < arg.length; i++) {
ret.set(arg[i], cursor);
cursor += arg[i].length;
}
return ret;
}

@@ -13,3 +13,2 @@ import { AES_asm } from './aes.asm';

// The AES object state
this.result = null;
this.pos = 0;

@@ -68,6 +67,5 @@ this.len = 0;

}
this.result = result;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -98,14 +96,10 @@ AES_Encrypt_finish() {

}
if (!this.result)
throw new Error('There is no result');
const result = new Uint8Array(this.result.length + rlen);
result.set(this.result, 0);
const result = new Uint8Array(rlen);
if (len)
asm.cipher(amode, hpos + pos, len);
if (rlen)
result.set(heap.subarray(pos, pos + rlen), this.result.length);
this.result = result;
result.set(heap.subarray(pos, pos + rlen));
this.pos = 0;
this.len = 0;
return this;
return result;
}

@@ -150,6 +144,5 @@ AES_Decrypt_process(data) {

}
this.result = result;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -186,14 +179,10 @@ AES_Decrypt_finish() {

}
if (!this.result)
throw new Error('There is no result');
const result = new Uint8Array(rlen + this.result.length);
result.set(this.result, 0);
const result = new Uint8Array(rlen);
if (rlen > 0) {
result.set(heap.subarray(pos, pos + rlen), this.result.length);
result.set(heap.subarray(pos, pos + rlen));
}
this.result = result;
this.pos = 0;
this.len = 0;
return this;
return result;
}
}
import { AES } from './aes';
import { joinBytes } from '../other/utils';
export class AES_CBC extends AES {
static encrypt(data, key, padding = true, iv) {
return new AES_CBC(key, iv, padding).encrypt(data).result;
return new AES_CBC(key, iv, padding).encrypt(data);
}
static decrypt(data, key, padding = true, iv) {
return new AES_CBC(key, iv, padding).decrypt(data).result;
return new AES_CBC(key, iv, padding).decrypt(data);
}

@@ -13,9 +14,11 @@ constructor(key, iv, padding = true) {

encrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}
decrypt(data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
const r1 = this.AES_Decrypt_process(data);
const r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
}
}

@@ -51,11 +51,11 @@ /**

static encrypt(clear, key, nonce, adata, tagsize = 16) {
return new AES_CCM(key, nonce, adata, tagsize, clear.length).encrypt(clear).result;
return new AES_CCM(key, nonce, adata, tagsize, clear.length).encrypt(clear);
}
static decrypt(cipher, key, nonce, adata, tagsize = 16) {
return new AES_CCM(key, nonce, adata, tagsize, cipher.length - tagsize).decrypt(cipher).result;
return new AES_CCM(key, nonce, adata, tagsize, cipher.length - tagsize).decrypt(cipher);
}
encrypt(data) {
this.dataLength = data.length || 0;
const result1 = this.AES_CCM_Encrypt_process(data).result;
const result2 = this.AES_CCM_Encrypt_finish().result;
const result1 = this.AES_CCM_Encrypt_process(data);
const result2 = this.AES_CCM_Encrypt_finish();
const result = new Uint8Array(result1.length + result2.length);

@@ -66,9 +66,8 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
}
decrypt(data) {
this.dataLength = data.length || 0;
const result1 = this.AES_CCM_Decrypt_process(data).result;
const result2 = this.AES_CCM_Decrypt_finish().result;
const result1 = this.AES_CCM_Decrypt_process(data);
const result2 = this.AES_CCM_Decrypt_finish();
const result = new Uint8Array(result1.length + result2.length);

@@ -79,4 +78,3 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
}

@@ -167,7 +165,6 @@ AES_CCM_calculate_iv() {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -192,7 +189,6 @@ AES_CCM_Encrypt_finish() {

result.set(heap.subarray(0, tagSize), len);
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
}

@@ -232,7 +228,6 @@ AES_CCM_Decrypt_process(data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -264,7 +259,6 @@ AES_CCM_Decrypt_finish() {

throw new SecurityError('data integrity check failed');
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
}

@@ -271,0 +265,0 @@ AES_CTR_set_options(nonce, counter, size) {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
export class AES_CFB extends AES {
static encrypt(data, key, iv) {
return new AES_CFB(key, iv).encrypt(data).result;
return new AES_CFB(key, iv).encrypt(data);
}
static decrypt(data, key, iv) {
return new AES_CFB(key, iv).decrypt(data).result;
return new AES_CFB(key, iv).decrypt(data);
}

@@ -14,9 +15,11 @@ constructor(key, iv) {

encrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}
decrypt(data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
const r1 = this.AES_Decrypt_process(data);
const r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
}
}

@@ -13,3 +13,3 @@ import { AES_ECB } from './ecb';

this.bufferLength = 0;
this.k = new AES_ECB(key).encrypt(new Uint8Array(16)).result;
this.k = new AES_ECB(key).encrypt(new Uint8Array(16));
mul2(this.k);

@@ -48,5 +48,5 @@ this.cbc = new AES_CBC(key, new Uint8Array(16), false);

}
this.result = this.cbc.encrypt(this.buffer).result;
this.result = this.cbc.encrypt(this.buffer);
return this;
}
}
import { AES } from './aes';
import { IllegalArgumentError } from '../other/errors';
import { joinBytes } from '../other/utils';
export class AES_CTR extends AES {
static encrypt(data, key, nonce) {
return new AES_CTR(key, nonce).encrypt(data).result;
return new AES_CTR(key, nonce).encrypt(data);
}
static decrypt(data, key, nonce) {
return new AES_CTR(key, nonce).encrypt(data).result;
return new AES_CTR(key, nonce).encrypt(data);
}

@@ -16,8 +17,10 @@ constructor(key, nonce) {

encrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}
decrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}

@@ -24,0 +27,0 @@ AES_CTR_set_options(nonce, counter, size) {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
export class AES_ECB extends AES {
static encrypt(data, key, padding = false) {
return new AES_ECB(key, padding).encrypt(data).result;
return new AES_ECB(key, padding).encrypt(data);
}
static decrypt(data, key, padding = false) {
return new AES_ECB(key, padding).decrypt(data).result;
return new AES_ECB(key, padding).decrypt(data);
}

@@ -13,9 +14,11 @@ constructor(key, padding = false) {

encrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}
decrypt(data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
const r1 = this.AES_Decrypt_process(data);
const r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
}
}

@@ -72,6 +72,6 @@ import { IllegalArgumentError, IllegalStateError, SecurityError } from '../other/errors';

static encrypt(cleartext, key, nonce, adata, tagsize) {
return new AES_GCM(key, nonce, adata, tagsize).encrypt(cleartext).result;
return new AES_GCM(key, nonce, adata, tagsize).encrypt(cleartext);
}
static decrypt(ciphertext, key, nonce, adata, tagsize) {
return new AES_GCM(key, nonce, adata, tagsize).decrypt(ciphertext).result;
return new AES_GCM(key, nonce, adata, tagsize).decrypt(ciphertext);
}

@@ -118,7 +118,6 @@ encrypt(data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -162,7 +161,6 @@ AES_GCM_Encrypt_finish() {

result.set(heap.subarray(0, tagSize), len);
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
}

@@ -202,7 +200,6 @@ AES_GCM_Decrypt_process(data) {

}
this.result = result;
this.counter = counter;
this.pos = pos;
this.len = len;
return this;
return result;
}

@@ -254,11 +251,10 @@ AES_GCM_Decrypt_finish() {

throw new SecurityError('data integrity check failed');
this.result = result;
this.counter = 1;
this.pos = 0;
this.len = 0;
return this;
return result;
}
AES_GCM_decrypt(data) {
const result1 = this.AES_GCM_Decrypt_process(data).result;
const result2 = this.AES_GCM_Decrypt_finish().result;
const result1 = this.AES_GCM_Decrypt_process(data);
const result2 = this.AES_GCM_Decrypt_finish();
const result = new Uint8Array(result1.length + result2.length);

@@ -269,8 +265,7 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
}
AES_GCM_encrypt(data) {
const result1 = this.AES_GCM_Encrypt_process(data).result;
const result2 = this.AES_GCM_Encrypt_finish().result;
const result1 = this.AES_GCM_Encrypt_process(data);
const result2 = this.AES_GCM_Encrypt_finish();
const result = new Uint8Array(result1.length + result2.length);

@@ -281,4 +276,3 @@ if (result1.length)

result.set(result2, result1.length);
this.result = result;
return this;
return result;
}

@@ -285,0 +279,0 @@ _gcm_mac_process(data) {

import { AES } from './aes';
import { joinBytes } from '../other/utils';
export class AES_OFB extends AES {
static encrypt(data, key, iv) {
return new AES_OFB(key, iv).encrypt(data).result;
return new AES_OFB(key, iv).encrypt(data);
}
static decrypt(data, key, iv) {
return new AES_OFB(key, iv).decrypt(data).result;
return new AES_OFB(key, iv).decrypt(data);
}

@@ -13,9 +14,11 @@ constructor(key, iv) {

encrypt(data) {
this.AES_Encrypt_process(data);
return this.AES_Encrypt_finish();
const r1 = this.AES_Encrypt_process(data);
const r2 = this.AES_Encrypt_finish();
return joinBytes(r1, r2);
}
decrypt(data) {
this.AES_Decrypt_process(data);
return this.AES_Decrypt_finish();
const r1 = this.AES_Decrypt_process(data);
const r2 = this.AES_Decrypt_finish();
return joinBytes(r1, r2);
}
}

@@ -143,1 +143,11 @@ const local_atob = typeof atob === 'undefined' ? (str) => Buffer.from(str, 'base64').toString('binary') : atob;

}
export function joinBytes(...arg) {
const totalLenght = arg.reduce((sum, curr) => sum + curr.length, 0);
const ret = new Uint8Array(totalLenght);
let cursor = 0;
for (let i = 0; i < arg.length; i++) {
ret.set(arg[i], cursor);
cursor += arg[i].length;
}
return ret;
}
{
"name": "asmcrypto.js",
"version": "2.0.0",
"version": "2.0.1",
"description": "Asm.js implementation of WebCrypto API",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/asmcrypto/asmcrypto.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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