|
2 | 2 |
|
3 | 3 | const { AsyncWrap, Providers } = process.binding('async_wrap');
|
4 | 4 | const { Buffer } = require('buffer');
|
5 |
| -const { INT_MAX, scrypt: _scrypt } = process.binding('crypto'); |
6 |
| -const { validateInt32 } = require('internal/validators'); |
| 5 | +const { scrypt: _scrypt } = process.binding('crypto'); |
| 6 | +const { validateUint32 } = require('internal/validators'); |
7 | 7 | const {
|
8 | 8 | ERR_CRYPTO_SCRYPT_INVALID_PARAMETER,
|
9 | 9 | ERR_CRYPTO_SCRYPT_NOT_SUPPORTED,
|
@@ -76,31 +76,31 @@ function check(password, salt, keylen, options, callback) {
|
76 | 76 |
|
77 | 77 | password = validateArrayBufferView(password, 'password');
|
78 | 78 | salt = validateArrayBufferView(salt, 'salt');
|
79 |
| - keylen = validateInt32(keylen, 'keylen', 0, INT_MAX); |
| 79 | + keylen = validateUint32(keylen, 'keylen'); |
80 | 80 |
|
81 | 81 | let { N, r, p, maxmem } = defaults;
|
82 | 82 | if (options && options !== defaults) {
|
83 | 83 | let has_N, has_r, has_p;
|
84 | 84 | if (has_N = (options.N !== undefined))
|
85 |
| - N = validateInt32(options.N, 'N', 0, INT_MAX); |
| 85 | + N = validateUint32(options.N, 'N'); |
86 | 86 | if (options.cost !== undefined) {
|
87 | 87 | if (has_N) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER();
|
88 |
| - N = validateInt32(options.cost, 'cost', 0, INT_MAX); |
| 88 | + N = validateUint32(options.cost, 'cost'); |
89 | 89 | }
|
90 | 90 | if (has_r = (options.r !== undefined))
|
91 |
| - r = validateInt32(options.r, 'r', 0, INT_MAX); |
| 91 | + r = validateUint32(options.r, 'r'); |
92 | 92 | if (options.blockSize !== undefined) {
|
93 | 93 | if (has_r) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER();
|
94 |
| - r = validateInt32(options.blockSize, 'blockSize', 0, INT_MAX); |
| 94 | + r = validateUint32(options.blockSize, 'blockSize'); |
95 | 95 | }
|
96 | 96 | if (has_p = (options.p !== undefined))
|
97 |
| - p = validateInt32(options.p, 'p', 0, INT_MAX); |
| 97 | + p = validateUint32(options.p, 'p'); |
98 | 98 | if (options.parallelization !== undefined) {
|
99 | 99 | if (has_p) throw new ERR_CRYPTO_SCRYPT_INVALID_PARAMETER();
|
100 |
| - p = validateInt32(options.parallelization, 'parallelization', 0, INT_MAX); |
| 100 | + p = validateUint32(options.parallelization, 'parallelization'); |
101 | 101 | }
|
102 | 102 | if (options.maxmem !== undefined)
|
103 |
| - maxmem = validateInt32(options.maxmem, 'maxmem', 0, INT_MAX); |
| 103 | + maxmem = validateUint32(options.maxmem, 'maxmem'); |
104 | 104 | if (N === 0) N = defaults.N;
|
105 | 105 | if (r === 0) r = defaults.r;
|
106 | 106 | if (p === 0) p = defaults.p;
|
|
0 commit comments