summaryrefslogtreecommitdiff
path: root/src/SSL_Message.h
blob: 20df62d18f022743b14b80dcabe2a6aee816d1ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#pragma once

#define MIN(a, b)                    ((a) <= (b) ? (a):(b))


#define SSL_HEADER_LEN	5+1	//use the hand_shake first bytes

#define RANDOM_TIME_LEN 			4
#define SSL_RANDOM_SIZE 			28


#define SSL_HANDSHAKE_MSG_HDRLEN    4
#define SSL_RECORD_HDRLEN  			5
#define SSL_HELLO_PROTO_HDRLEN  	6

#define SSL_HANDSHAKE_NOTRUNK       0
#define SSL_HANDSHAKE_PROTO_TRUNKED 1
#define SSL_HANDSHAKE_MSG_TRUNKED   2

#define CHANGE_CIPHER_SEP 			0x14
#define ALERT			 			0x15
#define HANDSHAKE 					0x16
#define APPLICATION_DATA 			0x17

#define CERT_MAXNUM			 		8


//#############################################client hello
#define CLIENT_HELLO_HDRLEN 		4

struct client_server_name
{
	short 					list_len;
	unsigned short 			type;
	unsigned char 			len;
	unsigned char* 			data;
}__attribute__((packed));

#define  SERVER_HELLO_HDRLEN 		4

#define CERTIFICATE_HDRLEN			7
#define SSL_CERTIFICATE_HDRLEN  	3

struct ssl_value2string
{
    unsigned int value;
    const char *string;
};

struct ssl_serial_string
{
    unsigned char serial[16];
    const char *string;
};

struct ssl_record_header
{
    unsigned char content_type;
    unsigned short version;
    unsigned short total_len;
}__attribute__((packed));


struct ssl_handshake_type
{
    unsigned char content_type;
}__attribute__((packed));

enum SSL_HANDSHAKE_TYPE
{
    CLIENT_HELLO=1,
    SERVER_HELLO=2,
    CERTIFICATE=11,
	NEW_SESSION_TICKET=4,
    MSG_UNKNOWN=255,
};

int ssl_parse_stream(const struct streaminfo *a_tcp, struct ssl_runtime_context *ssl_context, int thread_seq, const void *a_packet);