github.com/decred/dcrlnd@v0.7.6/fuzz/brontide/static_resp_decrypt.go (about)

     1  //go:build gofuzz
     2  // +build gofuzz
     3  
     4  package brontidefuzz
     5  
     6  import (
     7  	"bytes"
     8  )
     9  
    10  // Fuzz_static_resp_decrypt is a go-fuzz harness that decrypts arbitrary data
    11  // with the responder.
    12  func Fuzz_static_resp_decrypt(data []byte) int {
    13  	// This will return brontide machines with static keys.
    14  	initiator, responder := getStaticBrontideMachines()
    15  
    16  	// Complete the brontide handshake.
    17  	completeHandshake(initiator, responder)
    18  
    19  	// Create a reader with the byte array.
    20  	r := bytes.NewReader(data)
    21  
    22  	// Decrypt the encrypted message using ReadMessage w/ responder machine.
    23  	if _, err := responder.ReadMessage(r); err == nil {
    24  		nilAndPanic(initiator, responder, nil)
    25  	}
    26  
    27  	return 1
    28  }