@@ -5745,6 +5745,9 @@ Throws an error if FIPS mode is not available.
57455745<!-- YAML
57465746added: v12.0.0
57475747changes:
5748+ - version: REPLACEME
5749+ pr-url: https://github.com/nodejs/node/pull/XXXXX
5750+ description: Add support for Ed25519 context parameter.
57485751 - version: v24.8.0
57495752 pr-url: https://github.com/nodejs/node/pull/59570
57505753 description: Add support for ML-DSA, Ed448, and SLH-DSA context parameter.
@@ -5808,12 +5811,68 @@ additional properties can be passed:
58085811 ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
58095812 size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
58105813 maximum permissible value.
5811- * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed448, ML-DSA, and SLH-DSA,
5814+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519, Ed448, ML-DSA, and SLH-DSA,
58125815 this option specifies the optional context to differentiate signatures generated
58135816 for different purposes with the same key.
58145817
58155818If the ` callback ` function is provided this function uses libuv's threadpool.
58165819
5820+ ### ` crypto.signDigest(algorithm, digest, key[, callback]) `
5821+
5822+ <!-- YAML
5823+ added: REPLACEME
5824+ -->
5825+
5826+ <!-- lint disable maximum-line-length remark-lint-->
5827+
5828+ * ` algorithm ` {string | null | undefined}
5829+ * ` digest ` {ArrayBuffer|Buffer|TypedArray|DataView}
5830+ * ` key ` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
5831+ * ` callback ` {Function}
5832+ * ` err ` {Error}
5833+ * ` signature ` {Buffer}
5834+ * Returns: {Buffer} if the ` callback ` function is not provided.
5835+
5836+ <!-- lint enable maximum-line-length remark-lint-->
5837+
5838+ Calculates and returns the signature for ` digest ` using the given private key
5839+ and algorithm. Unlike [ ` crypto.sign() ` ] [ ] , this function does not hash the data
5840+ internally — ` digest ` is expected to be a pre-computed hash digest.
5841+
5842+ For RSA, ECDSA, and DSA keys, ` algorithm ` identifies the hash function that was
5843+ used to create ` digest ` . For Ed25519 and Ed448 keys, ` algorithm ` must be ` null `
5844+ or ` undefined ` , and ` digest ` must be the output of the appropriate prehash
5845+ function (SHA-512 for Ed25519ph, SHAKE256 with 64-byte output for Ed448ph).
5846+
5847+ If ` key ` is not a [ ` KeyObject ` ] [ ] , this function behaves as if ` key ` had been
5848+ passed to [ ` crypto.createPrivateKey() ` ] [ ] . If it is an object, the following
5849+ additional properties can be passed:
5850+
5851+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
5852+ format of the generated signature. It can be one of the following:
5853+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
5854+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
5855+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
5856+
5857+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
5858+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
5859+
5860+ ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
5861+ used to create the digest as specified in section 3.1 of [ RFC 4055] [ ] .
5862+ * ` saltLength ` {integer} Salt length for when padding is
5863+ ` RSA_PKCS1_PSS_PADDING ` . The special value
5864+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
5865+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
5866+ maximum permissible value.
5867+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519ph and Ed448ph,
5868+ this option specifies the optional context to differentiate signatures
5869+ generated for different purposes with the same key.
5870+
5871+ This function does not support key types that require one-shot signing without
5872+ prehash variants, such as ML-DSA and SLH-DSA.
5873+
5874+ If the ` callback ` function is provided this function uses libuv's threadpool.
5875+
58175876### ` crypto.subtle `
58185877
58195878<!-- YAML
@@ -5870,6 +5929,9 @@ not introduce timing vulnerabilities.
58705929<!-- YAML
58715930added: v12.0.0
58725931changes:
5932+ - version: REPLACEME
5933+ pr-url: https://github.com/nodejs/node/pull/XXXXX
5934+ description: Add support for Ed25519 context parameter.
58735935 - version: v24.8.0
58745936 pr-url: https://github.com/nodejs/node/pull/59570
58755937 description: Add support for ML-DSA, Ed448, and SLH-DSA context parameter.
@@ -5939,7 +6001,7 @@ additional properties can be passed:
59396001 ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
59406002 size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
59416003 maximum permissible value.
5942- * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed448, ML-DSA, and SLH-DSA,
6004+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519, Ed448, ML-DSA, and SLH-DSA,
59436005 this option specifies the optional context to differentiate signatures generated
59446006 for different purposes with the same key.
59456007
@@ -5950,6 +6012,70 @@ key may be passed for `key`.
59506012
59516013If the ` callback ` function is provided this function uses libuv's threadpool.
59526014
6015+ ### ` crypto.verifyDigest(algorithm, digest, key, signature[, callback]) `
6016+
6017+ <!-- YAML
6018+ added: REPLACEME
6019+ -->
6020+
6021+ <!-- lint disable maximum-line-length remark-lint-->
6022+
6023+ * ` algorithm ` {string|null|undefined}
6024+ * ` digest ` {ArrayBuffer|Buffer|TypedArray|DataView}
6025+ * ` key ` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject|CryptoKey}
6026+ * ` signature ` {ArrayBuffer|Buffer|TypedArray|DataView}
6027+ * ` callback ` {Function}
6028+ * ` err ` {Error}
6029+ * ` result ` {boolean}
6030+ * Returns: {boolean} ` true ` or ` false ` depending on the validity of the
6031+ signature for the digest and public key if the ` callback ` function is not
6032+ provided.
6033+
6034+ <!-- lint enable maximum-line-length remark-lint-->
6035+
6036+ Verifies the given signature for ` digest ` using the given key and algorithm.
6037+ Unlike [ ` crypto.verify() ` ] [ ] , this function does not hash the data
6038+ internally — ` digest ` is expected to be a pre-computed hash digest.
6039+
6040+ For RSA, ECDSA, and DSA keys, ` algorithm ` identifies the hash function that was
6041+ used to create ` digest ` . For Ed25519 and Ed448 keys, ` algorithm ` must be ` null `
6042+ or ` undefined ` , and ` digest ` must be the output of the appropriate prehash
6043+ function (SHA-512 for Ed25519ph, SHAKE256 with 64-byte output for Ed448ph).
6044+
6045+ If ` key ` is not a [ ` KeyObject ` ] [ ] , this function behaves as if ` key ` had been
6046+ passed to [ ` crypto.createPublicKey() ` ] [ ] . If it is an object, the following
6047+ additional properties can be passed:
6048+
6049+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
6050+ format of the signature. It can be one of the following:
6051+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
6052+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
6053+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
6054+
6055+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
6056+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
6057+
6058+ ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
6059+ used to create the digest as specified in section 3.1 of [ RFC 4055] [ ] .
6060+ * ` saltLength ` {integer} Salt length for when padding is
6061+ ` RSA_PKCS1_PSS_PADDING ` . The special value
6062+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
6063+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
6064+ maximum permissible value.
6065+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519ph and Ed448ph,
6066+ this option specifies the optional context to differentiate signatures
6067+ generated for different purposes with the same key.
6068+
6069+ The ` signature ` argument is the previously calculated signature for the ` digest ` .
6070+
6071+ Because public keys can be derived from private keys, a private key or a public
6072+ key may be passed for ` key ` .
6073+
6074+ This function does not support key types that require one-shot verification
6075+ without prehash variants, such as ML-DSA and SLH-DSA.
6076+
6077+ If the ` callback ` function is provided this function uses libuv's threadpool.
6078+
59536079### ` crypto.webcrypto `
59546080
59556081<!-- YAML
@@ -6572,6 +6698,8 @@ See the [list of SSL OP Flags][] for details.
65726698[ `crypto.publicEncrypt()` ] : #cryptopublicencryptkey-buffer
65736699[ `crypto.randomBytes()` ] : #cryptorandombytessize-callback
65746700[ `crypto.randomFill()` ] : #cryptorandomfillbuffer-offset-size-callback
6701+ [ `crypto.sign()` ] : #cryptosignalgorithm-data-key-callback
6702+ [ `crypto.verify()` ] : #cryptoverifyalgorithm-data-key-signature-callback
65756703[ `crypto.webcrypto.getRandomValues()` ] : webcrypto.md#cryptogetrandomvaluestypedarray
65766704[ `crypto.webcrypto.subtle` ] : webcrypto.md#class-subtlecrypto
65776705[ `decipher.final()` ] : #decipherfinaloutputencoding
0 commit comments