Skip to content

Commit

Permalink
Revert "Fix: support certificate pem type (sigstore#633)"
Browse files Browse the repository at this point in the history
This reverts commit 44be03d.
  • Loading branch information
k4leung4 committed Aug 21, 2022
1 parent 44be03d commit 693d3d2
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 23 deletions.
2 changes: 0 additions & 2 deletions pkg/cryptoutils/publickey.go
Expand Up @@ -53,8 +53,6 @@ func UnmarshalPEMToPublicKey(pemBytes []byte) (crypto.PublicKey, error) {
return nil, errors.New("PEM decoding failed")
}
switch derBytes.Type {
case string(CertificatePEMType):
fallthrough
case string(PublicKeyPEMType):
return x509.ParsePKIXPublicKey(derBytes.Bytes)
default:
Expand Down
21 changes: 0 additions & 21 deletions pkg/cryptoutils/publickey_test.go
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"strings"
"testing"

Expand Down Expand Up @@ -52,26 +51,6 @@ func TestECDSAPublicKeyPEMRoundtrip(t *testing.T) {
verifyPublicKeyPEMRoundtrip(t, priv.Public())
}

func TestECDSAPublicKeyPEMEncodeCertificate(t *testing.T) {
t.Parallel()
priv, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)
if err != nil {
t.Fatalf("ecdsa.GenerateKey failed: %v", err)
}
pubBytes, err := x509.MarshalPKIXPublicKey(&priv.PublicKey)
if err != nil {
t.Fatalf("x509.MarshalPKIXPublicKey() = %v", err)
}
pemBytes := PEMEncode(CertificatePEMType, pubBytes)
rtPub, err := UnmarshalPEMToPublicKey(pemBytes)
if err != nil {
t.Fatalf("UnmarshalPEMToPublicKey returned error: %v", err)
}
if d := cmp.Diff(&priv.PublicKey, rtPub); d != "" {
t.Errorf("round-tripped public key was malformed (-before +after): %s", d)
}
}

func TestEd25519PublicKeyPEMRoundtrip(t *testing.T) {
t.Parallel()
pub, _, err := ed25519.GenerateKey(rand.Reader)
Expand Down

0 comments on commit 693d3d2

Please sign in to comment.