@@ -964,6 +964,10 @@ console.log(sign.sign(privateKey).toString('hex'));
964
964
### sign.sign(private_key[ , output_format] )
965
965
<!-- YAML
966
966
added: v0.1.92
967
+ changes:
968
+ - version: REPLACEME
969
+ pr-url: https://github.com/nodejs/node/pull/11705
970
+ description: Support for RSASSA-PSS and additional options was added.
967
971
-->
968
972
- ` private_key ` {string | Object}
969
973
- ` key ` {string}
@@ -975,10 +979,21 @@ Calculates the signature on all the data passed through using either
975
979
976
980
The ` private_key ` argument can be an object or a string. If ` private_key ` is a
977
981
string, it is treated as a raw key with no passphrase. If ` private_key ` is an
978
- object, it is interpreted as a hash containing two properties:
982
+ object, it must contain one or more of the following properties:
979
983
980
- * ` key ` : {string} - PEM encoded private key
984
+ * ` key ` : {string} - PEM encoded private key (required)
981
985
* ` passphrase ` : {string} - passphrase for the private key
986
+ * ` padding ` : {integer} - Optional padding value for RSA, one of the following:
987
+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
988
+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
989
+
990
+ Note that ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
991
+ used to sign the message as specified in section 3.1 of [ RFC 4055] [ ] .
992
+ * ` saltLength ` : {integer} - salt length for when padding is
993
+ ` RSA_PKCS1_PSS_PADDING ` . The special value
994
+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
995
+ size, ` crypto.constants.RSA_PSS_SALTLEN_MAX_SIGN ` (default) sets it to the
996
+ maximum permissible value.
982
997
983
998
The ` output_format ` can specify one of ` 'latin1' ` , ` 'hex' ` or ` 'base64' ` . If
984
999
` output_format ` is provided a string is returned; otherwise a [ ` Buffer ` ] [ ] is
@@ -1073,14 +1088,33 @@ This can be called many times with new data as it is streamed.
1073
1088
### verifier.verify(object, signature[ , signature_format] )
1074
1089
<!-- YAML
1075
1090
added: v0.1.92
1091
+ changes:
1092
+ - version: REPLACEME
1093
+ pr-url: https://github.com/nodejs/node/pull/11705
1094
+ description: Support for RSASSA-PSS and additional options was added.
1076
1095
-->
1077
- - ` object ` {string}
1096
+ - ` object ` {string | Object }
1078
1097
- ` signature ` {string | Buffer | Uint8Array}
1079
1098
- ` signature_format ` {string}
1080
1099
1081
1100
Verifies the provided data using the given ` object ` and ` signature ` .
1082
- The ` object ` argument is a string containing a PEM encoded object, which can be
1083
- an RSA public key, a DSA public key, or an X.509 certificate.
1101
+ The ` object ` argument can be either a string containing a PEM encoded object,
1102
+ which can be an RSA public key, a DSA public key, or an X.509 certificate,
1103
+ or an object with one or more of the following properties:
1104
+
1105
+ * ` key ` : {string} - PEM encoded private key (required)
1106
+ * ` padding ` : {integer} - Optional padding value for RSA, one of the following:
1107
+ * ` crypto.constants.RSA_PKCS1_PADDING ` (default)
1108
+ * ` crypto.constants.RSA_PKCS1_PSS_PADDING `
1109
+
1110
+ Note that ` RSA_PKCS1_PSS_PADDING ` will use MGF1 with the same hash function
1111
+ used to verify the message as specified in section 3.1 of [ RFC 4055] [ ] .
1112
+ * ` saltLength ` : {integer} - salt length for when padding is
1113
+ ` RSA_PKCS1_PSS_PADDING ` . The special value
1114
+ ` crypto.constants.RSA_PSS_SALTLEN_DIGEST ` sets the salt length to the digest
1115
+ size, ` crypto.constants.RSA_PSS_SALTLEN_AUTO ` (default) causes it to be
1116
+ determined automatically.
1117
+
1084
1118
The ` signature ` argument is the previously calculated signature for the data, in
1085
1119
the ` signature_format ` which can be ` 'latin1' ` , ` 'hex' ` or ` 'base64' ` .
1086
1120
If a ` signature_format ` is specified, the ` signature ` is expected to be a
@@ -2047,6 +2081,21 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
2047
2081
<td><code>RSA_PKCS1_PSS_PADDING</code></td>
2048
2082
<td></td>
2049
2083
</tr >
2084
+ <tr >
2085
+ <td><code>RSA_PSS_SALTLEN_DIGEST</code></td>
2086
+ <td>Sets the salt length for `RSA_PKCS1_PSS_PADDING` to the digest size
2087
+ when signing or verifying.</td>
2088
+ </tr >
2089
+ <tr >
2090
+ <td><code>RSA_PSS_SALTLEN_MAX_SIGN</code></td>
2091
+ <td>Sets the salt length for `RSA_PKCS1_PSS_PADDING` to the maximum
2092
+ permissible value when signing data.</td>
2093
+ </tr >
2094
+ <tr >
2095
+ <td><code>RSA_PSS_SALTLEN_AUTO</code></td>
2096
+ <td>Causes the salt length for `RSA_PKCS1_PSS_PADDING` to be determined
2097
+ automatically when verifying a signature.</td>
2098
+ </tr >
2050
2099
<tr >
2051
2100
<td><code>POINT_CONVERSION_COMPRESSED</code></td>
2052
2101
<td></td>
@@ -2122,6 +2171,7 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL.
2122
2171
[ publicly trusted list of CAs ] : https://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt
2123
2172
[ RFC 2412 ] : https://www.rfc-editor.org/rfc/rfc2412.txt
2124
2173
[ RFC 3526 ] : https://www.rfc-editor.org/rfc/rfc3526.txt
2174
+ [ RFC 4055 ] : https://www.rfc-editor.org/rfc/rfc4055.txt
2125
2175
[ stream ] : stream.html
2126
2176
[ stream-writable-write ] : stream.html#stream_writable_write_chunk_encoding_callback
2127
2177
[ Crypto Constants ] : #crypto_crypto_constants_1
0 commit comments