协议记录层(Record Protocol format)的格式
TLS 记录的头部有三个组成部分
第0个字节: TLS 记录的类别
第1-2个字节: TLS 版本(主版本/次版本)
第3-4个字节:包含头部在内的总长度
Length of data in the record (excluding the header itself). The maximum supported is 16384 (16K).
record type (1 byte)
/
/ version (1 byte major, 1 byte minor)
/ /
/ / length (2 bytes)
/ / /
+----+----+----+----+----+
| | | | | |
| | | | | | TLS Record header
+----+----+----+----+----+
Recode Type的种类
Record Type Values
dec
hex
CHANGE_CIPHER_SPEC
20
0x14
ALERT
21
0x15
HANDSHAKE
22
0x16
APPLICATION_DATA
23
0x17
版本号的种类
Version Values
dec
hex
SSL 3.0
3,0
0x0300
TLS 1.0
3,1
0x0301
TLS 1.1
3,2
0x0302
TLS 1.2
3,3
0x0303
TLS1.3
3,4
0x0304
握手协议(Handshake Protocol)的格式
握手协议在recode Layer的type是22,后面会包括握手的类型,握手消息的长度,和消息体三部分。
Handshake Type是8位
handshake message length 24位
|
|
|
Record Layer | Handshake Layer
| |
| | ...more messages
+----+----+----+----+----+----+----+----+----+------ - - - -+--
| 22 | | | | | | | | | |
|0x16| | | | | | | | |message |
+----+----+----+----+----+----+----+----+----+------ - - - -+--
/ / | \ \----\-----\ |
/ / | \ \
type: 22 / | \ handshake message length
/ type
/
length: arbitrary (up t