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

pki: clean up fuzzer #1594

Merged
merged 1 commit into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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