Skip to content

x/crypto/openpgp: pointer usage for rsa.PublicKey is inconsistent with crypto/x509 #27606

@mattmoyer

Description

@mattmoyer

What version of Go are you using (go version)?

go version go1.11 darwin/amd64

Also golang/crypto@0e37d00.

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOOS="darwin"

What did you do?

I wrote some code which implements crypto.Signer. My original use case for this was to plug into golang.org/x/crypto/openpgp so I can perform PGP signatures using my signer. To do this, I had to make my PublicKey() method return a rsa.PublicKey (no pointer) so I can pass the type check in NewSignerPrivateKey().

So far, so good.

What did you expect to see?

I expected my crypto.Signer implementation to work, without changes, with crypto/x509.

What did you see instead?

crypto/x509 also has a type check, but it checks for *rsa.PublicKey (pointer) rather than rsa.PublicKey.

It doesn't seem that I can implement one crypto.Signer that will work with both golang.org/x/crypto/openpgp and crypto/x509. I think we can fix this and keep backwards compatibility by extending the the type check in golang.org/x/crypto/openpgp 's NewSignerPrivateKey() to treat *rsa.PublicKey the same as rsa.PublicKey.

Thanks to @joemiller for originally reporting this downstream (vmware-archive/google-kms-pgp#2).

Metadata

Metadata

Assignees

No one assigned

    Labels

    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