Skip to content

Export Version 2 PKCS #8 Private Keys #34092

@JonathanWilbur

Description

@JonathanWilbur

Is your feature request related to a problem? Please describe.
Currently, NodeJS exports PKCS 8 private keys as Version 1 PrivateKeyInfo objects, but as of 2010, RFC 5958 specifies Version 2. This only differs from Version 1 by optionally including the public key at the end of the object, and, of course, the version number being incremented.

Describe the solution you'd like
The ability to export Version 2 PKCS 8 Private Keys. All keys can be exported to Version 2 because the included public key at the end is still optional in Version 2. If it is too much work to generate public keys for all algorithms, the public key can be generated just for selected algorithms (presumably those most commonly used, such as RSA and DSA).

This would change Crypto.KeyObject.export() by adding a new export type: pkcs8v2. Again, if the public key cannot be generated, it will simply not be included in the export.

Describe alternatives you've considered
There are no native alternatives. You would have to use third-party crypto libraries to generate PKCS 8 Version 2 keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cryptoIssues and PRs related to the crypto subsystem.feature requestIssues that request new features to be added to Node.js.opensslIssues and PRs related to the OpenSSL dependency.wrong repoIssues that should be opened in another repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions