1 | var MAX_ALLOC = Math.pow(2, 30) - 1 // default in iojs
|
2 |
|
3 | module.exports = function (iterations, keylen) {
|
4 | if (typeof iterations !== 'number') {
|
5 | throw new TypeError('Iterations not a number')
|
6 | }
|
7 |
|
8 | if (iterations < 0) {
|
9 | throw new TypeError('Bad iterations')
|
10 | }
|
11 |
|
12 | if (typeof keylen !== 'number') {
|
13 | throw new TypeError('Key length not a number')
|
14 | }
|
15 |
|
16 | if (keylen < 0 || keylen > MAX_ALLOC || keylen !== keylen) { /* eslint no-self-compare: 0 */
|
17 | throw new TypeError('Bad key length')
|
18 | }
|
19 | }
|