Refactoring
Refactored Protocol.Name -> Protocol.Type; added Encapsulation field Refactored TLS parsing; added support for ALPN
This commit is contained in:
42
tls_test.go
42
tls_test.go
@@ -72,6 +72,39 @@ func TestDecodeTLSServerHello(t *testing.T) {
|
||||
t.Fatalf("failed to decode test ServerHello: %s", err)
|
||||
}
|
||||
|
||||
tls11ServerHello := []byte{
|
||||
// --- Handshake Protocol: ServerHello (64 bytes) ---
|
||||
0x02, // Handshake Type: ServerHello (2)
|
||||
0x00, 0x00, 0x3c, // Length of the rest of the message (60 bytes)
|
||||
0x03, 0x02, // Server Version: TLS 1.1 (Major=3, Minor=2)
|
||||
|
||||
// Random (32 bytes)
|
||||
0xb7, 0xa8, 0xdf, 0xd5, 0x17, 0xb1, 0x50, 0xb4,
|
||||
0x28, 0xb7, 0xf6, 0xf3, 0xb9, 0x83, 0xcf, 0x9f,
|
||||
0x31, 0x55, 0x79, 0x1f, 0x3b, 0x07, 0x6d, 0x17,
|
||||
0x44, 0x4f, 0x57, 0x4e, 0x47, 0x52, 0x44, 0x00,
|
||||
|
||||
// Session ID
|
||||
0x00, // Session ID Length: 0 (new session)
|
||||
|
||||
0xc0, 0x09, // Cipher Suite
|
||||
0x00, // Compression Method
|
||||
|
||||
// --- Extensions (20 bytes) ---
|
||||
0x00, 0x14, // Extensions Length: 20 bytes
|
||||
0xff, 0x01, // Extension Type: renegotiation_info
|
||||
0x00, 0x01, // Extension Length: 1 byte
|
||||
0x00, // Renegotiation Info Length: 0 bytes
|
||||
0x00, 0x10, // Extension Type: alpn
|
||||
0x00, 0x05, // Extension Length: 5 bytes
|
||||
0x00, 0x03, // ALPN Extension Length: 3 bytes
|
||||
0x02, 'h', '2',
|
||||
0x0, 0x0b, // Extension Type: ec_points_format
|
||||
0x0, 0x02, // Extension Length: 2 bytes
|
||||
0x01, // EC Points Format Length: 1 byte
|
||||
0x00, // EC Point Format: uncompressed
|
||||
}
|
||||
|
||||
t.Run("Server Hello", func(t *testing.T) {
|
||||
hello, err := DecodeTLSServerHello(serverHelloBytes)
|
||||
if err != nil {
|
||||
@@ -80,6 +113,15 @@ func TestDecodeTLSServerHello(t *testing.T) {
|
||||
}
|
||||
t.Logf("%#+v", hello)
|
||||
})
|
||||
|
||||
t.Run("TLS 1.1 Server Hello", func(t *testing.T) {
|
||||
hello, err := DecodeTLSServerHello(tls11ServerHello)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
return
|
||||
}
|
||||
t.Logf("%#+v", hello)
|
||||
})
|
||||
}
|
||||
|
||||
func testDecodeHexString(s string) ([]byte, error) {
|
||||
|
Reference in New Issue
Block a user