-
Notifications
You must be signed in to change notification settings - Fork 1
/
SSLCommon.h
495 lines (469 loc) · 12.1 KB
/
SSLCommon.h
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
#ifndef PACKETPP_SSL_LAYER_COMMON
#define PACKETPP_SSL_LAYER_COMMON
/**
* @file
* See detailed explanation of the TLS/SSL protocol support in PcapPlusPlus in SSLLayer.h
*/
/**
* \namespace pcpp
* \brief The main namespace for the PcapPlusPlus lib
*/
namespace pcpp
{
/**
* @struct ssl_tls_record_layer
* The common part of all SSL/TLS messages
*/
#pragma pack(push, 1)
struct ssl_tls_record_layer
{
/** Message (record) type (one of ::SSLRecordType) */
uint8_t recordType;
/** Message (record) version (one of ::SSLVersion) */
uint16_t recordVersion;
/** Message (record) length in bytes */
uint16_t length;
};
#pragma pack(pop)
/**
* @struct ssl_tls_handshake_layer
* The common part of all SSL/TLS handshake message types
*/
#pragma pack(push, 1)
struct ssl_tls_handshake_layer
{
/** Type of the handshake message (one of ::SSLHandshakeType) */
uint8_t handshakeType;
/** Length of the message. Length is 3-Byte long, This is the MSB byte */
uint8_t length1;
/** Length of the message. Length is 3-Byte long, This is the 2 LSB bytes */
uint16_t length2;
};
#pragma pack(pop)
/**
* @struct ssl_tls_client_server_hello
* The common header part of client-hello and server-hello handshake messages
*/
#pragma pack(push, 1)
struct ssl_tls_client_server_hello : ssl_tls_handshake_layer
{
/** SSL/TLS handshake version (one of ::SSLVersion) */
uint16_t handshakeVersion;
/** 32-bytes random number */
uint8_t random[32];
};
#pragma pack(pop)
/**
* @struct ssl_tls_change_cipher_spec
* SSL/TLS change-cipher-spec message structure
*/
#pragma pack(push, 1)
struct ssl_tls_change_cipher_spec
{
/** Unused byte */
uint8_t changeCipherSpec;
};
#pragma pack(pop)
/**
* @struct ssl_tls_alert
* SSL/TLS alert message structure
*/
#pragma pack(push, 1)
struct ssl_tls_alert
{
/** Alert level (one of ::SSLAlertLevel) */
uint8_t alertLevel;
/** Alert description (one of ::SSLAlertDescription) */
uint8_t alertDescription;
};
#pragma pack(pop)
/**
* SSL/TLS message types
*/
enum SSLRecordType
{
/** Change-cipher-spec message */
SSL_CHANGE_CIPHER_SPEC = 20,
/** SSL alert message */
SSL_ALERT = 21,
/** SSL handshake message */
SSL_HANDSHAKE = 22,
/** SSL data message */
SSL_APPLICATION_DATA = 23
};
/**
* SSL/TLS versions. Only SSL3.0 and above are supported
*/
enum SSLVersion
{
/** SSLv2.0 */
SSL2 = 0x0200,
/** SSLv3.0 */
SSL3 = 0x0300,
/** TLSv1.0 */
TLS1_0 = 0x0301,
/** TLSv1.1 */
TLS1_1 = 0x0302,
/** TLSv1.2 */
TLS1_2 = 0x0303
};
/**
* SSL/TLS handshake message types
*/
enum SSLHandshakeType
{
/** Hello-request message type */
SSL_HELLO_REQUEST = 0,
/** Client-hello message type */
SSL_CLIENT_HELLO = 1,
/** Server-hello message type */
SSL_SERVER_HELLO = 2,
/** New-session-ticket message type */
SSL_NEW_SESSION_TICKET = 4,
/** Certificate message type */
SSL_CERTIFICATE = 11,
/** Server-key-exchange message type */
SSL_SERVER_KEY_EXCHANGE = 12,
/** Certificate-request message type */
SSL_CERTIFICATE_REQUEST = 13,
/** Server-hello-done message type */
SSL_SERVER_DONE = 14,
/** Certificate-verify message type */
SSL_CERTIFICATE_VERIFY = 15,
/** Client-key-exchange message type */
SSL_CLIENT_KEY_EXCHANGE = 16,
/** Finish message type */
SSL_FINISHED = 20,
/** Unknown SSL handshake message */
SSL_HANDSHAKE_UNKNOWN = 255
};
/**
* SSL/TLS alert levels
*/
enum SSLAlertLevel
{
/** Warning level alert */
SSL_ALERT_LEVEL_WARNING = 1,
/** Fatal level alert */
SSL_ALERT_LEVEL_FATAL = 2,
/** For encrypted alerts the level is unknown so this type will be returned */
SSL_ALERT_LEVEL_ENCRYPTED = 255
};
/**
* SSL/TLS alert description types
*/
enum SSLAlertDescription
{
/** Close notify alert */
SSL_ALERT_CLOSE_NOTIFY = 0,
/** Unexpected message alert */
SSL_ALERT_UNEXPECTED_MESSAGE = 10,
/** Bad record MAC alert */
SSL_ALERT_BAD_RECORD_MAC = 20,
/** Decryption failed alert */
SSL_ALERT_DECRYPTION_FAILED = 21,
/** */
SSL_ALERT_RECORD_OVERFLOW = 22,
/** Decompression failure alert */
SSL_ALERT_DECOMPRESSION_FAILURE = 30,
/** Handshake failure alert */
SSL_ALERT_HANDSHAKE_FAILURE = 40,
/** No certificate alert */
SSL_ALERT_NO_CERTIFICATE = 41,
/** Bad certificate alert */
SSL_ALERT_BAD_CERTIFICATE = 42,
/** Unsupported certificate */
SSL_ALERT_UNSUPPORTED_CERTIFICATE = 43,
/** Certificate revoked alert */
SSL_ALERT_CERTIFICATE_REVOKED = 44,
/** Certificate expired alert */
SSL_ALERT_CERTIFICATE_EXPIRED = 45,
/** Certificate unknown alert */
SSL_ALERT_CERTIFICATE_UNKNOWN = 46,
/** Illegal parameter alert */
SSL_ALERT_ILLEGAL_PARAMETER = 47,
/** Unknown CA alert */
SSL_ALERT_UNKNOWN_CA = 48,
/** Access denied alert */
SSL_ALERT_ACCESS_DENIED = 49,
/** Decode error alert */
SSL_ALERT_DECODE_ERROR = 50,
/** Decrypt error alert */
SSL_ALERT_DECRYPT_ERROR = 51,
/** Export restriction alert */
SSL_ALERT_EXPORT_RESTRICTION = 60,
/** Protocol version alert */
SSL_ALERT_PROTOCOL_VERSION = 70,
/** Insufficient security alert */
SSL_ALERT_INSUFFICIENT_SECURITY = 71,
/** Internal error alert */
SSL_ALERT_INTERNAL_ERROR = 80,
/** User cancelled alert */
SSL_ALERT_USER_CANCELLED = 90,
/** No negotiation alert */
SSL_ALERT_NO_RENEGOTIATION = 100,
/** Unsupported extension alert */
SSL_ALERT_UNSUPPORTED_EXTENSION = 110,
/** Encrtpyed alert (cannot determine its type) */
SSL_ALERT_ENCRYPRED = 255
};
/**
* SSL/TLS key exchange algorithms
*/
enum SSLKeyExchangeAlgorithm
{
/** NULL value */
SSL_KEYX_NULL,
/** RSA (Rivest-Shamir-Adleman) */
SSL_KEYX_RSA,
/** Diffie-Hellman */
SSL_KEYX_DH,
/** Diffie-Hellman ephemeral */
SSL_KEYX_DHE,
/** Elliptic curve Diffie–Hellman */
SSL_KEYX_ECDH,
/** Elliptic curve Diffie–Hellman ephemeral */
SSL_KEYX_ECDHE,
/** Fortezza Crypto Card */
SSL_KEYX_FORTEZZA,
/** Kerberos 5 */
SSL_KEYX_KRB5,
/** Pre-Shared Key */
SSL_KEYX_PSK,
/** GOST */
SSL_KEYX_GOST,
/** Secure Remote Password */
SSL_KEYX_SRP,
/** PCT */
SSL_KEYX_PCT,
/** Unknown algorithm */
SSL_KEYX_Unknown
};
/**
* SSL/TLS authentication algorithms
*/
enum SSLAuthenticationAlgorithm
{
/** NULL value */
SSL_AUTH_NULL,
/** RSA (Rivest-Shamir-Adleman) */
SSL_AUTH_RSA,
/** Digital Signature Standard */
SSL_AUTH_DSS,
/** Anonymous */
SSL_AUTH_anon,
/** Diffie-Hellman based key-exchange protocol */
SSL_AUTH_KEA,
/** Kerberos 5 */
SSL_AUTH_KRB5,
/** Pre-Shared Key */
SSL_AUTH_PSK,
/** Elliptic Curve Digital Signature Algorithm */
SSL_AUTH_ECDSA,
/** GOST */
SSL_AUTH_GOST,
/** SHA-1 (Secure Hash Algorithm) */
SSL_AUTH_SHA,
/** PCT */
SSL_AUTH_PCT,
/** Diffie-Hellman ephemeral */
SSL_AUTH_DHE,
/** Unknown algorithm */
SSL_AUTH_Unknown
};
/**
* SSL/TLS symmetric encryption algorithms
*/
enum SSLSymetricEncryptionAlgorithm
{
/** NULL value */
SSL_SYM_NULL,
/** RC4_40 */
SSL_SYM_RC4_40,
/** RC4_128 */
SSL_SYM_RC4_128,
/** RC2_CBC_40 */
SSL_SYM_RC2_CBC_40,
/** IDEA_CBC */
SSL_SYM_IDEA_CBC,
/** DES40_CBC */
SSL_SYM_DES40_CBC,
/** DES_CBC */
SSL_SYM_DES_CBC,
/** 3DES_EDE_CBC */
SSL_SYM_3DES_EDE_CBC,
/** FORTEZZA_CBC */
SSL_SYM_FORTEZZA_CBC,
/** DES_CBC_40 */
SSL_SYM_DES_CBC_40,
/** AES_128_CBC */
SSL_SYM_AES_128_CBC,
/** AES_256_CBC */
SSL_SYM_AES_256_CBC,
/** CAMELLIA_128_CBC */
SSL_SYM_CAMELLIA_128_CBC,
/** CAMELLIA_128_GCM */
SSL_SYM_CAMELLIA_128_GCM,
/** CAMELLIA_256_GCM */
SSL_SYM_CAMELLIA_256_GCM,
/** RC4_56 */
SSL_SYM_RC4_56,
/** RC2_CBC_56 */
SSL_SYM_RC2_CBC_56,
/** GOST28147 */
SSL_SYM_GOST28147,
/** CAMELLIA_256_CBC */
SSL_SYM_CAMELLIA_256_CBC,
/** SEED_CBC */
SSL_SYM_SEED_CBC,
/** AES_128 */
SSL_SYM_AES_128,
/** AES_256 */
SSL_SYM_AES_256,
/** SSL_SYM_AES_128_GCM */
SSL_SYM_AES_128_GCM,
/** AES_256_GCM */
SSL_SYM_AES_256_GCM,
/** RC4_128_EXPORT40 */
SSL_SYM_RC4_128_EXPORT40,
/** RC2_CBC_128_CBC */
SSL_SYM_RC2_CBC_128_CBC,
/** IDEA_128_CBC */
SSL_SYM_IDEA_128_CBC,
/** DES_64_CBC */
SSL_SYM_DES_64_CBC,
/** DES_192_EDE3_CBC */
SSL_SYM_DES_192_EDE3_CBC,
/** RC4_64 */
SSL_SYM_RC4_64,
/** ARIA_128_CBC*/
SSL_SYM_ARIA_128_CBC,
/** ARIA_256_CBC */
SSL_SYM_ARIA_256_CBC,
/** ARIA_128_GCM */
SSL_SYM_ARIA_128_GCM,
/** ARIA_256_GCM */
SSL_SYM_ARIA_256_GCM,
/** CHACHA20_POLY1305 */
SSL_SYM_CHACHA20_POLY1305,
/** Unknown algorithm */
SSL_SYM_Unknown
};
/**
* SSL/TLS hashing algortihms
*/
enum SSLHashingAlgorithm
{
/** NULL value */
SSL_HASH_NULL,
/** Message-Digest Algorithm */
SSL_HASH_MD5,
/** SHA-1 (Secure Hash Algorithm) */
SSL_HASH_SHA,
/** SHA-256 (Secure Hash Algorithm) */
SSL_HASH_SHA256,
/** GOST 28147 */
SSL_HASH_GOST28147,
/** GOST R 34.11 */
SSL_HASH_GOSTR3411,
/** SHA-384 (Secure Hash Algorithm) */
SSL_HASH_SHA384,
/** CCM mode (Counter with CBC-MAC) */
SSL_HASH_CCM,
/** CCM mode (Counter with CBC-MAC) */
SSL_HASH_CCM_8,
/** Unknown algorithm */
SSL_HASH_Unknown
};
/**
* SSL/TLS extension types
*/
enum SSLExtensionType
{
/** Server Name Indication extension */
SSL_EXT_SERVER_NAME = 0,
/** Maximum Fragment Length Negotiation extension */
SSL_EXT_MAX_FRAGMENT_LENGTH = 1,
/** Client Certificate URLs extension */
SSL_EXT_CLIENT_CERTIFICATE_URL = 2,
/** Trusted CA Indication extension */
SSL_EXT_TRUSTED_CA_KEYS = 3,
/** Truncated HMAC extension */
SSL_EXT_TRUNCATED_HMAC = 4,
/** Certificate Status Request extension */
SSL_EXT_STATUS_REQUEST = 5,
/** TLS User Mapping extension */
SSL_EXT_USER_MAPPING = 6,
/** Client Authorization extension */
SSL_EXT_CLIENT_AUTHZ = 7,
/** Server Authorization extension */
SSL_EXT_SERVER_AUTHZ = 8,
/** Certificate Type extension */
SSL_EXT_CERT_TYPE = 9,
/** Supported Elliptic Curves extension */
SSL_EXT_ELLIPTIC_CURVES = 10,
/** Elliptic Curves Point Format extension */
SSL_EXT_EC_POINT_FORMATS = 11,
/** Secure Remote Password extension */
SSL_EXT_SRP = 12,
/** Signature Algorithms extension */
SSL_EXT_SIGNATURE_ALGORITHMS = 13,
/** Use Secure Real-time Transport Protocol extension */
SSL_EXT_USE_SRTP = 14,
/** TLS Heartbit extension */
SSL_EXT_HEARTBEAT = 15,
/** Application Layer Protocol Negotiation (ALPN) extension */
SSL_EXT_APPLICATION_LAYER_PROTOCOL_NEGOTIATION = 16,
/** Status Request extension */
SSL_EXT_STATUS_REQUEST_V2 = 17,
/** Signed Certificate Timestamp extension */
SSL_EXT_SIGNED_CERTIFICATE_TIMESTAMP = 18,
/** Client Certificate Type extension */
SSL_EXT_CLIENT_CERTIFICATE_TYPE = 19,
/** Server Certificate Type extension */
SSL_EXT_SERVER_CERTIFICATE_TYPE = 20,
/** ClientHello Padding extension */
SSL_EXT_PADDING = 21,
/** Encrypt-then-MAC extension */
SSL_EXT_ENCRYPT_THEN_MAC = 22,
/** Extended Master Secret extension */
SSL_EXT_EXTENDED_MASTER_SECRET = 23,
/** Token Binding extension */
SSL_EXT_TOKEN_BINDING = 24,
/** SessionTicket TLS extension */
SSL_EXT_SESSIONTICKET_TLS = 35,
/** Renegotiation Indication extension */
SSL_EXT_RENEGOTIATION_INFO = 65281,
/** Unknown extension */
SSL_EXT_Unknown
};
/**
* SSL/TLS client certificate types
*/
enum SSLClientCertificateType
{
/** RSA_SIGN */
SSL_CCT_RSA_SIGN = 1,
/** DSS_SIGN */
SSL_CCT_DSS_SIGN = 2,
/** RSA_FIXED_DH */
SSL_CCT_RSA_FIXED_DH = 3,
/** DSS_FIXED_DH */
SSL_CCT_DSS_FIXED_DH = 4,
/** RSA_EPHEMERAL_DH_RESERVED */
SSL_CCT_RSA_EPHEMERAL_DH_RESERVED = 5,
/** DSS_EPHEMERAL_DH_RESERVED */
SSL_CCT_DSS_EPHEMERAL_DH_RESERVED = 6,
/** FORTEZZA_DMS_RESERVED */
SSL_CCT_FORTEZZA_DMS_RESERVED = 20,
/** ECDSA_SIGN */
SSL_CCT_ECDSA_SIGN = 64,
/** FIXED_ECDH */
SSL_CCT_RSA_FIXED_ECDH = 65,
/** ECDSA_FIXED_ECDH */
SSL_CCT_ECDSA_FIXED_ECDH = 66,
/** Unknown client certificate type */
SSL_CCT_UNKNOWN
};
} //namespace pcpp
#endif // PACKETPP_SSL_LAYER_COMMON