mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-12 22:22:36 +02:00
fuzz/brontide: random+static decrypt harnesses
This commit is contained in:
27
fuzz/brontide/random_init_decrypt.go
Normal file
27
fuzz/brontide/random_init_decrypt.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user