@@ -1961,6 +1961,48 @@ is currently in use. Setting to true requires a FIPS build of Node.js.
1961
1961
This property is deprecated. Please use ` crypto.setFips() ` and
1962
1962
` crypto.getFips() ` instead.
1963
1963
1964
+ ### ` crypto.checkPrime(candidate[, options, [callback]]) `
1965
+ <!-- YAML
1966
+ added: REPLACEME
1967
+ -->
1968
+
1969
+ * ` candidate ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
1970
+ A possible prime encoded as a sequence of big endian octets of arbitrary
1971
+ length.
1972
+ * ` options ` {Object}
1973
+ * ` checks ` {number} The number of Miller-Rabin probabilistic primality
1974
+ iterations to perform. When the value is ` 0 ` (zero), a number of checks
1975
+ is used that yields a false positive rate of at most 2<sup >-64</sup > for
1976
+ random input. Care must be used when selecting a number of checks. Refer
1977
+ to the OpenSSL documentation for the [ ` BN_is_prime_ex ` ] [ ] function ` nchecks `
1978
+ options for more details. ** Defaults** : ` 0 `
1979
+ * ` callback ` {Function}
1980
+ * ` err ` {Error} Set to an {Error} object if an error occured during check.
1981
+ * ` result ` {boolean} ` true ` if the candidate is a prime with an error
1982
+ probability less than ` 0.25 ** options.checks ` .
1983
+
1984
+ Checks the primality of the ` candidate ` .
1985
+
1986
+ ### ` crypto.checkPrimeSync(candidate[, options]) `
1987
+ <!-- YAML
1988
+ added: REPLACEME
1989
+ -->
1990
+
1991
+ * ` candidate ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
1992
+ A possible prime encoded as a sequence of big endian octets of arbitrary
1993
+ length.
1994
+ * ` options ` {Object}
1995
+ * ` checks ` {number} The number of Miller-Rabin probabilistic primality
1996
+ iterations to perform. When the value is ` 0 ` (zero), a number of checks
1997
+ is used that yields a false positive rate of at most 2<sup >-64</sup > for
1998
+ random input. Care must be used when selecting a number of checks. Refer
1999
+ to the OpenSSL documentation for the [ ` BN_is_prime_ex ` ] [ ] function ` nchecks `
2000
+ options for more details. ** Defaults** : ` 0 `
2001
+ * Returns: {boolean} ` true ` if the candidate is a prime with an error
2002
+ probability less than ` 0.25 ** options.checks ` .
2003
+
2004
+ Checks the primality of the ` candidate ` .
2005
+
1964
2006
### ` crypto.createCipher(algorithm, password[, options]) `
1965
2007
<!-- YAML
1966
2008
added: v0.1.94
@@ -2694,6 +2736,78 @@ The return value `{ publicKey, privateKey }` represents the generated key pair.
2694
2736
When PEM encoding was selected, the respective key will be a string, otherwise
2695
2737
it will be a buffer containing the data encoded as DER.
2696
2738
2739
+ ### ` crypto.generatePrime(size[, options[, callback]]) `
2740
+ <!-- YAML
2741
+ added: REPLACEME
2742
+ -->
2743
+
2744
+ * ` size ` {number} The size (in bits) of the prime to generate.
2745
+ * ` options ` {Object}
2746
+ * ` add ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
2747
+ * ` rem ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
2748
+ * ` safe ` {boolean} ** Defaults** : ` false ` .
2749
+ * ` bigint ` {boolean} When ` true ` , the generated prime is returned
2750
+ as a ` bigint ` .
2751
+ * ` callback ` {Function}
2752
+ * ` err ` {Error}
2753
+ * ` prime ` {ArrayBuffer|bigint}
2754
+
2755
+ Generates a pseudo-random prime of ` size ` bits.
2756
+
2757
+ If ` options.safe ` is ` true ` , the prime will be a safe prime -- that is,
2758
+ ` (prime - 1) / 2 ` will also be a prime.
2759
+
2760
+ If ` options.add ` and ` options.rem ` are set, the prime will satisfy the
2761
+ condition that ` prime % add = rem ` . The ` options.rem ` is ignored if
2762
+ ` options.add ` is not given. If ` options.safe ` is ` true ` , ` options.add `
2763
+ is given, and ` options.rem ` is ` undefined ` , then the prime generated
2764
+ will satisfy the condition ` prime % add = 3 ` . Otherwise if ` options.safe `
2765
+ is ` false ` and ` options.rem ` is ` undefined ` , ` options.add ` will be
2766
+ ignored.
2767
+
2768
+ Both ` options.add ` and ` options.rem ` must be encoded as big-endian sequences
2769
+ if given as an ` ArrayBuffer ` , ` SharedArrayBuffer ` , ` TypedArray ` , ` Buffer ` , or
2770
+ ` DataView ` .
2771
+
2772
+ By default, the prime is encoded as a big-endian sequence of octets
2773
+ in an {ArrayBuffer}. If the ` bigint ` option is ` true ` , then a {bigint}
2774
+ is provided.
2775
+
2776
+ ### ` crypto.generatePrimeSync(size[, options]) `
2777
+ <!-- YAML
2778
+ added: REPLACEME
2779
+ -->
2780
+
2781
+ * ` size ` {number} The size (in bits) of the prime to generate.
2782
+ * ` options ` {Object}
2783
+ * ` add ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
2784
+ * ` rem ` {ArrayBuffer|SharedArrayBuffer|TypedArray|Buffer|DataView|bigint}
2785
+ * ` safe ` {boolean} ** Defaults** : ` false ` .
2786
+ * ` bigint ` {boolean} When ` true ` , the generated prime is returned
2787
+ as a ` bigint ` .
2788
+ * Returns: {ArrayBuffer|bigint}
2789
+
2790
+ Generates a pseudo-random prime of ` size ` bits.
2791
+
2792
+ If ` options.safe ` is ` true ` , the prime will be a safe prime -- that is,
2793
+ ` (prime - 1) ` / 2 will also be a prime.
2794
+
2795
+ If ` options.add ` and ` options.rem ` are set, the prime will satisfy the
2796
+ condition that ` prime % add = rem ` . The ` options.rem ` is ignored if
2797
+ ` options.add ` is not given. If ` options.safe ` is ` true ` , ` options.add `
2798
+ is given, and ` options.rem ` is ` undefined ` , then the prime generated
2799
+ will satisfy the condition ` prime % add = 3 ` . Otherwise if ` options.safe `
2800
+ is ` false ` and ` options.rem ` is ` undefined ` , ` options.add ` will be
2801
+ ignored.
2802
+
2803
+ Both ` options.add ` and ` options.rem ` must be encoded as big-endian sequences
2804
+ if given as an ` ArrayBuffer ` , ` SharedArrayBuffer ` , ` TypedArray ` , ` Buffer ` , or
2805
+ ` DataView ` .
2806
+
2807
+ By default, the prime is encoded as a big-endian sequence of octets
2808
+ in an {ArrayBuffer}. If the ` bigint ` option is ` true ` , then a {bigint}
2809
+ is provided.
2810
+
2697
2811
### ` crypto.getCiphers() `
2698
2812
<!-- YAML
2699
2813
added: v0.9.3
@@ -4234,6 +4348,7 @@ See the [list of SSL OP Flags][] for details.
4234
4348
[ RFC 4122 ] : https://www.rfc-editor.org/rfc/rfc4122.txt
4235
4349
[ RFC 5208 ] : https://www.rfc-editor.org/rfc/rfc5208.txt
4236
4350
[ Web Crypto API documentation ] : webcrypto.md
4351
+ [ `BN_is_prime_ex` ] : https://www.openssl.org/docs/man1.1.1/man3/BN_is_prime_ex.html
4237
4352
[ `Buffer` ] : buffer.md
4238
4353
[ `EVP_BytesToKey` ] : https://www.openssl.org/docs/man1.1.0/crypto/EVP_BytesToKey.html
4239
4354
[ `KeyObject` ] : #crypto_class_keyobject
0 commit comments