Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: crypto/x509: create typed versions of ParsePKCS8PrivateKey #26485

Closed
HaraldNordgren opened this issue Jul 19, 2018 · 6 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@HaraldNordgren
Copy link
Member

It bothers me that me as an end-user of ParsePKCS8PrivateKey have to do type assertion logic on the key even when you know what you expect.

We should utilize Go's strong type system to create type-specific functions called for example

  • ParsePKCS8PrivateKeyRSA(der []byte) (key *rsa.PrivateKey, err error)
  • ParsePKCS8PrivateKeyECDSA(der []byte) (key *ecdsa.PrivateKey, err error)
@gopherbot
Copy link

Change https://golang.org/cl/125056 mentions this issue: crypto/x509: create typed versions of ParsePKCS8PrivateKey

@bcmills
Copy link
Contributor

bcmills commented Jul 19, 2018

CC @FiloSottile

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 19, 2018
@bcmills bcmills added this to the Go1.12 milestone Jul 19, 2018
@adamdecaf
Copy link
Contributor

adamdecaf commented Aug 11, 2018

I'm indifferent, but adding new methods adds to the overall api surface, which has its own problems with maintenance.

@adamdecaf
Copy link
Contributor

@gopherbot proposal-crypto

@andybons andybons modified the milestones: Go1.12, Go1.13 Feb 12, 2019
@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@odeke-em odeke-em changed the title crypto/x509: Create typed versions of ParsePKCS8PrivateKey proposal: crypto/x509: create typed versions of ParsePKCS8PrivateKey Sep 26, 2019
@odeke-em
Copy link
Member

I've retitled this as a proposal as it hasn't been looked at since Go1.11 but it is a proposal that we have to examine and decide on.

@odeke-em odeke-em added the Proposal-Crypto Proposal related to crypto packages or other security issues label Sep 26, 2019
@FiloSottile
Copy link
Contributor

I agree with Adam (https://go-review.googlesource.com/c/go/+/125056/4#message-46b6bcfdedbc7383393b0e37c5a640be477bd615) that the increased API surface is not worth it. There is already a dizzying array of Parse functions in crypto/x509, and the type assertion is not much more work than checking the error.

@golang golang locked and limited conversation to collaborators Sep 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
None yet
Development

No branches or pull requests

7 participants