@@ -2551,8 +2551,8 @@ added:
2551
2551
* Returns: {Buffer}
2552
2552
2553
2553
Computes the Diffie-Hellman secret based on a ` privateKey ` and a ` publicKey ` .
2554
- Both keys must have the same ` asymmetricKeyType ` , which must be one of ` 'dh' `
2555
- (for Diffie-Hellman), ` 'ec' ` (for ECDH) , ` 'x448' ` , or ` 'x25519' ` (for ECDH-ES) .
2554
+ Both keys must have the same ` asymmetricKeyType ` , which must be one of ` 'dh' ` ,
2555
+ ` 'ec' ` , ` 'x448' ` , or ` 'x25519' ` .
2556
2556
2557
2557
### ` crypto.generateKey(type, options, callback) `
2558
2558
<!-- YAML
@@ -3895,6 +3895,130 @@ Type: {Crypto} An implementation of the Web Crypto API standard.
3895
3895
3896
3896
See the [ Web Crypto API documentation] [ ] for details.
3897
3897
3898
+ ## ` crypto ` Promises API
3899
+ <!-- YAML
3900
+ added: REPLACEME
3901
+ -->
3902
+
3903
+ > Stability: 1 - Experimental
3904
+
3905
+ The ` crypto.promises ` API provides an alternative set of asynchronous crypto
3906
+ methods that return ` Promise ` objects and execute operations in libuv's
3907
+ threadpool.
3908
+ The API is accessible via ` require('crypto').promises ` or ` require('crypto/promises') ` .
3909
+
3910
+ ### ` cryptoPromises.diffieHellman(options) `
3911
+ <!-- YAML
3912
+ added: REPLACEME
3913
+ -->
3914
+
3915
+ * ` options ` : {Object}
3916
+ * ` privateKey ` : {KeyObject|CryptoKey}
3917
+ * ` publicKey ` : {KeyObject|CryptoKey}
3918
+ * Returns: {Promise} containing {Buffer}
3919
+
3920
+ Computes the Diffie-Hellman secret based on a ` privateKey ` and a ` publicKey ` .
3921
+ Both keys must have the same ` asymmetricKeyType ` , which must be one of ` 'dh' ` ,
3922
+ ` 'ec' ` , ` 'x448' ` , or ` 'x25519' ` .
3923
+
3924
+ ### ` cryptoPromises.digest(algorithm, data[, options]) `
3925
+ <!-- YAML
3926
+ added: REPLACEME
3927
+ -->
3928
+
3929
+ * ` algorithm ` {string}
3930
+ * ` data ` {ArrayBuffer|TypedArray|DataView|Buffer}
3931
+ * ` options ` {Object}
3932
+ * ` outputLength ` {number} Used to specify the desired output length in bytes
3933
+ for XOF hash functions such as ` 'shake256' ` .
3934
+ * Returns: {Promise} containing {Buffer}
3935
+
3936
+ Calculates the digest for the ` data ` using the given ` algorithm ` .
3937
+
3938
+ The ` algorithm ` is dependent on the available algorithms supported by the
3939
+ version of OpenSSL on the platform. Examples are ` 'sha256' ` , ` 'sha512' ` , etc.
3940
+ On recent releases of OpenSSL, ` openssl list -digest-algorithms `
3941
+ (` openssl list-message-digest-algorithms ` for older versions of OpenSSL) will
3942
+ display the available digest algorithms.
3943
+
3944
+ ### ` cryptoPromises.hmac(algorithm, data, key) `
3945
+ <!-- YAML
3946
+ added: REPLACEME
3947
+ -->
3948
+
3949
+ * ` algorithm ` {string}
3950
+ * ` data ` {ArrayBuffer|TypedArray|DataView|Buffer}
3951
+ * ` key ` {KeyObject|CryptoKey}
3952
+ * Returns: {Promise} containing {Buffer}
3953
+
3954
+ Calculates the HMAC digest for the ` data ` using the given ` algorithm ` .
3955
+
3956
+ The ` algorithm ` is dependent on the available algorithms supported by the
3957
+ version of OpenSSL on the platform. Examples are ` 'sha256' ` , ` 'sha512' ` , etc.
3958
+ On recent releases of OpenSSL, ` openssl list -digest-algorithms `
3959
+ (` openssl list-message-digest-algorithms ` for older versions of OpenSSL) will
3960
+ display the available digest algorithms.
3961
+
3962
+ ### ` cryptoPromises.sign(algorithm, data, key[, options]) `
3963
+ <!-- YAML
3964
+ added: REPLACEME
3965
+ -->
3966
+
3967
+ * ` algorithm ` {string|null|undefined}
3968
+ * ` data ` {ArrayBuffer|TypedArray|DataView|Buffer}
3969
+ * ` key ` {KeyObject|CryptoKey}
3970
+ * ` options ` {Object}
3971
+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
3972
+ format of the generated signature. It can be one of the following:
3973
+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
3974
+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
3975
+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
3976
+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
3977
+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
3978
+ * ` saltLength ` {integer} Salt length for when padding is
3979
+ ` RSA_PKCS1_PSS_PADDING ` . The special value
3980
+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
3981
+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
3982
+ maximum permissible value.
3983
+ * Returns: {Promise} containing {Buffer}
3984
+
3985
+ Calculates the signature for ` data ` using the given private key and
3986
+ algorithm. If ` algorithm ` is ` null ` or ` undefined ` , then the algorithm is
3987
+ dependent upon the key type (especially Ed25519 and Ed448).
3988
+
3989
+ ### ` cryptoPromises.verify(algorithm, data, key, signature[, options]) `
3990
+ <!-- YAML
3991
+ added: REPLACEME
3992
+ -->
3993
+
3994
+ * ` algorithm ` {string|null|undefined}
3995
+ * ` data ` {ArrayBuffer|TypedArray|DataView|Buffer}
3996
+ * ` key ` {KeyObject|CryptoKey}
3997
+ * ` signature ` {ArrayBuffer|TypedArray|DataView|Buffer}
3998
+ * ` options ` {Object}
3999
+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
4000
+ format of the generated signature. It can be one of the following:
4001
+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
4002
+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
4003
+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
4004
+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
4005
+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
4006
+ * ` saltLength ` {integer} Salt length for when padding is
4007
+ ` RSA_PKCS1_PSS_PADDING ` . The special value
4008
+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
4009
+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
4010
+ maximum permissible value.
4011
+ * Returns: {Promise} containing {boolean}
4012
+
4013
+ Verifies the given signature for ` data ` using the given key and algorithm. If
4014
+ ` algorithm ` is ` null ` or ` undefined ` , then the algorithm is dependent upon the
4015
+ key type (especially Ed25519 and Ed448).
4016
+
4017
+ The ` signature ` argument is the previously calculated signature for the ` data ` .
4018
+
4019
+ Because public keys can be derived from private keys, a private key or a public
4020
+ key may be passed for ` key ` .
4021
+
3898
4022
## Notes
3899
4023
3900
4024
### Legacy streams API (prior to Node.js 0.10)
0 commit comments