Skip to content

crypto/x509: Incorrect documentation for ParsePKCS8PrivateKey #58789

@babolivier

Description

@babolivier

Apologies for not following the template, it did not seem relevant since my issue is with the documentation of crypto/x509 as it currently shows on https://pkg.go.dev/crypto/x509#ParsePKCS8PrivateKey. I also did not open this issue as a pkg.go.dev bug since it's an issue with the package's documentation, not the documentation website itself. If either decision was incorrect please let me know and I'll correct them.

The documentation for x509.ParsePKCS8PrivateKey mentions the possible return types of the function as:

It returns a *rsa.PrivateKey, a *ecdsa.PrivateKey, a ed25519.PrivateKey (not a pointer), or a *ecdh.PublicKey (for X25519).

However, in the case of X25519, the actual implementation returns a *ecdh.PrivateKey (ref), which makes more sense, and also fits with what types x509.MarshalPKCS8PrivateKey is documented to accept for the key parameter.

Therefore it looks to me like the documentation is incorrect, and should instead be:

It returns a *rsa.PrivateKey, a *ecdsa.PrivateKey, a ed25519.PrivateKey (not a pointer), or a *ecdh.PrivateKey (for X25519).

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions