diff options
author | Tobias Nießen <tniessen@tnie.de> | 2018-12-25 13:13:52 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-01-08 00:20:09 +0100 |
commit | ae2d1f0e05449221ee770a393e5c967b359d9b1b (patch) | |
tree | 5d43c4d7b0509e47ca51ad7e6cfb4d3192c29f61 /doc/api/crypto.md | |
parent | 27a03b84c42a021c94649b3f601800b7502a9c15 (diff) | |
download | android-node-v8-ae2d1f0e05449221ee770a393e5c967b359d9b1b.tar.gz android-node-v8-ae2d1f0e05449221ee770a393e5c967b359d9b1b.tar.bz2 android-node-v8-ae2d1f0e05449221ee770a393e5c967b359d9b1b.zip |
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 <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Diffstat (limited to 'doc/api/crypto.md')
-rw-r--r-- | doc/api/crypto.md | 16 |
1 files changed, 16 insertions, 0 deletions
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. <!-- YAML added: v0.1.92 changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/25217 + description: The key can now be a private key. - version: v8.0.0 pr-url: https://github.com/nodejs/node/pull/11705 description: Support for RSASSA-PSS and additional options was added. @@ -1419,6 +1422,9 @@ The `verify` object can not be used again after `verify.verify()` has been called. Multiple calls to `verify.verify()` will result in an error being thrown. +Because public keys can be derived from private keys, a private key may +be passed instead of a public key. + ## `crypto` module methods and properties ### crypto.constants @@ -1829,6 +1835,10 @@ must be an object with the properties described above. ### crypto.createPublicKey(key) <!-- YAML added: v11.6.0 +changes: + - version: REPLACEME + pr-url: https://github.com/nodejs/node/pull/25217 + description: The `key` argument can now be a private key. --> * `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) <!-- YAML added: v11.6.0 |