fuzz/brontide: random+static decrypt harnesses

This commit is contained in:
nsa 2020-01-30 13:41:46 -05:00
parent 116c5469bc
commit 468e5c03e9
No known key found for this signature in database
GPG Key ID: 118759E83439A9B1
4 changed files with 108 additions and 0 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}