File: ssl_enum.c

package info (click to toggle)
ssldump 0.9b3-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,196 kB
  • ctags: 1,379
  • sloc: ansic: 6,151; sh: 1,508; yacc: 183; makefile: 90; lex: 67
file content (385 lines) | stat: -rw-r--r-- 6,474 bytes parent folder | download | duplicates (3)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#include "network.h"
#include "ssl.h"
#include "sslprint.h"
static int decode_ContentType_change_cipher_spec(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_ContentType_alert(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_ContentType_handshake(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {


    extern decoder HandshakeType_decoder[];
    int r;
    UINT4 t,l;

    SSL_DECODE_UINT8(ssl,0,0,data,&t);
    SSL_DECODE_UINT24(ssl,0,0,data,&l);

    if(data->len!=l){
      fprintf(stderr,"Error: short handshake length: expected %d got %d\n",
        l,data->len);
      ERETURN(R_EOD);
    }
      
    ssl_decode_switch(ssl,HandshakeType_decoder,t,dir,seg,data);

  }
static int decode_ContentType_application_data(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
decoder ContentType_decoder[]={
	{
		20,
		"change_cipher_spec",
		decode_ContentType_change_cipher_spec
	},
	{
		21,
		"alert",
		decode_ContentType_alert
	},
	{
		22,
		"handshake",
		decode_ContentType_handshake
	},
	{
		23,
		"application_data",
		decode_ContentType_application_data
	},
{-1}
};

static int decode_HandshakeType_hello_request(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_client_hello(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {


    UINT4 vj,vn,cs,cslen,complen,comp;
    Data session_id,random;
    int r;

    extern decoder cipher_suite_decoder[];
    extern decoder compression_method_decoder[];    
    
    SSL_DECODE_UINT8(ssl,0,0,data,&vj);
    SSL_DECODE_UINT8(ssl,0,0,data,&vn);    

    P_(P_ND) {explain(ssl,"Client version %d.%d ",vj,vn);}

    printf("\n");
    SSL_DECODE_OPAQUE_ARRAY(ssl,"random",32,P_ND,data,&random);
    SSL_DECODE_OPAQUE_ARRAY(ssl,"session_id",-32,0,data,&session_id);

    if(session_id.len)
      exdump(ssl,"resume ",&session_id);

    SSL_DECODE_UINT16(ssl,"cipher Suites len",0,data,&cslen);
    explain(ssl,"cipher suites\n");
    
    for(;cslen;cslen-=2){
      SSL_DECODE_ENUM(ssl,0,2,cipher_suite_decoder,
        P_HL,data,&cs);
      printf("\n");
    }

    SSL_DECODE_UINT8(ssl,"compressionMethod len",0,data,&complen);
    if(complen){
      explain(ssl,"compression methods\n");
      for(;complen;complen--){
        SSL_DECODE_ENUM(ssl,0,1,compression_method_decoder,P_HL,data,&comp);
        printf("\n");
      }
    }
    return(0);

  }
static int decode_HandshakeType_server_hello(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {


    int r;

    UINT4 vj,vn;
    
    SSL_DECODE_UINT8(ssl,0,0,data,&vj);
    SSL_DECODE_UINT8(ssl,0,0,data,&vn);    

    P_(P_ND) {explain(ssl,"SSL version %d.%d ",vj,vn);}
    SSL_DECODE_OPAQUE_ARRAY(ssl,"random",32,P_ND,data,0);
    SSL_DECODE_OPAQUE_ARRAY(ssl,"session_id",32,P_ND,data,0);
    SSL_DECODE_ENUM(ssl,0,2,cipher_suite_decoder,
      P_HL,data,0);
    SSL_DECODE_ENUM(ssl,0,1,compression_method_decoder,P_HL,data,0);

    return(0);

  }
static int decode_HandshakeType_certificate(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_server_key_exchange(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_certificate_request(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_server_hello_done(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_certificate_verify(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_client_key_exchange(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
static int decode_HandshakeType_finished(ssl,dir,seg,data)
  ssl_obj *ssl;
  int dir;
  segment *seg;
  Data *data;
  {
	return(0);
  }
decoder HandshakeType_decoder[]={
	{
		0,
		"hello_request",
		decode_HandshakeType_hello_request
	},
	{
		1,
		"client_hello",
		decode_HandshakeType_client_hello
	},
	{
		2,
		"server_hello",
		decode_HandshakeType_server_hello
	},
	{
		11,
		"certificate",
		decode_HandshakeType_certificate
	},
	{
		12,
		"server_key_exchange",
		decode_HandshakeType_server_key_exchange
	},
	{
		13,
		"certificate_request",
		decode_HandshakeType_certificate_request
	},
	{
		14,
		"server_hello_done",
		decode_HandshakeType_server_hello_done
	},
	{
		15,
		"certificate_verify",
		decode_HandshakeType_certificate_verify
	},
	{
		16,
		"client_key_exchange",
		decode_HandshakeType_client_key_exchange
	},
	{
		20,
		"finished",
		decode_HandshakeType_finished
	},
{-1}
};

decoder cipher_suite_decoder[]={
	{
		1,
		"TLS_RSA_WITH_NULL_MD5",
		0	},
	{
		2,
		"TLS_RSA_WITH_NULL_SHA",
		0	},
	{
		3,
		"TLS_RSA_EXPORT_WITH_RC4_40_MD5",
		0	},
	{
		4,
		"TLS_RSA_WITH_RC4_128_MD5",
		0	},
	{
		5,
		"TLS_RSA_WITH_RC4_128_SHA",
		0	},
	{
		6,
		"TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5",
		0	},
	{
		7,
		"TLS_RSA_WITH_IDEA_CBC_SHA",
		0	},
	{
		8,
		"TLS_RSA_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		9,
		"TLS_RSA_WITH_DES_CBC_SHA",
		0	},
	{
		10,
		"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
		0	},
	{
		11,
		"TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		12,
		"TLS_DH_DSS_WITH_DES_CBC_SHA",
		0	},
	{
		13,
		"TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA",
		0	},
	{
		14,
		"TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		15,
		"TLS_DH_RSA_WITH_DES_CBC_SHA",
		0	},
	{
		16,
		"TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA",
		0	},
	{
		17,
		"TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		18,
		"TLS_DHE_DSS_WITH_DES_CBC_SHA",
		0	},
	{
		19,
		"TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA",
		0	},
	{
		20,
		"TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		21,
		"TLS_DHE_RSA_WITH_DES_CBC_SHA",
		0	},
	{
		22,
		"TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA",
		0	},
	{
		23,
		"TLS_DH_anon_EXPORT_WITH_RC4_40_MD5",
		0	},
	{
		24,
		"TLS_DH_anon_WITH_RC4_128_MD5",
		0	},
	{
		25,
		"TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA",
		0	},
	{
		26,
		"TLS_DH_anon_WITH_DES_CBC_SHA",
		0	},
	{
		27,
		"TLS_DH_anon_WITH_3DES_EDE_CBC_SHA",
		0	},
{-1}
};

decoder compression_method_decoder[]={
	{
		7,
		"NULL",
		0	},
{-1}
};