| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -60,11 +60,6 @@ const { | |||
| 60 | 60 | generateKey, | |
| 61 | 61 | } = require('internal/crypto/keygen'); | |
| 62 | 62 | ||
| 63 | - const { | ||
| 64 | - validateInteger, | ||
| 65 | - validateOneOf, | ||
| 66 | - } = require('internal/validators'); | ||
| 67 | - | ||
| 68 | 63 | const kMaxCounterLength = 128; | |
| 69 | 64 | const kTagLengths = [32, 64, 96, 104, 112, 120, 128]; | |
| 70 | 65 | ||
@@ -227,8 +222,11 @@ function aesCipher(mode, key, data, algorithm) { | |||
| 227 | 222 | ||
| 228 | 223 | async function aesGenerateKey(algorithm, extractable, keyUsages) { | |
| 229 | 224 | const { name, length } = algorithm; | |
| 230 | - validateInteger(length, 'algorithm.length'); | ||
| 231 | - validateOneOf(length, 'algorithm.length', kAesKeyLengths); | ||
| 225 | + if (!ArrayPrototypeIncludes(kAesKeyLengths, length)) { | ||
| 226 | + throw lazyDOMException( | ||
| 227 | + 'AES key length must be 128, 192, or 256 bits', | ||
| 228 | + 'OperationError'); | ||
| 229 | + } | ||
| 232 | 230 | ||
| 233 | 231 | const checkUsages = ['wrapKey', 'unwrapKey']; | |
| 234 | 232 | if (name !== 'AES-KW') | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -512,14 +512,14 @@ const vectors = { | |||
| 512 | 512 | [1, 100, 257].forEach(async (length) => { | |
| 513 | 513 | await assert.rejects( | |
| 514 | 514 | subtle.generateKey({ name, length }, true, usages), { | |
| 515 | - code: 'ERR_INVALID_ARG_VALUE' | ||
| 515 | + name: 'OperationError' | ||
| 516 | 516 | }); | |
| 517 | 517 | }); | |
| 518 | 518 | ||
| 519 | 519 | ['', {}, [], false, null, undefined].forEach(async (length) => { | |
| 520 | 520 | await assert.rejects( | |
| 521 | 521 | subtle.generateKey({ name, length }, true, usages), { | |
| 522 | - code: 'ERR_INVALID_ARG_TYPE' | ||
| 522 | + name: 'OperationError', | ||
| 523 | 523 | }); | |
| 524 | 524 | }); | |
| 525 | 525 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments