New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@stablelib/gcm

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stablelib/gcm - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

10

dist/gcm.d.ts

@@ -25,3 +25,3 @@ import { AEAD } from "@stablelib/aead";

/**
* Encrypts and authenticates plaintext, authenticates additional data,
* Encrypts and authenticates plaintext, authenticates associated data,
* and returns sealed ciphertext, which includes authentication tag.

@@ -32,6 +32,6 @@ *

*/
seal(nonce: Uint8Array, plaintext: Uint8Array, additionalData?: Uint8Array, dst?: Uint8Array): Uint8Array;
seal(nonce: Uint8Array, plaintext: Uint8Array, associatedData?: Uint8Array, dst?: Uint8Array): Uint8Array;
/**
* Authenticates sealed ciphertext (which includes authentication tag) and
* additional data, decrypts ciphertext and returns decrypted plaintext.
* associated data, decrypts ciphertext and returns decrypted plaintext.
*

@@ -43,5 +43,5 @@ * If authentication fails, it returns null.

*/
open(nonce: Uint8Array, sealed: Uint8Array, additionalData?: Uint8Array, dst?: Uint8Array): Uint8Array | null;
open(nonce: Uint8Array, sealed: Uint8Array, associatedData?: Uint8Array, dst?: Uint8Array): Uint8Array | null;
clean(): this;
private _authenticate(tagOut, tagMask, ciphertext, additionalData?);
private _authenticate(tagOut, tagMask, ciphertext, associatedData?);
}

@@ -38,3 +38,3 @@ // Copyright (C) 2016 Dmitry Chestnykh

/**
* Encrypts and authenticates plaintext, authenticates additional data,
* Encrypts and authenticates plaintext, authenticates associated data,
* and returns sealed ciphertext, which includes authentication tag.

@@ -45,3 +45,3 @@ *

*/
GCM.prototype.seal = function (nonce, plaintext, additionalData, dst) {
GCM.prototype.seal = function (nonce, plaintext, associatedData, dst) {
if (nonce.length !== this.nonceLength) {

@@ -81,3 +81,3 @@ throw new Error("GCM: incorrect nonce length");

// Authenticate.
this._authenticate(result.subarray(result.length - this.tagLength, result.length), tagMask, result.subarray(0, result.length - this.tagLength), additionalData);
this._authenticate(result.subarray(result.length - this.tagLength, result.length), tagMask, result.subarray(0, result.length - this.tagLength), associatedData);
// Cleanup.

@@ -90,3 +90,3 @@ wipe_1.wipe(counter);

* Authenticates sealed ciphertext (which includes authentication tag) and
* additional data, decrypts ciphertext and returns decrypted plaintext.
* associated data, decrypts ciphertext and returns decrypted plaintext.
*

@@ -98,3 +98,3 @@ * If authentication fails, it returns null.

*/
GCM.prototype.open = function (nonce, sealed, additionalData, dst) {
GCM.prototype.open = function (nonce, sealed, associatedData, dst) {
if (nonce.length !== this.nonceLength) {

@@ -121,3 +121,3 @@ throw new Error("GCM: incorrect nonce length");

var calculatedTag = new Uint8Array(this.tagLength);
this._authenticate(calculatedTag, tagMask, sealed.subarray(0, sealed.length - this.tagLength), additionalData);
this._authenticate(calculatedTag, tagMask, sealed.subarray(0, sealed.length - this.tagLength), associatedData);
// Constant-time compare tags and return null if they differ.

@@ -154,8 +154,8 @@ if (!constant_time_1.equal(calculatedTag, sealed.subarray(sealed.length - this.tagLength, sealed.length))) {

};
GCM.prototype._authenticate = function (tagOut, tagMask, ciphertext, additionalData) {
GCM.prototype._authenticate = function (tagOut, tagMask, ciphertext, associatedData) {
var blockSize = this._cipher.blockSize;
// Authenticate additional data.
if (additionalData) {
for (var i = 0; i < additionalData.length; i += blockSize) {
var slice = additionalData.subarray(i, Math.min(i + blockSize, additionalData.length));
// Authenticate associated data.
if (associatedData) {
for (var i = 0; i < associatedData.length; i += blockSize) {
var slice = associatedData.subarray(i, Math.min(i + blockSize, associatedData.length));
addmul(tagOut, slice, this._subkey);

@@ -169,7 +169,7 @@ }

}
// Make a block of additional data and ciphertext (plaintext) bit lengths.
// Make a block of associated data and ciphertext (plaintext) bit lengths.
// XXX: can avoid allocation here?
var lengthsBlock = new Uint8Array(blockSize);
if (additionalData) {
writeBitLength(additionalData.length, lengthsBlock, 0);
if (associatedData) {
writeBitLength(associatedData.length, lengthsBlock, 0);
}

@@ -176,0 +176,0 @@ writeBitLength(ciphertext.length, lengthsBlock, 8);

@@ -50,3 +50,3 @@ // Copyright (C) 2016 Dmitry Chestnykh

/**
* Encrypts and authenticates plaintext, authenticates additional data,
* Encrypts and authenticates plaintext, authenticates associated data,
* and returns sealed ciphertext, which includes authentication tag.

@@ -57,3 +57,3 @@ *

*/
seal(nonce: Uint8Array, plaintext: Uint8Array, additionalData?: Uint8Array,
seal(nonce: Uint8Array, plaintext: Uint8Array, associatedData?: Uint8Array,
dst?: Uint8Array): Uint8Array {

@@ -104,3 +104,3 @@ if (nonce.length !== this.nonceLength) {

this._authenticate(result.subarray(result.length - this.tagLength, result.length),
tagMask, result.subarray(0, result.length - this.tagLength), additionalData);
tagMask, result.subarray(0, result.length - this.tagLength), associatedData);

@@ -116,3 +116,3 @@ // Cleanup.

* Authenticates sealed ciphertext (which includes authentication tag) and
* additional data, decrypts ciphertext and returns decrypted plaintext.
* associated data, decrypts ciphertext and returns decrypted plaintext.
*

@@ -124,3 +124,3 @@ * If authentication fails, it returns null.

*/
open(nonce: Uint8Array, sealed: Uint8Array, additionalData?: Uint8Array,
open(nonce: Uint8Array, sealed: Uint8Array, associatedData?: Uint8Array,
dst?: Uint8Array): Uint8Array | null {

@@ -156,3 +156,3 @@ if (nonce.length !== this.nonceLength) {

this._authenticate(calculatedTag, tagMask,
sealed.subarray(0, sealed.length - this.tagLength), additionalData);
sealed.subarray(0, sealed.length - this.tagLength), associatedData);

@@ -197,11 +197,11 @@ // Constant-time compare tags and return null if they differ.

private _authenticate(tagOut: Uint8Array, tagMask: Uint8Array,
ciphertext: Uint8Array, additionalData?: Uint8Array) {
ciphertext: Uint8Array, associatedData?: Uint8Array) {
const blockSize = this._cipher.blockSize;
// Authenticate additional data.
if (additionalData) {
for (let i = 0; i < additionalData.length; i += blockSize) {
const slice = additionalData.subarray(i,
Math.min(i + blockSize, additionalData.length));
// Authenticate associated data.
if (associatedData) {
for (let i = 0; i < associatedData.length; i += blockSize) {
const slice = associatedData.subarray(i,
Math.min(i + blockSize, associatedData.length));
addmul(tagOut, slice, this._subkey);

@@ -217,7 +217,7 @@ }

// Make a block of additional data and ciphertext (plaintext) bit lengths.
// Make a block of associated data and ciphertext (plaintext) bit lengths.
// XXX: can avoid allocation here?
const lengthsBlock = new Uint8Array(blockSize);
if (additionalData) {
writeBitLength(additionalData.length, lengthsBlock, 0);
if (associatedData) {
writeBitLength(associatedData.length, lengthsBlock, 0);
}

@@ -224,0 +224,0 @@ writeBitLength(ciphertext.length, lengthsBlock, 8);

{
"name": "@stablelib/gcm",
"version": "0.1.1",
"description": "GCM authenticated encryption mode with additional data (AEAD)",
"version": "0.1.2",
"description": "GCM authenticated encryption mode with associated data (AEAD)",
"main": "./dist/gcm.js",

@@ -18,11 +18,11 @@ "typings": "./dist/gcm.d.ts",

"dependencies": {
"@stablelib/aead": "^0.0.1",
"@stablelib/aead": "^0.1.2",
"@stablelib/binary": "^0.0.1",
"@stablelib/blockcipher": "^0.1.1",
"@stablelib/blockcipher": "^0.1.2",
"@stablelib/constant-time": "^0.0.2",
"@stablelib/ctr": "^0.1.1",
"@stablelib/ctr": "^0.1.2",
"@stablelib/wipe": "^0.0.1"
},
"devDependencies": {
"@stablelib/aes": "^0.1.1",
"@stablelib/aes": "^0.1.2",
"@stablelib/benchmark": "^0.0.1",

@@ -29,0 +29,0 @@ "@stablelib/hex": "^0.0.1"

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