Skip to content

Commit

Permalink
fix: A192CBC-HS384 and A256CBC-HS512 direct encryption key derivation
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed May 12, 2020
1 parent 9270b61 commit ead23a7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/models/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ const clientKeyStoreAdditions = {
};

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

0 comments on commit ead23a7

Please sign in to comment.