| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent d746207 commit 19c060f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3624,7 +3624,7 @@ changes: | |||
| 3624 | 3624 | * `options`: {Object} | |
| 3625 | 3625 | * `length`: {number} The bit length of the key to generate. This must be a | |
| 3626 | 3626 | value greater than 0. | |
| 3627 | - * If `type` is `'hmac'`, the minimum is 1, and the maximum length is | ||
| 3627 | + * If `type` is `'hmac'`, the minimum is 8, and the maximum length is | ||
| 3628 | 3628 | 2<sup>31</sup>-1. If the value is not a multiple of 8, the generated | |
| 3629 | 3629 | key will be truncated to `Math.floor(length / 8)`. | |
| 3630 | 3630 | * If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`. | |
@@ -3896,7 +3896,7 @@ added: v15.0.0 | |||
| 3896 | 3896 | accepted values are `'hmac'` and `'aes'`. | |
| 3897 | 3897 | * `options`: {Object} | |
| 3898 | 3898 | * `length`: {number} The bit length of the key to generate. | |
| 3899 | - * If `type` is `'hmac'`, the minimum is 1, and the maximum length is | ||
| 3899 | + * If `type` is `'hmac'`, the minimum is 8, and the maximum length is | ||
| 3900 | 3900 | 2<sup>31</sup>-1. If the value is not a multiple of 8, the generated | |
| 3901 | 3901 | key will be truncated to `Math.floor(length / 8)`. | |
| 3902 | 3902 | * If `type` is `'aes'`, the length must be one of `128`, `192`, or `256`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -349,7 +349,7 @@ function generateKeyJob(mode, keyType, options) { | |||
| 349 | 349 | const { length } = options; | |
| 350 | 350 | switch (keyType) { | |
| 351 | 351 | case 'hmac': | |
| 352 | - validateInteger(length, 'options.length', 1, 2 ** 31 - 1); | ||
| 352 | + validateInteger(length, 'options.length', 8, 2 ** 31 - 1); | ||
| 353 | 353 | break; | |
| 354 | 354 | case 'aes': | |
| 355 | 355 | validateOneOf(length, 'options.length', kAesKeyLengths); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,6 +51,14 @@ assert.throws(() => generateKey('hmac', { length: -1 }, common.mustNotCall()), { | |||
| 51 | 51 | code: 'ERR_OUT_OF_RANGE' | |
| 52 | 52 | }); | |
| 53 | 53 | ||
| 54 | + assert.throws(() => generateKey('hmac', { length: 4 }, common.mustNotCall()), { | ||
| 55 | + code: 'ERR_OUT_OF_RANGE' | ||
| 56 | + }); | ||
| 57 | + | ||
| 58 | + assert.throws(() => generateKey('hmac', { length: 7 }, common.mustNotCall()), { | ||
| 59 | + code: 'ERR_OUT_OF_RANGE' | ||
| 60 | + }); | ||
| 61 | + | ||
| 54 | 62 | assert.throws( | |
| 55 | 63 | () => generateKey('hmac', { length: 2 ** 31 }, common.mustNotCall()), { | |
| 56 | 64 | code: 'ERR_OUT_OF_RANGE' | |
@@ -60,6 +68,14 @@ assert.throws(() => generateKeySync('hmac', { length: -1 }), { | |||
| 60 | 68 | code: 'ERR_OUT_OF_RANGE' | |
| 61 | 69 | }); | |
| 62 | 70 | ||
| 71 | + assert.throws(() => generateKeySync('hmac', { length: 4 }), { | ||
| 72 | + code: 'ERR_OUT_OF_RANGE' | ||
| 73 | + }); | ||
| 74 | + | ||
| 75 | + assert.throws(() => generateKeySync('hmac', { length: 7 }), { | ||
| 76 | + code: 'ERR_OUT_OF_RANGE' | ||
| 77 | + }); | ||
| 78 | + | ||
| 63 | 79 | assert.throws( | |
| 64 | 80 | () => generateKeySync('hmac', { length: 2 ** 31 }), { | |
| 65 | 81 | code: 'ERR_OUT_OF_RANGE' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments