Issues (615)

lib/keyderivation.js (1 issue)

Labels
Severity
1
var assert = require('assert'),
2
    pbkdf2Sha512 = require('./pbkdf2_sha512');
3
4
var KeyDerivation = {
5
    defaultIterations: 35000,
6
    subkeyIterations: 1,
7
    keySizeBits: 256
8
};
9
10
KeyDerivation.compute = function(pw, salt, iterations) {
11
    iterations = iterations || this.defaultIterations;
12
    assert(pw instanceof Buffer, 'Password must be provided as a Buffer');
0 ignored issues
show
The variable Buffer seems to be never declared. If this is a global, consider adding a /** global: Buffer */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
13
    assert(salt instanceof Buffer, 'Salt must be provided as a Buffer');
14
    assert(salt.length > 0, 'Salt must not be empty');
15
    assert(typeof iterations === 'number', 'Iterations must be a number');
16
    assert(iterations > 0, 'Iteration count should be at least 1');
17
18
    if (salt.length > 0x80) {
19
        throw new Error('Sanity check: Invalid salt, length can never be greater than 128');
20
    }
21
22
    return pbkdf2Sha512.digest(pw, salt, iterations, this.keySizeBits / 8);
23
};
24
25
module.exports = KeyDerivation;
26