Skip to content

Commit e34509e

Browse files
bnoordhuistargos
authored andcommitted
doc: public keys don't accept passphrases
Since `crypto.publicDecrypt()` and `crypto.publicEncrypt()` accept both public and private keys, make it clear that the `passphrase` option only applies to private keys. PR-URL: #16087 Ref: #16038 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Nikolai Vavilov <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Daniel Bevenius <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent f501062 commit e34509e

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

doc/api/crypto.md

+14-14
Original file line numberDiff line numberDiff line change
@@ -1658,45 +1658,45 @@ Encrypts `buffer` with `privateKey`.
16581658
`privateKey` can be an object or a string. If `privateKey` is a string, it is
16591659
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
16601660

1661-
### crypto.publicDecrypt(publicKey, buffer)
1661+
### crypto.publicDecrypt(key, buffer)
16621662
<!-- YAML
16631663
added: v1.1.0
16641664
-->
1665-
- `publicKey` {Object | string}
1666-
- `key` {string} A PEM encoded public key.
1667-
- `passphrase` {string} An optional passphrase for the public key.
1665+
- `key` {Object | string}
1666+
- `key` {string} A PEM encoded public or private key.
1667+
- `passphrase` {string} An optional passphrase for the private key.
16681668
- `padding` {crypto.constants} An optional padding value defined in
16691669
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or
16701670
`RSA_PKCS1_PADDING`.
16711671
- `buffer` {Buffer | TypedArray | DataView}
16721672
- Returns: {Buffer} A new `Buffer` with the decrypted content.
16731673

1674-
Decrypts `buffer` with `publicKey`.
1674+
Decrypts `buffer` with `key`.
16751675

1676-
`publicKey` can be an object or a string. If `publicKey` is a string, it is
1677-
treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`.
1676+
`key` can be an object or a string. If `key` is a string, it is treated as
1677+
the key with no passphrase and will use `RSA_PKCS1_PADDING`.
16781678

16791679
Because RSA public keys can be derived from private keys, a private key may
16801680
be passed instead of a public key.
16811681

1682-
### crypto.publicEncrypt(publicKey, buffer)
1682+
### crypto.publicEncrypt(key, buffer)
16831683
<!-- YAML
16841684
added: v0.11.14
16851685
-->
1686-
- `publicKey` {Object | string}
1687-
- `key` {string} A PEM encoded public key.
1688-
- `passphrase` {string} An optional passphrase for the public key.
1686+
- `key` {Object | string}
1687+
- `key` {string} A PEM encoded public or private key.
1688+
- `passphrase` {string} An optional passphrase for the private key.
16891689
- `padding` {crypto.constants} An optional padding value defined in
16901690
`crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`,
16911691
`RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`.
16921692
- `buffer` {Buffer | TypedArray | DataView}
16931693
- Returns: {Buffer} A new `Buffer` with the encrypted content.
16941694

1695-
Encrypts the content of `buffer` with `publicKey` and returns a new
1695+
Encrypts the content of `buffer` with `key` and returns a new
16961696
[`Buffer`][] with encrypted content.
16971697

1698-
`publicKey` can be an object or a string. If `publicKey` is a string, it is
1699-
treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
1698+
`key` can be an object or a string. If `key` is a string, it is treated as
1699+
the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`.
17001700

17011701
Because RSA public keys can be derived from private keys, a private key may
17021702
be passed instead of a public key.

0 commit comments

Comments
 (0)