(candidate, options = kEmptyObject)
| 618 | } |
| 619 | |
| 620 | function checkPrimeSync(candidate, options = kEmptyObject) { |
| 621 | if (typeof candidate === 'bigint') |
| 622 | candidate = unsignedBigIntToBuffer(candidate, 'candidate'); |
| 623 | if (!isAnyArrayBuffer(candidate) && !isArrayBufferView(candidate)) { |
| 624 | throw new ERR_INVALID_ARG_TYPE( |
| 625 | 'candidate', |
| 626 | [ |
| 627 | 'ArrayBuffer', |
| 628 | 'TypedArray', |
| 629 | 'Buffer', |
| 630 | 'DataView', |
| 631 | 'bigint', |
| 632 | ], |
| 633 | candidate, |
| 634 | ); |
| 635 | } |
| 636 | validateObject(options, 'options'); |
| 637 | let { |
| 638 | checks = 0, |
| 639 | } = options; |
| 640 | |
| 641 | // The checks option is unsigned but must fit into a signed C int for OpenSSL. |
| 642 | validateInt32(checks, 'options.checks', 0); |
| 643 | // Coerce -0 to +0. |
| 644 | checks += 0; |
| 645 | |
| 646 | const job = new CheckPrimeJob(kCryptoJobSync, candidate, checks); |
| 647 | const { 0: err, 1: result } = job.run(); |
| 648 | if (err) |
| 649 | throw err; |
| 650 | |
| 651 | return result; |
| 652 | } |
| 653 | |
| 654 | module.exports = { |
| 655 | checkPrime, |
no test coverage detected
searching dependent graphs…