Skip to content

Commit

Permalink
try another way to build
Browse files Browse the repository at this point in the history
Signed-off-by: bytemare <3641580+bytemare@users.noreply.github.com>
  • Loading branch information
bytemare committed Apr 30, 2024
1 parent 64e4602 commit 4d17655
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
15 changes: 8 additions & 7 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

set -ex

compile_go_fuzzer github.com/bytemare/opaque FuzzConfiguration Fuzz_Configuration fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationRequest Fuzz_DeserializeRegistrationRequest fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationResponse Fuzz_DeserializeRegistrationResponse fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationRecord Fuzz_DeserializeRegistrationRecord fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE1 Fuzz_DeserializeKE1 fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE2 Fuzz_DeserializeKE2 fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE3 Fuzz_DeserializeKE3 fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzConfiguration Fuzz_Configuration fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationRequest Fuzz_DeserializeRegistrationRequest fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationResponse Fuzz_DeserializeRegistrationResponse fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeRegistrationRecord Fuzz_DeserializeRegistrationRecord fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE1 Fuzz_DeserializeKE1 fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE2 Fuzz_DeserializeKE2 fuzz
# compile_go_fuzzer github.com/bytemare/opaque FuzzDeserializeKE3 Fuzz_DeserializeKE3 fuzz
compile_go_fuzzer github.com/bytemare/opaque FuzzKE3 Fuzz_DeserializeKE3 fuzz
36 changes: 29 additions & 7 deletions fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func DoFuzzServerConfiguration(t *testing.T, c *opaque.Configuration) (*opaque.S

func FuzzConfiguration(f *testing.F) {
// seed corpus
//loadVectorSeedCorpus(f, "")
// loadVectorSeedCorpus(f, "")

f.Fuzz(func(t *testing.T, ke1, context []byte, kdf, mac, h uint, o []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, o, ksfID, ake)
Expand Down Expand Up @@ -231,7 +231,7 @@ func FuzzDeserializeRegistrationRequest(f *testing.F) {
errInvalidBlindedData = errors.New("blinded data is an invalid point")
)

//loadVectorSeedCorpus(f, "RegistrationRequest")
// loadVectorSeedCorpus(f, "RegistrationRequest")

f.Fuzz(func(t *testing.T, r1, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand Down Expand Up @@ -265,7 +265,7 @@ func FuzzDeserializeRegistrationResponse(f *testing.F) {
errInvalidServerPK = errors.New("invalid server public key")
)

//loadVectorSeedCorpus(f, "RegistrationResponse")
// loadVectorSeedCorpus(f, "RegistrationResponse")

f.Fuzz(func(t *testing.T, r2, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand Down Expand Up @@ -305,7 +305,7 @@ func FuzzDeserializeRegistrationRecord(f *testing.F) {
errInvalidClientPK = errors.New("invalid client public key")
)

//loadVectorSeedCorpus(f, "RegistrationRecord")
// loadVectorSeedCorpus(f, "RegistrationRecord")

f.Fuzz(func(t *testing.T, r3, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand Down Expand Up @@ -341,7 +341,7 @@ func FuzzDeserializeKE1(f *testing.F) {
errInvalidClientEPK = errors.New("invalid ephemeral client public key")
)

//loadVectorSeedCorpus(f, "KE1")
// loadVectorSeedCorpus(f, "KE1")

f.Fuzz(func(t *testing.T, ke1, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand Down Expand Up @@ -407,7 +407,7 @@ func FuzzDeserializeKE2(f *testing.F) {
errInvalidServerEPK = errors.New("invalid ephemeral server public key")
)

//loadVectorSeedCorpus(f, "KE2")
// loadVectorSeedCorpus(f, "KE2")

f.Fuzz(func(t *testing.T, ke2, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand Down Expand Up @@ -447,7 +447,7 @@ func FuzzDeserializeKE3(f *testing.F) {
// Error tested for
errInvalidMessageLength := errors.New("invalid message length for the configuration")

//loadVectorSeedCorpus(f, "KE3")
// loadVectorSeedCorpus(f, "KE3")

f.Fuzz(func(t *testing.T, ke3, context []byte, kdf, mac, h uint, oprf []byte, ksfID, ake byte) {
c := inputToConfig(context, kdf, mac, h, oprf, ksfID, ake)
Expand All @@ -467,3 +467,25 @@ func FuzzDeserializeKE3(f *testing.F) {
}
})
}

func FuzzKE3(data []byte) int {

Check failure on line 471 in fuzz_test.go

View workflow job for this annotation

GitHub Actions / Test (1.21)

wrong signature for FuzzKE3, must be: func FuzzKE3(f *testing.F)

Check failure on line 471 in fuzz_test.go

View workflow job for this annotation

GitHub Actions / Test (1.20)

wrong signature for FuzzKE3, must be: func FuzzKE3(f *testing.F)
// Error tested for
errInvalidMessageLength := errors.New("invalid message length for the configuration")

server, err := opaque.NewServer(nil)
if err != nil {
fmt.Println(err)
return 0
}

_, err = server.Deserialize.KE3(data)
if err != nil {
conf := server.GetConf()
maxMessageLength := conf.MAC.Size()

if strings.Contains(err.Error(), errInvalidMessageLength.Error()) && len(data) == maxMessageLength {
fmt.Printf(fmtGotValidInput+"\n", errInvalidMessageLength)
return 0
}
}
}

0 comments on commit 4d17655

Please sign in to comment.