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.
As a nice side effect, this also allows to derive public keys from private keys using the new KeyObject API.
I am not 100% sure whether this is the best way to go, so I would love opinions from @nodejs/crypto or other people! Allowing private keys to be passed to verify
makes sense in my opinion, but what if the user passes a public and a private key (both in the same PEM string) to createPublicKey
? With this change, the public key would be used, but we should make sure to be on the same page about this.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines