node-webcrypto-ossl
Advanced tools
Comparing version 1.0.21 to 1.0.23
@@ -0,0 +0,0 @@ /// <reference types="node" /> |
@@ -68,3 +68,3 @@ // Core | ||
// set alg | ||
jwk.alg = "A" + (key.algorithm as any).length + /-(\w+)$/.exec(key.algorithm.name) ![1].toUpperCase(); | ||
jwk.alg = "A" + (key.algorithm as any).length + /-(\w+)$/.exec(key.algorithm.name)![1].toUpperCase(); | ||
nativeKey.export((err, data) => { | ||
@@ -112,6 +112,6 @@ if (err) { | ||
const nativeKey = key.native as native.AesKey; | ||
const iv = new Buffer(algorithm.iv as Uint8Array); | ||
switch (algorithm.name.toLowerCase()) { | ||
case AlgorithmNames.AesGCM.toLowerCase(): | ||
case AlgorithmNames.AesGCM.toLowerCase(): { | ||
const algGCM = algorithm as AesGcmParams; | ||
const iv = new Buffer(algorithm.iv as Uint8Array); | ||
const aad = algGCM.additionalData ? new Buffer(algGCM.additionalData as Uint8Array) : new Buffer(0); | ||
@@ -137,4 +137,6 @@ const tagLength = algGCM.tagLength || 128; | ||
break; | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
} | ||
case AlgorithmNames.AesCBC.toLowerCase(): { | ||
const algCBC = "CBC"; | ||
const iv = new Buffer(algorithm.iv as Uint8Array); | ||
if (type) { | ||
@@ -158,2 +160,23 @@ nativeKey.encrypt(algCBC, iv, data, (err, data2) => { | ||
break; | ||
} | ||
case AlgorithmNames.AesECB.toLowerCase(): { | ||
if (type) { | ||
nativeKey.encryptEcb(data, (err, data2) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data2.buffer); | ||
} | ||
}); | ||
} else { | ||
nativeKey.decryptEcb(data, (err, data2) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data2.buffer); | ||
} | ||
}); | ||
} | ||
break; | ||
} | ||
default: throw new AlgorithmError(AlgorithmError.NOT_SUPPORTED, algorithm.name); | ||
@@ -160,0 +183,0 @@ } |
@@ -0,0 +0,0 @@ // Core |
@@ -0,0 +0,0 @@ // Core |
@@ -0,0 +0,0 @@ // Core |
@@ -0,0 +0,0 @@ // Core |
@@ -0,0 +0,0 @@ // Core |
@@ -192,4 +192,6 @@ const native = require("../build/Release/nodessl.node"); | ||
public encryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void; | ||
public encryptEcb(input: Buffer, callback: (err: Error, data: Buffer) => void): void; | ||
public decrypt(cipher: string, iv: Buffer, input: Buffer, callback: (err: Error, data: Buffer) => void): void; | ||
public decryptGcm(iv: Buffer, input: Buffer, aad: Buffer | undefined, tag: number, callback: (err: Error, data: Buffer) => void): void; | ||
public decryptEcb(input: Buffer, callback: (err: Error, data: Buffer) => void): void; | ||
public export(callback: (err: Error, raw: Buffer) => void): void; | ||
@@ -196,0 +198,0 @@ public wrapKey(data: Buffer, callback: (err: Error, data: Buffer) => void): void; |
@@ -102,2 +102,3 @@ // Core | ||
break; | ||
case AlgorithmNames.AesECB.toLowerCase(): | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
@@ -191,2 +192,3 @@ case AlgorithmNames.AesGCM.toLowerCase(): | ||
break; | ||
case AlgorithmNames.AesECB.toLowerCase(): | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
@@ -216,2 +218,3 @@ case AlgorithmNames.AesGCM.toLowerCase(): | ||
break; | ||
case AlgorithmNames.AesECB.toLowerCase(): | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
@@ -346,2 +349,3 @@ case AlgorithmNames.AesGCM.toLowerCase(): | ||
break; | ||
case AlgorithmNames.AesECB.toLowerCase(): | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
@@ -390,2 +394,3 @@ case AlgorithmNames.AesGCM.toLowerCase(): | ||
break; | ||
case AlgorithmNames.AesECB.toLowerCase(): | ||
case AlgorithmNames.AesCBC.toLowerCase(): | ||
@@ -392,0 +397,0 @@ case AlgorithmNames.AesGCM.toLowerCase(): |
type NodeBufferSource = BufferSource | Buffer; |
{ | ||
"name": "node-webcrypto-ossl", | ||
"version": "1.0.21", | ||
"version": "1.0.23", | ||
"repository": { | ||
@@ -51,3 +51,3 @@ "type": "git", | ||
"typescript": "^2", | ||
"webcrypto-core": "^0" | ||
"webcrypto-core": "^0.1.15" | ||
}, | ||
@@ -54,0 +54,0 @@ "devDependencies": { |
@@ -70,2 +70,3 @@ # node-webcrypto-ossl | ||
| AES-CBC | X | | X | | X | X | | | ||
| AES-ECB <sub>2</sub> | X | | X | | X | X | | | ||
| AES-GCM | X | | X | | X | X | | | ||
@@ -78,2 +79,4 @@ | AES-KW | X | | X | | | X | | | ||
<sub>2 ECB support is not defined by the WebCrypto specifications. Use of EBC in a safe way is hard, it was added for the purpose of enabling interoperability with an existing system. We recommend against its use unless needed for interoperability.</sub> | ||
## Using | ||
@@ -80,0 +83,0 @@ |
@@ -20,2 +20,3 @@ "use strict"; | ||
var KEYS = [ | ||
{ alg: "AES-ECB", usages: ["encrypt", "decrypt", "wrapKey", "unwrapKey"] }, | ||
{ alg: "AES-CBC", usages: ["encrypt", "decrypt", "wrapKey", "unwrapKey"] }, | ||
@@ -58,2 +59,24 @@ { alg: "AES-GCM", usages: ["encrypt", "decrypt", "wrapKey", "unwrapKey"] }, | ||
context("AES-ECB", () => { | ||
// Filter ECB | ||
keys.filter(key => /AES-ECB/.test(key.name)) | ||
.forEach(key => { | ||
messages.forEach(message => { | ||
it(`${message.name} message\t${key.name}`, done => { | ||
var alg = { name: "AES-ECB" }; | ||
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); | ||
}); | ||
}) | ||
}); | ||
}); | ||
context("AES-CBC", () => { | ||
@@ -164,2 +187,23 @@ | ||
}); | ||
context("AES-ECB", () => { | ||
// AES keys | ||
keys.filter(key => /AES-ECB/.test(key.name)).forEach(key => { | ||
["jwk", "raw"].forEach(format => { | ||
it(`format:${format} ${key.name}`, done => { | ||
var _alg = { name: "AES-ECB" }; | ||
webcrypto.subtle.wrapKey(format, key.key, key.key, _alg) | ||
.then(wrappedKey => { | ||
assert.equal(!!wrappedKey, true, "Wrapped key is empty"); | ||
return webcrypto.subtle.unwrapKey(format, wrappedKey, key.key, _alg, key.key.algorithm, true, ["encrypt", "decrypt"]); | ||
}) | ||
.then(key => { | ||
assert.equal(!!key, true, "Unwrapped key is empty"); | ||
}) | ||
.then(done, done); | ||
}) | ||
}); | ||
}); | ||
}); | ||
context("AES-GCM", () => { | ||
@@ -166,0 +210,0 @@ // AES keys |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict" |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,0 @@ "use strict"; |
@@ -0,0 +0,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
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
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
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
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
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
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
367022
108
4141
162
Updatedwebcrypto-core@^0.1.15