We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9270b61 commit ead23a7Copy full SHA for ead23a7
lib/models/client.js
@@ -191,7 +191,12 @@ const clientKeyStoreAdditions = {
191
};
192
193
function deriveKey(secret, length) {
194
- const derived = crypto.createHash('sha256')
+ 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)
200
.update(secret)
201
.digest()
202
.slice(0, length);
0 commit comments