| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c47c79e commit 989fd73
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | 3 | const { AsyncWrap, Providers } = process.binding('async_wrap'); | |
| 4 | 4 | const { Buffer } = require('buffer'); | |
| 5 | - const { INT_MAX, pbkdf2: _pbkdf2 } = process.binding('crypto'); | ||
| 6 | - const { validateInt32 } = require('internal/validators'); | ||
| 5 | + const { pbkdf2: _pbkdf2 } = process.binding('crypto'); | ||
| 6 | + const { validateUint32 } = require('internal/validators'); | ||
| 7 | 7 | const { | |
| 8 | 8 | ERR_CRYPTO_INVALID_DIGEST, | |
| 9 | 9 | ERR_CRYPTO_PBKDF2_ERROR, | |
@@ -59,8 +59,8 @@ function check(password, salt, iterations, keylen, digest, callback) { | |||
| 59 | 59 | ||
| 60 | 60 | password = validateArrayBufferView(password, 'password'); | |
| 61 | 61 | salt = validateArrayBufferView(salt, 'salt'); | |
| 62 | - iterations = validateInt32(iterations, 'iterations', 0, INT_MAX); | ||
| 63 | - keylen = validateInt32(keylen, 'keylen', 0, INT_MAX); | ||
| 62 | + iterations = validateUint32(iterations, 'iterations', 0); | ||
| 63 | + keylen = validateUint32(keylen, 'keylen', 0); | ||
| 64 | 64 | ||
| 65 | 65 | return { password, salt, iterations, keylen, digest }; | |
| 66 | 66 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,8 +2,8 @@ | |||
| 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; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,8 +6,6 @@ if (!common.hasCrypto) | |||
| 6 | 6 | const assert = require('assert'); | |
| 7 | 7 | const crypto = require('crypto'); | |
| 8 | 8 | ||
| 9 | - const { INT_MAX } = process.binding('constants').crypto; | ||
| 10 | - | ||
| 11 | 9 | // | |
| 12 | 10 | // Test PBKDF2 with RFC 6070 test vectors (except #4) | |
| 13 | 11 | // | |
@@ -71,7 +69,7 @@ assert.throws( | |||
| 71 | 69 | code: 'ERR_OUT_OF_RANGE', | |
| 72 | 70 | name: 'RangeError [ERR_OUT_OF_RANGE]', | |
| 73 | 71 | message: 'The value of "iterations" is out of range. ' + | |
| 74 | - 'It must be >= 0 && <= 2147483647. Received -1' | ||
| 72 | + 'It must be >= 0 && < 4294967296. Received -1' | ||
| 75 | 73 | } | |
| 76 | 74 | ); | |
| 77 | 75 | ||
@@ -100,7 +98,7 @@ assert.throws( | |||
| 100 | 98 | }); | |
| 101 | 99 | }); | |
| 102 | 100 | ||
| 103 | - [-1, 4073741824, INT_MAX + 1].forEach((input) => { | ||
| 101 | + [-1, 4294967297].forEach((input) => { | ||
| 104 | 102 | assert.throws( | |
| 105 | 103 | () => { | |
| 106 | 104 | crypto.pbkdf2('password', 'salt', 1, input, 'sha256', | |
@@ -109,7 +107,7 @@ assert.throws( | |||
| 109 | 107 | code: 'ERR_OUT_OF_RANGE', | |
| 110 | 108 | name: 'RangeError [ERR_OUT_OF_RANGE]', | |
| 111 | 109 | message: 'The value of "keylen" is out of range. It ' + | |
| 112 | - `must be >= 0 && <= 2147483647. Received ${input}` | ||
| 110 | + `must be >= 0 && < 4294967296. Received ${input}` | ||
| 113 | 111 | }); | |
| 114 | 112 | }); | |
| 115 | 113 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments