(mode, keyType, options)
| 384 | // Symmetric Key Generation |
| 385 | |
| 386 | function generateKeyJob(mode, keyType, options) { |
| 387 | validateString(keyType, 'type'); |
| 388 | validateObject(options, 'options'); |
| 389 | const { length } = options; |
| 390 | switch (keyType) { |
| 391 | case 'hmac': |
| 392 | validateInteger(length, 'options.length', 8, 2 ** 31 - 1); |
| 393 | break; |
| 394 | case 'aes': |
| 395 | validateOneOf(length, 'options.length', [128, 192, 256]); |
| 396 | break; |
| 397 | default: |
| 398 | throw new ERR_INVALID_ARG_VALUE( |
| 399 | 'type', |
| 400 | keyType, |
| 401 | 'must be a supported key type'); |
| 402 | } |
| 403 | |
| 404 | return new SecretKeyGenJob(mode, length); |
| 405 | } |
| 406 | |
| 407 | function handleGenerateKeyError(ret) { |
| 408 | if (ret === undefined) |
no outgoing calls
no test coverage detected
searching dependent graphs…