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

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

HaraldNordgren opened this issue Jul 19, 2018 · 6 comments

Comments

@HaraldNordgren
Copy link
Member

@HaraldNordgren HaraldNordgren commented Jul 19, 2018

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

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Jul 19, 2018

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

@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Jul 19, 2018

@bcmills bcmills added this to the Go1.12 milestone Jul 19, 2018
@adamdecaf

This comment has been minimized.

Copy link
Contributor

@adamdecaf 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

This comment has been minimized.

Copy link
Contributor

@adamdecaf adamdecaf commented Aug 11, 2018

@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
@gopherbot gopherbot added the Proposal label Sep 26, 2019
@odeke-em

This comment has been minimized.

Copy link
Member

@odeke-em odeke-em commented Sep 26, 2019

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.

@FiloSottile

This comment has been minimized.

Copy link
Member

@FiloSottile FiloSottile commented Oct 1, 2019

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.

@FiloSottile FiloSottile closed this Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.