(mode, type, options)
| 207 | }; |
| 208 | |
| 209 | function createJob(mode, type, options) { |
| 210 | validateString(type, 'type'); |
| 211 | |
| 212 | const encoding = new SafeArrayIterator(parseKeyEncoding(type, options)); |
| 213 | |
| 214 | if (options !== undefined) |
| 215 | validateObject(options, 'options'); |
| 216 | |
| 217 | switch (type) { |
| 218 | case 'rsa': |
| 219 | case 'rsa-pss': |
| 220 | { |
| 221 | validateObject(options, 'options'); |
| 222 | let { modulusLength } = options; |
| 223 | validateUint32(modulusLength, 'options.modulusLength'); |
| 224 | // Coerce -0 to +0. |
| 225 | modulusLength += 0; |
| 226 | |
| 227 | let { publicExponent } = options; |
| 228 | if (publicExponent == null) { |
| 229 | publicExponent = 0x10001; |
| 230 | } else { |
| 231 | validateUint32(publicExponent, 'options.publicExponent'); |
| 232 | // Coerce -0 to +0. |
| 233 | publicExponent += 0; |
| 234 | } |
| 235 | |
| 236 | if (type === 'rsa') { |
| 237 | return new RsaKeyPairGenJob( |
| 238 | mode, |
| 239 | kKeyVariantRSA_SSA_PKCS1_v1_5, // Used also for RSA-OAEP |
| 240 | modulusLength, |
| 241 | publicExponent, |
| 242 | ...encoding); |
| 243 | } |
| 244 | |
| 245 | const { hashAlgorithm, mgf1HashAlgorithm } = options; |
| 246 | let { saltLength } = options; |
| 247 | |
| 248 | if (saltLength !== undefined) { |
| 249 | validateInt32(saltLength, 'options.saltLength', 0); |
| 250 | // Coerce -0 to +0. |
| 251 | saltLength += 0; |
| 252 | } |
| 253 | if (hashAlgorithm !== undefined) |
| 254 | validateString(hashAlgorithm, 'options.hashAlgorithm'); |
| 255 | if (mgf1HashAlgorithm !== undefined) |
| 256 | validateString(mgf1HashAlgorithm, 'options.mgf1HashAlgorithm'); |
| 257 | if (options.hash !== undefined) { |
| 258 | // This API previously accepted a `hash` option that was deprecated |
| 259 | // and removed. However, in order to make the change more visible, we |
| 260 | // opted to throw an error if hash is specified rather than removing it |
| 261 | // entirely. |
| 262 | throw new ERR_INVALID_ARG_VALUE( |
| 263 | 'options.hash', |
| 264 | options.hash, |
| 265 | 'is no longer supported', |
| 266 | ); |
no test coverage detected
searching dependent graphs…