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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
/**
* @file
* This file as well as SSLCommon.h and SSLHandshake.h provide structures that represent SSL/TLS protocol.
* Main features:
* - All common SSL/TLS version are supported from SSL 3.0 to TLS 1.3
* - All SSL/TLS message types are supported (at least the message types that are not encrypted)
* - More than 300 cipher-suites are supported
* - Only parsing capabilities exist, editing and creation of messages are not supported
* - X509 certificate parsing is not supported
*
* <BR><BR>
*
* __SSL Records:__ <BR>
*
* The SSL/TLS protocol has 4 types of records:
* - Handshake record type
* - Change cipher spec record type
* - Alert record type
* - Application data record type
*
* Each record type corresponds to a layer class, and these classes inherit from one base class which is pcpp::SSLLayer.
* The pcpp::SSLLayer is an abstract class which cannot be instantiated. Only its 4 derived classes can be instantiated.
* This means you'll never see a layer of type pcpp::SSLLayer, you'll only see the type of the derived classes.
* A basic class diagram looks like this:
@verbatim
+----------------------------+
+---| SSLHandshakeLayer | ===> Handshake record type
| +----------------------------+
|
| +----------------------------+
+---| SSLChangeCipherSpecLayer | ===> Change cipher spec record type
| +----------------------------+
|
+------------+ | +----------------------------+
| SSLLayer |-------------+---| SSLAlertLayer | ===> Alert record type
| (abstract) | | +----------------------------+
+------------+ |
| +----------------------------+
+---| SSLApplicationDataLayer | ===> Application data record type
+----------------------------+
@endverbatim
*
* A single packet may include several SSL/TLS records, meaning several layer instances of these types, for example:
*
@verbatim
+--------------------------+
| EthLayer |
+--------------------------+
| IPv4Layer |
+--------------------------+
| TcpLayer |
+--------------------------+
| SSLHandshakeLayer | \
+--------------------------+ \
| SSLChangeCipherSpecLayer | -------- 3 SSL/TLS records in the same packet!
+--------------------------+ /
| SSLHandshakeLayer | /
+--------------------------+
@endverbatim
*
* <BR><BR>
*
* __SSL/TLS Handshake records:__ <BR>
*
* The SSL/TLS handshake records are the most complex ones. These type of records encapsulate all messages between
* client and server during SSL/TLS connection establishment. To accomplish that a SSL/TLS handshake record holds
* zero or more handshake messages (usually it holds 1 message). These messages form the handshake negotiation between
* the client and the server. There are several types of handshake messages. Some of the are sent from client to server
* and some from server to client. PcapPlusPlus supports 11 of these types (definitely the most common ones). For each
* message there is a designated class which parses the message and exposes its attributes in an easy-to-use manner.
* Here are the list of supported messages:
* - Client-hello
* - Server-hello
* - Certificate
* - Hello-request
* - Server-key-exchange
* - Client-key-exchange
* - Certificate-request
* - Server-hello-done
* - Certificate-verify
* - Finished
* - New-session-ticket
*
* All handshake messages classes inherit from a base abstract class: pcpp::SSLHandshakeMessage which cannot be instantiated.
* Also, all of them reside in SSLHandshake.h. Following is a simple diagram of these classes:
*
@verbatim
SSLHandshakeMessage
|
+-------------------------------+ |--- SSLClientHelloMessage ==> Client-hello message
| SSLHandshakeLayer | |
+-------------------------------+ |--- SSLServerHelloMessage ==> Server-hello message
| -List of SSLHandshakeMessage | |
| Message1 | |---SSLCertificateMessage ==> Certificate message
| Message2 | |
| ... | |---SSLHelloRequestMessage ==> Hello-request message
| | |
+-------------------------------+ |---SSLServerKeyExchangeMessage ==> Server-key-exchange message
|
|---SSLClientKeyExchangeMessage ==> Client-key-exchange message
|
|---SSLCertificateRequestMessage ==> Certificate-request message
|
|---SSLServerHelloDoneMessage ==> Server-hello-done message
|
|---SSLCertificateVerifyMessage ==> Certificate-verify message
|
|---SSLFinishedMessage ==> Finished message
|
|---SSLNewSessionTicketMessage ==> New-session-ticket message
@endverbatim
*
* In addition, for all handshake messages which aren't supported in PcapPlusPlus or for encrypted handshake messages
* There is another class: pcpp::SSLUnknownMessage
*
* <BR><BR>
*
* __Cipher suites:__ <BR>
*
* Cipher suites are named combinations of authentication, encryption, message authentication code (MAC) and key exchange
* algorithms used to negotiate the security settings for a network connection using SSL/TLS.
* There are many known cipher-suites. PcapPlusPlus support above 300 of them, according to this list:
* http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml
* There is a designated class in PcapPlusPlus called pcpp::SSLCipherSuite which represents the cipher-suites and provides
* access to their attributes. Then there is a static instance of this class for each one of the supported cipher-suites.
* This means there are 300+ static instances of pcpp::SSLCipherSuite representing the different cipher suites. The user can
* access them through static methods in pcpp::SSLCipherSuite or from client-hello and server-hello messages where they appear
*
* <BR><BR>
*
* __SSL/TLS extensions:__ <BR>
*
* SSL/TLS handshake messages, specifically client-hello and server-hello usually include extensions. There are various
* types of extensions - some are more broadly used, some are less. In PcapPlusPlus there is a base class for all
* extensions: pcpp::SSLExtension. This class is instantiable and represents a generic extension, which means extension data
* isn't parsed and given to the user as raw data. Currently there are only two extension that are fully parsed which are
* server-name-indication (pcpp::SSLServerNameIndicationExtension) and SupportedVersions (pcpp::SSLSupportedVersionsExtension).
* Both inherit from pcpp::SSLExtension and add additional parsing relevant for the specific extension.
* All other extensions aren't parsed and are represented by instance of pcpp::SSLExtension.
* Access to extensions is done through the handshake messages classes, specifically pcpp::SSLClientHelloMessage and pcpp::SSLServerHelloMessage
*/
/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace // namespace pcpp
/* PACKETPP_SSL_LAYER */