@@ -6133,6 +6133,68 @@ additional properties can be passed:
61336133
61346134If the ` callback ` function is provided this function uses libuv's threadpool.
61356135
6136+ ### ` crypto.signDigest(algorithm, digest, key[, callback]) `
6137+
6138+ <!-- YAML
6139+ added: REPLACEME
6140+ -->
6141+
6142+ <!-- lint disable maximum-line-length remark-lint-->
6143+
6144+ * ` algorithm ` {string | null | undefined}
6145+ * ` digest ` {ArrayBuffer|Buffer|TypedArray|DataView}
6146+ * ` key ` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject}
6147+ * ` callback ` {Function}
6148+ * ` err ` {Error}
6149+ * ` signature ` {Buffer}
6150+ * Returns: {Buffer} if the ` callback ` function is not provided.
6151+
6152+ <!-- lint enable maximum-line-length remark-lint-->
6153+
6154+ Calculates and returns the signature for ` digest ` using the given private key
6155+ and algorithm. Unlike [ ` crypto.sign() ` ] [ ] , this function does not hash the data
6156+ internally — ` digest ` is expected to be a pre-computed hash digest.
6157+
6158+ The interpretation of ` algorithm ` and ` digest ` depends on the key type:
6159+
6160+ * RSA, ECDSA, DSA: ` algorithm ` identifies the hash function used to create
6161+ ` digest ` . The resulting signatures are compatible with [ ` crypto.verify() ` ] [ ]
6162+ and signatures produced by [ ` crypto.sign() ` ] [ ] can be verified with
6163+ [ ` crypto.verifyDigest() ` ] [ ] .
6164+
6165+ * Ed25519, Ed448: ` algorithm ` must be ` null ` or ` undefined ` . These keys
6166+ use the Ed25519ph and Ed448ph prehash variants from [ RFC 8032] [ ]
6167+ respectively. ` digest ` must be the output of the appropriate prehash
6168+ function (SHA-512 for Ed25519ph, SHAKE256 with 64-byte output for
6169+ Ed448ph). The resulting signatures can only be verified with
6170+ [ ` crypto.verifyDigest() ` ] [ ] , not with [ ` crypto.verify() ` ] [ ] .
6171+
6172+ If ` key ` is not a [ ` KeyObject ` ] [ ] , this function behaves as if ` key ` had been
6173+ passed to [ ` crypto.createPrivateKey() ` ] [ ] . If it is an object, the following
6174+ additional properties can be passed:
6175+
6176+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
6177+ format of the generated signature. It can be one of the following:
6178+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
6179+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
6180+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
6181+
6182+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
6183+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
6184+
6185+ ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
6186+ used to create the digest as specified in section 3.1 of [ RFC 4055] [ ] .
6187+ * ` saltLength ` {integer} Salt length for when padding is
6188+ ` RSA_PKCS1_PSS_PADDING ` . The special value
6189+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
6190+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
6191+ maximum permissible value.
6192+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519ph and Ed448ph,
6193+ this option specifies the optional context to differentiate signatures
6194+ generated for different purposes with the same key.
6195+
6196+ If the ` callback ` function is provided this function uses libuv's threadpool.
6197+
61366198### ` crypto.subtle `
61376199
61386200<!-- YAML
@@ -6273,6 +6335,75 @@ key may be passed for `key`.
62736335
62746336If the ` callback ` function is provided this function uses libuv's threadpool.
62756337
6338+ ### ` crypto.verifyDigest(algorithm, digest, key, signature[, callback]) `
6339+
6340+ <!-- YAML
6341+ added: REPLACEME
6342+ -->
6343+
6344+ <!-- lint disable maximum-line-length remark-lint-->
6345+
6346+ * ` algorithm ` {string|null|undefined}
6347+ * ` digest ` {ArrayBuffer|Buffer|TypedArray|DataView}
6348+ * ` key ` {Object|string|ArrayBuffer|Buffer|TypedArray|DataView|KeyObject}
6349+ * ` signature ` {ArrayBuffer|Buffer|TypedArray|DataView}
6350+ * ` callback ` {Function}
6351+ * ` err ` {Error}
6352+ * ` result ` {boolean}
6353+ * Returns: {boolean} ` true ` or ` false ` depending on the validity of the
6354+ signature for the digest and public key if the ` callback ` function is not
6355+ provided.
6356+
6357+ <!-- lint enable maximum-line-length remark-lint-->
6358+
6359+ Verifies the given signature for ` digest ` using the given key and algorithm.
6360+ Unlike [ ` crypto.verify() ` ] [ ] , this function does not hash the data
6361+ internally — ` digest ` is expected to be a pre-computed hash digest.
6362+
6363+ The interpretation of ` algorithm ` and ` digest ` depends on the key type:
6364+
6365+ * RSA, ECDSA, DSA: ` algorithm ` identifies the hash function used to create
6366+ ` digest ` . Signatures produced by [ ` crypto.sign() ` ] [ ] can be verified with
6367+ this function, and signatures produced by [ ` crypto.signDigest() ` ] [ ] can be
6368+ verified with [ ` crypto.verify() ` ] [ ] .
6369+ * Ed25519, Ed448: ` algorithm ` must be ` null ` or ` undefined ` . These keys
6370+ use the Ed25519ph and Ed448ph prehash variants from [ RFC 8032] [ ]
6371+ respectively. ` digest ` must be the output of the appropriate prehash
6372+ function (SHA-512 for Ed25519ph, SHAKE256 with 64-byte output for
6373+ Ed448ph). Only signatures produced by [ ` crypto.signDigest() ` ] [ ] can be
6374+ verified with this function, not those from [ ` crypto.sign() ` ] [ ] .
6375+
6376+ If ` key ` is not a [ ` KeyObject ` ] [ ] , this function behaves as if ` key ` had been
6377+ passed to [ ` crypto.createPublicKey() ` ] [ ] . If it is an object, the following
6378+ additional properties can be passed:
6379+
6380+ * ` dsaEncoding ` {string} For DSA and ECDSA, this option specifies the
6381+ format of the signature. It can be one of the following:
6382+ * ` 'der' ` (default): DER-encoded ASN.1 signature structure encoding ` (r, s) ` .
6383+ * ` 'ieee-p1363' ` : Signature format ` r || s ` as proposed in IEEE-P1363.
6384+ * ` padding ` {integer} Optional padding value for RSA, one of the following:
6385+
6386+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
6387+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
6388+
6389+ ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
6390+ used to create the digest as specified in section 3.1 of [ RFC 4055] [ ] .
6391+ * ` saltLength ` {integer} Salt length for when padding is
6392+ ` RSA_PKCS1_PSS_PADDING ` . The special value
6393+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
6394+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
6395+ maximum permissible value.
6396+ * ` context ` {ArrayBuffer|Buffer|TypedArray|DataView} For Ed25519ph and Ed448ph,
6397+ this option specifies the optional context to differentiate signatures
6398+ generated for different purposes with the same key.
6399+
6400+ The ` signature ` argument is the previously calculated signature for the ` digest ` .
6401+
6402+ Because public keys can be derived from private keys, a private key or a public
6403+ key may be passed for ` key ` .
6404+
6405+ If the ` callback ` function is provided this function uses libuv's threadpool.
6406+
62766407### ` crypto.webcrypto `
62776408
62786409<!-- YAML
@@ -6899,7 +7030,9 @@ See the [list of SSL OP Flags][] for details.
68997030[ `crypto.randomBytes()` ] : #cryptorandombytessize-callback
69007031[ `crypto.randomFill()` ] : #cryptorandomfillbuffer-offset-size-callback
69017032[ `crypto.sign()` ] : #cryptosignalgorithm-data-key-callback
7033+ [ `crypto.signDigest()` ] : #cryptosigndigestalgorithm-digest-key-callback
69027034[ `crypto.verify()` ] : #cryptoverifyalgorithm-data-key-signature-callback
7035+ [ `crypto.verifyDigest()` ] : #cryptoverifydigestalgorithm-digest-key-signature-callback
69037036[ `crypto.webcrypto.getRandomValues()` ] : webcrypto.md#cryptogetrandomvaluestypedarray
69047037[ `crypto.webcrypto.subtle` ] : webcrypto.md#class-subtlecrypto
69057038[ `decipher.final()` ] : #decipherfinaloutputencoding
0 commit comments