mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 18:10:34 +01:00
0b4e03f5fc
With go 1.17 a change to the build flags was implemented: https://go.googlesource.com/proposal/+/master/design/draft-gobuild.md The formatter now automatically adds the forward-compatible build tag format and the linter checks for them, so we need to include them in our code.
39 lines
891 B
Go
39 lines
891 B
Go
//go:build gofuzz
|
|
// +build gofuzz
|
|
|
|
package brontidefuzz
|
|
|
|
import (
|
|
"bytes"
|
|
"math"
|
|
)
|
|
|
|
// Fuzz_static_resp_encrypt is a go-fuzz harness that encrypts arbitrary data
|
|
// with the responder.
|
|
func Fuzz_static_resp_encrypt(data []byte) int {
|
|
// Ensure that length of message is not greater than max allowed size.
|
|
if len(data) > math.MaxUint16 {
|
|
return 1
|
|
}
|
|
|
|
// This will return brontide machines with static keys.
|
|
initiator, responder := getStaticBrontideMachines()
|
|
|
|
// Complete the brontide handshake.
|
|
completeHandshake(initiator, responder)
|
|
|
|
var b bytes.Buffer
|
|
|
|
// Encrypt the message using WriteMessage w/ responder machine.
|
|
if err := responder.WriteMessage(data); err != nil {
|
|
nilAndPanic(initiator, responder, err)
|
|
}
|
|
|
|
// Flush the encrypted message w/ responder machine.
|
|
if _, err := responder.Flush(&b); err != nil {
|
|
nilAndPanic(initiator, responder, err)
|
|
}
|
|
|
|
return 1
|
|
}
|