From 468e5c03e9290705167b4c3207f54ff1840e08fd Mon Sep 17 00:00:00 2001 From: nsa Date: Thu, 30 Jan 2020 13:41:46 -0500 Subject: [PATCH] fuzz/brontide: random+static decrypt harnesses --- fuzz/brontide/random_init_decrypt.go | 27 +++++++++++++++++++++++++++ fuzz/brontide/random_resp_decrypt.go | 27 +++++++++++++++++++++++++++ fuzz/brontide/static_init_decrypt.go | 27 +++++++++++++++++++++++++++ fuzz/brontide/static_resp_decrypt.go | 27 +++++++++++++++++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 fuzz/brontide/random_init_decrypt.go create mode 100644 fuzz/brontide/random_resp_decrypt.go create mode 100644 fuzz/brontide/static_init_decrypt.go create mode 100644 fuzz/brontide/static_resp_decrypt.go diff --git a/fuzz/brontide/random_init_decrypt.go b/fuzz/brontide/random_init_decrypt.go new file mode 100644 index 000000000..3328a2b6b --- /dev/null +++ b/fuzz/brontide/random_init_decrypt.go @@ -0,0 +1,27 @@ +// +build gofuzz + +package brontidefuzz + +import ( + "bytes" +) + +// Fuzz_random_init_decrypt is a go-fuzz harness that decrypts arbitrary data +// with the initiator. +func Fuzz_random_init_decrypt(data []byte) int { + // This will return brontide machines with random keys. + initiator, responder := getBrontideMachines() + + // Complete the brontide handshake. + completeHandshake(initiator, responder) + + // Create a reader with the byte array. + r := bytes.NewReader(data) + + // Decrypt the encrypted message using ReadMessage w/ initiator machine. + if _, err := initiator.ReadMessage(r); err == nil { + nilAndPanic(initiator, responder, nil) + } + + return 1 +} diff --git a/fuzz/brontide/random_resp_decrypt.go b/fuzz/brontide/random_resp_decrypt.go new file mode 100644 index 000000000..1ae40bd27 --- /dev/null +++ b/fuzz/brontide/random_resp_decrypt.go @@ -0,0 +1,27 @@ +// +build gofuzz + +package brontidefuzz + +import ( + "bytes" +) + +// Fuzz_random_resp_decrypt is a go-fuzz harness that decrypts arbitrary data +// with the responder. +func Fuzz_random_resp_decrypt(data []byte) int { + // This will return brontide machines with random keys. + initiator, responder := getBrontideMachines() + + // Complete the brontide handshake. + completeHandshake(initiator, responder) + + // Create a reader with the byte array. + r := bytes.NewReader(data) + + // Decrypt the encrypted message using ReadMessage w/ responder machine. + if _, err := responder.ReadMessage(r); err == nil { + nilAndPanic(initiator, responder, nil) + } + + return 1 +} diff --git a/fuzz/brontide/static_init_decrypt.go b/fuzz/brontide/static_init_decrypt.go new file mode 100644 index 000000000..35525d203 --- /dev/null +++ b/fuzz/brontide/static_init_decrypt.go @@ -0,0 +1,27 @@ +// +build gofuzz + +package brontidefuzz + +import ( + "bytes" +) + +// Fuzz_static_init_decrypt is a go-fuzz harness that decrypts arbitrary data +// with the initiator. +func Fuzz_static_init_decrypt(data []byte) int { + // This will return brontide machines with static keys. + initiator, responder := getStaticBrontideMachines() + + // Complete the brontide handshake. + completeHandshake(initiator, responder) + + // Create a reader with the byte array. + r := bytes.NewReader(data) + + // Decrypt the encrypted message using ReadMessage w/ initiator machine. + if _, err := initiator.ReadMessage(r); err == nil { + nilAndPanic(initiator, responder, nil) + } + + return 1 +} diff --git a/fuzz/brontide/static_resp_decrypt.go b/fuzz/brontide/static_resp_decrypt.go new file mode 100644 index 000000000..fee4500b5 --- /dev/null +++ b/fuzz/brontide/static_resp_decrypt.go @@ -0,0 +1,27 @@ +// +build gofuzz + +package brontidefuzz + +import ( + "bytes" +) + +// Fuzz_static_resp_decrypt is a go-fuzz harness that decrypts arbitrary data +// with the responder. +func Fuzz_static_resp_decrypt(data []byte) int { + // This will return brontide machines with static keys. + initiator, responder := getStaticBrontideMachines() + + // Complete the brontide handshake. + completeHandshake(initiator, responder) + + // Create a reader with the byte array. + r := bytes.NewReader(data) + + // Decrypt the encrypted message using ReadMessage w/ responder machine. + if _, err := responder.ReadMessage(r); err == nil { + nilAndPanic(initiator, responder, nil) + } + + return 1 +}