FILE / ScuroNeko/mtg

mtglib/internal/obfuscated2/client_handshake_fuzz_internal_test.go

Исходный файл и его история в репозитории.
FILE 36546cec2f7b6114c5381ec42dbf507fe16fcfa7
Files
mtg/mtglib/internal/obfuscated2/client_handshake_fuzz_internal_test.go
T
2022-03-18 14:58:08 +03:00

33 lines
703 B
Go

package obfuscated2
import (
"bytes"
"testing"
"github.com/stretchr/testify/require"
)
var FuzzClientHandshakeSecret = []byte{1, 2, 3}
func FuzzClientHandshake(f *testing.F) {
f.Add([]byte{1, 2, 3})
f.Fuzz(func(t *testing.T, frame []byte) {
data := bytes.NewReader(frame)
if _, _, _, err := ClientHandshake(FuzzClientHandshakeSecret, data); err != nil {
return
}
handshake := clientHandhakeFrame{}
require.Len(t, frame, handshakeFrameLen)
copy(handshake.data[:], frame)
decryptor := handshake.decryptor(FuzzClientHandshakeSecret)
decryptor.XORKeyStream(handshake.data[:], handshake.data[:])
require.Equal(t, handshakeConnectionType, handshake.connectionType())
})
}