Skip to content

Commit ead23a7

Browse files
committed
fix: A192CBC-HS384 and A256CBC-HS512 direct encryption key derivation
1 parent 9270b61 commit ead23a7

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/models/client.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,12 @@ const clientKeyStoreAdditions = {
191191
};
192192

193193
function deriveKey(secret, length) {
194-
const derived = crypto.createHash('sha256')
194+
const digest = length <= 32 ? 'sha256' : length <= 48 ? 'sha384' : length <= 64 ? 'sha512' : false; // eslint-disable-line no-nested-ternary
195+
/* istanbul ignore if */
196+
if (!digest) {
197+
throw new Error('unsupported symmetric encryption key derivation');
198+
}
199+
const derived = crypto.createHash(digest)
195200
.update(secret)
196201
.digest()
197202
.slice(0, length);

0 commit comments

Comments
 (0)