Skip to content

Commit

Permalink
pki: clean up fuzzer (#1594)
Browse files Browse the repository at this point in the history
Signed-off-by: AdamKorcz <adam@adalogics.com>
  • Loading branch information
AdamKorcz authored Jul 22, 2023
1 parent 05bdadc commit c44b8b5
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions pkg/pki/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"io"
"testing"

"github.com/google/go-cmp/cmp"

"github.com/sigstore/rekor/pkg/pki/minisign"
"github.com/sigstore/rekor/pkg/pki/pgp"
"github.com/sigstore/rekor/pkg/pki/pkcs7"
Expand All @@ -31,14 +29,6 @@ import (
)

var (
cmpOpts = []cmp.Option{cmp.AllowUnexported(minisign.PublicKey{},
pgp.PublicKey{},
ssh.PublicKey{},
x509.PublicKey{},
pkcs7.PublicKey{},
tuf.PublicKey{},
)}

fuzzArtifactFactoryMap = map[uint]pkiImpl{
0: {
newPubKey: func(r io.Reader) (PublicKey, error) {
Expand Down Expand Up @@ -93,23 +83,6 @@ var (

func FuzzKeys(f *testing.F) {
f.Fuzz(func(t *testing.T, keyType uint, origSignatureData, verSignatureData, keyData []byte) {

// test public key
pub1, err := fuzzArtifactFactoryMap[keyType%6].newPubKey(bytes.NewReader(keyData))
if err == nil && pub1 != nil {
b, err := pub1.CanonicalValue()
if err == nil {
pub2, err := fuzzArtifactFactoryMap[keyType%6].newPubKey(bytes.NewReader(b))
if err != nil {
t.Fatal("Could not create a key from valid key data")
}
if !cmp.Equal(pub1, pub2, cmpOpts...) {
t.Fatal("The two public keys should be equal but are not")
}
}
}

// test signature
s, err := fuzzArtifactFactoryMap[keyType%6].newSignature(bytes.NewReader(origSignatureData))
if err == nil && s != nil {
b, err := s.CanonicalValue()
Expand Down

0 comments on commit c44b8b5

Please sign in to comment.