From ae2d1f0e05449221ee770a393e5c967b359d9b1b Mon Sep 17 00:00:00 2001 From: Tobias Nießen Date: Tue, 25 Dec 2018 13:13:52 +0100 Subject: crypto: always accept private keys as public keys Some APIs already accept private keys instead of public keys. This changes all relevant crypto APIs to do so. PR-URL: https://github.com/nodejs/node/pull/25217 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Sam Roberts --- doc/api/crypto.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'doc/api/crypto.md') diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 95b1e9114a..2605393878 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1379,6 +1379,9 @@ This can be called many times with new data as it is streamed. * `key` {Object | string | Buffer} - `key`: {string | Buffer} @@ -1843,6 +1853,12 @@ must be an object with the properties described above. If the format is `'pem'`, the `'key'` may also be an X.509 certificate. +Because public keys can be derived from private keys, a private key may be +passed instead of a public key. In that case, this function behaves as if +[`crypto.createPrivateKey()`][] had been called, except that the type of the +returned `KeyObject` will be `public` and that the private key cannot be +extracted from the returned `KeyObject`. + ### crypto.createSecretKey(key)