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