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

Fix : Failing Fuzz tests for FuzzRSAPSSSignerVerfier #664

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 6 additions & 15 deletions test/fuzz/signature/fuzz_signature_test.go
Expand Up @@ -23,9 +23,10 @@ import (
"crypto/elliptic"
"crypto/rsa"
"math/big"
"strings"
"testing"

"github.com/sigstore/sigstore/pkg/cryptoutils"

fuzz "github.com/AdaLogics/go-fuzz-headers"
"github.com/sigstore/sigstore/pkg/signature"
)
Expand Down Expand Up @@ -153,21 +154,11 @@ func FuzzRSAPKCS1v15SignerVerfier(f *testing.F) {

func FuzzRSAPSSSignerVerfier(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
if len(data) == 0 {
t.Skip("not valid key")
}

s := string(data)

// Skip when the data is not a valid RSA PSS signature.
if strings.TrimSpace(s) == "" {
t.Skip("not valid key")
privateKey, err := cryptoutils.UnmarshalPEMToPrivateKey(data, cryptoutils.SkipPassword)
if err != nil {
t.Skip()
}

f := fuzz.NewConsumer(data)
x := rsa.PrivateKey{}
f.GenerateStruct(&x)
signer, err := signature.LoadRSAPSSSignerVerifier(&x, crypto.SHA512, nil)
signer, err := signature.LoadRSAPSSSignerVerifier(privateKey.(*rsa.PrivateKey), crypto.SHA512, nil)
if err != nil {
if signer != nil {
t.Errorf("key %v is not nil when there is an error %v ", signer, err)
Expand Down