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

node-webcrypto-ossl

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-webcrypto-ossl - npm Package Compare versions

Comparing version 1.0.14 to 1.0.15

3

lib/crypto/aes.ts

@@ -45,2 +45,3 @@ // Core

}
(algorithm as any).length = raw.byteLength * 8;
native.AesKey.import(raw, (err, key) => {

@@ -70,3 +71,3 @@ if (err) reject(err);

// set alg
jwk.alg = "A" + (key.algorithm as any).length + /-(\w+)$/.exec(key.algorithm.name) ![1];
jwk.alg = "A" + (key.algorithm as any).length + /-(\w+)$/.exec(key.algorithm.name) ![1].toUpperCase();
nkey.export((err, data) => {

@@ -73,0 +74,0 @@ if (err) reject(err);

@@ -229,3 +229,3 @@ // Core

// derive key
(baseKey.native as native.Key).EcdhDeriveKey((_algorithm.public as any).native, _derivedKeyType.length, (err, raw) => {
(baseKey.native as native.Key).EcdhDeriveKey((_algorithm.public as any).native, _derivedKeyType.length / 8, (err, raw) => {
if (err) reject(err);

@@ -232,0 +232,0 @@ else {

{
"name": "node-webcrypto-ossl",
"version": "1.0.14",
"version": "1.0.15",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

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

"use strict";
const assert = require('assert');

@@ -9,3 +10,11 @@ const webcrypto = require('./config');

var TEST_MESSAGE = new Buffer("1234567890123456");
let BIG_MESSAGE;
let i = 0;
while (i++ < 200)
BIG_MESSAGE += "0123456789";
var SMALL_MESSAGE = "1234567890123456";
let messages = [
{ name: "small", data: SMALL_MESSAGE },
{ name: "big", data: BIG_MESSAGE },
];
var KEYS = [

@@ -53,16 +62,18 @@ { alg: "AES-CBC", usages: ["encrypt", "decrypt", "wrapKey", "unwrapKey"] },

.forEach(key => {
[new Uint8Array(16), new Uint8Array(16)].forEach(iv => {
it(`iv:${iv.length}\t${key.name}`, done => {
var alg = { name: "AES-CBC", iv: iv };
webcrypto.subtle.encrypt(alg, key.key, TEST_MESSAGE)
.then(enc => {
assert(!!enc, true, "Encrypted message is empty");
return webcrypto.subtle.decrypt(alg, key.key, enc);
})
.then(dec => {
assert(new Buffer(dec).toString(), TEST_MESSAGE.toString(), "Decrypted message is wrong");
})
.then(done, done);
});
});
messages.forEach(message =>
[webcrypto.getRandomValues(new Uint8Array(16))].forEach(iv => {
it(`${message.name} message iv:${iv.length}\t${key.name}`, done => {
var alg = { name: "AES-CBC", iv: iv };
webcrypto.subtle.encrypt(alg, key.key, new Buffer(message.data))
.then(enc => {
assert(!!enc, true, "Encrypted message is empty");
return webcrypto.subtle.decrypt(alg, key.key, enc);
})
.then(dec => {
assert(new Buffer(dec).toString(), message.data, "Decrypted message is wrong");
})
.then(done, done);
});
})
)
});

@@ -75,23 +86,25 @@ });

.forEach(key => {
// IV
[new Uint8Array(16)].forEach(iv => {
// AAD
[new Uint8Array([1, 2, 3, 4, 5]), null].forEach(aad => {
// Tag
[32, 64, 96, 104, 112, 120, 128].forEach(tag => {
it(`aad:${aad ? "+" : "-"} t:${tag}\t${key.name}`, done => {
var alg = { name: "AES-GCM", iv: iv, aad: aad, tagLength: tag };
webcrypto.subtle.encrypt(alg, key.key, TEST_MESSAGE)
.then(enc => {
assert(!!enc, true, "Encrypted message is empty");
return webcrypto.subtle.decrypt(alg, key.key, enc);
})
.then(dec => {
assert(new Buffer(dec).toString(), TEST_MESSAGE.toString(), "Decrypted message is wrong");
})
.then(done, done);
messages.forEach(message =>
// IV
[new Uint8Array(16)].forEach(iv => {
// AAD
[new Uint8Array([1, 2, 3, 4, 5]), null].forEach(aad => {
// Tag
[32, 64, 96, 104, 112, 120, 128].forEach(tag => {
it(`${message.name} message aad:${aad ? "+" : "-"} t:${tag}\t${key.name}`, done => {
var alg = { name: "AES-GCM", iv: iv, aad: aad, tagLength: tag };
webcrypto.subtle.encrypt(alg, key.key, new Buffer(message.data))
.then(enc => {
assert(!!enc, true, "Encrypted message is empty");
return webcrypto.subtle.decrypt(alg, key.key, enc);
})
.then(dec => {
assert(new Buffer(dec).toString(), message.data, "Decrypted message is wrong");
})
.then(done, done);
});
});
});
});
});
})
)
});

@@ -98,0 +111,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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