d8810255b89ec0cf875662a181457b3f5b65c9a880bd8c5263d37ab32686431e690d6b88d5593857ce04f0f268d28e81661e9a8f3592a81a127b4553e90cc9 512 B

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