Add fuzzing for client hello

This commit is contained in:
9seconds
2022-03-18 17:24:36 +03:00
parent e0850869ba
commit d8b14dc765
2 changed files with 22 additions and 1 deletions
@@ -0,0 +1,21 @@
package faketls_test
import (
"testing"
"github.com/9seconds/mtg/v2/mtglib/internal/faketls"
"github.com/stretchr/testify/require"
)
var FuzzClientHelloSecret = []byte{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
func FuzzClientHello(f *testing.F) {
f.Add([]byte{1, 2, 3})
f.Fuzz(func(t *testing.T, frame []byte) {
_, err := faketls.ParseClientHello(FuzzClientHelloSecret, frame)
// a probability of having != err is almost negligible
require.Error(t, err)
})
}
+1 -1
View File
@@ -19,7 +19,7 @@ const (
// ClientHelloMinLen is a minimal possible length of // ClientHelloMinLen is a minimal possible length of
// ClientHello record. // ClientHello record.
ClientHelloMinLen = 4 ClientHelloMinLen = 6
// WelcomePacketRandomOffset is an offset of random in ServerHello // WelcomePacketRandomOffset is an offset of random in ServerHello
// packet (including record envelope). // packet (including record envelope).