2 * ssl manipulation functions
3 * By Paolo Abeni <paolo.abeni@email.com>
5 * Copyright (c) 2013, Hauke Mehrtens <hauke@hauke-m.de>
6 * Copyright (c) 2014, Peter Wu <peter@lekensteyn.nl>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
36 #include <epan/packet.h>
37 #include <epan/strutil.h>
38 #include <epan/addr_resolv.h>
39 #include <epan/ipv6-utils.h>
40 #include <epan/expert.h>
41 #include <epan/asn1.h>
42 #include <wsutil/filesystem.h>
43 #include <wsutil/file_util.h>
44 #include <wsutil/str_util.h>
45 #include <wsutil/report_err.h>
46 #include <wsutil/pint.h>
47 #include "packet-x509af.h"
48 #include "packet-x509if.h"
49 #include "packet-ssl-utils.h"
50 #include "packet-ssl.h"
51 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
52 #include <gnutls/abstract.h>
58 const value_string ssl_version_short_names[] = {
59 { SSL_VER_UNKNOWN, "SSL" },
60 { SSL_VER_SSLv2, "SSLv2" },
61 { SSL_VER_SSLv3, "SSLv3" },
62 { SSL_VER_TLS, "TLSv1" },
63 { SSL_VER_TLSv1DOT1, "TLSv1.1" },
64 { SSL_VER_DTLS, "DTLSv1.0" },
65 { SSL_VER_DTLS1DOT2, "DTLSv1.2" },
66 { SSL_VER_DTLS_OPENSSL, "DTLS 1.0 (OpenSSL pre 0.9.8f)" },
67 { SSL_VER_PCT, "PCT" },
68 { SSL_VER_TLSv1DOT2, "TLSv1.2" },
72 const value_string ssl_20_msg_types[] = {
73 { SSL2_HND_ERROR, "Error" },
74 { SSL2_HND_CLIENT_HELLO, "Client Hello" },
75 { SSL2_HND_CLIENT_MASTER_KEY, "Client Master Key" },
76 { SSL2_HND_CLIENT_FINISHED, "Client Finished" },
77 { SSL2_HND_SERVER_HELLO, "Server Hello" },
78 { SSL2_HND_SERVER_VERIFY, "Server Verify" },
79 { SSL2_HND_SERVER_FINISHED, "Server Finished" },
80 { SSL2_HND_REQUEST_CERTIFICATE, "Request Certificate" },
81 { SSL2_HND_CLIENT_CERTIFICATE, "Client Certificate" },
84 /* http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml */
85 /* Note: sorted by ascending value so value_string-ext can do a binary search */
86 static const value_string ssl_20_cipher_suites[] = {
87 { 0x000000, "TLS_NULL_WITH_NULL_NULL" },
88 { 0x000001, "TLS_RSA_WITH_NULL_MD5" },
89 { 0x000002, "TLS_RSA_WITH_NULL_SHA" },
90 { 0x000003, "TLS_RSA_EXPORT_WITH_RC4_40_MD5" },
91 { 0x000004, "TLS_RSA_WITH_RC4_128_MD5" },
92 { 0x000005, "TLS_RSA_WITH_RC4_128_SHA" },
93 { 0x000006, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5" },
94 { 0x000007, "TLS_RSA_WITH_IDEA_CBC_SHA" },
95 { 0x000008, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA" },
96 { 0x000009, "TLS_RSA_WITH_DES_CBC_SHA" },
97 { 0x00000a, "TLS_RSA_WITH_3DES_EDE_CBC_SHA" },
98 { 0x00000b, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA" },
99 { 0x00000c, "TLS_DH_DSS_WITH_DES_CBC_SHA" },
100 { 0x00000d, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA" },
101 { 0x00000e, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA" },
102 { 0x00000f, "TLS_DH_RSA_WITH_DES_CBC_SHA" },
103 { 0x000010, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA" },
104 { 0x000011, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" },
105 { 0x000012, "TLS_DHE_DSS_WITH_DES_CBC_SHA" },
106 { 0x000013, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" },
107 { 0x000014, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA" },
108 { 0x000015, "TLS_DHE_RSA_WITH_DES_CBC_SHA" },
109 { 0x000016, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" },
110 { 0x000017, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5" },
111 { 0x000018, "TLS_DH_anon_WITH_RC4_128_MD5" },
112 { 0x000019, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA" },
113 { 0x00001a, "TLS_DH_anon_WITH_DES_CBC_SHA" },
114 { 0x00001b, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA" },
115 { 0x00001c, "SSL_FORTEZZA_KEA_WITH_NULL_SHA" },
116 { 0x00001d, "SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA" },
118 { 0x00001e, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA" },
121 { 0x00001E, "TLS_KRB5_WITH_DES_CBC_SHA" },
122 { 0x00001F, "TLS_KRB5_WITH_3DES_EDE_CBC_SHA" },
123 { 0x000020, "TLS_KRB5_WITH_RC4_128_SHA" },
124 { 0x000021, "TLS_KRB5_WITH_IDEA_CBC_SHA" },
125 { 0x000022, "TLS_KRB5_WITH_DES_CBC_MD5" },
126 { 0x000023, "TLS_KRB5_WITH_3DES_EDE_CBC_MD5" },
127 { 0x000024, "TLS_KRB5_WITH_RC4_128_MD5" },
128 { 0x000025, "TLS_KRB5_WITH_IDEA_CBC_MD5" },
129 { 0x000026, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA" },
130 { 0x000027, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA" },
131 { 0x000028, "TLS_KRB5_EXPORT_WITH_RC4_40_SHA" },
132 { 0x000029, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5" },
133 { 0x00002A, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5" },
134 { 0x00002B, "TLS_KRB5_EXPORT_WITH_RC4_40_MD5" },
136 { 0x00002C, "TLS_PSK_WITH_NULL_SHA" },
137 { 0x00002D, "TLS_DHE_PSK_WITH_NULL_SHA" },
138 { 0x00002E, "TLS_RSA_PSK_WITH_NULL_SHA" },
140 { 0x00002f, "TLS_RSA_WITH_AES_128_CBC_SHA" },
141 { 0x000030, "TLS_DH_DSS_WITH_AES_128_CBC_SHA" },
142 { 0x000031, "TLS_DH_RSA_WITH_AES_128_CBC_SHA" },
143 { 0x000032, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" },
144 { 0x000033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" },
145 { 0x000034, "TLS_DH_anon_WITH_AES_128_CBC_SHA" },
146 { 0x000035, "TLS_RSA_WITH_AES_256_CBC_SHA" },
147 { 0x000036, "TLS_DH_DSS_WITH_AES_256_CBC_SHA" },
148 { 0x000037, "TLS_DH_RSA_WITH_AES_256_CBC_SHA" },
149 { 0x000038, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" },
150 { 0x000039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" },
151 { 0x00003A, "TLS_DH_anon_WITH_AES_256_CBC_SHA" },
152 { 0x00003B, "TLS_RSA_WITH_NULL_SHA256" },
153 { 0x00003C, "TLS_RSA_WITH_AES_128_CBC_SHA256" },
154 { 0x00003D, "TLS_RSA_WITH_AES_256_CBC_SHA256" },
155 { 0x00003E, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256" },
156 { 0x00003F, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256" },
157 { 0x000040, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" },
158 { 0x000041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" },
159 { 0x000042, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA" },
160 { 0x000043, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA" },
161 { 0x000044, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" },
162 { 0x000045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" },
163 { 0x000046, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" },
164 { 0x000047, "TLS_ECDH_ECDSA_WITH_NULL_SHA" },
165 { 0x000048, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA" },
166 { 0x000049, "TLS_ECDH_ECDSA_WITH_DES_CBC_SHA" },
167 { 0x00004A, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA" },
168 { 0x00004B, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA" },
169 { 0x00004C, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA" },
170 { 0x000060, "TLS_RSA_EXPORT1024_WITH_RC4_56_MD5" },
171 { 0x000061, "TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5" },
172 { 0x000062, "TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA" },
173 { 0x000063, "TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA" },
174 { 0x000064, "TLS_RSA_EXPORT1024_WITH_RC4_56_SHA" },
175 { 0x000065, "TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA" },
176 { 0x000066, "TLS_DHE_DSS_WITH_RC4_128_SHA" },
177 { 0x000067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" },
178 { 0x000068, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256" },
179 { 0x000069, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256" },
180 { 0x00006A, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" },
181 { 0x00006B, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" },
182 { 0x00006C, "TLS_DH_anon_WITH_AES_128_CBC_SHA256" },
183 { 0x00006D, "TLS_DH_anon_WITH_AES_256_CBC_SHA256" },
184 /* 0x00,0x6E-83 Unassigned */
185 { 0x000084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" },
186 { 0x000085, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA" },
187 { 0x000086, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA" },
188 { 0x000087, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" },
189 { 0x000088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" },
190 { 0x000089, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" },
192 { 0x00008A, "TLS_PSK_WITH_RC4_128_SHA" },
193 { 0x00008B, "TLS_PSK_WITH_3DES_EDE_CBC_SHA" },
194 { 0x00008C, "TLS_PSK_WITH_AES_128_CBC_SHA" },
195 { 0x00008D, "TLS_PSK_WITH_AES_256_CBC_SHA" },
196 { 0x00008E, "TLS_DHE_PSK_WITH_RC4_128_SHA" },
197 { 0x00008F, "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" },
198 { 0x000090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" },
199 { 0x000091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" },
200 { 0x000092, "TLS_RSA_PSK_WITH_RC4_128_SHA" },
201 { 0x000093, "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" },
202 { 0x000094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" },
203 { 0x000095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" },
205 { 0x000096, "TLS_RSA_WITH_SEED_CBC_SHA" },
206 { 0x000097, "TLS_DH_DSS_WITH_SEED_CBC_SHA" },
207 { 0x000098, "TLS_DH_RSA_WITH_SEED_CBC_SHA" },
208 { 0x000099, "TLS_DHE_DSS_WITH_SEED_CBC_SHA" },
209 { 0x00009A, "TLS_DHE_RSA_WITH_SEED_CBC_SHA" },
210 { 0x00009B, "TLS_DH_anon_WITH_SEED_CBC_SHA" },
212 { 0x00009C, "TLS_RSA_WITH_AES_128_GCM_SHA256" },
213 { 0x00009D, "TLS_RSA_WITH_AES_256_GCM_SHA384" },
214 { 0x00009E, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" },
215 { 0x00009F, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" },
216 { 0x0000A0, "TLS_DH_RSA_WITH_AES_128_GCM_SHA256" },
217 { 0x0000A1, "TLS_DH_RSA_WITH_AES_256_GCM_SHA384" },
218 { 0x0000A2, "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" },
219 { 0x0000A3, "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" },
220 { 0x0000A4, "TLS_DH_DSS_WITH_AES_128_GCM_SHA256" },
221 { 0x0000A5, "TLS_DH_DSS_WITH_AES_256_GCM_SHA384" },
222 { 0x0000A6, "TLS_DH_anon_WITH_AES_128_GCM_SHA256" },
223 { 0x0000A7, "TLS_DH_anon_WITH_AES_256_GCM_SHA384" },
225 { 0x0000A8, "TLS_PSK_WITH_AES_128_GCM_SHA256" },
226 { 0x0000A9, "TLS_PSK_WITH_AES_256_GCM_SHA384" },
227 { 0x0000AA, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" },
228 { 0x0000AB, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" },
229 { 0x0000AC, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" },
230 { 0x0000AD, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" },
231 { 0x0000AE, "TLS_PSK_WITH_AES_128_CBC_SHA256" },
232 { 0x0000AF, "TLS_PSK_WITH_AES_256_CBC_SHA384" },
233 { 0x0000B0, "TLS_PSK_WITH_NULL_SHA256" },
234 { 0x0000B1, "TLS_PSK_WITH_NULL_SHA384" },
235 { 0x0000B2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" },
236 { 0x0000B3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" },
237 { 0x0000B4, "TLS_DHE_PSK_WITH_NULL_SHA256" },
238 { 0x0000B5, "TLS_DHE_PSK_WITH_NULL_SHA384" },
239 { 0x0000B6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" },
240 { 0x0000B7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" },
241 { 0x0000B8, "TLS_RSA_PSK_WITH_NULL_SHA256" },
242 { 0x0000B9, "TLS_RSA_PSK_WITH_NULL_SHA384" },
244 { 0x0000BA, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
245 { 0x0000BB, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256" },
246 { 0x0000BC, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
247 { 0x0000BD, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" },
248 { 0x0000BE, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
249 { 0x0000BF, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" },
250 { 0x0000C0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
251 { 0x0000C1, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256" },
252 { 0x0000C2, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
253 { 0x0000C3, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" },
254 { 0x0000C4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
255 { 0x0000C5, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" },
256 /* 0x00,0xC6-FE Unassigned */
257 { 0x0000FF, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" },
258 /* 0x01-BF,* Unassigned */
260 { 0x00c001, "TLS_ECDH_ECDSA_WITH_NULL_SHA" },
261 { 0x00c002, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA" },
262 { 0x00c003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA" },
263 { 0x00c004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA" },
264 { 0x00c005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA" },
265 { 0x00c006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA" },
266 { 0x00c007, "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" },
267 { 0x00c008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" },
268 { 0x00c009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" },
269 { 0x00c00a, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" },
270 { 0x00c00b, "TLS_ECDH_RSA_WITH_NULL_SHA" },
271 { 0x00c00c, "TLS_ECDH_RSA_WITH_RC4_128_SHA" },
272 { 0x00c00d, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA" },
273 { 0x00c00e, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA" },
274 { 0x00c00f, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA" },
275 { 0x00c010, "TLS_ECDHE_RSA_WITH_NULL_SHA" },
276 { 0x00c011, "TLS_ECDHE_RSA_WITH_RC4_128_SHA" },
277 { 0x00c012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" },
278 { 0x00c013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" },
279 { 0x00c014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" },
280 { 0x00c015, "TLS_ECDH_anon_WITH_NULL_SHA" },
281 { 0x00c016, "TLS_ECDH_anon_WITH_RC4_128_SHA" },
282 { 0x00c017, "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" },
283 { 0x00c018, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" },
284 { 0x00c019, "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" },
286 { 0x00C01A, "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" },
287 { 0x00C01B, "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" },
288 { 0x00C01C, "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" },
289 { 0x00C01D, "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" },
290 { 0x00C01E, "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" },
291 { 0x00C01F, "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" },
292 { 0x00C020, "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" },
293 { 0x00C021, "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" },
294 { 0x00C022, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" },
296 { 0x00C023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" },
297 { 0x00C024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" },
298 { 0x00C025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256" },
299 { 0x00C026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384" },
300 { 0x00C027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" },
301 { 0x00C028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" },
302 { 0x00C029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256" },
303 { 0x00C02A, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384" },
304 { 0x00C02B, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" },
305 { 0x00C02C, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" },
306 { 0x00C02D, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256" },
307 { 0x00C02E, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384" },
308 { 0x00C02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" },
309 { 0x00C030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" },
310 { 0x00C031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256" },
311 { 0x00C032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384" },
313 { 0x00C033, "TLS_ECDHE_PSK_WITH_RC4_128_SHA" },
314 { 0x00C034, "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" },
315 { 0x00C035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" },
316 { 0x00C036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" },
317 { 0x00C037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" },
318 { 0x00C038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" },
319 { 0x00C039, "TLS_ECDHE_PSK_WITH_NULL_SHA" },
320 { 0x00C03A, "TLS_ECDHE_PSK_WITH_NULL_SHA256" },
321 { 0x00C03B, "TLS_ECDHE_PSK_WITH_NULL_SHA384" },
322 /* 0xC0,0x3C-FF Unassigned
324 0xFE,0x00-FD Unassigned
325 0xFE,0xFE-FF Reserved to avoid conflicts with widely deployed implementations [Pasi_Eronen]
326 0xFF,0x00-FF Reserved for Private Use [RFC5246]
329 /* http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305 */
330 { 0x00CC13, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
331 { 0x00CC14, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" },
332 { 0x00CC15, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
334 /* http://tools.ietf.org/html/draft-josefsson-salsa20-tls */
335 { 0x00E410, "TLS_RSA_WITH_ESTREAM_SALSA20_SHA1" },
336 { 0x00E411, "TLS_RSA_WITH_SALSA20_SHA1" },
337 { 0x00E412, "TLS_ECDHE_RSA_WITH_ESTREAM_SALSA20_SHA1" },
338 { 0x00E413, "TLS_ECDHE_RSA_WITH_SALSA20_SHA1" },
339 { 0x00E414, "TLS_ECDHE_ECDSA_WITH_ESTREAM_SALSA20_SHA1" },
340 { 0x00E415, "TLS_ECDHE_ECDSA_WITH_SALSA20_SHA1" },
341 { 0x00E416, "TLS_PSK_WITH_ESTREAM_SALSA20_SHA1" },
342 { 0x00E417, "TLS_PSK_WITH_SALSA20_SHA1" },
343 { 0x00E418, "TLS_ECDHE_PSK_WITH_ESTREAM_SALSA20_SHA1" },
344 { 0x00E419, "TLS_ECDHE_PSK_WITH_SALSA20_SHA1" },
345 { 0x00E41A, "TLS_RSA_PSK_WITH_ESTREAM_SALSA20_SHA1" },
346 { 0x00E41B, "TLS_RSA_PSK_WITH_SALSA20_SHA1" },
347 { 0x00E41C, "TLS_DHE_PSK_WITH_ESTREAM_SALSA20_SHA1" },
348 { 0x00E41D, "TLS_DHE_PSK_WITH_SALSA20_SHA1" },
349 { 0x00E41E, "TLS_DHE_RSA_WITH_ESTREAM_SALSA20_SHA1" },
350 { 0x00E41F, "TLS_DHE_RSA_WITH_SALSA20_SHA1" },
352 /* these from http://www.mozilla.org/projects/
353 security/pki/nss/ssl/fips-ssl-ciphersuites.html */
354 { 0x00fefe, "SSL_RSA_FIPS_WITH_DES_CBC_SHA"},
355 { 0x00feff, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA" },
356 { 0x00ffe0, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA" },
357 { 0x00ffe1, "SSL_RSA_FIPS_WITH_DES_CBC_SHA"},
358 /* note that ciphersuites of {0x00????} are TLS cipher suites in
359 * a sslv2 client hello message; the ???? above is the two-byte
360 * tls cipher suite id
363 { 0x010080, "SSL2_RC4_128_WITH_MD5" },
364 { 0x020080, "SSL2_RC4_128_EXPORT40_WITH_MD5" },
365 { 0x030080, "SSL2_RC2_CBC_128_CBC_WITH_MD5" },
366 { 0x040080, "SSL2_RC2_CBC_128_CBC_WITH_MD5" },
367 { 0x050080, "SSL2_IDEA_128_CBC_WITH_MD5" },
368 { 0x060040, "SSL2_DES_64_CBC_WITH_MD5" },
369 { 0x0700c0, "SSL2_DES_192_EDE3_CBC_WITH_MD5" },
370 { 0x080080, "SSL2_RC4_64_WITH_MD5" },
372 /* Microsoft's old PCT protocol. These are from Eric Rescorla's
373 book "SSL and TLS" */
374 { 0x800001, "PCT_SSL_CERT_TYPE | PCT1_CERT_X509" },
375 { 0x800003, "PCT_SSL_CERT_TYPE | PCT1_CERT_X509_CHAIN" },
376 { 0x810001, "PCT_SSL_HASH_TYPE | PCT1_HASH_MD5" },
377 { 0x810003, "PCT_SSL_HASH_TYPE | PCT1_HASH_SHA" },
378 { 0x820001, "PCT_SSL_EXCH_TYPE | PCT1_EXCH_RSA_PKCS1" },
379 { 0x830004, "PCT_SSL_CIPHER_TYPE_1ST_HALF | PCT1_CIPHER_RC4" },
380 { 0x842840, "PCT_SSL_CIPHER_TYPE_2ND_HALF | PCT1_ENC_BITS_40 | PCT1_MAC_BITS_128" },
381 { 0x848040, "PCT_SSL_CIPHER_TYPE_2ND_HALF | PCT1_ENC_BITS_128 | PCT1_MAC_BITS_128" },
382 { 0x8f8001, "PCT_SSL_COMPAT | PCT_VERSION_1" },
386 value_string_ext ssl_20_cipher_suites_ext = VALUE_STRING_EXT_INIT(ssl_20_cipher_suites);
389 const value_string ssl_extension_curves[] = {
415 { 26, "brainpoolP256r1" }, /* RFC 7027 */
416 { 27, "brainpoolP384r1" }, /* RFC 7027 */
417 { 28, "brainpoolP512r1" }, /* RFC 7027 */
418 { 0xFF01, "arbitrary_explicit_prime_curves" },
419 { 0xFF02, "arbitrary_explicit_char2_curves" },
423 const value_string ssl_curve_types[] = {
424 { 1, "explicit_prime" },
425 { 2, "explicit_char2" },
426 { 3, "named_curve" },
430 const value_string ssl_extension_ec_point_formats[] = {
431 { 0, "uncompressed" },
432 { 1, "ansiX962_compressed_prime" },
433 { 2, "ansiX962_compressed_char2" },
437 const value_string ssl_20_certificate_type[] = {
439 { 0x01, "X.509 Certificate" },
443 const value_string ssl_31_content_type[] = {
444 { 20, "Change Cipher Spec" },
447 { 23, "Application Data" },
452 const value_string ssl_versions[] = {
453 { 0xfefd, "DTLS 1.2" },
454 { 0xfeff, "DTLS 1.0" },
455 { 0x0100, "DTLS 1.0 (OpenSSL pre 0.9.8f)" },
456 { 0x0303, "TLS 1.2" },
457 { 0x0302, "TLS 1.1" },
458 { 0x0301, "TLS 1.0" },
459 { 0x0300, "SSL 3.0" },
460 { 0x0002, "SSL 2.0" },
465 /* XXX - would be used if we dissected the body of a Change Cipher Spec
467 const value_string ssl_31_change_cipher_spec[] = {
468 { 1, "Change Cipher Spec" },
473 const value_string ssl_31_alert_level[] = {
479 const value_string ssl_31_alert_description[] = {
480 { 0, "Close Notify" },
481 { 10, "Unexpected Message" },
482 { 20, "Bad Record MAC" },
483 { 21, "Decryption Failed" },
484 { 22, "Record Overflow" },
485 { 30, "Decompression Failure" },
486 { 40, "Handshake Failure" },
487 { 41, "No Certificate" },
488 { 42, "Bad Certificate" },
489 { 43, "Unsupported Certificate" },
490 { 44, "Certificate Revoked" },
491 { 45, "Certificate Expired" },
492 { 46, "Certificate Unknown" },
493 { 47, "Illegal Parameter" },
494 { 48, "Unknown CA" },
495 { 49, "Access Denied" },
496 { 50, "Decode Error" },
497 { 51, "Decrypt Error" },
498 { 60, "Export Restriction" },
499 { 70, "Protocol Version" },
500 { 71, "Insufficient Security" },
501 { 80, "Internal Error" },
502 { 86, "Inappropriate Fallback" },
503 { 90, "User Canceled" },
504 { 100, "No Renegotiation" },
505 { 110, "Unsupported Extension" },
506 { 111, "Certificate Unobtainable" },
507 { 112, "Unrecognized Name" },
508 { 113, "Bad Certificate Status Response" },
509 { 114, "Bad Certificate Hash Value" },
510 { 115, "Unknown PSK Identity" },
511 { 120, "No application Protocol" },
515 const value_string ssl_31_handshake_type[] = {
516 { SSL_HND_HELLO_REQUEST, "Hello Request" },
517 { SSL_HND_CLIENT_HELLO, "Client Hello" },
518 { SSL_HND_SERVER_HELLO, "Server Hello" },
519 { SSL_HND_HELLO_VERIFY_REQUEST, "Hello Verify Request"},
520 { SSL_HND_NEWSESSION_TICKET, "New Session Ticket" },
521 { SSL_HND_CERTIFICATE, "Certificate" },
522 { SSL_HND_SERVER_KEY_EXCHG, "Server Key Exchange" },
523 { SSL_HND_CERT_REQUEST, "Certificate Request" },
524 { SSL_HND_SVR_HELLO_DONE, "Server Hello Done" },
525 { SSL_HND_CERT_VERIFY, "Certificate Verify" },
526 { SSL_HND_CLIENT_KEY_EXCHG, "Client Key Exchange" },
527 { SSL_HND_FINISHED, "Finished" },
528 { SSL_HND_CERT_URL, "Client Certificate URL" },
529 { SSL_HND_CERT_STATUS, "Certificate Status" },
530 { SSL_HND_SUPPLEMENTAL_DATA, "Supplemental Data" },
531 { SSL_HND_ENCRYPTED_EXTS, "Encrypted Extensions" },
535 const value_string tls_heartbeat_type[] = {
541 const value_string tls_heartbeat_mode[] = {
542 { 1, "Peer allowed to send requests" },
543 { 2, "Peer not allowed to send requests" },
547 const value_string ssl_31_compression_method[] = {
555 /* XXX - would be used if we dissected a Signature, as would be
556 seen in a server key exchange or certificate verify message. */
557 const value_string ssl_31_key_exchange_algorithm[] = {
559 { 1, "Diffie Hellman" },
563 const value_string ssl_31_signature_algorithm[] = {
571 const value_string ssl_31_client_certificate_type[] = {
574 { 3, "RSA Fixed DH" },
575 { 4, "DSS Fixed DH" },
576 /* GOST certificate types */
577 /* Section 3.5 of draft-chudov-cryptopro-cptls-04 */
578 { 21, "GOST R 34.10-94" },
579 { 22, "GOST R 34.10-2001" },
580 /* END GOST certificate types */
581 { 64, "ECDSA Sign" },
582 { 65, "RSA Fixed ECDH" },
583 { 66, "ECDSA Fixed ECDH" },
588 /* XXX - would be used if we dissected exchange keys, as would be
589 seen in a client key exchange message. */
590 const value_string ssl_31_public_value_encoding[] = {
597 /* http://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml */
598 /* Note: sorted by ascending value so value_string_ext fcns can do a binary search */
599 static const value_string ssl_31_ciphersuite[] = {
600 /* RFC 2246, RFC 4346, RFC 5246 */
601 { 0x0000, "TLS_NULL_WITH_NULL_NULL" },
602 { 0x0001, "TLS_RSA_WITH_NULL_MD5" },
603 { 0x0002, "TLS_RSA_WITH_NULL_SHA" },
604 { 0x0003, "TLS_RSA_EXPORT_WITH_RC4_40_MD5" },
605 { 0x0004, "TLS_RSA_WITH_RC4_128_MD5" },
606 { 0x0005, "TLS_RSA_WITH_RC4_128_SHA" },
607 { 0x0006, "TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5" },
608 { 0x0007, "TLS_RSA_WITH_IDEA_CBC_SHA" },
609 { 0x0008, "TLS_RSA_EXPORT_WITH_DES40_CBC_SHA" },
610 { 0x0009, "TLS_RSA_WITH_DES_CBC_SHA" },
611 { 0x000a, "TLS_RSA_WITH_3DES_EDE_CBC_SHA" },
612 { 0x000b, "TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA" },
613 { 0x000c, "TLS_DH_DSS_WITH_DES_CBC_SHA" },
614 { 0x000d, "TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA" },
615 { 0x000e, "TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA" },
616 { 0x000f, "TLS_DH_RSA_WITH_DES_CBC_SHA" },
617 { 0x0010, "TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA" },
618 { 0x0011, "TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA" },
619 { 0x0012, "TLS_DHE_DSS_WITH_DES_CBC_SHA" },
620 { 0x0013, "TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA" },
621 { 0x0014, "TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA" },
622 { 0x0015, "TLS_DHE_RSA_WITH_DES_CBC_SHA" },
623 { 0x0016, "TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA" },
624 { 0x0017, "TLS_DH_anon_EXPORT_WITH_RC4_40_MD5" },
625 { 0x0018, "TLS_DH_anon_WITH_RC4_128_MD5" },
626 { 0x0019, "TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA" },
627 { 0x001a, "TLS_DH_anon_WITH_DES_CBC_SHA" },
628 { 0x001b, "TLS_DH_anon_WITH_3DES_EDE_CBC_SHA" },
630 { 0x001c, "SSL_FORTEZZA_KEA_WITH_NULL_SHA" },
631 { 0x001d, "SSL_FORTEZZA_KEA_WITH_FORTEZZA_CBC_SHA" },
632 #if 0 /* Because it clashes with KRB5, is never used any more, and is safe
633 to remove according to David Hopwood <david.hopwood@zetnet.co.uk>
634 of the ietf-tls list */
635 { 0x001e, "SSL_FORTEZZA_KEA_WITH_RC4_128_SHA" },
639 { 0x001E, "TLS_KRB5_WITH_DES_CBC_SHA" },
640 { 0x001F, "TLS_KRB5_WITH_3DES_EDE_CBC_SHA" },
641 { 0x0020, "TLS_KRB5_WITH_RC4_128_SHA" },
642 { 0x0021, "TLS_KRB5_WITH_IDEA_CBC_SHA" },
643 { 0x0022, "TLS_KRB5_WITH_DES_CBC_MD5" },
644 { 0x0023, "TLS_KRB5_WITH_3DES_EDE_CBC_MD5" },
645 { 0x0024, "TLS_KRB5_WITH_RC4_128_MD5" },
646 { 0x0025, "TLS_KRB5_WITH_IDEA_CBC_MD5" },
647 { 0x0026, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA" },
648 { 0x0027, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_SHA" },
649 { 0x0028, "TLS_KRB5_EXPORT_WITH_RC4_40_SHA" },
650 { 0x0029, "TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5" },
651 { 0x002A, "TLS_KRB5_EXPORT_WITH_RC2_CBC_40_MD5" },
652 { 0x002B, "TLS_KRB5_EXPORT_WITH_RC4_40_MD5" },
655 { 0x002C, "TLS_PSK_WITH_NULL_SHA" },
656 { 0x002D, "TLS_DHE_PSK_WITH_NULL_SHA" },
657 { 0x002E, "TLS_RSA_PSK_WITH_NULL_SHA" },
660 { 0x002F, "TLS_RSA_WITH_AES_128_CBC_SHA" },
661 { 0x0030, "TLS_DH_DSS_WITH_AES_128_CBC_SHA" },
662 { 0x0031, "TLS_DH_RSA_WITH_AES_128_CBC_SHA" },
663 { 0x0032, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA" },
664 { 0x0033, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA" },
665 { 0x0034, "TLS_DH_anon_WITH_AES_128_CBC_SHA" },
666 { 0x0035, "TLS_RSA_WITH_AES_256_CBC_SHA" },
667 { 0x0036, "TLS_DH_DSS_WITH_AES_256_CBC_SHA" },
668 { 0x0037, "TLS_DH_RSA_WITH_AES_256_CBC_SHA" },
669 { 0x0038, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" },
670 { 0x0039, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA" },
671 { 0x003A, "TLS_DH_anon_WITH_AES_256_CBC_SHA" },
672 { 0x003B, "TLS_RSA_WITH_NULL_SHA256" },
673 { 0x003C, "TLS_RSA_WITH_AES_128_CBC_SHA256" },
674 { 0x003D, "TLS_RSA_WITH_AES_256_CBC_SHA256" },
675 { 0x003E, "TLS_DH_DSS_WITH_AES_128_CBC_SHA256" },
676 { 0x003F, "TLS_DH_RSA_WITH_AES_128_CBC_SHA256" },
677 { 0x0040, "TLS_DHE_DSS_WITH_AES_128_CBC_SHA256" },
680 { 0x0041, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA" },
681 { 0x0042, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA" },
682 { 0x0043, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA" },
683 { 0x0044, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA" },
684 { 0x0045, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA" },
685 { 0x0046, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA" },
687 /* 0x00,0x60-66 Reserved to avoid conflicts with widely deployed implementations */
689 { 0x0060, "TLS_RSA_EXPORT1024_WITH_RC4_56_MD5" },
690 { 0x0061, "TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5" },
691 /* draft-ietf-tls-56-bit-ciphersuites-01.txt */
692 { 0x0062, "TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA" },
693 { 0x0063, "TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA" },
694 { 0x0064, "TLS_RSA_EXPORT1024_WITH_RC4_56_SHA" },
695 { 0x0065, "TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA" },
696 { 0x0066, "TLS_DHE_DSS_WITH_RC4_128_SHA" },
699 { 0x0067, "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256" },
700 { 0x0068, "TLS_DH_DSS_WITH_AES_256_CBC_SHA256" },
701 { 0x0069, "TLS_DH_RSA_WITH_AES_256_CBC_SHA256" },
702 { 0x006A, "TLS_DHE_DSS_WITH_AES_256_CBC_SHA256" },
703 { 0x006B, "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256" },
704 { 0x006C, "TLS_DH_anon_WITH_AES_128_CBC_SHA256" },
705 { 0x006D, "TLS_DH_anon_WITH_AES_256_CBC_SHA256" },
707 /* draft-chudov-cryptopro-cptls-04.txt */
708 { 0x0080, "TLS_GOSTR341094_WITH_28147_CNT_IMIT" },
709 { 0x0081, "TLS_GOSTR341001_WITH_28147_CNT_IMIT" },
710 { 0x0082, "TLS_GOSTR341094_WITH_NULL_GOSTR3411" },
711 { 0x0083, "TLS_GOSTR341001_WITH_NULL_GOSTR3411" },
714 { 0x0084, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA" },
715 { 0x0085, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA" },
716 { 0x0086, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA" },
717 { 0x0087, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA" },
718 { 0x0088, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA" },
719 { 0x0089, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA" },
722 { 0x008A, "TLS_PSK_WITH_RC4_128_SHA" },
723 { 0x008B, "TLS_PSK_WITH_3DES_EDE_CBC_SHA" },
724 { 0x008C, "TLS_PSK_WITH_AES_128_CBC_SHA" },
725 { 0x008D, "TLS_PSK_WITH_AES_256_CBC_SHA" },
726 { 0x008E, "TLS_DHE_PSK_WITH_RC4_128_SHA" },
727 { 0x008F, "TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA" },
728 { 0x0090, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA" },
729 { 0x0091, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA" },
730 { 0x0092, "TLS_RSA_PSK_WITH_RC4_128_SHA" },
731 { 0x0093, "TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA" },
732 { 0x0094, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA" },
733 { 0x0095, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA" },
736 { 0x0096, "TLS_RSA_WITH_SEED_CBC_SHA" },
737 { 0x0097, "TLS_DH_DSS_WITH_SEED_CBC_SHA" },
738 { 0x0098, "TLS_DH_RSA_WITH_SEED_CBC_SHA" },
739 { 0x0099, "TLS_DHE_DSS_WITH_SEED_CBC_SHA" },
740 { 0x009A, "TLS_DHE_RSA_WITH_SEED_CBC_SHA" },
741 { 0x009B, "TLS_DH_anon_WITH_SEED_CBC_SHA" },
744 { 0x009C, "TLS_RSA_WITH_AES_128_GCM_SHA256" },
745 { 0x009D, "TLS_RSA_WITH_AES_256_GCM_SHA384" },
746 { 0x009E, "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256" },
747 { 0x009F, "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384" },
748 { 0x00A0, "TLS_DH_RSA_WITH_AES_128_GCM_SHA256" },
749 { 0x00A1, "TLS_DH_RSA_WITH_AES_256_GCM_SHA384" },
750 { 0x00A2, "TLS_DHE_DSS_WITH_AES_128_GCM_SHA256" },
751 { 0x00A3, "TLS_DHE_DSS_WITH_AES_256_GCM_SHA384" },
752 { 0x00A4, "TLS_DH_DSS_WITH_AES_128_GCM_SHA256" },
753 { 0x00A5, "TLS_DH_DSS_WITH_AES_256_GCM_SHA384" },
754 { 0x00A6, "TLS_DH_anon_WITH_AES_128_GCM_SHA256" },
755 { 0x00A7, "TLS_DH_anon_WITH_AES_256_GCM_SHA384" },
758 { 0x00A8, "TLS_PSK_WITH_AES_128_GCM_SHA256" },
759 { 0x00A9, "TLS_PSK_WITH_AES_256_GCM_SHA384" },
760 { 0x00AA, "TLS_DHE_PSK_WITH_AES_128_GCM_SHA256" },
761 { 0x00AB, "TLS_DHE_PSK_WITH_AES_256_GCM_SHA384" },
762 { 0x00AC, "TLS_RSA_PSK_WITH_AES_128_GCM_SHA256" },
763 { 0x00AD, "TLS_RSA_PSK_WITH_AES_256_GCM_SHA384" },
764 { 0x00AE, "TLS_PSK_WITH_AES_128_CBC_SHA256" },
765 { 0x00AF, "TLS_PSK_WITH_AES_256_CBC_SHA384" },
766 { 0x00B0, "TLS_PSK_WITH_NULL_SHA256" },
767 { 0x00B1, "TLS_PSK_WITH_NULL_SHA384" },
768 { 0x00B2, "TLS_DHE_PSK_WITH_AES_128_CBC_SHA256" },
769 { 0x00B3, "TLS_DHE_PSK_WITH_AES_256_CBC_SHA384" },
770 { 0x00B4, "TLS_DHE_PSK_WITH_NULL_SHA256" },
771 { 0x00B5, "TLS_DHE_PSK_WITH_NULL_SHA384" },
772 { 0x00B6, "TLS_RSA_PSK_WITH_AES_128_CBC_SHA256" },
773 { 0x00B7, "TLS_RSA_PSK_WITH_AES_256_CBC_SHA384" },
774 { 0x00B8, "TLS_RSA_PSK_WITH_NULL_SHA256" },
775 { 0x00B9, "TLS_RSA_PSK_WITH_NULL_SHA384" },
778 { 0x00BA, "TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
779 { 0x00BB, "TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256" },
780 { 0x00BC, "TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
781 { 0x00BD, "TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256" },
782 { 0x00BE, "TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
783 { 0x00BF, "TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256" },
784 { 0x00C0, "TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
785 { 0x00C1, "TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256" },
786 { 0x00C2, "TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
787 { 0x00C3, "TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256" },
788 { 0x00C4, "TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256" },
789 { 0x00C5, "TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256" },
790 /* 0x00,0xC6-FE Unassigned */
792 { 0x00FF, "TLS_EMPTY_RENEGOTIATION_INFO_SCSV" },
794 { 0x5600, "TLS_FALLBACK_SCSV" },
796 { 0xc001, "TLS_ECDH_ECDSA_WITH_NULL_SHA" },
797 { 0xc002, "TLS_ECDH_ECDSA_WITH_RC4_128_SHA" },
798 { 0xc003, "TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA" },
799 { 0xc004, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA" },
800 { 0xc005, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA" },
801 { 0xc006, "TLS_ECDHE_ECDSA_WITH_NULL_SHA" },
802 { 0xc007, "TLS_ECDHE_ECDSA_WITH_RC4_128_SHA" },
803 { 0xc008, "TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA" },
804 { 0xc009, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA" },
805 { 0xc00a, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA" },
806 { 0xc00b, "TLS_ECDH_RSA_WITH_NULL_SHA" },
807 { 0xc00c, "TLS_ECDH_RSA_WITH_RC4_128_SHA" },
808 { 0xc00d, "TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA" },
809 { 0xc00e, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA" },
810 { 0xc00f, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA" },
811 { 0xc010, "TLS_ECDHE_RSA_WITH_NULL_SHA" },
812 { 0xc011, "TLS_ECDHE_RSA_WITH_RC4_128_SHA" },
813 { 0xc012, "TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA" },
814 { 0xc013, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA" },
815 { 0xc014, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA" },
816 { 0xc015, "TLS_ECDH_anon_WITH_NULL_SHA" },
817 { 0xc016, "TLS_ECDH_anon_WITH_RC4_128_SHA" },
818 { 0xc017, "TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA" },
819 { 0xc018, "TLS_ECDH_anon_WITH_AES_128_CBC_SHA" },
820 { 0xc019, "TLS_ECDH_anon_WITH_AES_256_CBC_SHA" },
823 { 0xC01A, "TLS_SRP_SHA_WITH_3DES_EDE_CBC_SHA" },
824 { 0xC01B, "TLS_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA" },
825 { 0xC01C, "TLS_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA" },
826 { 0xC01D, "TLS_SRP_SHA_WITH_AES_128_CBC_SHA" },
827 { 0xC01E, "TLS_SRP_SHA_RSA_WITH_AES_128_CBC_SHA" },
828 { 0xC01F, "TLS_SRP_SHA_DSS_WITH_AES_128_CBC_SHA" },
829 { 0xC020, "TLS_SRP_SHA_WITH_AES_256_CBC_SHA" },
830 { 0xC021, "TLS_SRP_SHA_RSA_WITH_AES_256_CBC_SHA" },
831 { 0xC022, "TLS_SRP_SHA_DSS_WITH_AES_256_CBC_SHA" },
834 { 0xC023, "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256" },
835 { 0xC024, "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384" },
836 { 0xC025, "TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256" },
837 { 0xC026, "TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384" },
838 { 0xC027, "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256" },
839 { 0xC028, "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384" },
840 { 0xC029, "TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256" },
841 { 0xC02A, "TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384" },
842 { 0xC02B, "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" },
843 { 0xC02C, "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384" },
844 { 0xC02D, "TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256" },
845 { 0xC02E, "TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384" },
846 { 0xC02F, "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" },
847 { 0xC030, "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384" },
848 { 0xC031, "TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256" },
849 { 0xC032, "TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384" },
852 { 0xC033, "TLS_ECDHE_PSK_WITH_RC4_128_SHA" },
853 { 0xC034, "TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA" },
854 { 0xC035, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA" },
855 { 0xC036, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA" },
856 { 0xC037, "TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256" },
857 { 0xC038, "TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384" },
858 { 0xC039, "TLS_ECDHE_PSK_WITH_NULL_SHA" },
859 { 0xC03A, "TLS_ECDHE_PSK_WITH_NULL_SHA256" },
860 { 0xC03B, "TLS_ECDHE_PSK_WITH_NULL_SHA384" },
863 { 0xC03C, "TLS_RSA_WITH_ARIA_128_CBC_SHA256" },
864 { 0xC03D, "TLS_RSA_WITH_ARIA_256_CBC_SHA384" },
865 { 0xC03E, "TLS_DH_DSS_WITH_ARIA_128_CBC_SHA256" },
866 { 0xC03F, "TLS_DH_DSS_WITH_ARIA_256_CBC_SHA384" },
867 { 0xC040, "TLS_DH_RSA_WITH_ARIA_128_CBC_SHA256" },
868 { 0xC041, "TLS_DH_RSA_WITH_ARIA_256_CBC_SHA384" },
869 { 0xC042, "TLS_DHE_DSS_WITH_ARIA_128_CBC_SHA256" },
870 { 0xC043, "TLS_DHE_DSS_WITH_ARIA_256_CBC_SHA384" },
871 { 0xC044, "TLS_DHE_RSA_WITH_ARIA_128_CBC_SHA256" },
872 { 0xC045, "TLS_DHE_RSA_WITH_ARIA_256_CBC_SHA384" },
873 { 0xC046, "TLS_DH_anon_WITH_ARIA_128_CBC_SHA256" },
874 { 0xC047, "TLS_DH_anon_WITH_ARIA_256_CBC_SHA384" },
875 { 0xC048, "TLS_ECDHE_ECDSA_WITH_ARIA_128_CBC_SHA256" },
876 { 0xC049, "TLS_ECDHE_ECDSA_WITH_ARIA_256_CBC_SHA384" },
877 { 0xC04A, "TLS_ECDH_ECDSA_WITH_ARIA_128_CBC_SHA256" },
878 { 0xC04B, "TLS_ECDH_ECDSA_WITH_ARIA_256_CBC_SHA384" },
879 { 0xC04C, "TLS_ECDHE_RSA_WITH_ARIA_128_CBC_SHA256" },
880 { 0xC04D, "TLS_ECDHE_RSA_WITH_ARIA_256_CBC_SHA384" },
881 { 0xC04E, "TLS_ECDH_RSA_WITH_ARIA_128_CBC_SHA256" },
882 { 0xC04F, "TLS_ECDH_RSA_WITH_ARIA_256_CBC_SHA384" },
883 { 0xC050, "TLS_RSA_WITH_ARIA_128_GCM_SHA256" },
884 { 0xC051, "TLS_RSA_WITH_ARIA_256_GCM_SHA384" },
885 { 0xC052, "TLS_DHE_RSA_WITH_ARIA_128_GCM_SHA256" },
886 { 0xC053, "TLS_DHE_RSA_WITH_ARIA_256_GCM_SHA384" },
887 { 0xC054, "TLS_DH_RSA_WITH_ARIA_128_GCM_SHA256" },
888 { 0xC055, "TLS_DH_RSA_WITH_ARIA_256_GCM_SHA384" },
889 { 0xC056, "TLS_DHE_DSS_WITH_ARIA_128_GCM_SHA256" },
890 { 0xC057, "TLS_DHE_DSS_WITH_ARIA_256_GCM_SHA384" },
891 { 0xC058, "TLS_DH_DSS_WITH_ARIA_128_GCM_SHA256" },
892 { 0xC059, "TLS_DH_DSS_WITH_ARIA_256_GCM_SHA384" },
893 { 0xC05A, "TLS_DH_anon_WITH_ARIA_128_GCM_SHA256" },
894 { 0xC05B, "TLS_DH_anon_WITH_ARIA_256_GCM_SHA384" },
895 { 0xC05C, "TLS_ECDHE_ECDSA_WITH_ARIA_128_GCM_SHA256" },
896 { 0xC05D, "TLS_ECDHE_ECDSA_WITH_ARIA_256_GCM_SHA384" },
897 { 0xC05E, "TLS_ECDH_ECDSA_WITH_ARIA_128_GCM_SHA256" },
898 { 0xC05F, "TLS_ECDH_ECDSA_WITH_ARIA_256_GCM_SHA384" },
899 { 0xC060, "TLS_ECDHE_RSA_WITH_ARIA_128_GCM_SHA256" },
900 { 0xC061, "TLS_ECDHE_RSA_WITH_ARIA_256_GCM_SHA384" },
901 { 0xC062, "TLS_ECDH_RSA_WITH_ARIA_128_GCM_SHA256" },
902 { 0xC063, "TLS_ECDH_RSA_WITH_ARIA_256_GCM_SHA384" },
903 { 0xC064, "TLS_PSK_WITH_ARIA_128_CBC_SHA256" },
904 { 0xC065, "TLS_PSK_WITH_ARIA_256_CBC_SHA384" },
905 { 0xC066, "TLS_DHE_PSK_WITH_ARIA_128_CBC_SHA256" },
906 { 0xC067, "TLS_DHE_PSK_WITH_ARIA_256_CBC_SHA384" },
907 { 0xC068, "TLS_RSA_PSK_WITH_ARIA_128_CBC_SHA256" },
908 { 0xC069, "TLS_RSA_PSK_WITH_ARIA_256_CBC_SHA384" },
909 { 0xC06A, "TLS_PSK_WITH_ARIA_128_GCM_SHA256" },
910 { 0xC06B, "TLS_PSK_WITH_ARIA_256_GCM_SHA384" },
911 { 0xC06C, "TLS_DHE_PSK_WITH_ARIA_128_GCM_SHA256" },
912 { 0xC06D, "TLS_DHE_PSK_WITH_ARIA_256_GCM_SHA384" },
913 { 0xC06E, "TLS_RSA_PSK_WITH_ARIA_128_GCM_SHA256" },
914 { 0xC06F, "TLS_RSA_PSK_WITH_ARIA_256_GCM_SHA384" },
915 { 0xC070, "TLS_ECDHE_PSK_WITH_ARIA_128_CBC_SHA256" },
916 { 0xC071, "TLS_ECDHE_PSK_WITH_ARIA_256_CBC_SHA384" },
919 { 0xC072, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" },
920 { 0xC073, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" },
921 { 0xC074, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256" },
922 { 0xC075, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384" },
923 { 0xC076, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
924 { 0xC077, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384" },
925 { 0xC078, "TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256" },
926 { 0xC079, "TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384" },
927 { 0xC07A, "TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
928 { 0xC07B, "TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
929 { 0xC07C, "TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
930 { 0xC07D, "TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
931 { 0xC07E, "TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
932 { 0xC07F, "TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
933 { 0xC080, "TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256" },
934 { 0xC081, "TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384" },
935 { 0xC082, "TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256" },
936 { 0xC083, "TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384" },
937 { 0xC084, "TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256" },
938 { 0xC085, "TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384" },
939 { 0xC086, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256" },
940 { 0xC087, "TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384" },
941 { 0xC088, "TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256" },
942 { 0xC089, "TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384" },
943 { 0xC08A, "TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
944 { 0xC08B, "TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
945 { 0xC08C, "TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256" },
946 { 0xC08D, "TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384" },
947 { 0xC08E, "TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256" },
948 { 0xC08F, "TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384" },
949 { 0xC090, "TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256" },
950 { 0xC091, "TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384" },
951 { 0xC092, "TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256" },
952 { 0xC093, "TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384" },
953 { 0xC094, "TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256" },
954 { 0xC095, "TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384" },
955 { 0xC096, "TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" },
956 { 0xC097, "TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" },
957 { 0xC098, "TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256" },
958 { 0xC099, "TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384" },
959 { 0xC09A, "TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256" },
960 { 0xC09B, "TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384" },
963 { 0xC09C, "TLS_RSA_WITH_AES_128_CCM" },
964 { 0xC09D, "TLS_RSA_WITH_AES_256_CCM" },
965 { 0xC09E, "TLS_DHE_RSA_WITH_AES_128_CCM" },
966 { 0xC09F, "TLS_DHE_RSA_WITH_AES_256_CCM" },
967 { 0xC0A0, "TLS_RSA_WITH_AES_128_CCM_8" },
968 { 0xC0A1, "TLS_RSA_WITH_AES_256_CCM_8" },
969 { 0xC0A2, "TLS_DHE_RSA_WITH_AES_128_CCM_8" },
970 { 0xC0A3, "TLS_DHE_RSA_WITH_AES_256_CCM_8" },
971 { 0xC0A4, "TLS_PSK_WITH_AES_128_CCM" },
972 { 0xC0A5, "TLS_PSK_WITH_AES_256_CCM" },
973 { 0xC0A6, "TLS_DHE_PSK_WITH_AES_128_CCM" },
974 { 0xC0A7, "TLS_DHE_PSK_WITH_AES_256_CCM" },
975 { 0xC0A8, "TLS_PSK_WITH_AES_128_CCM_8" },
976 { 0xC0A9, "TLS_PSK_WITH_AES_256_CCM_8" },
977 { 0xC0AA, "TLS_PSK_DHE_WITH_AES_128_CCM_8" },
978 { 0xC0AB, "TLS_PSK_DHE_WITH_AES_256_CCM_8" },
981 { 0xC0AC, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM" },
982 { 0xC0AD, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM" },
983 { 0xC0AE, "TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8" },
984 { 0xC0AF, "TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8" },
986 0xC0,0xAB-FF Unassigned
988 0xFE,0x00-FD Unassigned
989 0xFE,0xFE-FF Reserved to avoid conflicts with widely deployed implementations [Pasi_Eronen]
990 0xFF,0x00-FF Reserved for Private Use [RFC5246]
993 /* http://tools.ietf.org/html/draft-agl-tls-chacha20poly1305 */
994 { 0xCC13, "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
995 { 0xCC14, "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" },
996 { 0xCC15, "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256" },
998 /* http://tools.ietf.org/html/draft-josefsson-salsa20-tls */
999 { 0xE410, "TLS_RSA_WITH_ESTREAM_SALSA20_SHA1" },
1000 { 0xE411, "TLS_RSA_WITH_SALSA20_SHA1" },
1001 { 0xE412, "TLS_ECDHE_RSA_WITH_ESTREAM_SALSA20_SHA1" },
1002 { 0xE413, "TLS_ECDHE_RSA_WITH_SALSA20_SHA1" },
1003 { 0xE414, "TLS_ECDHE_ECDSA_WITH_ESTREAM_SALSA20_SHA1" },
1004 { 0xE415, "TLS_ECDHE_ECDSA_WITH_SALSA20_SHA1" },
1005 { 0xE416, "TLS_PSK_WITH_ESTREAM_SALSA20_SHA1" },
1006 { 0xE417, "TLS_PSK_WITH_SALSA20_SHA1" },
1007 { 0xE418, "TLS_ECDHE_PSK_WITH_ESTREAM_SALSA20_SHA1" },
1008 { 0xE419, "TLS_ECDHE_PSK_WITH_SALSA20_SHA1" },
1009 { 0xE41A, "TLS_RSA_PSK_WITH_ESTREAM_SALSA20_SHA1" },
1010 { 0xE41B, "TLS_RSA_PSK_WITH_SALSA20_SHA1" },
1011 { 0xE41C, "TLS_DHE_PSK_WITH_ESTREAM_SALSA20_SHA1" },
1012 { 0xE41D, "TLS_DHE_PSK_WITH_SALSA20_SHA1" },
1013 { 0xE41E, "TLS_DHE_RSA_WITH_ESTREAM_SALSA20_SHA1" },
1014 { 0xE41F, "TLS_DHE_RSA_WITH_SALSA20_SHA1" },
1016 /* these from http://www.mozilla.org/projects/
1017 security/pki/nss/ssl/fips-ssl-ciphersuites.html */
1018 { 0xfefe, "SSL_RSA_FIPS_WITH_DES_CBC_SHA"},
1019 { 0xfeff, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA" },
1020 { 0xffe0, "SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA" },
1021 { 0xffe1, "SSL_RSA_FIPS_WITH_DES_CBC_SHA"},
1022 /* note that ciphersuites 0xff00 - 0xffff are private */
1026 value_string_ext ssl_31_ciphersuite_ext = VALUE_STRING_EXT_INIT(ssl_31_ciphersuite);
1029 const value_string pct_msg_types[] = {
1030 { PCT_MSG_CLIENT_HELLO, "Client Hello" },
1031 { PCT_MSG_SERVER_HELLO, "Server Hello" },
1032 { PCT_MSG_CLIENT_MASTER_KEY, "Client Master Key" },
1033 { PCT_MSG_SERVER_VERIFY, "Server Verify" },
1034 { PCT_MSG_ERROR, "Error" },
1038 const value_string pct_cipher_type[] = {
1039 { PCT_CIPHER_DES, "DES" },
1040 { PCT_CIPHER_IDEA, "IDEA" },
1041 { PCT_CIPHER_RC2, "RC2" },
1042 { PCT_CIPHER_RC4, "RC4" },
1043 { PCT_CIPHER_DES_112, "DES 112 bit" },
1044 { PCT_CIPHER_DES_168, "DES 168 bit" },
1048 const value_string pct_hash_type[] = {
1049 { PCT_HASH_MD5, "MD5" },
1050 { PCT_HASH_MD5_TRUNC_64, "MD5_TRUNC_64"},
1051 { PCT_HASH_SHA, "SHA"},
1052 { PCT_HASH_SHA_TRUNC_80, "SHA_TRUNC_80"},
1053 { PCT_HASH_DES_DM, "DES_DM"},
1057 const value_string pct_cert_type[] = {
1058 { PCT_CERT_NONE, "None" },
1059 { PCT_CERT_X509, "X.509" },
1060 { PCT_CERT_PKCS7, "PKCS #7" },
1063 const value_string pct_sig_type[] = {
1064 { PCT_SIG_NONE, "None" },
1065 { PCT_SIG_RSA_MD5, "MD5" },
1066 { PCT_SIG_RSA_SHA, "RSA SHA" },
1067 { PCT_SIG_DSA_SHA, "DSA SHA" },
1071 const value_string pct_exch_type[] = {
1072 { PCT_EXCH_RSA_PKCS1, "RSA PKCS#1" },
1073 { PCT_EXCH_RSA_PKCS1_TOKEN_DES, "RSA PKCS#1 Token DES" },
1074 { PCT_EXCH_RSA_PKCS1_TOKEN_DES3, "RSA PKCS#1 Token 3DES" },
1075 { PCT_EXCH_RSA_PKCS1_TOKEN_RC2, "RSA PKCS#1 Token RC-2" },
1076 { PCT_EXCH_RSA_PKCS1_TOKEN_RC4, "RSA PKCS#1 Token RC-4" },
1077 { PCT_EXCH_DH_PKCS3, "DH PKCS#3" },
1078 { PCT_EXCH_DH_PKCS3_TOKEN_DES, "DH PKCS#3 Token DES" },
1079 { PCT_EXCH_DH_PKCS3_TOKEN_DES3, "DH PKCS#3 Token 3DES" },
1080 { PCT_EXCH_FORTEZZA_TOKEN, "Fortezza" },
1084 const value_string pct_error_code[] = {
1085 { PCT_ERR_BAD_CERTIFICATE, "PCT_ERR_BAD_CERTIFICATE" },
1086 { PCT_ERR_CLIENT_AUTH_FAILED, "PCT_ERR_CLIENT_AUTH_FAILE" },
1087 { PCT_ERR_ILLEGAL_MESSAGE, "PCT_ERR_ILLEGAL_MESSAGE" },
1088 { PCT_ERR_INTEGRITY_CHECK_FAILED, "PCT_ERR_INTEGRITY_CHECK_FAILED" },
1089 { PCT_ERR_SERVER_AUTH_FAILED, "PCT_ERR_SERVER_AUTH_FAILED" },
1090 { PCT_ERR_SPECS_MISMATCH, "PCT_ERR_SPECS_MISMATCH" },
1094 /* http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#tls-extensiontype-values-1 */
1095 const value_string tls_hello_extension_types[] = {
1096 { SSL_HND_HELLO_EXT_SERVER_NAME, "server_name" }, /* RFC 3546 */
1097 { 1, "max_fragment_length" },
1098 { 2, "client_certificate_url" },
1099 { 3, "trusted_ca_keys" },
1100 { 4, "truncated_hmac" },
1101 { SSL_HND_HELLO_EXT_STATUS_REQUEST, "status_request" }, /* RFC 6066 */
1102 { 6, "user_mapping" }, /* RFC 4681 */
1103 { 7, "client_authz" },
1104 { 8, "server_authz" },
1105 { SSL_HND_HELLO_EXT_CERT_TYPE, "cert_type" }, /* RFC 5081 */
1106 { SSL_HND_HELLO_EXT_ELLIPTIC_CURVES, "elliptic_curves" }, /* RFC 4492 */
1107 { SSL_HND_HELLO_EXT_EC_POINT_FORMATS, "ec_point_formats" }, /* RFC 4492 */
1108 { 12, "srp" }, /* RFC 5054 */
1109 { 13, "signature_algorithms" }, /* RFC 5246 */
1111 { SSL_HND_HELLO_EXT_HEARTBEAT, "Heartbeat" }, /* RFC 6520 */
1112 { SSL_HND_HELLO_EXT_ALPN, "Application Layer Protocol Negotiation" }, /* RFC 7301 */
1113 { SSL_HND_HELLO_EXT_STATUS_REQUEST_V2, "status_request_v2" }, /* RFC 6961 */
1114 { 18, "signed_certificate_timestamp" }, /* RFC 6962 */
1115 { SSL_HND_HELLO_EXT_CLIENT_CERT_TYPE, "client_certificate_type" }, /* RFC 7250 */
1116 { SSL_HND_HELLO_EXT_SERVER_CERT_TYPE, "server_certificate_type" }, /* RFC 7250 */
1117 { SSL_HND_HELLO_EXT_PADDING, "Padding" }, /* http://tools.ietf.org/html/draft-agl-tls-padding */
1118 { SSL_HND_HELLO_EXT_EXTENDED_MASTER_SECRET_TYPE, "Extended Master Secret" }, /* https://tools.ietf.org/html/draft-ietf-tls-session-hash-01 */
1119 { SSL_HND_HELLO_EXT_SESSION_TICKET, "SessionTicket TLS" }, /* RFC 4507 */
1120 { SSL_HND_HELLO_EXT_NPN, "next_protocol_negotiation"}, /* http://technotes.googlecode.com/git/nextprotoneg.html */
1121 { SSL_HND_HELLO_EXT_RENEG_INFO, "renegotiation_info" }, /* RFC 5746 */
1122 /* http://tools.ietf.org/html/draft-balfanz-tls-channelid-00
1123 https://twitter.com/ericlaw/status/274237352531083264 */
1124 { SSL_HND_HELLO_EXT_CHANNEL_ID_OLD, "channel_id_old" },
1125 /* http://tools.ietf.org/html/draft-balfanz-tls-channelid-01
1126 https://code.google.com/p/chromium/codesearch#chromium/src/net/third_party/nss/ssl/sslt.h&l=209 */
1127 { SSL_HND_HELLO_EXT_CHANNEL_ID, "channel_id" },
1131 const value_string tls_hello_ext_server_name_type_vs[] = {
1136 /* RFC 5246 7.4.1.4.1 */
1137 const value_string tls_hash_algorithm[] = {
1148 const value_string tls_signature_algorithm[] = {
1157 const value_string tls_certificate_type[] = {
1160 { SSL_HND_CERT_TYPE_RAW_PUBLIC_KEY, "Raw Public Key" }, /* RFC 7250 */
1164 const value_string tls_cert_chain_type[] = {
1165 { SSL_HND_CERT_URL_TYPE_INDIVIDUAL_CERT, "Individual Certificates" },
1166 { SSL_HND_CERT_URL_TYPE_PKIPATH, "PKI Path" },
1170 const value_string tls_cert_status_type[] = {
1171 { SSL_HND_CERT_STATUS_TYPE_OCSP, "OCSP" },
1172 { SSL_HND_CERT_STATUS_TYPE_OCSP_MULTI, "OCSP Multi" },
1176 /* string_string is inappropriate as it compares strings while
1177 * "byte strings MUST NOT be truncated" (RFC 7301) */
1178 typedef struct ssl_alpn_protocol {
1179 const guint8 *proto_name;
1180 size_t proto_name_len;
1181 const char *dissector_name;
1182 } ssl_alpn_protocol_t;
1183 /* http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids */
1184 static const ssl_alpn_protocol_t ssl_alpn_protocols[] = {
1185 { "http/1.1", sizeof("http/1.1"), "http" },
1186 /* SPDY moves so fast, just 1, 2 and 3 are registered with IANA but there
1187 * already exists 3.1 as of this writing... match the prefix. */
1188 { "spdy/", sizeof("spdy/") - 1, "spdy" },
1189 { "stun.turn", sizeof("stun.turn"), "turnchannel" },
1190 { "stun.nat-discovery", sizeof("stun.nat-discovery"), "stun" },
1191 /* draft-ietf-httpbis-http2-16 */
1192 { "h2-", sizeof("h2-") - 1, "http2" }, /* draft versions */
1193 { "h2", sizeof("h2"), "http2" }, /* final version */
1196 /* we keep this internal to packet-ssl-utils, as there should be
1197 no need to access it any other way.
1199 This also allows us to hide the dependency on zlib.
1201 struct _SslDecompress {
1208 /* To assist in parsing client/server key exchange messages
1209 0 indicates unknown */
1210 gint ssl_get_keyex_alg(gint cipher)
1336 return KEX_ECDH_ANON;
1350 return KEX_ECDH_ECDSA;
1364 return KEX_ECDH_RSA;
1384 return KEX_ECDHE_ECDSA;
1398 return KEX_ECDHE_PSK;
1414 return KEX_ECDHE_RSA;
1518 return KEX_SRP_SHA_DSS;
1522 return KEX_SRP_SHA_RSA;
1534 ssl_data_alloc(StringInfo* str, size_t len)
1536 str->data = (guchar *)g_malloc(len);
1537 /* the allocator can return a null pointer for a size equal to 0,
1538 * and that must be allowed */
1539 if (len > 0 && !str->data)
1541 str->data_len = (guint) len;
1546 ssl_data_set(StringInfo* str, const guchar* data, guint len)
1548 DISSECTOR_ASSERT(data);
1549 memcpy(str->data, data, len);
1550 str->data_len = len;
1554 ssl_data_clone(StringInfo *str)
1556 StringInfo *cloned_str;
1557 cloned_str = (StringInfo *) wmem_alloc0(wmem_file_scope(),
1558 sizeof(StringInfo) + str->data_len);
1559 cloned_str->data = (guchar *) (cloned_str + 1);
1560 ssl_data_set(cloned_str, str->data, str->data_len);
1564 /* from_hex converts |hex_len| bytes of hex data from |in| and sets |*out| to
1565 * the result. |out->data| will be allocated using wmem_file_scope. Returns TRUE on
1567 static gboolean from_hex(StringInfo* out, const char* in, gsize hex_len) {
1573 out->data = (guchar *)wmem_alloc(wmem_file_scope(), hex_len / 2);
1574 for (i = 0; i < hex_len / 2; i++) {
1575 int a = ws_xton(in[i*2]);
1576 int b = ws_xton(in[i*2 + 1]);
1577 if (a == -1 || b == -1)
1579 out->data[i] = a << 4 | b;
1581 out->data_len = (guint)hex_len / 2;
1586 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
1588 /* hmac abstraction layer */
1589 #define SSL_HMAC gcry_md_hd_t
1592 ssl_hmac_init(SSL_HMAC* md, const void * key, gint len, gint algo)
1595 const char *err_str, *err_src;
1597 err = gcry_md_open(md,algo, GCRY_MD_FLAG_HMAC);
1599 err_str = gcry_strerror(err);
1600 err_src = gcry_strsource(err);
1601 ssl_debug_printf("ssl_hmac_init(): gcry_md_open failed %s/%s", err_str, err_src);
1604 gcry_md_setkey (*(md), key, len);
1608 ssl_hmac_update(SSL_HMAC* md, const void* data, gint len)
1610 gcry_md_write(*(md), data, len);
1613 ssl_hmac_final(SSL_HMAC* md, guchar* data, guint* datalen)
1618 algo = gcry_md_get_algo (*(md));
1619 len = gcry_md_get_algo_dlen(algo);
1620 DISSECTOR_ASSERT(len <= *datalen);
1621 memcpy(data, gcry_md_read(*(md), algo), len);
1625 ssl_hmac_cleanup(SSL_HMAC* md)
1627 gcry_md_close(*(md));
1630 /* memory digest abstraction layer*/
1631 #define SSL_MD gcry_md_hd_t
1634 ssl_md_init(SSL_MD* md, gint algo)
1637 const char *err_str, *err_src;
1638 err = gcry_md_open(md,algo, 0);
1640 err_str = gcry_strerror(err);
1641 err_src = gcry_strsource(err);
1642 ssl_debug_printf("ssl_md_init(): gcry_md_open failed %s/%s", err_str, err_src);
1648 ssl_md_update(SSL_MD* md, guchar* data, gint len)
1650 gcry_md_write(*(md), data, len);
1653 ssl_md_final(SSL_MD* md, guchar* data, guint* datalen)
1657 algo = gcry_md_get_algo (*(md));
1658 len = gcry_md_get_algo_dlen (algo);
1659 memcpy(data, gcry_md_read(*(md), algo), len);
1663 ssl_md_cleanup(SSL_MD* md)
1665 gcry_md_close(*(md));
1668 /* md5 /sha abstraction layer */
1669 #define SSL_SHA_CTX gcry_md_hd_t
1670 #define SSL_MD5_CTX gcry_md_hd_t
1673 ssl_sha_init(SSL_SHA_CTX* md)
1675 gcry_md_open(md,GCRY_MD_SHA1, 0);
1678 ssl_sha_update(SSL_SHA_CTX* md, guchar* data, gint len)
1680 gcry_md_write(*(md), data, len);
1683 ssl_sha_final(guchar* buf, SSL_SHA_CTX* md)
1685 memcpy(buf, gcry_md_read(*(md), GCRY_MD_SHA1),
1686 gcry_md_get_algo_dlen(GCRY_MD_SHA1));
1689 ssl_sha_cleanup(SSL_SHA_CTX* md)
1691 gcry_md_close(*(md));
1695 ssl_md5_init(SSL_MD5_CTX* md)
1697 return gcry_md_open(md,GCRY_MD_MD5, 0);
1700 ssl_md5_update(SSL_MD5_CTX* md, guchar* data, gint len)
1702 gcry_md_write(*(md), data, len);
1705 ssl_md5_final(guchar* buf, SSL_MD5_CTX* md)
1707 memcpy(buf, gcry_md_read(*(md), GCRY_MD_MD5),
1708 gcry_md_get_algo_dlen(GCRY_MD_MD5));
1711 ssl_md5_cleanup(SSL_MD5_CTX* md)
1713 gcry_md_close(*(md));
1717 ssl_cipher_setiv(SSL_CIPHER_CTX *cipher, guchar* iv, gint iv_len)
1724 c=(gcry_cipher_hd_t)*cipher;
1726 ssl_debug_printf("--------------------------------------------------------------------");
1728 for(ivp=c->iv,i=0; i < iv_len; i++ )
1730 ssl_debug_printf("%d ",ivp[i]);
1734 ssl_debug_printf("--------------------------------------------------------------------");
1735 ret = gcry_cipher_setiv(*(cipher), iv, iv_len);
1737 for(ivp=c->iv,i=0; i < iv_len; i++ )
1739 ssl_debug_printf("%d ",ivp[i]);
1743 ssl_debug_printf("--------------------------------------------------------------------");
1746 /* stream cipher abstraction layer*/
1748 ssl_cipher_init(gcry_cipher_hd_t *cipher, gint algo, guchar* sk,
1749 guchar* iv, gint mode)
1751 gint gcry_modes[]={GCRY_CIPHER_MODE_STREAM,GCRY_CIPHER_MODE_CBC,GCRY_CIPHER_MODE_CTR,GCRY_CIPHER_MODE_CTR,GCRY_CIPHER_MODE_CTR};
1755 *(cipher) = (gcry_cipher_hd_t)-1;
1758 err = gcry_cipher_open(cipher, algo, gcry_modes[mode], 0);
1761 err = gcry_cipher_setkey(*(cipher), sk, gcry_cipher_get_algo_keylen (algo));
1764 err = gcry_cipher_setiv(*(cipher), iv, gcry_cipher_get_algo_blklen (algo));
1770 ssl_cipher_decrypt(gcry_cipher_hd_t *cipher, guchar * out, gint outl,
1771 const guchar * in, gint inl)
1773 if ((*cipher) == (gcry_cipher_hd_t)-1)
1776 memcpy(out, in, outl < inl ? outl : inl);
1779 return gcry_cipher_decrypt ( *(cipher), out, outl, in, inl);
1782 ssl_get_digest_by_name(const gchar*name)
1784 return gcry_md_map_name(name);
1787 ssl_get_cipher_by_name(const gchar* name)
1789 return gcry_cipher_map_name(name);
1793 ssl_cipher_cleanup(gcry_cipher_hd_t *cipher)
1795 if ((*cipher) != (gcry_cipher_hd_t)-1)
1796 gcry_cipher_close(*cipher);
1801 _gcry_rsa_decrypt (int algo, gcry_mpi_t *result, gcry_mpi_t *data,
1802 gcry_mpi_t *skey, gint flags);
1804 /* decrypt data with private key. Store decrypted data directly into input
1807 ssl_private_decrypt(const guint len, guchar* data, gcry_sexp_t pk)
1810 size_t decr_len = 0, i = 0;
1811 gcry_sexp_t s_data = NULL, s_plain = NULL;
1812 gcry_mpi_t encr_mpi = NULL, text = NULL;
1814 /* create mpi representation of encrypted data */
1815 rc = gcry_mpi_scan(&encr_mpi, GCRYMPI_FMT_USG, data, len, NULL);
1817 ssl_debug_printf("pcry_private_decrypt: can't convert data to mpi (size %d):%s\n",
1818 len, gcry_strerror(rc));
1822 /* put the data into a simple list */
1823 rc = gcry_sexp_build(&s_data, NULL, "(enc-val(rsa(a%m)))", encr_mpi);
1825 ssl_debug_printf("pcry_private_decrypt: can't build encr_sexp:%s\n",
1831 /* pass it to libgcrypt */
1832 rc = gcry_pk_decrypt(&s_plain, s_data, pk);
1835 ssl_debug_printf("pcry_private_decrypt: can't decrypt key:%s\n",
1841 /* convert plain text sexp to mpi format */
1842 text = gcry_sexp_nth_mpi(s_plain, 0, 0);
1844 ssl_debug_printf("pcry_private_decrypt: can't convert sexp to mpi\n");
1849 /* compute size requested for plaintext buffer */
1850 rc = gcry_mpi_print(GCRYMPI_FMT_USG, NULL, 0, &decr_len, text);
1852 ssl_debug_printf("pcry_private_decrypt: can't compute decr size:%s\n",
1858 /* sanity check on out buffer */
1859 if (decr_len > len) {
1860 ssl_debug_printf("pcry_private_decrypt: decrypted data is too long ?!? (%" G_GSIZE_MODIFIER "u max %d)\n", decr_len, len);
1865 /* write plain text to newly allocated buffer */
1866 rc = gcry_mpi_print(GCRYMPI_FMT_USG, data, len, &decr_len, text);
1868 ssl_debug_printf("pcry_private_decrypt: can't print decr data to mpi (size %" G_GSIZE_MODIFIER "u):%s\n", decr_len, gcry_strerror(rc));
1873 ssl_print_data("decrypted_unstrip_pre_master", data, decr_len);
1875 /* strip the padding*/
1877 for (i = 1; i < decr_len; i++) {
1884 ssl_debug_printf("pcry_private_decrypt: stripping %d bytes, decr_len %" G_GSIZE_MODIFIER "u\n", rc, decr_len);
1886 memmove(data, data+rc, decr_len);
1889 gcry_sexp_release(s_data);
1890 gcry_sexp_release(s_plain);
1891 gcry_mpi_release(encr_mpi);
1892 gcry_mpi_release(text);
1893 return (int) decr_len;
1896 /* stringinfo interface */
1898 ssl_data_realloc(StringInfo* str, guint len)
1900 str->data = (guchar *)g_realloc(str->data, len);
1903 str->data_len = len;
1908 ssl_data_copy(StringInfo* dst, StringInfo* src)
1910 if (dst->data_len < src->data_len) {
1911 if (ssl_data_realloc(dst, src->data_len))
1914 memcpy(dst->data, src->data, src->data_len);
1915 dst->data_len = src->data_len;
1919 static const SslDigestAlgo digests[]={
1924 {"Not Applicable", 0},
1927 #define DIGEST_MAX_SIZE 48
1929 /* get index digest index */
1930 static const SslDigestAlgo *
1931 ssl_cipher_suite_dig(SslCipherSuite *cs) {
1932 return &digests[cs->dig - DIG_MD5];
1935 static const gchar *ciphers[]={
1938 "ARCFOUR", /* libgcrypt does not support rc4, but this should be 100% compatible*/
1939 "RFC2268_128", /* libgcrypt name for RC2 with a 128-bit key */
1949 static SslCipherSuite cipher_suites[]={
1950 {0x0001,KEX_RSA, ENC_NULL, 1, 0, 0,DIG_MD5, MODE_STREAM}, /* TLS_RSA_WITH_NULL_MD5 */
1951 {0x0002,KEX_RSA, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_RSA_WITH_NULL_SHA */
1952 {0x0003,KEX_RSA, ENC_RC4, 1,128, 40,DIG_MD5, MODE_STREAM}, /* TLS_RSA_EXPORT_WITH_RC4_40_MD5 */
1953 {0x0004,KEX_RSA, ENC_RC4, 1,128,128,DIG_MD5, MODE_STREAM}, /* TLS_RSA_WITH_RC4_128_MD5 */
1954 {0x0005,KEX_RSA, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_RSA_WITH_RC4_128_SHA */
1955 {0x0006,KEX_RSA, ENC_RC2, 8,128, 40,DIG_MD5, MODE_CBC }, /* TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5 */
1956 {0x0007,KEX_RSA, ENC_IDEA, 8,128,128,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_IDEA_CBC_SHA */
1957 {0x0008,KEX_RSA, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_RSA_EXPORT_WITH_DES40_CBC_SHA */
1958 {0x0009,KEX_RSA, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_DES_CBC_SHA */
1959 {0x000A,KEX_RSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_3DES_EDE_CBC_SHA */
1960 {0x000B,KEX_DH_DSS, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA */
1961 {0x000C,KEX_DH_DSS, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_DES_CBC_SHA */
1962 {0x000D,KEX_DH_DSS, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA */
1963 {0x000E,KEX_DH_RSA, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA */
1964 {0x000F,KEX_DH_RSA, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_DES_CBC_SHA */
1965 {0x0010,KEX_DH_RSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA */
1966 {0x0011,KEX_DHE_DSS, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA */
1967 {0x0012,KEX_DHE_DSS, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_DES_CBC_SHA */
1968 {0x0013,KEX_DHE_DSS, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA */
1969 {0x0014,KEX_DHE_RSA, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA */
1970 {0x0015,KEX_DHE_RSA, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_DES_CBC_SHA */
1971 {0x0016,KEX_DHE_RSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA */
1972 {0x0017,KEX_DH_ANON, ENC_RC4, 1,128, 40,DIG_MD5, MODE_STREAM}, /* TLS_DH_anon_EXPORT_WITH_RC4_40_MD5 */
1973 {0x0018,KEX_DH_ANON, ENC_RC4, 1,128,128,DIG_MD5, MODE_STREAM}, /* TLS_DH_anon_WITH_RC4_128_MD5 */
1974 {0x0019,KEX_DH_ANON, ENC_DES, 8, 64, 40,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA */
1975 {0x001A,KEX_DH_ANON, ENC_DES, 8, 64, 64,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_DES_CBC_SHA */
1976 {0x001B,KEX_DH_ANON, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_3DES_EDE_CBC_SHA */
1977 {0x002C,KEX_PSK, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_PSK_WITH_NULL_SHA */
1978 {0x002D,KEX_DHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_DHE_PSK_WITH_NULL_SHA */
1979 {0x002E,KEX_RSA_PSK, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_RSA_PSK_WITH_NULL_SHA */
1980 {0x002F,KEX_RSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_AES_128_CBC_SHA */
1981 {0x0030,KEX_DH_DSS, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_AES_128_CBC_SHA */
1982 {0x0031,KEX_DH_RSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_AES_128_CBC_SHA */
1983 {0x0032,KEX_DHE_DSS, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_AES_128_CBC_SHA */
1984 {0x0033,KEX_DHE_RSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_AES_128_CBC_SHA */
1985 {0x0034,KEX_DH_ANON, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_AES_128_CBC_SHA */
1986 {0x0035,KEX_RSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_AES_256_CBC_SHA */
1987 {0x0036,KEX_DH_DSS, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_AES_256_CBC_SHA */
1988 {0x0037,KEX_DH_RSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_AES_256_CBC_SHA */
1989 {0x0038,KEX_DHE_DSS, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_AES_256_CBC_SHA */
1990 {0x0039,KEX_DHE_RSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_AES_256_CBC_SHA */
1991 {0x003A,KEX_DH_ANON, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_AES_256_CBC_SHA */
1992 {0x003B,KEX_RSA, ENC_NULL, 1, 0, 0,DIG_SHA256, MODE_STREAM}, /* TLS_RSA_WITH_NULL_SHA256 */
1993 {0x003C,KEX_RSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_RSA_WITH_AES_128_CBC_SHA256 */
1994 {0x003D,KEX_RSA, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_RSA_WITH_AES_256_CBC_SHA256 */
1995 {0x003E,KEX_DH_DSS, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_DSS_WITH_AES_128_CBC_SHA256 */
1996 {0x003F,KEX_DH_RSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_RSA_WITH_AES_128_CBC_SHA256 */
1997 {0x0040,KEX_DHE_DSS, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_DSS_WITH_AES_128_CBC_SHA256 */
1998 {0x0041,KEX_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_CAMELLIA_128_CBC_SHA */
1999 {0x0042,KEX_DH_DSS, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA */
2000 {0x0043,KEX_DH_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA */
2001 {0x0044,KEX_DHE_DSS, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA */
2002 {0x0045,KEX_DHE_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA */
2003 {0x0046,KEX_DH_ANON, ENC_CAMELLIA128,16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA */
2004 {0x0060,KEX_RSA, ENC_RC4, 1,128, 56,DIG_MD5, MODE_STREAM}, /* TLS_RSA_EXPORT1024_WITH_RC4_56_MD5 */
2005 {0x0061,KEX_RSA, ENC_RC2, 1,128, 56,DIG_MD5, MODE_STREAM}, /* TLS_RSA_EXPORT1024_WITH_RC2_CBC_56_MD5 */
2006 {0x0062,KEX_RSA, ENC_DES, 8, 64, 56,DIG_SHA, MODE_CBC }, /* TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA */
2007 {0x0063,KEX_DHE_DSS, ENC_DES, 8, 64, 56,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA */
2008 {0x0064,KEX_RSA, ENC_RC4, 1,128, 56,DIG_SHA, MODE_STREAM}, /* TLS_RSA_EXPORT1024_WITH_RC4_56_SHA */
2009 {0x0065,KEX_DHE_DSS, ENC_RC4, 1,128, 56,DIG_SHA, MODE_STREAM}, /* TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA */
2010 {0x0066,KEX_DHE_DSS, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_DHE_DSS_WITH_RC4_128_SHA */
2011 {0x0067,KEX_DHE_RSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 */
2012 {0x0068,KEX_DH_DSS, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_DSS_WITH_AES_256_CBC_SHA256 */
2013 {0x0069,KEX_DH_RSA, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_RSA_WITH_AES_256_CBC_SHA256 */
2014 {0x006A,KEX_DHE_DSS, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DHE_DSS_WITH_AES_256_CBC_SHA256 */
2015 {0x006B,KEX_DHE_RSA, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 */
2016 {0x006C,KEX_DH_ANON, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_anon_WITH_AES_128_CBC_SHA256 */
2017 {0x006D,KEX_DH_ANON, ENC_AES256, 16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_anon_WITH_AES_256_CBC_SHA256 */
2018 {0x0084,KEX_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_CAMELLIA_256_CBC_SHA */
2019 {0x0085,KEX_DH_DSS, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA */
2020 {0x0086,KEX_DH_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA */
2021 {0x0087,KEX_DHE_DSS, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA */
2022 {0x0088,KEX_DHE_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA */
2023 {0x0089,KEX_DH_ANON, ENC_CAMELLIA256,16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA */
2024 {0x008A,KEX_PSK, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_PSK_WITH_RC4_128_SHA */
2025 {0x008B,KEX_PSK, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_PSK_WITH_3DES_EDE_CBC_SHA */
2026 {0x008C,KEX_PSK, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_PSK_WITH_AES_128_CBC_SHA */
2027 {0x008D,KEX_PSK, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_PSK_WITH_AES_256_CBC_SHA */
2028 {0x008E,KEX_DHE_PSK, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_DHE_PSK_WITH_RC4_128_SHA */
2029 {0x008F,KEX_DHE_PSK, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_DHE_PSK_WITH_3DES_EDE_CBC_SHA */
2030 {0x0090,KEX_DHE_PSK, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_PSK_WITH_AES_128_CBC_SHA */
2031 {0x0091,KEX_DHE_PSK, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_DHE_PSK_WITH_AES_256_CBC_SHA */
2032 {0x0092,KEX_RSA_PSK, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_RSA_PSK_WITH_RC4_128_SHA */
2033 {0x0093,KEX_RSA_PSK, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_RSA_PSK_WITH_3DES_EDE_CBC_SHA */
2034 {0x0094,KEX_RSA_PSK, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_RSA_PSK_WITH_AES_128_CBC_SHA */
2035 {0x0095,KEX_RSA_PSK, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_RSA_PSK_WITH_AES_256_CBC_SHA */
2036 {0x0096,KEX_RSA, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_RSA_WITH_SEED_CBC_SHA */
2037 {0x0097,KEX_DH_DSS, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_DSS_WITH_SEED_CBC_SHA */
2038 {0x0098,KEX_DH_RSA, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_RSA_WITH_SEED_CBC_SHA */
2039 {0x0099,KEX_DHE_DSS, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_DSS_WITH_SEED_CBC_SHA */
2040 {0x009A,KEX_DHE_RSA, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DHE_RSA_WITH_SEED_CBC_SHA */
2041 {0x009B,KEX_DH_ANON, ENC_SEED, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_DH_anon_WITH_SEED_CBC_SHA */
2042 {0x009C,KEX_RSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_RSA_WITH_AES_128_GCM_SHA256 */
2043 {0x009D,KEX_RSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_RSA_WITH_AES_256_GCM_SHA384 */
2044 {0x009E,KEX_DHE_RSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 */
2045 {0x009F,KEX_DHE_RSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 */
2046 {0x00A0,KEX_DH_RSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_RSA_WITH_AES_128_GCM_SHA256 */
2047 {0x00A1,KEX_DH_RSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_RSA_WITH_AES_256_GCM_SHA384 */
2048 {0x00A2,KEX_DHE_DSS, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 */
2049 {0x00A3,KEX_DHE_DSS, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 */
2050 {0x00A4,KEX_DH_DSS, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_DSS_WITH_AES_128_GCM_SHA256 */
2051 {0x00A5,KEX_DH_DSS, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_DSS_WITH_AES_256_GCM_SHA384 */
2052 {0x00A6,KEX_DH_ANON, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_anon_WITH_AES_128_GCM_SHA256 */
2053 {0x00A7,KEX_DH_ANON, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_anon_WITH_AES_256_GCM_SHA384 */
2054 {0x00A8,KEX_PSK, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_PSK_WITH_AES_128_GCM_SHA256 */
2055 {0x00A9,KEX_PSK, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_PSK_WITH_AES_256_GCM_SHA384 */
2056 {0x00AA,KEX_DHE_PSK, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_PSK_WITH_AES_128_GCM_SHA256 */
2057 {0x00AB,KEX_DHE_PSK, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_PSK_WITH_AES_256_GCM_SHA384 */
2058 {0x00AC,KEX_RSA_PSK, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_RSA_PSK_WITH_AES_128_GCM_SHA256 */
2059 {0x00AD,KEX_RSA_PSK, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_RSA_PSK_WITH_AES_256_GCM_SHA384 */
2060 {0x00AE,KEX_PSK, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_PSK_WITH_AES_128_CBC_SHA256 */
2061 {0x00AF,KEX_PSK, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_PSK_WITH_AES_256_CBC_SHA384 */
2062 {0x00B0,KEX_PSK, ENC_NULL, 1, 0, 0,DIG_SHA256, MODE_STREAM}, /* TLS_PSK_WITH_NULL_SHA256 */
2063 {0x00B1,KEX_PSK, ENC_NULL, 1, 0, 0,DIG_SHA384, MODE_STREAM}, /* TLS_PSK_WITH_NULL_SHA384 */
2064 {0x00B2,KEX_DHE_PSK, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_PSK_WITH_AES_128_CBC_SHA256 */
2065 {0x00B3,KEX_DHE_PSK, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_DHE_PSK_WITH_AES_256_CBC_SHA384 */
2066 {0x00B4,KEX_DHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA256, MODE_STREAM}, /* TLS_DHE_PSK_WITH_NULL_SHA256 */
2067 {0x00B5,KEX_DHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA384, MODE_STREAM}, /* TLS_DHE_PSK_WITH_NULL_SHA384 */
2068 {0x00B6,KEX_RSA_PSK, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_RSA_PSK_WITH_AES_128_CBC_SHA256 */
2069 {0x00B7,KEX_RSA_PSK, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_RSA_PSK_WITH_AES_256_CBC_SHA384 */
2070 {0x00B8,KEX_RSA_PSK, ENC_NULL, 1, 0, 0,DIG_SHA256, MODE_STREAM}, /* TLS_RSA_PSK_WITH_NULL_SHA256 */
2071 {0x00B9,KEX_RSA_PSK, ENC_NULL, 1, 0, 0,DIG_SHA384, MODE_STREAM}, /* TLS_RSA_PSK_WITH_NULL_SHA384 */
2072 {0x00BA,KEX_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_RSA_WITH_CAMELLIA_128_CBC_SHA256 */
2073 {0x00BB,KEX_DH_DSS, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 */
2074 {0x00BC,KEX_DH_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 */
2075 {0x00BD,KEX_DHE_DSS, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 */
2076 {0x00BE,KEX_DHE_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 */
2077 {0x00BF,KEX_DH_ANON, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA256 */
2078 {0x00C0,KEX_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_RSA_WITH_CAMELLIA_256_CBC_SHA256 */
2079 {0x00C1,KEX_DH_DSS, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 */
2080 {0x00C2,KEX_DH_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 */
2081 {0x00C3,KEX_DHE_DSS, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 */
2082 {0x00C4,KEX_DHE_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 */
2083 {0x00C5,KEX_DH_ANON, ENC_CAMELLIA256,16,256,256,DIG_SHA256, MODE_CBC }, /* TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA256 */
2084 {0xC001,KEX_ECDH_ECDSA, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_ECDSA_WITH_NULL_SHA */
2085 {0xC002,KEX_ECDH_ECDSA, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_ECDSA_WITH_RC4_128_SHA */
2086 {0xC003,KEX_ECDH_ECDSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA */
2087 {0xC004,KEX_ECDH_ECDSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA */
2088 {0xC005,KEX_ECDH_ECDSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA */
2089 {0xC006,KEX_ECDHE_ECDSA, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_ECDSA_WITH_NULL_SHA */
2090 {0xC007,KEX_ECDHE_ECDSA, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_ECDSA_WITH_RC4_128_SHA */
2091 {0xC008,KEX_ECDHE_ECDSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA */
2092 {0xC009,KEX_ECDHE_ECDSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA */
2093 {0xC00A,KEX_ECDHE_ECDSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA */
2094 {0xC00B,KEX_ECDH_RSA, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_RSA_WITH_NULL_SHA */
2095 {0xC00C,KEX_ECDH_RSA, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_RSA_WITH_RC4_128_SHA */
2096 {0xC00D,KEX_ECDH_RSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA */
2097 {0xC00E,KEX_ECDH_RSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDH_RSA_WITH_AES_128_CBC_SHA */
2098 {0xC00F,KEX_ECDH_RSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDH_RSA_WITH_AES_256_CBC_SHA */
2099 {0xC010,KEX_ECDHE_RSA, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_RSA_WITH_NULL_SHA */
2100 {0xC011,KEX_ECDHE_RSA, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_RSA_WITH_RC4_128_SHA */
2101 {0xC012,KEX_ECDHE_RSA, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA */
2102 {0xC013,KEX_ECDHE_RSA, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA */
2103 {0xC014,KEX_ECDHE_RSA, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA */
2104 {0xC015,KEX_ECDH_ANON, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_anon_WITH_NULL_SHA */
2105 {0xC016,KEX_ECDH_ANON, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDH_anon_WITH_RC4_128_SHA */
2106 {0xC017,KEX_ECDH_ANON, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA */
2107 {0xC018,KEX_ECDH_ANON, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDH_anon_WITH_AES_128_CBC_SHA */
2108 {0xC019,KEX_ECDH_ANON, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDH_anon_WITH_AES_256_CBC_SHA */
2109 {0xC023,KEX_ECDHE_ECDSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 */
2110 {0xC024,KEX_ECDHE_ECDSA, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 */
2111 {0xC025,KEX_ECDH_ECDSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256 */
2112 {0xC026,KEX_ECDH_ECDSA, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384 */
2113 {0xC027,KEX_ECDHE_RSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 */
2114 {0xC028,KEX_ECDHE_RSA, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 */
2115 {0xC029,KEX_ECDH_RSA, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256 */
2116 {0xC02A,KEX_ECDH_RSA, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384 */
2117 {0xC02B,KEX_ECDHE_ECDSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 */
2118 {0xC02C,KEX_ECDHE_ECDSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 */
2119 {0xC02D,KEX_ECDH_ECDSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 */
2120 {0xC02E,KEX_ECDH_ECDSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 */
2121 {0xC02F,KEX_ECDHE_RSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 */
2122 {0xC030,KEX_ECDHE_RSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 */
2123 {0xC031,KEX_ECDH_RSA, ENC_AES, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256 */
2124 {0xC032,KEX_ECDH_RSA, ENC_AES256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384 */
2125 {0xC033,KEX_ECDHE_PSK, ENC_RC4, 1,128,128,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_PSK_WITH_RC4_128_SHA */
2126 {0xC034,KEX_ECDHE_PSK, ENC_3DES, 8,192,192,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA */
2127 {0xC035,KEX_ECDHE_PSK, ENC_AES, 16,128,128,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA */
2128 {0xC036,KEX_ECDHE_PSK, ENC_AES256, 16,256,256,DIG_SHA, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA */
2129 {0xC037,KEX_ECDHE_PSK, ENC_AES, 16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_AES_128_CBC_SHA256 */
2130 {0xC038,KEX_ECDHE_PSK, ENC_AES256, 16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_AES_256_CBC_SHA384 */
2131 {0xC039,KEX_ECDHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA, MODE_STREAM}, /* TLS_ECDHE_PSK_WITH_NULL_SHA */
2132 {0xC03A,KEX_ECDHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA256, MODE_STREAM}, /* TLS_ECDHE_PSK_WITH_NULL_SHA256 */
2133 {0xC03B,KEX_ECDHE_PSK, ENC_NULL, 1, 0, 0,DIG_SHA384, MODE_STREAM}, /* TLS_ECDHE_PSK_WITH_NULL_SHA384 */
2134 {0xC072,KEX_ECDHE_ECDSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 */
2135 {0xC073,KEX_ECDHE_ECDSA, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 */
2136 {0xC074,KEX_ECDH_ECDSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 */
2137 {0xC075,KEX_ECDH_ECDSA, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 */
2138 {0xC076,KEX_ECDHE_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 */
2139 {0xC077,KEX_ECDHE_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 */
2140 {0xC078,KEX_ECDH_RSA, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 */
2141 {0xC079,KEX_ECDH_RSA, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 */
2142 {0xC07A,KEX_RSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_RSA_WITH_CAMELLIA_128_GCM_SHA256 */
2143 {0xC07B,KEX_RSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_RSA_WITH_CAMELLIA_256_GCM_SHA384 */
2144 {0xC07C,KEX_DHE_RSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 */
2145 {0xC07D,KEX_DHE_RSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 */
2146 {0xC07E,KEX_DH_RSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_RSA_WITH_CAMELLIA_128_GCM_SHA256 */
2147 {0xC07F,KEX_DH_RSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */
2148 {0xC080,KEX_DHE_DSS, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_DSS_WITH_CAMELLIA_128_GCM_SHA256 */
2149 {0xC081,KEX_DHE_DSS, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_DSS_WITH_CAMELLIA_256_GCM_SHA384 */
2150 {0xC082,KEX_DH_DSS, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_DSS_WITH_CAMELLIA_128_GCM_SHA256 */
2151 {0xC083,KEX_DH_DSS, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_DSS_WITH_CAMELLIA_256_GCM_SHA384 */
2152 {0xC084,KEX_DH_ANON, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DH_anon_WITH_CAMELLIA_128_GCM_SHA256 */
2153 {0xC085,KEX_DH_ANON, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DH_anon_WITH_CAMELLIA_256_GCM_SHA384 */
2154 {0xC086,KEX_ECDHE_ECDSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDHE_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 */
2155 {0xC087,KEX_ECDHE_ECDSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDHE_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */
2156 {0xC088,KEX_ECDH_ECDSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDH_ECDSA_WITH_CAMELLIA_128_GCM_SHA256 */
2157 {0xC089,KEX_ECDH_ECDSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDH_ECDSA_WITH_CAMELLIA_256_GCM_SHA384 */
2158 {0xC08A,KEX_ECDHE_RSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDHE_RSA_WITH_CAMELLIA_128_GCM_SHA256 */
2159 {0xC08B,KEX_ECDHE_RSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDHE_RSA_WITH_CAMELLIA_256_GCM_SHA384 */
2160 {0xC08C,KEX_ECDH_RSA, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_ECDH_RSA_WITH_CAMELLIA_128_GCM_SHA256 */
2161 {0xC08D,KEX_ECDH_RSA, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_ECDH_RSA_WITH_CAMELLIA_256_GCM_SHA384 */
2162 {0xC08E,KEX_PSK, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_PSK_WITH_CAMELLIA_128_GCM_SHA256 */
2163 {0xC08F,KEX_PSK, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_PSK_WITH_CAMELLIA_256_GCM_SHA384 */
2164 {0xC090,KEX_DHE_PSK, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_DHE_PSK_WITH_CAMELLIA_128_GCM_SHA256 */
2165 {0xC091,KEX_DHE_PSK, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_DHE_PSK_WITH_CAMELLIA_256_GCM_SHA384 */
2166 {0xC092,KEX_RSA_PSK, ENC_CAMELLIA128, 4,128,128,DIG_SHA256, MODE_GCM }, /* TLS_RSA_PSK_WITH_CAMELLIA_128_GCM_SHA256 */
2167 {0xC093,KEX_RSA_PSK, ENC_CAMELLIA256, 4,256,256,DIG_SHA384, MODE_GCM }, /* TLS_RSA_PSK_WITH_CAMELLIA_256_GCM_SHA384 */
2168 {0xC094,KEX_PSK, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_PSK_WITH_CAMELLIA_128_CBC_SHA256 */
2169 {0xC095,KEX_PSK, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_PSK_WITH_CAMELLIA_256_CBC_SHA384 */
2170 {0xC096,KEX_DHE_PSK, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 */
2171 {0xC097,KEX_DHE_PSK, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 */
2172 {0xC098,KEX_RSA_PSK, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 */
2173 {0xC099,KEX_RSA_PSK, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 */
2174 {0xC09A,KEX_ECDHE_PSK, ENC_CAMELLIA128,16,128,128,DIG_SHA256, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 */
2175 {0xC09B,KEX_ECDHE_PSK, ENC_CAMELLIA256,16,256,256,DIG_SHA384, MODE_CBC }, /* TLS_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 */
2176 {0xC09C,KEX_RSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM }, /* TLS_RSA_WITH_AES_128_CCM */
2177 {0xC09D,KEX_RSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM }, /* TLS_RSA_WITH_AES_256_CCM */
2178 {0xC09E,KEX_DHE_RSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM }, /* TLS_DHE_RSA_WITH_AES_128_CCM */
2179 {0xC09F,KEX_DHE_RSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM }, /* TLS_DHE_RSA_WITH_AES_256_CCM */
2180 {0xC0A0,KEX_RSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM_8 }, /* TLS_RSA_WITH_AES_128_CCM_8 */
2181 {0xC0A1,KEX_RSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM_8 }, /* TLS_RSA_WITH_AES_256_CCM_8 */
2182 {0xC0A2,KEX_DHE_RSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM_8 }, /* TLS_DHE_RSA_WITH_AES_128_CCM_8 */
2183 {0xC0A3,KEX_DHE_RSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM_8 }, /* TLS_DHE_RSA_WITH_AES_256_CCM_8 */
2184 {0xC0A4,KEX_PSK, ENC_AES, 4,128,128,DIG_NA, MODE_CCM }, /* TLS_PSK_WITH_AES_128_CCM */
2185 {0xC0A5,KEX_PSK, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM }, /* TLS_PSK_WITH_AES_256_CCM */
2186 {0xC0A6,KEX_DHE_PSK, ENC_AES, 4,128,128,DIG_NA, MODE_CCM }, /* TLS_DHE_PSK_WITH_AES_128_CCM */
2187 {0xC0A7,KEX_DHE_PSK, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM }, /* TLS_DHE_PSK_WITH_AES_256_CCM */
2188 {0xC0A8,KEX_PSK, ENC_AES, 4,128,128,DIG_NA, MODE_CCM_8 }, /* TLS_PSK_WITH_AES_128_CCM_8 */
2189 {0xC0A9,KEX_PSK, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM_8 }, /* TLS_PSK_WITH_AES_256_CCM_8 */
2190 {0xC0AA,KEX_DHE_PSK, ENC_AES, 4,128,128,DIG_NA, MODE_CCM_8 }, /* TLS_PSK_DHE_WITH_AES_128_CCM_8 */
2191 {0xC0AB,KEX_DHE_PSK, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM_8 }, /* TLS_PSK_DHE_WITH_AES_256_CCM_8 */
2192 {0xC0AC,KEX_ECDHE_ECDSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM }, /* TLS_ECDHE_ECDSA_WITH_AES_128_CCM */
2193 {0xC0AD,KEX_ECDHE_ECDSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM }, /* TLS_ECDHE_ECDSA_WITH_AES_256_CCM */
2194 {0xC0AE,KEX_ECDHE_ECDSA, ENC_AES, 4,128,128,DIG_NA, MODE_CCM_8 }, /* TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8 */
2195 {0xC0AF,KEX_ECDHE_ECDSA, ENC_AES256, 4,256,256,DIG_NA, MODE_CCM_8 }, /* TLS_ECDHE_ECDSA_WITH_AES_256_CCM_8 */
2196 {-1, 0, 0, 0, 0, 0,0, MODE_STREAM}
2199 #define MAX_BLOCK_SIZE 16
2200 #define MAX_KEY_SIZE 32
2203 ssl_find_cipher(int num,SslCipherSuite* cs)
2207 for(c=cipher_suites;c->number!=-1;c++){
2218 tls_hash(StringInfo *secret, StringInfo *seed, gint md,
2219 StringInfo *out, guint out_len)
2221 /* RFC 2246 5. HMAC and the pseudorandom function
2222 * '+' denotes concatenation.
2223 * P_hash(secret, seed) = HMAC_hash(secret, A(1) + seed) +
2224 * HMAC_hash(secret, A(2) + seed) + ...
2226 * A(i) = HMAC_hash(secret, A(i - 1))
2231 guint8 _A[DIGEST_MAX_SIZE], tmp[DIGEST_MAX_SIZE];
2238 ssl_print_string("tls_hash: hash secret", secret);
2239 ssl_print_string("tls_hash: hash seed", seed);
2242 A_l = seed->data_len;
2245 /* A(i) = HMAC_hash(secret, A(i-1)) */
2246 ssl_hmac_init(&hm, secret->data, secret->data_len, md);
2247 ssl_hmac_update(&hm, A, A_l);
2248 A_l = sizeof(_A); /* upper bound len for hash output */
2249 ssl_hmac_final(&hm, _A, &A_l);
2250 ssl_hmac_cleanup(&hm);
2253 /* HMAC_hash(secret, A(i) + seed) */
2254 ssl_hmac_init(&hm, secret->data, secret->data_len, md);
2255 ssl_hmac_update(&hm, A, A_l);
2256 ssl_hmac_update(&hm, seed->data, seed->data_len);
2257 tmp_l = sizeof(tmp); /* upper bound len for hash output */
2258 ssl_hmac_final(&hm, tmp, &tmp_l);
2259 ssl_hmac_cleanup(&hm);
2261 /* ssl_hmac_final puts the actual digest output size in tmp_l */
2262 tocpy = MIN(left, tmp_l);
2263 memcpy(ptr, tmp, tocpy);
2267 out->data_len = out_len;
2269 ssl_print_string("hash out", out);
2273 tls_prf(StringInfo* secret, const gchar *usage,
2274 StringInfo* rnd1, StringInfo* rnd2, StringInfo* out, guint out_len)
2276 StringInfo seed, sha_out, md5_out;
2280 size_t usage_len, rnd2_len;
2281 gboolean success = FALSE;
2282 usage_len = strlen(usage);
2283 rnd2_len = rnd2 ? rnd2->data_len : 0;
2285 /* initalize buffer for sha, md5 random seed*/
2286 if (ssl_data_alloc(&sha_out, MAX(out_len, 20)) < 0) {
2287 ssl_debug_printf("tls_prf: can't allocate sha out\n");
2290 if (ssl_data_alloc(&md5_out, MAX(out_len, 16)) < 0) {
2291 ssl_debug_printf("tls_prf: can't allocate md5 out\n");
2294 if (ssl_data_alloc(&seed, usage_len+rnd1->data_len+rnd2_len) < 0) {
2295 ssl_debug_printf("tls_prf: can't allocate rnd %d\n",
2296 (int) (usage_len+rnd1->data_len+rnd2_len));
2301 memcpy(ptr,usage,usage_len);
2303 memcpy(ptr,rnd1->data,rnd1->data_len);
2305 ptr+=rnd1->data_len;
2306 memcpy(ptr,rnd2->data,rnd2->data_len);
2307 /*ptr+=rnd2->data_len;*/
2310 /* initalize buffer for client/server seeds*/
2311 s_l=secret->data_len/2 + secret->data_len%2;
2312 if (ssl_data_alloc(&s1, s_l) < 0) {
2313 ssl_debug_printf("tls_prf: can't allocate secret %d\n", s_l);
2316 if (ssl_data_alloc(&s2, s_l) < 0) {
2317 ssl_debug_printf("tls_prf: can't allocate secret(2) %d\n", s_l);
2321 memcpy(s1.data,secret->data,s_l);
2322 memcpy(s2.data,secret->data + (secret->data_len - s_l),s_l);
2324 ssl_debug_printf("tls_prf: tls_hash(md5 secret_len %d seed_len %d )\n", s1.data_len, seed.data_len);
2325 tls_hash(&s1, &seed, ssl_get_digest_by_name("MD5"), &md5_out, out_len);
2326 ssl_debug_printf("tls_prf: tls_hash(sha)\n");
2327 tls_hash(&s2, &seed, ssl_get_digest_by_name("SHA1"), &sha_out, out_len);
2329 for (i = 0; i < out_len; i++)
2330 out->data[i] = md5_out.data[i] ^ sha_out.data[i];
2331 /* success, now store the new meaningful data length */
2332 out->data_len = out_len;
2335 ssl_print_string("PRF out",out);
2342 g_free(md5_out.data);
2344 g_free(sha_out.data);
2349 tls12_prf(gint md, StringInfo* secret, const gchar* usage,
2350 StringInfo* rnd1, StringInfo* rnd2, StringInfo* out, guint out_len)
2352 StringInfo label_seed;
2353 size_t usage_len, rnd2_len;
2354 rnd2_len = rnd2 ? rnd2->data_len : 0;
2356 usage_len = strlen(usage);
2357 if (ssl_data_alloc(&label_seed, usage_len+rnd1->data_len+rnd2_len) < 0) {
2358 ssl_debug_printf("tls12_prf: can't allocate label_seed\n");
2361 memcpy(label_seed.data, usage, usage_len);
2362 memcpy(label_seed.data+usage_len, rnd1->data, rnd1->data_len);
2364 memcpy(label_seed.data+usage_len+rnd1->data_len, rnd2->data, rnd2->data_len);
2366 ssl_debug_printf("tls12_prf: tls_hash(hash_alg %s secret_len %d seed_len %d )\n", gcry_md_algo_name(md), secret->data_len, label_seed.data_len);
2367 tls_hash(secret, &label_seed, md, out, out_len);
2368 g_free(label_seed.data);
2369 ssl_print_string("PRF out", out);
2374 ssl3_generate_export_iv(StringInfo *r1, StringInfo *r2,
2375 StringInfo *out, guint out_len)
2381 ssl_md5_update(&md5,r1->data,r1->data_len);
2382 ssl_md5_update(&md5,r2->data,r2->data_len);
2383 ssl_md5_final(tmp,&md5);
2384 ssl_md5_cleanup(&md5);
2386 DISSECTOR_ASSERT(out_len <= sizeof(tmp));
2387 ssl_data_set(out, tmp, out_len);
2388 ssl_print_string("export iv", out);
2392 ssl3_prf(StringInfo* secret, const gchar* usage,
2393 StringInfo* rnd1, StringInfo* rnd2, StringInfo* out, guint out_len)
2401 for (off = 0; off < out_len; off += 16) {
2405 ssl_debug_printf("ssl3_prf: sha1_hash(%d)\n",i);
2406 /* A, BB, CCC, ... */
2412 ssl_sha_update(&sha,buf,i);
2413 ssl_sha_update(&sha,secret->data,secret->data_len);
2415 if(!strcmp(usage,"client write key") || !strcmp(usage,"server write key")){
2417 ssl_sha_update(&sha,rnd2->data,rnd2->data_len);
2418 ssl_sha_update(&sha,rnd1->data,rnd1->data_len);
2421 ssl_sha_update(&sha,rnd1->data,rnd1->data_len);
2423 ssl_sha_update(&sha,rnd2->data,rnd2->data_len);
2426 ssl_sha_final(buf,&sha);
2427 ssl_sha_cleanup(&sha);
2429 ssl_debug_printf("ssl3_prf: md5_hash(%d) datalen %d\n",i,
2432 ssl_md5_update(&md5,secret->data,secret->data_len);
2433 ssl_md5_update(&md5,buf,20);
2434 ssl_md5_final(outbuf,&md5);
2435 ssl_md5_cleanup(&md5);
2437 memcpy(out->data + off, outbuf, MIN(out_len - off, 16));
2439 out->data_len = out_len;
2444 /* out_len is the wanted output length for the pseudorandom function */
2446 prf(SslDecryptSession *ssl, StringInfo *secret, const gchar *usage,
2447 StringInfo *rnd1, StringInfo *rnd2, StringInfo *out, guint out_len)
2449 switch (ssl->version_netorder) {
2451 return ssl3_prf(secret, usage, rnd1, rnd2, out, out_len);
2454 case TLSV1DOT1_VERSION:
2455 case DTLSV1DOT0_VERSION:
2456 case DTLSV1DOT0_VERSION_NOT:
2457 return tls_prf(secret, usage, rnd1, rnd2, out, out_len);
2459 default: /* TLSv1.2 */
2460 switch (ssl->cipher_suite.dig) {
2462 return tls12_prf(GCRY_MD_SHA384, secret, usage, rnd1, rnd2,
2465 return tls12_prf(GCRY_MD_SHA256, secret, usage, rnd1, rnd2,
2471 static gint tls_handshake_hash(SslDecryptSession* ssl, StringInfo* out)
2476 if (ssl_data_alloc(out, 36) < 0)
2480 ssl_md5_update(&md5,ssl->handshake_data.data,ssl->handshake_data.data_len);
2481 ssl_md5_final(out->data,&md5);
2482 ssl_md5_cleanup(&md5);
2485 ssl_sha_update(&sha,ssl->handshake_data.data,ssl->handshake_data.data_len);
2486 ssl_sha_final(out->data+16,&sha);
2487 ssl_sha_cleanup(&sha);
2491 static gint tls12_handshake_hash(SslDecryptSession* ssl, gint md, StringInfo* out)
2497 ssl_md_init(&mc, md);
2498 ssl_md_update(&mc,ssl->handshake_data.data,ssl->handshake_data.data_len);
2499 ssl_md_final(&mc, tmp, &len);
2500 ssl_md_cleanup(&mc);
2502 if (ssl_data_alloc(out, len) < 0)
2504 memcpy(out->data, tmp, len);
2509 ssl_create_flow(void)
2513 flow = (SslFlow *)wmem_alloc(wmem_file_scope(), sizeof(SslFlow));
2516 flow->multisegment_pdus = wmem_tree_new(wmem_file_scope());
2521 /* memory allocation functions for zlib initialization */
2522 static void* ssl_zalloc(void* opaque _U_, unsigned int no, unsigned int size)
2524 return g_malloc0(no*size);
2526 static void ssl_zfree(void* opaque _U_, void* addr)
2532 static SslDecompress*
2533 ssl_create_decompressor(gint compression)
2535 SslDecompress *decomp;
2540 if (compression == 0) return NULL;
2541 ssl_debug_printf("ssl_create_decompressor: compression method %d\n", compression);
2542 decomp = (SslDecompress *)wmem_alloc(wmem_file_scope(), sizeof(SslDecompress));
2543 decomp->compression = compression;
2544 switch (decomp->compression) {
2546 case 1: /* DEFLATE */
2547 decomp->istream.zalloc = ssl_zalloc;
2548 decomp->istream.zfree = ssl_zfree;
2549 decomp->istream.opaque = Z_NULL;
2550 decomp->istream.next_in = Z_NULL;
2551 decomp->istream.next_out = Z_NULL;
2552 decomp->istream.avail_in = 0;
2553 decomp->istream.avail_out = 0;
2554 err = inflateInit_(&decomp->istream, ZLIB_VERSION, sizeof(z_stream));
2556 ssl_debug_printf("ssl_create_decompressor: inflateInit_() failed - %d\n", err);
2562 ssl_debug_printf("ssl_create_decompressor: unsupported compression method %d\n", decomp->compression);
2569 ssl_create_decoder(SslCipherSuite *cipher_suite, gint compression,
2570 guint8 *mk, guint8 *sk, guint8 *iv)
2575 dec = (SslDecoder *)wmem_alloc0(wmem_file_scope(), sizeof(SslDecoder));
2576 /* Find the SSLeay cipher */
2577 if(cipher_suite->enc!=ENC_NULL) {
2578 ssl_debug_printf("ssl_create_decoder CIPHER: %s\n", ciphers[cipher_suite->enc-0x30]);
2579 ciph=ssl_get_cipher_by_name(ciphers[cipher_suite->enc-0x30]);
2581 ssl_debug_printf("ssl_create_decoder CIPHER: %s\n", "NULL");
2585 ssl_debug_printf("ssl_create_decoder can't find cipher %s\n",
2586 ciphers[cipher_suite->enc > ENC_NULL ? ENC_NULL-0x30 : (cipher_suite->enc-0x30)]);
2590 /* init mac buffer: mac storage is embedded into decoder struct to save a
2591 memory allocation and waste samo more memory*/
2592 dec->cipher_suite=cipher_suite;
2593 dec->compression = compression;
2594 /* AEED ciphers don't have a MAC but need to keep the write IV instead */
2596 dec->write_iv.data = dec->_mac_key_or_write_iv;
2597 ssl_data_set(&dec->write_iv, iv, cipher_suite->block);
2599 dec->mac_key.data = dec->_mac_key_or_write_iv;
2600 ssl_data_set(&dec->mac_key, mk, ssl_cipher_suite_dig(cipher_suite)->len);
2603 dec->decomp = ssl_create_decompressor(compression);
2604 dec->flow = ssl_create_flow();
2607 ssl_cipher_cleanup(&dec->evp);
2609 if (ssl_cipher_init(&dec->evp,ciph,sk,iv,cipher_suite->mode) < 0) {
2610 ssl_debug_printf("ssl_create_decoder: can't create cipher id:%d mode:%d\n",
2611 ciph, cipher_suite->mode);
2615 ssl_debug_printf("decoder initialized (digest len %d)\n", ssl_cipher_suite_dig(cipher_suite)->len);
2620 ssl_decrypt_pre_master_secret(SslDecryptSession *ssl_session,
2621 StringInfo *encrypted_pre_master,
2624 ssl_restore_master_key(SslDecryptSession *ssl, const char *label,
2625 gboolean is_pre_master, GHashTable *ht, StringInfo *key);
2628 ssl_generate_pre_master_secret(SslDecryptSession *ssl_session,
2629 guint32 length, tvbuff_t *tvb, guint32 offset,
2630 const gchar *ssl_psk,
2631 const ssl_master_key_map_t *mk_map)
2633 /* check for required session data */
2634 ssl_debug_printf("%s: found SSL_HND_CLIENT_KEY_EXCHG, state %X\n",
2635 G_STRFUNC, ssl_session->state);
2636 if ((ssl_session->state & (SSL_CIPHER|SSL_CLIENT_RANDOM|SSL_SERVER_RANDOM|SSL_VERSION)) !=
2637 (SSL_CIPHER|SSL_CLIENT_RANDOM|SSL_SERVER_RANDOM|SSL_VERSION)) {
2638 ssl_debug_printf("%s: not enough data to generate key (required state %X)\n", G_STRFUNC,
2639 (SSL_CIPHER|SSL_CLIENT_RANDOM|SSL_SERVER_RANDOM|SSL_VERSION));
2643 /* check to see if the PMS was provided to us*/
2644 if (ssl_restore_master_key(ssl_session, "Unencrypted pre-master secret", TRUE,
2645 mk_map->pms, &ssl_session->client_random)) {
2649 if (ssl_session->cipher_suite.kex == KEX_PSK)
2651 /* calculate pre master secret*/
2652 StringInfo pre_master_secret;
2653 guint psk_len, pre_master_len;
2655 if (!ssl_psk || (ssl_psk[0] == 0)) {
2656 ssl_debug_printf("%s: can't find pre-shared-key\n", G_STRFUNC);
2660 /* convert hex string into char*/
2661 if (!from_hex(&ssl_session->psk, ssl_psk, strlen(ssl_psk))) {
2662 ssl_debug_printf("%s: ssl.psk/dtls.psk contains invalid hex\n",
2667 psk_len = ssl_session->psk.data_len;
2668 if (psk_len >= (2 << 15)) {
2669 ssl_debug_printf("%s: ssl.psk/dtls.psk must not be larger than 2^15 - 1\n",
2675 pre_master_len = psk_len * 2 + 4;
2677 pre_master_secret.data = (guchar *)wmem_alloc(wmem_file_scope(), pre_master_len);
2678 pre_master_secret.data_len = pre_master_len;
2679 /* 2 bytes psk_len*/
2680 pre_master_secret.data[0] = psk_len >> 8;
2681 pre_master_secret.data[1] = psk_len & 0xFF;
2682 /* psk_len bytes times 0*/
2683 memset(&pre_master_secret.data[2], 0, psk_len);
2684 /* 2 bytes psk_len*/
2685 pre_master_secret.data[psk_len + 2] = psk_len >> 8;
2686 pre_master_secret.data[psk_len + 3] = psk_len & 0xFF;
2688 memcpy(&pre_master_secret.data[psk_len + 4], ssl_session->psk.data, psk_len);
2690 ssl_session->pre_master_secret.data = pre_master_secret.data;
2691 ssl_session->pre_master_secret.data_len = pre_master_len;
2692 /*ssl_debug_printf("pre master secret",&ssl->pre_master_secret);*/
2694 /* Remove the master secret if it was there.
2695 This forces keying material regeneration in
2696 case we're renegotiating */
2697 ssl_session->state &= ~(SSL_MASTER_SECRET|SSL_HAVE_SESSION_KEY);
2698 ssl_session->state |= SSL_PRE_MASTER_SECRET;
2703 StringInfo encrypted_pre_master;
2704 guint encrlen, skip;
2708 /* get encrypted data, on tls1 we have to skip two bytes
2709 * (it's the encrypted len and should be equal to record len - 2)
2710 * in case of rsa1024 that would be 128 + 2 = 130; for psk not necessary
2712 if (ssl_session->cipher_suite.kex == KEX_RSA &&
2713 (ssl_session->session.version == SSL_VER_TLS || ssl_session->session.version == SSL_VER_TLSv1DOT1 ||
2714 ssl_session->session.version == SSL_VER_TLSv1DOT2 || ssl_session->session.version == SSL_VER_DTLS ||
2715 ssl_session->session.version == SSL_VER_DTLS1DOT2))
2717 encrlen = tvb_get_ntohs(tvb, offset);
2719 if (encrlen > length - 2)
2721 ssl_debug_printf("%s: wrong encrypted length (%d max %d)\n",
2722 G_STRFUNC, encrlen, length);
2726 /* the valid lower bound is higher than 8, but it is sufficient for the
2727 * ssl keylog file below */
2729 ssl_debug_printf("%s: invalid encrypted pre-master key length %d\n",
2730 G_STRFUNC, encrlen);
2734 encrypted_pre_master.data = (guchar *)wmem_alloc(wmem_file_scope(), encrlen);
2735 encrypted_pre_master.data_len = encrlen;
2736 tvb_memcpy(tvb, encrypted_pre_master.data, offset+skip, encrlen);
2738 if (ssl_session->private_key) {
2739 /* try to decrypt encrypted pre-master with RSA key */
2740 if (ssl_decrypt_pre_master_secret(ssl_session,
2741 &encrypted_pre_master, ssl_session->private_key))
2744 ssl_debug_printf("%s: can't decrypt pre-master secret\n",
2748 /* try to find the pre-master secret from the encrypted one. The
2749 * ssl key logfile stores only the first 8 bytes, so truncate it */
2750 encrypted_pre_master.data_len = 8;
2751 if (ssl_restore_master_key(ssl_session, "Encrypted pre-master secret",
2752 TRUE, mk_map->pre_master, &encrypted_pre_master))
2759 ssl_generate_keyring_material(SslDecryptSession*ssl_session)
2761 StringInfo key_block;
2762 guint8 _iv_c[MAX_BLOCK_SIZE],_iv_s[MAX_BLOCK_SIZE];
2763 guint8 _key_c[MAX_KEY_SIZE],_key_s[MAX_KEY_SIZE];
2765 guint8 *ptr,*c_wk,*s_wk,*c_mk,*s_mk,*c_iv = _iv_c,*s_iv = _iv_s;
2767 /* check for enough info to proced */
2768 guint need_all = SSL_CIPHER|SSL_CLIENT_RANDOM|SSL_SERVER_RANDOM|SSL_VERSION;
2769 guint need_any = SSL_MASTER_SECRET | SSL_PRE_MASTER_SECRET;
2770 if (((ssl_session->state & need_all) != need_all) || ((ssl_session->state & need_any) == 0)) {
2771 ssl_debug_printf("ssl_generate_keyring_material not enough data to generate key "
2772 "(0x%02X required 0x%02X or 0x%02X)\n", ssl_session->state,
2773 need_all|SSL_MASTER_SECRET, need_all|SSL_PRE_MASTER_SECRET);
2777 /* if master key is not available, generate is from the pre-master secret */
2778 if (!(ssl_session->state & SSL_MASTER_SECRET)) {
2779 if ((ssl_session->state & SSL_EXTENDED_MASTER_SECRET_MASK) == SSL_EXTENDED_MASTER_SECRET_MASK) {
2780 StringInfo handshake_hashed_data;
2783 handshake_hashed_data.data = NULL;
2784 handshake_hashed_data.data_len = 0;
2786 ssl_debug_printf("%s:PRF(pre_master_secret_extended)\n", G_STRFUNC);
2787 ssl_print_string("pre master secret",&ssl_session->pre_master_secret);
2788 DISSECTOR_ASSERT(ssl_session->handshake_data.data_len > 0);
2790 switch(ssl_session->version_netorder) {
2792 case TLSV1DOT1_VERSION:
2793 case DTLSV1DOT0_VERSION:
2794 case DTLSV1DOT0_VERSION_NOT:
2795 ret = tls_handshake_hash(ssl_session, &handshake_hashed_data);
2798 switch (ssl_session->cipher_suite.dig) {
2800 ret = tls12_handshake_hash(ssl_session, GCRY_MD_SHA384, &handshake_hashed_data);
2803 ret = tls12_handshake_hash(ssl_session, GCRY_MD_SHA256, &handshake_hashed_data);
2809 ssl_debug_printf("%s can't generate handshake hash\n", G_STRFUNC);
2813 wmem_free(wmem_file_scope(), ssl_session->handshake_data.data);
2814 ssl_session->handshake_data.data = NULL;
2815 ssl_session->handshake_data.data_len = 0;
2817 if (!prf(ssl_session, &ssl_session->pre_master_secret, "extended master secret",
2818 &handshake_hashed_data,
2819 NULL, &ssl_session->master_secret,
2820 SSL_MASTER_SECRET_LENGTH)) {
2821 ssl_debug_printf("%s can't generate master_secret\n", G_STRFUNC);
2822 g_free(handshake_hashed_data.data);
2825 g_free(handshake_hashed_data.data);
2827 ssl_debug_printf("%s:PRF(pre_master_secret)\n", G_STRFUNC);
2828 ssl_print_string("pre master secret",&ssl_session->pre_master_secret);
2829 ssl_print_string("client random",&ssl_session->client_random);
2830 ssl_print_string("server random",&ssl_session->server_random);
2831 if (!prf(ssl_session, &ssl_session->pre_master_secret, "master secret",
2832 &ssl_session->client_random,
2833 &ssl_session->server_random, &ssl_session->master_secret,
2834 SSL_MASTER_SECRET_LENGTH)) {
2835 ssl_debug_printf("%s can't generate master_secret\n", G_STRFUNC);
2839 ssl_print_string("master secret",&ssl_session->master_secret);
2841 /* the pre-master secret has been 'consumend' so we must clear it now */
2842 ssl_session->state &= ~SSL_PRE_MASTER_SECRET;
2843 ssl_session->state |= SSL_MASTER_SECRET;
2846 /* Compute the key block. First figure out how much data we need*/
2847 needed=ssl_cipher_suite_dig(&ssl_session->cipher_suite)->len*2;
2848 needed+=ssl_session->cipher_suite.bits / 4;
2849 if(ssl_session->cipher_suite.block>1)
2850 needed+=ssl_session->cipher_suite.block*2;
2852 key_block.data = (guchar *)g_malloc(needed);
2853 ssl_debug_printf("%s sess key generation\n", G_STRFUNC);
2854 if (!prf(ssl_session, &ssl_session->master_secret, "key expansion",
2855 &ssl_session->server_random,&ssl_session->client_random,
2856 &key_block, needed)) {
2857 ssl_debug_printf("%s can't generate key_block\n", G_STRFUNC);
2860 ssl_print_string("key expansion", &key_block);
2863 /* AEAD ciphers do not have a separate MAC */
2864 if (ssl_session->cipher_suite.mode == MODE_GCM ||
2865 ssl_session->cipher_suite.mode == MODE_CCM ||
2866 ssl_session->cipher_suite.mode == MODE_CCM_8) {
2869 c_mk=ptr; ptr+=ssl_cipher_suite_dig(&ssl_session->cipher_suite)->len;
2870 s_mk=ptr; ptr+=ssl_cipher_suite_dig(&ssl_session->cipher_suite)->len;
2873 c_wk=ptr; ptr+=ssl_session->cipher_suite.eff_bits/8;
2874 s_wk=ptr; ptr+=ssl_session->cipher_suite.eff_bits/8;
2876 if(ssl_session->cipher_suite.block>1){
2877 c_iv=ptr; ptr+=ssl_session->cipher_suite.block;
2878 s_iv=ptr; /*ptr+=ssl_session->cipher_suite.block;*/
2881 /* export ciphers work with a smaller key length */
2882 if (ssl_session->cipher_suite.eff_bits < ssl_session->cipher_suite.bits) {
2883 if(ssl_session->cipher_suite.block>1){
2885 /* We only have room for MAX_BLOCK_SIZE bytes IVs, but that's
2886 all we should need. This is a sanity check */
2887 if(ssl_session->cipher_suite.block>MAX_BLOCK_SIZE) {
2888 ssl_debug_printf("%s cipher suite block must be at most %d nut is %d\n",
2889 G_STRFUNC, MAX_BLOCK_SIZE, ssl_session->cipher_suite.block);
2893 if(ssl_session->version_netorder==SSLV3_VERSION){
2894 /* The length of these fields are ignored by this caller */
2895 StringInfo iv_c, iv_s;
2899 ssl_debug_printf("%s ssl3_generate_export_iv\n", G_STRFUNC);
2900 ssl3_generate_export_iv(&ssl_session->client_random,
2901 &ssl_session->server_random, &iv_c,
2902 ssl_session->cipher_suite.block);
2903 ssl_debug_printf("%s ssl3_generate_export_iv(2)\n", G_STRFUNC);
2904 ssl3_generate_export_iv(&ssl_session->server_random,
2905 &ssl_session->client_random, &iv_s,
2906 ssl_session->cipher_suite.block);
2909 guint8 _iv_block[MAX_BLOCK_SIZE * 2];
2910 StringInfo iv_block;
2911 StringInfo key_null;
2914 key_null.data = &_key_null;
2915 key_null.data_len = 0;
2917 iv_block.data = _iv_block;
2919 ssl_debug_printf("%s prf(iv_block)\n", G_STRFUNC);
2920 if (!prf(ssl_session, &key_null, "IV block",
2921 &ssl_session->client_random,
2922 &ssl_session->server_random, &iv_block,
2923 ssl_session->cipher_suite.block * 2)) {
2924 ssl_debug_printf("%s can't generate tls31 iv block\n", G_STRFUNC);
2928 memcpy(_iv_c,iv_block.data,ssl_session->cipher_suite.block);
2929 memcpy(_iv_s,iv_block.data+ssl_session->cipher_suite.block,
2930 ssl_session->cipher_suite.block);
2937 if (ssl_session->version_netorder==SSLV3_VERSION){
2940 ssl_debug_printf("%s MD5(client_random)\n", G_STRFUNC);
2943 ssl_md5_update(&md5,c_wk,ssl_session->cipher_suite.eff_bits/8);
2944 ssl_md5_update(&md5,ssl_session->client_random.data,
2945 ssl_session->client_random.data_len);
2946 ssl_md5_update(&md5,ssl_session->server_random.data,
2947 ssl_session->server_random.data_len);
2948 ssl_md5_final(_key_c,&md5);
2949 ssl_md5_cleanup(&md5);
2953 ssl_debug_printf("%s MD5(server_random)\n", G_STRFUNC);
2954 ssl_md5_update(&md5,s_wk,ssl_session->cipher_suite.eff_bits/8);
2955 ssl_md5_update(&md5,ssl_session->server_random.data,
2956 ssl_session->server_random.data_len);
2957 ssl_md5_update(&md5,ssl_session->client_random.data,
2958 ssl_session->client_random.data_len);
2959 ssl_md5_final(_key_s,&md5);
2960 ssl_md5_cleanup(&md5);
2964 StringInfo key_c, key_s, k;
2965 key_c.data = _key_c;
2966 key_s.data = _key_s;
2969 k.data_len = ssl_session->cipher_suite.eff_bits/8;
2970 ssl_debug_printf("%s PRF(key_c)\n", G_STRFUNC);
2971 if (!prf(ssl_session, &k, "client write key",
2972 &ssl_session->client_random,
2973 &ssl_session->server_random, &key_c, sizeof(_key_c))) {
2974 ssl_debug_printf("%s can't generate tll31 server key \n", G_STRFUNC);
2980 k.data_len = ssl_session->cipher_suite.eff_bits/8;
2981 ssl_debug_printf("%s PRF(key_s)\n", G_STRFUNC);
2982 if (!prf(ssl_session, &k, "server write key",
2983 &ssl_session->client_random,
2984 &ssl_session->server_random, &key_s, sizeof(_key_s))) {
2985 ssl_debug_printf("%s can't generate tll31 client key \n", G_STRFUNC);
2992 /* show key material info */
2994 ssl_print_data("Client MAC key",c_mk,ssl_cipher_suite_dig(&ssl_session->cipher_suite)->len);
2995 ssl_print_data("Server MAC key",s_mk,ssl_cipher_suite_dig(&ssl_session->cipher_suite)->len);
2997 ssl_print_data("Client Write key",c_wk,ssl_session->cipher_suite.bits/8);
2998 ssl_print_data("Server Write key",s_wk,ssl_session->cipher_suite.bits/8);
3000 if(ssl_session->cipher_suite.block>1) {
3001 ssl_print_data("Client Write IV",c_iv,ssl_session->cipher_suite.block);
3002 ssl_print_data("Server Write IV",s_iv,ssl_session->cipher_suite.block);
3005 ssl_print_data("Client Write IV",c_iv,8);
3006 ssl_print_data("Server Write IV",s_iv,8);
3009 /* create both client and server ciphers*/
3010 ssl_debug_printf("%s ssl_create_decoder(client)\n", G_STRFUNC);
3011 ssl_session->client_new = ssl_create_decoder(&ssl_session->cipher_suite, ssl_session->session.compression, c_mk, c_wk, c_iv);
3012 if (!ssl_session->client_new) {
3013 ssl_debug_printf("%s can't init client decoder\n", G_STRFUNC);
3016 ssl_debug_printf("%s ssl_create_decoder(server)\n", G_STRFUNC);
3017 ssl_session->server_new = ssl_create_decoder(&ssl_session->cipher_suite, ssl_session->session.compression, s_mk, s_wk, s_iv);
3018 if (!ssl_session->server_new) {
3019 ssl_debug_printf("%s can't init client decoder\n", G_STRFUNC);
3023 ssl_debug_printf("%s: client seq %d, server seq %d\n",
3024 G_STRFUNC, ssl_session->client_new->seq, ssl_session->server_new->seq);
3025 g_free(key_block.data);
3026 ssl_session->state |= SSL_HAVE_SESSION_KEY;
3030 g_free(key_block.data);
3035 ssl_change_cipher(SslDecryptSession *ssl_session, gboolean server)
3037 ssl_debug_printf("ssl_change_cipher %s\n", (server)?"SERVER":"CLIENT");
3039 ssl_session->server = ssl_session->server_new;
3040 ssl_session->server_new = NULL;
3042 ssl_session->client = ssl_session->client_new;
3043 ssl_session->client_new = NULL;
3048 ssl_decrypt_pre_master_secret(SslDecryptSession*ssl_session,
3049 StringInfo* encrypted_pre_master, gcry_sexp_t pk)
3053 if (!encrypted_pre_master)
3055 if(ssl_session->cipher_suite.kex == KEX_DHE_DSS ||
3056 ssl_session->cipher_suite.kex == KEX_DHE_PSK ||
3057 ssl_session->cipher_suite.kex == KEX_DHE_RSA ||
3058 ssl_session->cipher_suite.kex == KEX_DH_ANON ||
3059 ssl_session->cipher_suite.kex == KEX_DH_DSS ||
3060 ssl_session->cipher_suite.kex == KEX_DH_RSA) {
3061 ssl_debug_printf("%s: session uses DH (%d) key exchange, which is "
3062 "impossible to decrypt\n", G_STRFUNC, ssl_session->cipher_suite.kex);
3064 } else if(ssl_session->cipher_suite.kex != KEX_RSA) {
3065 ssl_debug_printf("%s key exchange %d different from KEX_RSA (%d)\n",
3066 G_STRFUNC, ssl_session->cipher_suite.kex, KEX_RSA);
3070 /* with tls key loading will fail if not rsa type, so no need to check*/
3071 ssl_print_string("pre master encrypted",encrypted_pre_master);
3072 ssl_debug_printf("%s: RSA_private_decrypt\n", G_STRFUNC);
3073 i=ssl_private_decrypt(encrypted_pre_master->data_len,
3074 encrypted_pre_master->data, pk);
3077 ssl_debug_printf("%s wrong pre_master_secret length (%d, expected "
3078 "%d)\n", G_STRFUNC, i, 48);
3082 /* the decrypted data has been written into the pre_master key buffer */
3083 ssl_session->pre_master_secret.data = encrypted_pre_master->data;
3084 ssl_session->pre_master_secret.data_len=48;
3085 ssl_print_string("pre master secret",&ssl_session->pre_master_secret);
3087 /* Remove the master secret if it was there.
3088 This forces keying material regeneration in
3089 case we're renegotiating */
3090 ssl_session->state &= ~(SSL_MASTER_SECRET|SSL_HAVE_SESSION_KEY);
3091 ssl_session->state |= SSL_PRE_MASTER_SECRET;
3095 /* convert network byte order 32 byte number to right-aligned host byte order *
3097 static gint fmt_seq(guint32 num, guint8* buf)
3102 netnum=g_htonl(num);
3103 memcpy(buf+4,&netnum,4);
3109 tls_check_mac(SslDecoder*decoder, gint ct, gint ver, guint8* data,
3110 guint32 datalen, guint8* mac)
3115 guint8 buf[DIGEST_MAX_SIZE];
3118 md=ssl_get_digest_by_name(ssl_cipher_suite_dig(decoder->cipher_suite)->name);
3119 ssl_debug_printf("tls_check_mac mac type:%s md %d\n",
3120 ssl_cipher_suite_dig(decoder->cipher_suite)->name, md);
3122 if (ssl_hmac_init(&hm,decoder->mac_key.data,decoder->mac_key.data_len,md) != 0)
3125 /* hash sequence number */
3126 fmt_seq(decoder->seq,buf);
3130 ssl_hmac_update(&hm,buf,8);
3132 /* hash content type */
3134 ssl_hmac_update(&hm,buf,1);
3136 /* hash version,data length and data*/
3137 /* *((gint16*)buf) = g_htons(ver); */
3138 temp = g_htons(ver);
3139 memcpy(buf, &temp, 2);
3140 ssl_hmac_update(&hm,buf,2);
3142 /* *((gint16*)buf) = g_htons(datalen); */
3143 temp = g_htons(datalen);
3144 memcpy(buf, &temp, 2);
3145 ssl_hmac_update(&hm,buf,2);
3146 ssl_hmac_update(&hm,data,datalen);
3148 /* get digest and digest len*/
3150 ssl_hmac_final(&hm,buf,&len);
3151 ssl_hmac_cleanup(&hm);
3152 ssl_print_data("Mac", buf, len);
3153 if(memcmp(mac,buf,len))
3160 ssl3_check_mac(SslDecoder*decoder,int ct,guint8* data,
3161 guint32 datalen, guint8* mac)
3166 guint8 buf[64],dgst[20];
3170 pad_ct=(decoder->cipher_suite->dig==DIG_SHA)?40:48;
3172 /* get cipher used for digest comptuation */
3173 md=ssl_get_digest_by_name(ssl_cipher_suite_dig(decoder->cipher_suite)->name);
3174 if (ssl_md_init(&mc,md) !=0)
3177 /* do hash computation on data && padding */
3178 ssl_md_update(&mc,decoder->mac_key.data,decoder->mac_key.data_len);
3181 memset(buf,0x36,pad_ct);
3182 ssl_md_update(&mc,buf,pad_ct);
3184 /* hash sequence number */
3185 fmt_seq(decoder->seq,buf);
3187 ssl_md_update(&mc,buf,8);
3189 /* hash content type */
3191 ssl_md_update(&mc,buf,1);
3193 /* hash data length in network byte order and data*/
3194 /* *((gint16* )buf) = g_htons(datalen); */
3195 temp = g_htons(datalen);
3196 memcpy(buf, &temp, 2);
3197 ssl_md_update(&mc,buf,2);
3198 ssl_md_update(&mc,data,datalen);
3200 /* get partial digest */
3201 ssl_md_final(&mc,dgst,&len);
3202 ssl_md_cleanup(&mc);
3204 ssl_md_init(&mc,md);
3207 ssl_md_update(&mc,decoder->mac_key.data,decoder->mac_key.data_len);
3209 /* hash padding and partial digest*/
3210 memset(buf,0x5c,pad_ct);
3211 ssl_md_update(&mc,buf,pad_ct);
3212 ssl_md_update(&mc,dgst,len);
3214 ssl_md_final(&mc,dgst,&len);
3215 ssl_md_cleanup(&mc);
3217 if(memcmp(mac,dgst,len))
3224 dtls_check_mac(SslDecoder*decoder, gint ct,int ver, guint8* data,
3225 guint32 datalen, guint8* mac)
3230 guint8 buf[DIGEST_MAX_SIZE];
3233 md=ssl_get_digest_by_name(ssl_cipher_suite_dig(decoder->cipher_suite)->name);
3234 ssl_debug_printf("dtls_check_mac mac type:%s md %d\n",
3235 ssl_cipher_suite_dig(decoder->cipher_suite)->name, md);
3237 if (ssl_hmac_init(&hm,decoder->mac_key.data,decoder->mac_key.data_len,md) != 0)
3239 ssl_debug_printf("dtls_check_mac seq: %d epoch: %d\n",decoder->seq,decoder->epoch);
3240 /* hash sequence number */
3241 fmt_seq(decoder->seq,buf);
3242 buf[0]=decoder->epoch>>8;
3243 buf[1]=(guint8)decoder->epoch;
3245 ssl_hmac_update(&hm,buf,8);
3247 /* hash content type */
3249 ssl_hmac_update(&hm,buf,1);
3251 /* hash version,data length and data */
3252 temp = g_htons(ver);
3253 memcpy(buf, &temp, 2);
3254 ssl_hmac_update(&hm,buf,2);
3256 temp = g_htons(datalen);
3257 memcpy(buf, &temp, 2);
3258 ssl_hmac_update(&hm,buf,2);
3259 ssl_hmac_update(&hm,data,datalen);
3260 /* get digest and digest len */
3262 ssl_hmac_final(&hm,buf,&len);
3263 ssl_hmac_cleanup(&hm);
3264 ssl_print_data("Mac", buf, len);
3265 if(memcmp(mac,buf,len))
3273 ssl_decompress_record(SslDecompress* decomp, const guchar* in, guint inl, StringInfo* out_str, guint* outl)
3277 switch (decomp->compression) {
3278 case 1: /* DEFLATE */
3280 if (out_str->data_len < 16384) { /* maximal plain length */
3281 ssl_data_realloc(out_str, 16384);
3283 decomp->istream.next_in = (guchar*)in;
3284 decomp->istream.avail_in = inl;
3285 decomp->istream.next_out = out_str->data;
3286 decomp->istream.avail_out = out_str->data_len;
3288 err = inflate(&decomp->istream, Z_SYNC_FLUSH);
3290 ssl_debug_printf("ssl_decompress_record: inflate() failed - %d\n", err);
3293 *outl = out_str->data_len - decomp->istream.avail_out;
3296 ssl_debug_printf("ssl_decompress_record: unsupported compression method %d\n", decomp->compression);
3303 ssl_decompress_record(SslDecompress* decomp _U_, const guchar* in _U_, guint inl _U_, StringInfo* out_str _U_, guint* outl _U_)
3305 ssl_debug_printf("ssl_decompress_record: unsupported compression method %d\n", decomp->compression);
3311 ssl_decrypt_record(SslDecryptSession*ssl,SslDecoder* decoder, gint ct,
3312 const guchar* in, guint inl, StringInfo* comp_str, StringInfo* out_str, guint* outl)
3314 guint pad, worklen, uncomplen;
3317 ssl_debug_printf("ssl_decrypt_record ciphertext len %d\n", inl);
3318 ssl_print_data("Ciphertext",in, inl);
3320 /* ensure we have enough storage space for decrypted data */
3321 if (inl > out_str->data_len)
3323 ssl_debug_printf("ssl_decrypt_record: allocating %d bytes for decrypt data (old len %d)\n",
3324 inl + 32, out_str->data_len);
3325 ssl_data_realloc(out_str, inl + 32);
3328 /* RFC 6101/2246: SSLCipherText/TLSCipherText has two structures for types:
3329 * (notation: { unencrypted, [ encrypted ] })
3330 * GenericStreamCipher: { [content, mac] }
3331 * GenericBlockCipher: { IV (TLS 1.1+), [content, mac, padding, padding_len] }
3332 * RFC 5426 (TLS 1.2): TLSCipherText has additionally:
3333 * GenericAEADCipher: { nonce_explicit, [content] }
3334 * RFC 4347 (DTLS): based on TLS 1.1, only GenericBlockCipher is supported.
3335 * RFC 6347 (DTLS 1.2): based on TLS 1.2, includes GenericAEADCipher too.
3338 /* (TLS 1.1 and later, DTLS) Extract explicit IV for GenericBlockCipher */
3339 if (decoder->cipher_suite->mode == MODE_CBC) {
3340 switch (ssl->version_netorder) {
3341 case TLSV1DOT1_VERSION:
3342 case TLSV1DOT2_VERSION:
3343 case DTLSV1DOT0_VERSION:
3344 case DTLSV1DOT2_VERSION:
3345 case DTLSV1DOT0_VERSION_NOT:
3346 if ((gint)inl < decoder->cipher_suite->block) {
3347 ssl_debug_printf("ssl_decrypt_record failed: input %d has no space for IV %d\n",
3348 inl, decoder->cipher_suite->block);
3351 pad = gcry_cipher_setiv(decoder->evp, in, decoder->cipher_suite->block);
3353 ssl_debug_printf("ssl_decrypt_record failed: failed to set IV: %s %s\n",
3354 gcry_strsource (pad), gcry_strerror (pad));
3357 inl -= decoder->cipher_suite->block;
3358 in += decoder->cipher_suite->block;
3363 /* Nonce for GenericAEADCipher */
3364 if (decoder->cipher_suite->mode == MODE_GCM ||
3365 decoder->cipher_suite->mode == MODE_CCM ||
3366 decoder->cipher_suite->mode == MODE_CCM_8) {
3367 /* 4 bytes write_iv, 8 bytes explicit_nonce, 4 bytes counter */
3368 guchar gcm_nonce[16] = { 0 };
3370 if ((gint)inl < SSL_EX_NONCE_LEN_GCM) {
3371 ssl_debug_printf("ssl_decrypt_record failed: input %d has no space for nonce %d\n",
3372 inl, SSL_EX_NONCE_LEN_GCM);
3376 if (decoder->cipher_suite->mode == MODE_GCM) {
3377 memcpy(gcm_nonce, decoder->write_iv.data, decoder->write_iv.data_len); /* salt */
3378 memcpy(gcm_nonce + decoder->write_iv.data_len, in, SSL_EX_NONCE_LEN_GCM);
3379 /* NIST SP 800-38D, sect. 7.2 says that the 32-bit counter part starts
3380 * at 1, and gets incremented before passing to the block cipher. */
3381 gcm_nonce[4 + SSL_EX_NONCE_LEN_GCM + 3] = 2;
3382 } else { /* MODE_CCM and MODE_CCM_8 */
3383 /* The nonce for CCM and GCM are the same, but the nonce is used as input
3384 * in the CCM algorithm described in RFC 3610. The nonce generated here is
3385 * the one from RFC 3610 sect 2.3. Encryption. */
3386 /* Flags: (L-1) ; L = 16 - 1 - nonceSize */
3387 gcm_nonce[0] = 3 - 1;
3389 memcpy(gcm_nonce + 1, decoder->write_iv.data, decoder->write_iv.data_len); /* salt */
3390 memcpy(gcm_nonce + 1 + decoder->write_iv.data_len, in, SSL_EX_NONCE_LEN_GCM);
3391 gcm_nonce[4 + SSL_EX_NONCE_LEN_GCM + 3] = 1;
3394 pad = gcry_cipher_setctr (decoder->evp, gcm_nonce, sizeof (gcm_nonce));
3396 ssl_debug_printf("ssl_decrypt_record failed: failed to set CTR: %s %s\n",
3397 gcry_strsource (pad), gcry_strerror (pad));
3400 inl -= SSL_EX_NONCE_LEN_GCM;
3401 in += SSL_EX_NONCE_LEN_GCM;
3405 if ((pad = ssl_cipher_decrypt(&decoder->evp, out_str->data, out_str->data_len, in, inl))!= 0) {
3406 ssl_debug_printf("ssl_decrypt_record failed: ssl_cipher_decrypt: %s %s\n", gcry_strsource (pad),
3407 gcry_strerror (pad));
3411 ssl_print_data("Plaintext", out_str->data, inl);
3414 /* RFC 5116 sect 5.1/5.3: AES128/256 GCM/CCM uses 16 bytes for auth tag
3415 * RFC 6655 sect 6.1: AEAD_AES_128_CCM uses 16 bytes for auth tag */
3416 if (decoder->cipher_suite->mode == MODE_GCM ||
3417 decoder->cipher_suite->mode == MODE_CCM) {
3419 ssl_debug_printf("ssl_decrypt_record failed: missing tag, work %d\n", worklen);
3422 /* XXX - validate auth tag */
3425 /* RFC 6655 sect 6.1: AEAD_AES_128_CCM_8 uses 8 bytes for auth tag */
3426 if (decoder->cipher_suite->mode == MODE_CCM_8) {
3428 ssl_debug_printf("ssl_decrypt_record failed: missing tag, work %d\n", worklen);
3431 /* XXX - validate auth tag */
3435 /* strip padding for GenericBlockCipher */
3436 if (decoder->cipher_suite->mode == MODE_CBC) {
3437 if (inl < 1) { /* Should this check happen earlier? */
3438 ssl_debug_printf("ssl_decrypt_record failed: input length %d too small\n", inl);
3441 pad=out_str->data[inl-1];
3442 if (worklen <= pad) {
3443 ssl_debug_printf("ssl_decrypt_record failed: padding %d too large for work %d\n",
3448 ssl_debug_printf("ssl_decrypt_record found padding %d final len %d\n",
3452 /* MAC for GenericStreamCipher and GenericBlockCipher */
3453 if (decoder->cipher_suite->mode == MODE_STREAM ||
3454 decoder->cipher_suite->mode == MODE_CBC) {
3455 if (ssl_cipher_suite_dig(decoder->cipher_suite)->len > (gint)worklen) {
3456 ssl_debug_printf("ssl_decrypt_record wrong record len/padding outlen %d\n work %d\n",*outl, worklen);
3459 worklen-=ssl_cipher_suite_dig(decoder->cipher_suite)->len;
3460 mac = out_str->data + worklen;
3461 } else /* if (decoder->cipher_suite->mode == MODE_GCM) */ {
3462 /* GenericAEADCipher has no MAC */
3466 /* Now check the MAC */
3467 ssl_debug_printf("checking mac (len %d, version %X, ct %d seq %d)\n",
3468 worklen, ssl->version_netorder, ct, decoder->seq);
3469 if(ssl->version_netorder==SSLV3_VERSION){
3470 if(ssl3_check_mac(decoder,ct,out_str->data,worklen,mac) < 0) {
3471 if(ssl_ignore_mac_failed) {
3472 ssl_debug_printf("ssl_decrypt_record: mac failed, but ignored for troubleshooting ;-)\n");
3475 ssl_debug_printf("ssl_decrypt_record: mac failed\n");
3480 ssl_debug_printf("ssl_decrypt_record: mac ok\n");
3483 else if(ssl->version_netorder==TLSV1_VERSION || ssl->version_netorder==TLSV1DOT1_VERSION || ssl->version_netorder==TLSV1DOT2_VERSION){
3484 if(tls_check_mac(decoder,ct,ssl->version_netorder,out_str->data,worklen,mac)< 0) {
3485 if(ssl_ignore_mac_failed) {
3486 ssl_debug_printf("ssl_decrypt_record: mac failed, but ignored for troubleshooting ;-)\n");
3489 ssl_debug_printf("ssl_decrypt_record: mac failed\n");
3494 ssl_debug_printf("ssl_decrypt_record: mac ok\n");
3497 else if(ssl->version_netorder==DTLSV1DOT0_VERSION ||
3498 ssl->version_netorder==DTLSV1DOT2_VERSION ||
3499 ssl->version_netorder==DTLSV1DOT0_VERSION_NOT){
3500 /* Try rfc-compliant mac first, and if failed, try old openssl's non-rfc-compliant mac */
3501 if(dtls_check_mac(decoder,ct,ssl->version_netorder,out_str->data,worklen,mac)>= 0) {
3502 ssl_debug_printf("ssl_decrypt_record: mac ok\n");
3504 else if(tls_check_mac(decoder,ct,TLSV1_VERSION,out_str->data,worklen,mac)>= 0) {
3505 ssl_debug_printf("ssl_decrypt_record: dtls rfc-compliant mac failed, but old openssl's non-rfc-compliant mac ok\n");
3507 else if(ssl_ignore_mac_failed) {
3508 ssl_debug_printf("ssl_decrypt_record: mac failed, but ignored for troubleshooting ;-)\n");
3511 ssl_debug_printf("ssl_decrypt_record: mac failed\n");
3519 if (decoder->compression > 0) {
3520 ssl_debug_printf("ssl_decrypt_record: compression method %d\n", decoder->compression);
3521 ssl_data_copy(comp_str, out_str);
3522 ssl_print_data("Plaintext compressed", comp_str->data, worklen);
3523 if (!decoder->decomp) {
3524 ssl_debug_printf("decrypt_ssl3_record: no decoder available\n");
3527 if (ssl_decompress_record(decoder->decomp, comp_str->data, worklen, out_str, &uncomplen) < 0) return -1;
3528 ssl_print_data("Plaintext uncompressed", out_str->data, uncomplen);
3537 ssl_privkey_to_sexp(gnutls_x509_privkey_t priv_key)
3539 gnutls_datum_t rsa_datum[RSA_PARS]; /* m, e, d, p, q, u */
3542 gcry_sexp_t rsa_priv_key = NULL;
3544 gcry_mpi_t rsa_params[RSA_PARS];
3546 /* RSA get parameter */
3547 if (gnutls_x509_privkey_export_rsa_raw(priv_key,
3553 &rsa_datum[5]) != 0) {
3554 ssl_debug_printf("ssl_load_key: can't export rsa param (is a rsa private key file ?!?)\n");
3558 /* convert each rsa parameter to mpi format*/
3559 for(i=0; i<RSA_PARS; i++) {
3560 gret = gcry_mpi_scan(&rsa_params[i], GCRYMPI_FMT_USG, rsa_datum[i].data, rsa_datum[i].size,&tmp_size);
3561 /* these buffers were allocated by gnutls_x509_privkey_export_rsa_raw() */
3562 g_free(rsa_datum[i].data);
3564 ssl_debug_printf("ssl_load_key: can't convert m rsa param to int (size %d)\n", rsa_datum[i].size);
3569 /* libgcrypt expects p < q, and gnutls might not return it as such, depending on gnutls version and its crypto backend */
3570 if (gcry_mpi_cmp(rsa_params[3], rsa_params[4]) > 0)
3572 ssl_debug_printf("ssl_load_key: swapping p and q parameters and recomputing u\n");
3574 gcry_mpi_swap(rsa_params[3], rsa_params[4]);
3575 /* due to swapping p and q, u = p^-1 mod p which happens to be needed. */
3577 /* libgcrypt expects u = p^-1 mod q (for OpenPGP), but the u parameter
3578 * says u = q^-1 mod p. Recompute u = p^-1 mod q. Do this unconditionally as
3579 * at least GnuTLS 2.12.23 computes an invalid value. */
3580 gcry_mpi_invm(rsa_params[5], rsa_params[3], rsa_params[4]);
3582 if (gcry_sexp_build( &rsa_priv_key, NULL,
3583 "(private-key(rsa((n%m)(e%m)(d%m)(p%m)(q%m)(u%m))))", rsa_params[0],
3584 rsa_params[1], rsa_params[2], rsa_params[3], rsa_params[4],
3585 rsa_params[5]) != 0) {
3586 ssl_debug_printf("ssl_load_key: can't build rsa private key s-exp\n");
3590 for (i=0; i< 6; i++)
3591 gcry_mpi_release(rsa_params[i]);
3592 return rsa_priv_key;
3595 /** Load an RSA private key from specified file
3596 @param fp the file that contain the key data
3597 @return a pointer to the loaded key on success, or NULL */
3598 static gnutls_x509_privkey_t
3599 ssl_load_key(FILE* fp)
3601 /* gnutls makes our work much harder, since we have to work internally with
3602 * s-exp formatted data, but PEM loader exports only in "gnutls_datum_t"
3603 * format, and a datum -> s-exp convertion function does not exist.
3605 gnutls_x509_privkey_t priv_key;
3611 if (ws_fstat64(fileno(fp), &statbuf) == -1) {
3612 ssl_debug_printf("ssl_load_key: can't ws_fstat64 file\n");
3615 if (S_ISDIR(statbuf.st_mode)) {
3616 ssl_debug_printf("ssl_load_key: file is a directory\n");
3620 if (S_ISFIFO(statbuf.st_mode)) {
3621 ssl_debug_printf("ssl_load_key: file is a named pipe\n");
3625 if (!S_ISREG(statbuf.st_mode)) {
3626 ssl_debug_printf("ssl_load_key: file is not a regular file\n");
3630 /* XXX - check for a too-big size */
3631 /* load all file contents into a datum buffer*/
3632 key.data = (unsigned char *)g_malloc((size_t)statbuf.st_size);
3633 key.size = (int)statbuf.st_size;
3634 bytes = (guint) fread(key.data, 1, key.size, fp);
3635 if (bytes < key.size) {
3636 ssl_debug_printf("ssl_load_key: can't read from file %d bytes, got %d\n",
3642 /* init private key data*/
3643 gnutls_x509_privkey_init(&priv_key);
3645 /* import PEM data*/
3646 if ((ret = gnutls_x509_privkey_import(priv_key, &key, GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS) {
3647 ssl_debug_printf("ssl_load_key: can't import pem data: %s\n", gnutls_strerror(ret));
3652 if (gnutls_x509_privkey_get_pk_algorithm(priv_key) != GNUTLS_PK_RSA) {
3653 ssl_debug_printf("ssl_load_key: private key public key algorithm isn't RSA\n");
3664 BAGTYPE(gnutls_pkcs12_bag_type_t x) {
3666 case GNUTLS_BAG_EMPTY: return "Empty";
3667 case GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: return "PKCS#8 Encrypted key";
3668 case GNUTLS_BAG_PKCS8_KEY: return "PKCS#8 Key";
3669 case GNUTLS_BAG_CERTIFICATE: return "Certificate";
3670 case GNUTLS_BAG_CRL: return "CRL";
3671 case GNUTLS_BAG_ENCRYPTED: return "Encrypted";
3672 case GNUTLS_BAG_UNKNOWN: return "Unknown";
3673 default: return "<undefined>";
3678 * Load a RSA private key from a PKCS#12 file.
3679 * @param fp the file that contains the key data.
3680 * @param cert_passwd password to decrypt the PKCS#12 file.
3681 * @param[out] err error message upon failure; NULL upon success.
3682 * @return a pointer to the loaded key on success; NULL upon failure.
3684 static gnutls_x509_privkey_t
3685 ssl_load_pkcs12(FILE* fp, const gchar *cert_passwd, char** err) {
3690 gnutls_datum_t data;
3691 gnutls_pkcs12_bag_t bag = NULL;
3692 gnutls_pkcs12_bag_type_t bag_type;
3695 gnutls_pkcs12_t ssl_p12 = NULL;
3696 gnutls_x509_privkey_t ssl_pkey = NULL;
3698 gnutls_x509_privkey_t priv_key = NULL;
3702 data.data = (unsigned char *)g_malloc(rest);
3705 while ((len = fread(p, 1, rest, fp)) > 0) {
3710 data.data = (unsigned char *)g_realloc(data.data, data.size + rest);
3711 p = data.data + data.size;
3716 ssl_debug_printf("%d bytes read\n", data.size);
3718 *err = g_strdup("Error during certificate reading.");
3719 ssl_debug_printf("%s\n", *err);
3724 ret = gnutls_pkcs12_init(&ssl_p12);
3726 *err = g_strdup_printf("gnutls_pkcs12_init(&st_p12) - %s", gnutls_strerror(ret));
3727 ssl_debug_printf("%s\n", *err);
3732 /* load PKCS#12 in DER or PEM format */
3733 ret = gnutls_pkcs12_import(ssl_p12, &data, GNUTLS_X509_FMT_DER, 0);
3735 *err = g_strdup_printf("could not load PKCS#12 in DER format: %s", gnutls_strerror(ret));
3736 ssl_debug_printf("%s\n", *err);
3739 ret = gnutls_pkcs12_import(ssl_p12, &data, GNUTLS_X509_FMT_PEM, 0);
3741 *err = g_strdup_printf("could not load PKCS#12 in PEM format: %s", gnutls_strerror(ret));
3742 ssl_debug_printf("%s\n", *err);
3752 ssl_debug_printf( "PKCS#12 imported\n");
3754 /* TODO: Use gnutls_pkcs12_simple_parse, since 3.1.0 (August 2012) */
3757 ret = gnutls_pkcs12_bag_init(&bag);
3760 ret = gnutls_pkcs12_get_bag(ssl_p12, i, bag);
3763 for (j=0; j<gnutls_pkcs12_bag_get_count(bag); j++) {
3765 bag_type = gnutls_pkcs12_bag_get_type(bag, j);
3766 if (bag_type >= GNUTLS_BAG_UNKNOWN) goto done;
3767 ssl_debug_printf( "Bag %d/%d: %s\n", i, j, BAGTYPE(bag_type));
3768 if (bag_type == GNUTLS_BAG_ENCRYPTED) {
3769 ret = gnutls_pkcs12_bag_decrypt(bag, cert_passwd);
3771 bag_type = gnutls_pkcs12_bag_get_type(bag, j);
3772 if (bag_type >= GNUTLS_BAG_UNKNOWN) goto done;
3773 ssl_debug_printf( "Bag %d/%d decrypted: %s\n", i, j, BAGTYPE(bag_type));
3777 ret = gnutls_pkcs12_bag_get_data(bag, j, &data);
3778 if (ret < 0) goto done;
3782 case GNUTLS_BAG_PKCS8_KEY:
3783 case GNUTLS_BAG_PKCS8_ENCRYPTED_KEY:
3785 ret = gnutls_x509_privkey_init(&ssl_pkey);
3787 *err = g_strdup_printf("gnutls_x509_privkey_init(&ssl_pkey) - %s", gnutls_strerror(ret));
3788 ssl_debug_printf("%s\n", *err);
3791 ret = gnutls_x509_privkey_import_pkcs8(ssl_pkey, &data, GNUTLS_X509_FMT_DER, cert_passwd,
3792 (bag_type==GNUTLS_BAG_PKCS8_KEY) ? GNUTLS_PKCS_PLAIN : 0);
3794 *err = g_strdup_printf("Can not decrypt private key - %s", gnutls_strerror(ret));
3795 ssl_debug_printf("%s\n", *err);
3799 if (gnutls_x509_privkey_get_pk_algorithm(ssl_pkey) != GNUTLS_PK_RSA) {
3800 *err = g_strdup("ssl_load_pkcs12: private key public key algorithm isn't RSA");
3801 ssl_debug_printf("%s\n", *err);
3805 /* Private key found, return it. */
3806 priv_key = ssl_pkey;
3813 if (bag) { gnutls_pkcs12_bag_deinit(bag); bag = NULL; }
3817 if (!priv_key && ssl_pkey)
3818 gnutls_x509_privkey_deinit(ssl_pkey);
3820 gnutls_pkcs12_bag_deinit(bag);
3827 ssl_private_key_free(gpointer key)
3829 gcry_sexp_release((gcry_sexp_t) key);
3833 ssl_find_private_key_by_pubkey(SslDecryptSession *ssl, GHashTable *key_hash,
3834 gnutls_datum_t *subjectPublicKeyInfo)
3836 gnutls_pubkey_t pubkey = NULL;
3838 size_t key_id_len = sizeof(key_id);
3841 if (!subjectPublicKeyInfo->size) {
3842 ssl_debug_printf("%s: could not find SubjectPublicKeyInfo\n", G_STRFUNC);
3846 r = gnutls_pubkey_init(&pubkey);
3848 ssl_debug_printf("%s: failed to init pubkey: %s\n",
3849 G_STRFUNC, gnutls_strerror(r));
3853 r = gnutls_pubkey_import(pubkey, subjectPublicKeyInfo, GNUTLS_X509_FMT_DER);
3855 ssl_debug_printf("%s: failed to import pubkey from handshake: %s\n",
3856 G_STRFUNC, gnutls_strerror(r));
3860 /* Generate a 20-byte SHA-1 hash. */
3861 r = gnutls_pubkey_get_key_id(pubkey, 0, key_id, &key_id_len);
3863 ssl_debug_printf("%s: failed to extract key id from pubkey: %s\n",
3864 G_STRFUNC, gnutls_strerror(r));
3868 ssl_print_data("lookup(KeyID)", key_id, key_id_len);
3869 ssl->private_key = (gcry_sexp_t)g_hash_table_lookup(key_hash, key_id);
3870 ssl_debug_printf("%s: lookup result: %p\n", G_STRFUNC, (void *) ssl->private_key);
3873 gnutls_pubkey_deinit(pubkey);
3879 ssl_debug_printf("gnutls version: %s\n", gnutls_check_version(NULL));
3882 #else /* defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT) */
3883 /* no libgnutl: dummy operation to keep interface consistent*/
3890 ssl_private_key_free(gpointer key _U_)
3895 ssl_find_cipher(int num,SslCipherSuite* cs)
3897 ssl_debug_printf("ssl_find_cipher: dummy without gnutls. num %d cs %p\n",
3902 ssl_generate_pre_master_secret(SslDecryptSession *ssl_session _U_,
3903 guint32 length _U_, tvbuff_t *tvb _U_, guint32 offset _U_,
3904 const gchar *ssl_psk _U_, const ssl_master_key_map_t *mk_map _U_)
3906 ssl_debug_printf("%s: impossible without gnutls.\n", G_STRFUNC);
3910 ssl_generate_keyring_material(SslDecryptSession*ssl)
3912 ssl_debug_printf("ssl_generate_keyring_material: impossible without gnutls. ssl %p\n",
3917 ssl_change_cipher(SslDecryptSession *ssl_session, gboolean server)
3919 ssl_debug_printf("ssl_change_cipher %s: makes no sense without gnutls. ssl %p\n",
3920 (server)?"SERVER":"CLIENT", ssl_session);
3924 ssl_decrypt_record(SslDecryptSession*ssl, SslDecoder* decoder, gint ct,
3925 const guchar* in, guint inl, StringInfo* comp_str _U_, StringInfo* out, guint* outl)
3927 ssl_debug_printf("ssl_decrypt_record: impossible without gnutls. ssl %p"
3928 "decoder %p ct %d, in %p inl %d out %p outl %p\n", ssl, decoder, ct,
3929 in, inl, out, outl);
3934 ssl_cipher_setiv(SSL_CIPHER_CTX *cipher _U_, guchar* iv _U_, gint iv_len _U_)
3936 ssl_debug_printf("ssl_cipher_setiv: impossible without gnutls.\n");
3940 #endif /* defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT) */
3942 /* get ssl data for this session. if no ssl data is found allocate a new one*/
3944 ssl_get_session(conversation_t *conversation, dissector_handle_t ssl_handle)
3947 SslDecryptSession *ssl_session;
3950 proto_ssl = dissector_handle_get_protocol_index(ssl_handle);
3951 conv_data = conversation_get_proto_data(conversation, proto_ssl);
3952 if (conv_data != NULL)
3953 return (SslDecryptSession *)conv_data;
3955 /* no previous SSL conversation info, initialize it. */
3956 ssl_session = wmem_new0(wmem_file_scope(), SslDecryptSession);
3958 /* data_len is the part that is meaningful, not the allocated length */
3959 ssl_session->master_secret.data_len = 0;
3960 ssl_session->master_secret.data = ssl_session->_master_secret;
3961 ssl_session->session_id.data_len = 0;
3962 ssl_session->session_id.data = ssl_session->_session_id;
3963 ssl_session->client_random.data_len = 0;
3964 ssl_session->client_random.data = ssl_session->_client_random;
3965 ssl_session->server_random.data_len = 0;
3966 ssl_session->server_random.data = ssl_session->_server_random;
3967 ssl_session->session_ticket.data_len = 0;
3968 ssl_session->session_ticket.data = NULL; /* will be re-alloced as needed */
3969 ssl_session->server_data_for_iv.data_len = 0;
3970 ssl_session->server_data_for_iv.data = ssl_session->_server_data_for_iv;
3971 ssl_session->client_data_for_iv.data_len = 0;
3972 ssl_session->client_data_for_iv.data = ssl_session->_client_data_for_iv;
3973 ssl_session->app_data_segment.data = NULL;
3974 ssl_session->app_data_segment.data_len = 0;
3975 ssl_session->handshake_data.data=NULL;
3976 ssl_session->handshake_data.data_len=0;
3978 /* Initialize parameters which are not necessary specific to decryption. */
3979 ssl_session->session.version = SSL_VER_UNKNOWN;
3980 SET_ADDRESS(&ssl_session->session.srv_addr, AT_NONE, 0, NULL);
3981 ssl_session->session.srv_ptype = PT_NONE;
3982 ssl_session->session.srv_port = 0;
3984 conversation_add_proto_data(conversation, proto_ssl, ssl_session);
3989 ssl_set_server(SslSession *session, address *addr, port_type ptype, guint32 port)
3991 WMEM_COPY_ADDRESS(wmem_file_scope(), &session->srv_addr, addr);
3992 session->srv_ptype = ptype;
3993 session->srv_port = port;
3997 ssl_starttls_ack(dissector_handle_t ssl_handle, packet_info *pinfo,
3998 dissector_handle_t app_handle)
4000 conversation_t *conversation;
4001 SslSession *session;
4003 /* Ignore if the SSL dissector is disabled. */
4006 /* The caller should always pass a valid handle to its own dissector. */
4007 DISSECTOR_ASSERT(app_handle);
4009 conversation = find_or_create_conversation(pinfo);
4010 session = &ssl_get_session(conversation, ssl_handle)->session;
4012 ssl_debug_printf("%s: old frame %d, app_handle=%p (%s)\n", G_STRFUNC,
4013 session->last_nontls_frame,
4014 (void *)session->app_handle,
4015 dissector_handle_get_dissector_name(session->app_handle));
4016 ssl_debug_printf("%s: current frame %d, app_handle=%p (%s)\n", G_STRFUNC,
4017 pinfo->fd->num, (void *)app_handle,
4018 dissector_handle_get_dissector_name(app_handle));
4020 /* Do not switch again if a dissector did it before. */
4021 if (session->last_nontls_frame) {
4022 ssl_debug_printf("%s: not overriding previous app handle!\n", G_STRFUNC);
4023 return session->last_nontls_frame;
4026 session->app_handle = app_handle;
4027 /* The SSL dissector should be called first for this conversation. */
4028 conversation_set_dissector(conversation, ssl_handle);
4029 /* SSL starts after this frame. */
4030 session->last_nontls_frame = pinfo->fd->num;
4034 /* Hash Functions for TLS/DTLS sessions table and private keys table*/
4036 ssl_equal (gconstpointer v, gconstpointer v2)
4038 const StringInfo *val1;
4039 const StringInfo *val2;
4040 val1 = (const StringInfo *)v;
4041 val2 = (const StringInfo *)v2;
4043 if (val1->data_len == val2->data_len &&
4044 !memcmp(val1->data, val2->data, val2->data_len)) {
4051 ssl_hash (gconstpointer v)
4054 const StringInfo* id;
4057 id = (const StringInfo*) v;
4059 /* id and id->data are mallocated in ssl_save_master_key(). As such 'data'
4060 * should be aligned for any kind of access (for example as a guint as
4061 * is done below). The intermediate void* cast is to prevent "cast
4062 * increases required alignment of target type" warnings on CPUs (such
4063 * as SPARCs) that do not allow misaligned memory accesses.
4065 cur = (const guint*)(void*) id->data;
4067 for (l=4; (l < id->data_len); l+=4, cur++)
4068 hash = hash ^ (*cur);
4074 ssl_private_key_equal (gconstpointer v, gconstpointer v2)
4076 /* key ID length (SHA-1 hash, per GNUTLS_KEYID_USE_SHA1) */
4077 return !memcmp(v, v2, 20);
4081 ssl_private_key_hash (gconstpointer v)
4084 const guint8 *cur = (const guint8 *)v;
4086 /* The public key' SHA-1 hash (which maps to a private key) has a uniform
4087 * distribution, hence simply xor'ing them should be sufficient. */
4088 for (l = 0; l < 20; l += 4, cur += 4)
4089 hash ^= pntoh32(cur);
4094 /* handling of association between tls/dtls ports and clear text protocol */
4096 ssl_association_add(GTree* associations, dissector_handle_t handle, guint port, const gchar *protocol, gboolean tcp, gboolean from_key_list)
4099 SslAssociation* assoc;
4100 assoc = (SslAssociation *)g_malloc(sizeof(SslAssociation));
4103 assoc->ssl_port = port;
4104 assoc->info=g_strdup(protocol);
4105 assoc->handle = find_dissector(protocol);
4106 assoc->from_key_list = from_key_list;
4108 ssl_debug_printf("association_add %s port %d protocol %s handle %p\n",
4109 (assoc->tcp)?"TCP":"UDP", port, protocol, (void *)(assoc->handle));
4112 if (!assoc->handle) {
4113 ssl_debug_printf("association_add could not find handle for protocol '%s', try to find 'data' dissector\n", protocol);
4114 assoc->handle = find_dissector("data");
4117 DISSECTOR_ASSERT(assoc->handle != NULL);
4120 dissector_add_uint("tcp.port", port, handle);
4122 dissector_add_uint("udp.port", port, handle);
4124 g_tree_insert(associations, assoc, assoc);
4126 dissector_add_uint("sctp.port", port, handle);
4130 ssl_association_remove(GTree* associations, SslAssociation *assoc)
4132 ssl_debug_printf("ssl_association_remove removing %s %u - %s handle %p\n",
4133 (assoc->tcp)?"TCP":"UDP", assoc->ssl_port, assoc->info, (void *)(assoc->handle));
4135 dissector_delete_uint((assoc->tcp)?"tcp.port":"udp.port", assoc->ssl_port, assoc->handle);
4137 g_free(assoc->info);
4139 g_tree_remove(associations, assoc);
4144 ssl_association_cmp(gconstpointer a, gconstpointer b)
4146 const SslAssociation *assoc_a=(const SslAssociation *)a, *assoc_b=(const SslAssociation *)b;
4147 if (assoc_a->tcp != assoc_b->tcp) return (assoc_a->tcp)?1:-1;
4148 return assoc_a->ssl_port - assoc_b->ssl_port;
4152 ssl_association_find(GTree * associations, guint port, gboolean tcp)
4154 register SslAssociation* ret;
4155 SslAssociation assoc_tmp;
4157 assoc_tmp.tcp = tcp;
4158 assoc_tmp.ssl_port = port;
4159 ret = (SslAssociation *)g_tree_lookup(associations, &assoc_tmp);
4161 ssl_debug_printf("association_find: %s port %d found %p\n", (tcp)?"TCP":"UDP", port, (void *)ret);
4166 ssl_assoc_from_key_list(gpointer key _U_, gpointer data, gpointer user_data)
4168 if (((SslAssociation*)data)->from_key_list)
4169 wmem_stack_push((wmem_stack_t*)user_data, data);
4174 ssl_packet_from_server(SslSession *session, GTree *associations, packet_info *pinfo)
4177 if (session->srv_ptype != PT_NONE) {
4178 ret = (session->srv_ptype == pinfo->ptype) &&
4179 (session->srv_port == pinfo->srcport) &&
4180 ADDRESSES_EQUAL(&session->srv_addr, &pinfo->src);
4182 ret = ssl_association_find(associations, pinfo->srcport, pinfo->ptype != PT_UDP) != 0;
4185 ssl_debug_printf("packet_from_server: is from server - %s\n", (ret)?"TRUE":"FALSE");
4189 /* add to packet data a copy of the specified real data */
4191 ssl_add_record_info(gint proto, packet_info *pinfo, guchar* data, gint data_len, gint record_id)
4197 pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0);
4200 pi = (SslPacketInfo *)wmem_alloc0(wmem_file_scope(), sizeof(SslPacketInfo));
4201 p_add_proto_data(wmem_file_scope(), pinfo, proto, 0, pi);
4204 real_data = (guchar *)wmem_alloc(wmem_file_scope(), data_len);
4205 memcpy(real_data, data, data_len);
4207 rec = (SslRecordInfo *)wmem_alloc(wmem_file_scope(), sizeof(SslRecordInfo));
4208 rec->id = record_id;
4209 rec->real_data = real_data;
4210 rec->data_len = data_len;
4212 /* head insertion */
4213 rec->next= pi->handshake_data;
4214 pi->handshake_data = rec;
4217 /* search in packet data for the specified id; return a newly created tvb for the associated data */
4219 ssl_get_record_info(tvbuff_t *parent_tvb, int proto, packet_info *pinfo, gint record_id)
4223 pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0);
4228 for (rec = pi->handshake_data; rec; rec = rec->next)
4229 if (rec->id == record_id)
4230 /* link new real_data_tvb with a parent tvb so it is freed when frame dissection is complete */
4231 return tvb_new_child_real_data(parent_tvb, rec->real_data, rec->data_len, rec->data_len);
4237 ssl_add_data_info(gint proto, packet_info *pinfo, guchar* data, gint data_len, gint key, SslFlow *flow)
4239 SslDataInfo *rec, **prec;
4242 pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0);
4245 pi = (SslPacketInfo *)wmem_alloc0(wmem_file_scope(), sizeof(SslPacketInfo));
4246 p_add_proto_data(wmem_file_scope(), pinfo, proto, 0, pi);
4249 rec = (SslDataInfo *)wmem_alloc(wmem_file_scope(), sizeof(SslDataInfo)+data_len);
4251 rec->plain_data.data = (guchar*)(rec + 1);
4252 memcpy(rec->plain_data.data, data, data_len);
4253 rec->plain_data.data_len = data_len;
4256 rec->seq = flow->byte_seq;
4257 rec->nxtseq = flow->byte_seq + data_len;
4259 flow->byte_seq += data_len;
4264 prec = &pi->appl_data;
4265 while (*prec) prec = &(*prec)->next;
4268 ssl_debug_printf("ssl_add_data_info: new data inserted data_len = %d, seq = %u, nxtseq = %u\n",
4269 rec->plain_data.data_len, rec->seq, rec->nxtseq);
4273 ssl_get_data_info(int proto, packet_info *pinfo, gint key)
4277 pi = (SslPacketInfo *)p_get_proto_data(wmem_file_scope(), pinfo, proto, 0);
4279 if (!pi) return NULL;
4281 rec = pi->appl_data;
4283 if (rec->key == key) return rec;
4290 /* initialize/reset per capture state data (ssl sessions cache) */
4292 ssl_common_init(ssl_master_key_map_t *mk_map,
4293 StringInfo *decrypted_data, StringInfo *compressed_data)
4295 mk_map->session = g_hash_table_new(ssl_hash, ssl_equal);
4296 mk_map->crandom = g_hash_table_new(ssl_hash, ssl_equal);
4297 mk_map->pre_master = g_hash_table_new(ssl_hash, ssl_equal);
4298 mk_map->pms = g_hash_table_new(ssl_hash, ssl_equal);
4299 ssl_data_alloc(decrypted_data, 32);
4300 ssl_data_alloc(compressed_data, 32);
4304 ssl_common_cleanup(ssl_master_key_map_t *mk_map, FILE **ssl_keylog_file,
4305 StringInfo *decrypted_data, StringInfo *compressed_data)
4307 g_hash_table_destroy(mk_map->session);
4308 g_hash_table_destroy(mk_map->crandom);
4309 g_hash_table_destroy(mk_map->pre_master);
4310 g_hash_table_destroy(mk_map->pms);
4312 g_free(decrypted_data->data);
4313 g_free(compressed_data->data);
4315 /* close the previous keylog file now that the cache are cleared, this
4316 * allows the cache to be filled with the full keylog file contents. */
4317 if (*ssl_keylog_file) {
4318 fclose(*ssl_keylog_file);
4319 *ssl_keylog_file = NULL;
4323 /* parse ssl related preferences (private keys and ports association strings) */
4324 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
4326 ssl_parse_key_list(const ssldecrypt_assoc_t *uats, GHashTable *key_hash, GTree* associations, dissector_handle_t handle, gboolean tcp)
4328 gnutls_x509_privkey_t priv_key;
4329 gcry_sexp_t private_key;
4332 size_t key_id_len = 20;
4333 guchar *key_id = NULL;
4335 /* try to load keys file first */
4336 fp = ws_fopen(uats->keyfile, "rb");
4338 report_open_failure(uats->keyfile, errno, FALSE);
4342 if ((gint)strlen(uats->password) == 0) {
4343 priv_key = ssl_load_key(fp);
4346 priv_key = ssl_load_pkcs12(fp, uats->password, &err);
4348 report_failure("%s\n", err);
4355 report_failure("Can't load private key from %s\n", uats->keyfile);
4359 key_id = (guchar *) g_malloc0(key_id_len);
4360 ret = gnutls_x509_privkey_get_key_id(priv_key, 0, key_id, &key_id_len);
4362 report_failure("Can't calculate public key ID for %s: %s",
4363 uats->keyfile, gnutls_strerror(ret));
4366 ssl_print_data("KeyID", key_id, key_id_len);
4368 private_key = ssl_privkey_to_sexp(priv_key);
4370 report_failure("Can't extract private key parameters for %s", uats->keyfile);
4374 g_hash_table_replace(key_hash, key_id, private_key);
4375 key_id = NULL; /* used in key_hash, do not free. */
4376 ssl_debug_printf("ssl_init private key file %s successfully loaded.\n", uats->keyfile);
4379 /* Port to subprotocol mapping */
4380 int port = atoi(uats->port); /* Also maps "start_tls" -> 0 (wildcard) */
4381 ssl_debug_printf("ssl_init port '%d' filename '%s' password(only for p12 file) '%s'\n",
4382 port, uats->keyfile, uats->password);
4383 ssl_association_add(associations, handle, port, uats->protocol, tcp, TRUE);
4387 gnutls_x509_privkey_deinit(priv_key);
4392 ssl_parse_key_list(const ssldecrypt_assoc_t *uats _U_, GHashTable *key_hash _U_, GTree* associations _U_, dissector_handle_t handle _U_, gboolean tcp _U_)
4394 report_failure("Can't load private key files, support is not compiled in.");
4398 /** store a known (pre-)master secret into cache */
4400 ssl_save_master_key(const char *label, GHashTable *ht, StringInfo *key,
4403 StringInfo *ht_key, *master_secret;
4405 if (key->data_len == 0) {
4406 ssl_debug_printf("%s: not saving empty %s!\n", G_STRFUNC, label);
4410 if (mk->data_len == 0) {
4411 ssl_debug_printf("%s not saving empty (pre-)master secret for %s!\n",
4416 /* ssl_hash() depends on session_ticket->data being aligned for guint access
4417 * so be careful in changing how it is allocated. */
4418 ht_key = ssl_data_clone(key);
4419 master_secret = ssl_data_clone(mk);
4420 g_hash_table_insert(ht, ht_key, master_secret);
4422 ssl_debug_printf("%s inserted (pre-)master secret for %s\n", G_STRFUNC, label);
4423 ssl_print_string("stored key", ht_key);
4424 ssl_print_string("stored (pre-)master secret", master_secret);
4427 /** restore a (pre-)master secret given some key in the cache */
4429 ssl_restore_master_key(SslDecryptSession *ssl, const char *label,
4430 gboolean is_pre_master, GHashTable *ht, StringInfo *key)
4434 if (key->data_len == 0) {
4435 ssl_debug_printf("%s can't restore %smaster secret using an empty %s\n",
4436 G_STRFUNC, is_pre_master ? "pre-" : "", label);
4440 ms = (StringInfo *)g_hash_table_lookup(ht, key);
4442 ssl_debug_printf("%s can't find %smaster secret by %s\n", G_STRFUNC,
4443 is_pre_master ? "pre-" : "", label);
4447 /* (pre)master secret found, clear knowledge of other keys and set it in the
4448 * current conversation */
4449 ssl->state &= ~(SSL_MASTER_SECRET | SSL_PRE_MASTER_SECRET |
4450 SSL_HAVE_SESSION_KEY);
4451 if (is_pre_master) {
4452 /* unlike master secret, pre-master secret has a variable size (48 for
4453 * RSA, varying for PSK) and is therefore not statically allocated */
4454 ssl->pre_master_secret.data = (guchar *) wmem_alloc(wmem_file_scope(),
4456 ssl_data_set(&ssl->pre_master_secret, ms->data, ms->data_len);
4457 ssl->state |= SSL_PRE_MASTER_SECRET;
4459 ssl_data_set(&ssl->master_secret, ms->data, ms->data_len);
4460 ssl->state |= SSL_MASTER_SECRET;
4462 ssl_debug_printf("%s %smaster secret retrieved using %s\n", G_STRFUNC,
4463 is_pre_master ? "pre-" : "", label);
4464 ssl_print_string(label, key);
4465 ssl_print_string("(pre-)master secret", ms);
4469 /* Should be called when all parameters are ready (after ChangeCipherSpec), and
4470 * the decoder should be attempted to be initialized. */
4472 ssl_finalize_decryption(SslDecryptSession *ssl, ssl_master_key_map_t *mk_map)
4474 ssl_debug_printf("%s state = 0x%02X\n", G_STRFUNC, ssl->state);
4475 if (ssl->state & SSL_HAVE_SESSION_KEY) {
4476 ssl_debug_printf(" session key already available, nothing to do.\n");
4480 /* for decryption, there needs to be a master secret (which can be derived
4481 * from pre-master secret). If missing, try to pick a master key from cache
4482 * (an earlier packet in the capture or key logfile). */
4483 if (!(ssl->state & (SSL_MASTER_SECRET | SSL_PRE_MASTER_SECRET)) &&
4484 !ssl_restore_master_key(ssl, "Session ID", FALSE,
4485 mk_map->session, &ssl->session_id) &&
4486 !ssl_restore_master_key(ssl, "Session Ticket", FALSE,
4487 mk_map->session, &ssl->session_ticket) &&
4488 !ssl_restore_master_key(ssl, "Client Random", FALSE,
4489 mk_map->crandom, &ssl->client_random)) {
4490 /* how unfortunate, the master secret could not be found */
4491 ssl_debug_printf(" Cannot find master secret\n");
4495 if (ssl_generate_keyring_material(ssl) < 0) {
4496 ssl_debug_printf("%s can't generate keyring material\n", G_STRFUNC);
4499 /* Save Client Random/ Session ID for "SSL Export Session keys" */
4500 ssl_save_master_key("Client Random", mk_map->crandom,
4501 &ssl->client_random, &ssl->master_secret);
4502 ssl_save_master_key("Session ID", mk_map->session,
4503 &ssl->session_id, &ssl->master_secret);
4504 ssl_save_master_key("Session Ticket", mk_map->session,
4505 &ssl->session_ticket, &ssl->master_secret);
4509 ssl_is_valid_content_type(guint8 type)
4511 switch ((ContentType) type) {
4512 case SSL_ID_CHG_CIPHER_SPEC:
4514 case SSL_ID_HANDSHAKE:
4515 case SSL_ID_APP_DATA:
4516 case SSL_ID_HEARTBEAT:
4523 ssl_is_valid_handshake_type(guint8 hs_type, gboolean is_dtls)
4525 switch ((HandshakeType) hs_type) {
4526 case SSL_HND_HELLO_VERIFY_REQUEST:
4527 /* hello_verify_request is DTLS-only */
4530 case SSL_HND_HELLO_REQUEST:
4531 case SSL_HND_CLIENT_HELLO:
4532 case SSL_HND_SERVER_HELLO:
4533 case SSL_HND_NEWSESSION_TICKET:
4534 case SSL_HND_CERTIFICATE:
4535 case SSL_HND_SERVER_KEY_EXCHG:
4536 case SSL_HND_CERT_REQUEST:
4537 case SSL_HND_SVR_HELLO_DONE:
4538 case SSL_HND_CERT_VERIFY:
4539 case SSL_HND_CLIENT_KEY_EXCHG:
4540 case SSL_HND_FINISHED:
4541 case SSL_HND_CERT_URL:
4542 case SSL_HND_CERT_STATUS:
4543 case SSL_HND_SUPPLEMENTAL_DATA:
4544 case SSL_HND_ENCRYPTED_EXTS:
4551 /** keyfile handling */
4554 ssl_compile_keyfile_regex(void)
4556 #define OCTET "(?:[[:xdigit:]]{2})"
4557 const gchar *pattern =
4558 "(?:PMS_CLIENT_RANDOM (?<client_random_pms>" OCTET "{32}) (?<pms>" OCTET "{32}))"
4560 /* First part of encrypted RSA pre-master secret */
4561 "RSA (?<encrypted_pmk>" OCTET "{8}) "
4562 /* Matches Server Hellos having a Session ID */
4563 "|RSA Session-ID:(?<session_id>" OCTET "+) Master-Key:"
4564 /* Matches Client Hellos having this Client.Random */
4565 "|CLIENT_RANDOM (?<client_random>" OCTET "{32}) "
4566 ")(?<master_secret>" OCTET "{" G_STRINGIFY(SSL_MASTER_SECRET_LENGTH) "})";
4568 static GRegex *regex = NULL;
4569 GError *gerr = NULL;
4572 regex = g_regex_new(pattern, G_REGEX_OPTIMIZE,
4573 G_REGEX_MATCH_ANCHORED, &gerr);
4575 ssl_debug_printf("%s failed to compile regex: %s\n", G_STRFUNC,
4586 file_needs_reopen(FILE *fp, const char *filename)
4588 ws_statb64 open_stat, current_stat;
4590 /* consider a file deleted when stat fails for either file,
4591 * or when the residing device / inode has changed. */
4592 if (0 != ws_fstat64(fileno(fp), &open_stat))
4594 if (0 != ws_stat64(filename, ¤t_stat))
4597 /* Note: on Windows, ino may be 0. Existing files cannot be deleted on
4598 * Windows, but hopefully the size is a good indicator when a file got
4599 * removed and recreated */
4600 return open_stat.st_dev != current_stat.st_dev ||
4601 open_stat.st_ino != current_stat.st_ino ||
4602 open_stat.st_size > current_stat.st_size;
4605 typedef struct ssl_master_key_match_group {
4606 const char *re_group_name;
4607 GHashTable *master_key_ht;
4608 } ssl_master_key_match_group_t;
4611 ssl_load_keyfile(const gchar *ssl_keylog_filename, FILE **keylog_file,
4612 const ssl_master_key_map_t *mk_map)
4616 ssl_master_key_match_group_t mk_groups[] = {
4617 { "encrypted_pmk", mk_map->pre_master },
4618 { "session_id", mk_map->session },
4619 { "client_random", mk_map->crandom },
4620 { "client_random_pms", mk_map->pms},
4622 /* no need to try if no key log file is configured. */
4623 if (!ssl_keylog_filename || !*ssl_keylog_filename) {
4624 ssl_debug_printf("%s dtls/ssl.keylog_file is not configured!\n",
4629 /* The format of the file is a series of records with one of the following formats:
4631 * Where xxxx are the first 8 bytes of the encrypted pre-master secret (hex-encoded)
4632 * Where yyyy is the cleartext pre-master secret (hex-encoded)
4633 * (this is the original format introduced with bug 4349)
4635 * - "RSA Session-ID:xxxx Master-Key:yyyy"
4636 * Where xxxx is the SSL session ID (hex-encoded)
4637 * Where yyyy is the cleartext master secret (hex-encoded)
4638 * (added to support openssl s_client Master-Key output)
4639 * This is somewhat is a misnomer because there's nothing RSA specific
4642 * - "PMS_CLIENT_RANDOM xxxx yyyy"
4643 * Where xxxx is the client_random from the ClientHello (hex-encoded)
4644 * Where yyyy is the cleartext pre-master secret (hex-encoded)
4645 * (This format allows SSL connections to be decrypted, if a user can
4646 * capture the PMS but could not recover the MS for a specific session
4647 * with a SSL Server.)
4649 * - "CLIENT_RANDOM xxxx yyyy"
4650 * Where xxxx is the client_random from the ClientHello (hex-encoded)
4651 * Where yyyy is the cleartext master secret (hex-encoded)
4652 * (This format allows non-RSA SSL connections to be decrypted, i.e.
4655 regex = ssl_compile_keyfile_regex();
4659 ssl_debug_printf("trying to use SSL keylog in %s\n", ssl_keylog_filename);
4661 /* if the keylog file was deleted, re-open it */
4662 if (*keylog_file && file_needs_reopen(*keylog_file, ssl_keylog_filename)) {
4663 ssl_debug_printf("%s file got deleted, trying to re-open\n", G_STRFUNC);
4664 fclose(*keylog_file);
4665 *keylog_file = NULL;
4668 if (*keylog_file == NULL) {
4669 *keylog_file = ws_fopen(ssl_keylog_filename, "r");
4670 if (!*keylog_file) {
4671 ssl_debug_printf("%s failed to open SSL keylog\n", G_STRFUNC);
4677 char buf[512], *line;
4681 line = fgets(buf, sizeof(buf), *keylog_file);
4685 bytes_read = strlen(line);
4686 /* fgets includes the \n at the end of the line. */
4687 if (bytes_read > 0 && line[bytes_read - 1] == '\n') {
4688 line[bytes_read - 1] = 0;
4691 if (bytes_read > 0 && line[bytes_read - 1] == '\r') {
4692 line[bytes_read - 1] = 0;
4696 ssl_debug_printf(" checking keylog line: %s\n", line);
4697 if (g_regex_match(regex, line, G_REGEX_MATCH_ANCHORED, &mi)) {
4698 gchar *hex_key, *hex_pre_ms_or_ms;
4699 StringInfo *key = wmem_new(wmem_file_scope(), StringInfo);
4700 StringInfo *pre_ms_or_ms = NULL;
4701 GHashTable *ht = NULL;
4703 /* Is the PMS being supplied with the PMS_CLIENT_RANDOM
4704 * otherwise we will use the Master Secret
4706 hex_pre_ms_or_ms = g_match_info_fetch_named(mi, "master_secret");
4707 if (hex_pre_ms_or_ms == NULL || strlen(hex_pre_ms_or_ms) == 0){
4708 g_free(hex_pre_ms_or_ms);
4709 hex_pre_ms_or_ms = g_match_info_fetch_named(mi, "pms");
4711 /* There is always a match, otherwise the regex is wrong. */
4712 DISSECTOR_ASSERT(hex_pre_ms_or_ms && strlen(hex_pre_ms_or_ms));
4714 /* convert from hex to bytes and save to hashtable */
4715 pre_ms_or_ms = wmem_new(wmem_file_scope(), StringInfo);
4716 from_hex(pre_ms_or_ms, hex_pre_ms_or_ms, strlen(hex_pre_ms_or_ms));
4717 g_free(hex_pre_ms_or_ms);
4719 /* Find a master key from any format (CLIENT_RANDOM, SID, ...) */
4720 for (i = 0; i < G_N_ELEMENTS(mk_groups); i++) {
4721 ssl_master_key_match_group_t *g = &mk_groups[i];
4722 hex_key = g_match_info_fetch_named(mi, g->re_group_name);
4723 if (hex_key && *hex_key) {
4724 ssl_debug_printf(" matched %s\n", g->re_group_name);
4725 ht = g->master_key_ht;
4726 from_hex(key, hex_key, strlen(hex_key));
4732 DISSECTOR_ASSERT(ht); /* Cannot be reached, or regex is wrong. */
4734 g_hash_table_insert(ht, key, pre_ms_or_ms);
4737 ssl_debug_printf(" unrecognized line\n");
4739 /* always free match info even if there is no match. */
4740 g_match_info_free(mi);
4744 #ifdef SSL_DECRYPT_DEBUG
4746 static FILE* ssl_debug_file=NULL;
4749 ssl_set_debug(const gchar* name)
4751 static gint debug_file_must_be_closed;
4754 debug_file_must_be_closed = 0;
4755 use_stderr = name?(strcmp(name, SSL_DEBUG_USE_STDERR) == 0):0;
4757 if (debug_file_must_be_closed)
4758 fclose(ssl_debug_file);
4760 ssl_debug_file = stderr;
4761 else if (!name || (strcmp(name, "") ==0))
4762 ssl_debug_file = NULL;
4764 ssl_debug_file = ws_fopen(name, "w");
4765 if (!use_stderr && ssl_debug_file)
4766 debug_file_must_be_closed = 1;
4768 ssl_debug_printf("Wireshark SSL debug log \n\n");
4772 ssl_debug_flush(void)
4775 fflush(ssl_debug_file);
4779 ssl_debug_printf(const gchar* fmt, ...)
4783 if (!ssl_debug_file)
4787 vfprintf(ssl_debug_file, fmt, ap);
4792 ssl_print_data(const gchar* name, const guchar* data, size_t len)
4795 if (!ssl_debug_file)
4797 fprintf(ssl_debug_file,"%s[%d]:\n",name, (int) len);
4798 for (i=0; i<len; i+=16) {
4799 fprintf(ssl_debug_file,"| ");
4800 for (j=i, k=0; k<16 && j<len; ++j, ++k)
4801 fprintf(ssl_debug_file,"%.2x ",data[j]);
4803 fprintf(ssl_debug_file," ");
4804 fputc('|', ssl_debug_file);
4805 for (j=i, k=0; k<16 && j<len; ++j, ++k) {
4807 if (!g_ascii_isprint(c) || (c=='\t')) c = '.';
4808 fputc(c, ssl_debug_file);
4811 fputc(' ', ssl_debug_file);
4812 fprintf(ssl_debug_file,"|\n");
4817 ssl_print_string(const gchar* name, const StringInfo* data)
4819 ssl_print_data(name, data->data, data->data_len);
4821 #endif /* SSL_DECRYPT_DEBUG */
4823 /* checks for SSL and DTLS UAT key list fields */
4826 ssldecrypt_uat_fld_ip_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
4828 if (!p || strlen(p) == 0u) {
4829 *err = g_strdup_printf("No IP address given.");
4838 ssldecrypt_uat_fld_port_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
4840 if (!p || strlen(p) == 0u) {
4841 *err = g_strdup_printf("No Port given.");
4845 if (strcmp(p, "start_tls") != 0){
4846 const gint i = atoi(p);
4847 if (i < 0 || i > 65535) {
4848 *err = g_strdup_printf("Invalid port given.");
4858 ssldecrypt_uat_fld_protocol_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
4860 if (!p || strlen(p) == 0u) {
4861 *err = g_strdup_printf("No protocol given.");
4865 if (!find_dissector(p)) {
4866 if (proto_get_id_by_filter_name(p) != -1) {
4867 *err = g_strdup_printf("While '%s' is a valid dissector filter name, that dissector is not configured"
4868 " to support SSL decryption.\n\n"
4869 "If you need to decrypt '%s' over SSL, please contact the Wireshark development team.", p, p);
4871 char* ssl_str = ssl_association_info();
4872 *err = g_strdup_printf("Could not find dissector for: '%s'\nCommonly used SSL dissectors include:\n%s", p, ssl_str);
4883 ssldecrypt_uat_fld_fileopen_chk_cb(void* r _U_, const char* p, guint len _U_, const void* u1 _U_, const void* u2 _U_, char** err)
4887 if (!p || strlen(p) == 0u) {
4888 *err = g_strdup_printf("No filename given.");
4891 if (ws_stat64(p, &st) != 0) {
4892 *err = g_strdup_printf("File '%s' does not exist or access is denied.", p);
4902 ssldecrypt_uat_fld_password_chk_cb(void *r _U_, const char *p _U_, guint len _U_, const void *u1 _U_, const void *u2 _U_, char **err)
4904 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
4905 ssldecrypt_assoc_t* f = (ssldecrypt_assoc_t *)r;
4908 if (p && (strlen(p) > 0u)) {
4909 fp = ws_fopen(f->keyfile, "rb");
4912 gnutls_x509_privkey_t priv_key = ssl_load_pkcs12(fp, p, &msg);
4915 *err = g_strdup_printf("Could not load PKCS#12 key file: %s", msg);
4920 gnutls_x509_privkey_deinit(priv_key);
4923 *err = g_strdup_printf("Leave this field blank if the keyfile is not PKCS#12.");
4931 *err = g_strdup("Cannot load key files, support is not compiled in.");
4937 /* dissect a list of hash algorithms, return the number of bytes dissected
4938 this is used for the signature algorithms extension and for the
4939 TLS1.2 certificate request */
4941 ssl_dissect_hash_alg_list(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
4942 packet_info* pinfo, guint32 offset, guint16 len)
4944 guint32 offset_start;
4945 proto_tree *subtree, *alg_tree;
4948 offset_start = offset;
4952 ti = proto_tree_add_none_format(tree, hf->hf.hs_sig_hash_algs, tvb,
4954 "Signature Hash Algorithms (%u algorithm%s)",
4955 len / 2, plurality(len / 2, "", "s"));
4956 subtree = proto_item_add_subtree(ti, hf->ett.hs_sig_hash_algs);
4959 expert_add_info_format(pinfo, ti, &hf->ei.hs_sig_hash_algs_bad,
4960 "Invalid Signature Hash Algorithm length: %d", len);
4961 return offset-offset_start;
4965 ti = proto_tree_add_item(subtree, hf->hf.hs_sig_hash_alg,
4966 tvb, offset, 2, ENC_BIG_ENDIAN);
4967 alg_tree = proto_item_add_subtree(ti, hf->ett.hs_sig_hash_alg);
4969 proto_tree_add_item(alg_tree, hf->hf.hs_sig_hash_hash,
4970 tvb, offset, 1, ENC_BIG_ENDIAN);
4971 proto_tree_add_item(alg_tree, hf->hf.hs_sig_hash_sig,
4972 tvb, offset+1, 1, ENC_BIG_ENDIAN);
4977 return offset-offset_start;
4981 ssl_dissect_hnd_hello_ext_sig_hash_algs(ssl_common_dissect_t *hf, tvbuff_t *tvb,
4982 proto_tree *tree, packet_info* pinfo, guint32 offset, guint32 ext_len)
4984 guint16 sh_alg_length;
4987 sh_alg_length = tvb_get_ntohs(tvb, offset);
4988 proto_tree_add_uint(tree, hf->hf.hs_sig_hash_alg_len,
4989 tvb, offset, 2, sh_alg_length);
4991 if (ext_len < 2 || sh_alg_length != ext_len - 2) {
4992 /* ERROR: sh_alg_length must be 2 less than ext_len */
4996 ret = ssl_dissect_hash_alg_list(hf, tvb, tree, pinfo, offset, sh_alg_length);
5004 ssl_dissect_hnd_hello_ext_alpn(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5005 proto_tree *tree, guint32 offset, guint32 ext_len,
5006 gboolean is_client, SslSession *session)
5008 guint16 alpn_length;
5010 proto_tree *alpn_tree;
5013 alpn_length = tvb_get_ntohs(tvb, offset);
5014 if (ext_len < 2 || alpn_length != ext_len - 2) {
5015 /* ERROR: alpn_length must be 2 less than ext_len */
5018 proto_tree_add_item(tree, hf->hf.hs_ext_alpn_len,
5019 tvb, offset, 2, ENC_BIG_ENDIAN);
5022 ti = proto_tree_add_item(tree, hf->hf.hs_ext_alpn_list,
5023 tvb, offset, alpn_length, ENC_NA);
5024 alpn_tree = proto_item_add_subtree(ti, hf->ett.hs_ext_alpn);
5026 /* If ALPN is given in ServerHello, then ProtocolNameList MUST contain
5027 * exactly one "ProtocolName". */
5032 name_length = tvb_get_guint8(tvb, offset);
5033 /* '\0'-terminated string for prefix/full string comparison purposes. */
5034 proto_name = tvb_get_string_enc(wmem_packet_scope(), tvb, offset + 1,
5035 name_length, ENC_ASCII);
5036 for (i = 0; i < G_N_ELEMENTS(ssl_alpn_protocols); i++) {
5037 const ssl_alpn_protocol_t *alpn_proto = &ssl_alpn_protocols[i];
5039 if (name_length >= alpn_proto->proto_name_len &&
5040 (memcmp(proto_name, alpn_proto->proto_name,
5041 alpn_proto->proto_name_len) == 0)) {
5043 dissector_handle_t handle;
5044 /* ProtocolName match, so set the App data dissector handle.
5045 * This may override protocols given via the UAT dialog, but
5046 * since the ALPN hint is precise, do it anyway. */
5047 handle = find_dissector(alpn_proto->dissector_name);
5048 ssl_debug_printf("%s: changing handle %p to %p (%s)", G_STRFUNC,
5049 (void *)session->app_handle,
5050 (void *)handle, alpn_proto->dissector_name);
5051 /* if dissector is disabled, do not overwrite previous one */
5053 session->app_handle = handle;
5059 while (alpn_length > 0) {
5060 name_length = tvb_get_guint8(tvb, offset);
5061 proto_tree_add_item(alpn_tree, hf->hf.hs_ext_alpn_str_len,
5062 tvb, offset, 1, ENC_NA);
5065 proto_tree_add_item(alpn_tree, hf->hf.hs_ext_alpn_str,
5066 tvb, offset, name_length, ENC_ASCII|ENC_NA);
5067 offset += name_length;
5068 alpn_length -= name_length;
5075 ssl_dissect_hnd_hello_ext_npn(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5076 proto_tree *tree, guint32 offset, guint32 ext_len)
5079 proto_tree *npn_tree;
5085 npn_tree = proto_tree_add_subtree(tree, tvb, offset, ext_len, hf->ett.hs_ext_npn, NULL, "Next Protocol Negotiation");
5087 while (ext_len > 0) {
5088 npn_length = tvb_get_guint8(tvb, offset);
5089 proto_tree_add_item(npn_tree, hf->hf.hs_ext_npn_str_len,
5090 tvb, offset, 1, ENC_NA);
5094 if (npn_length > 0) {
5095 proto_tree_add_item(npn_tree, hf->hf.hs_ext_npn_str,
5096 tvb, offset, npn_length, ENC_ASCII|ENC_NA);
5097 offset += npn_length;
5098 ext_len -= npn_length;
5106 ssl_dissect_hnd_hello_ext_reneg_info(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5107 proto_tree *tree, guint32 offset, guint32 ext_len)
5109 guint8 reneg_info_length;
5110 proto_tree *reneg_info_tree;
5116 reneg_info_tree = proto_tree_add_subtree(tree, tvb, offset, ext_len, hf->ett.hs_ext_reneg_info, NULL, "Renegotiation Info extension");
5118 reneg_info_length = tvb_get_guint8(tvb, offset);
5119 proto_tree_add_item(reneg_info_tree, hf->hf.hs_ext_reneg_info_len,
5120 tvb, offset, 1, ENC_NA);
5123 if (reneg_info_length > 0) {
5124 proto_tree_add_item(reneg_info_tree, hf->hf.hs_ext_reneg_info, tvb, offset, reneg_info_length, ENC_NA);
5125 offset += reneg_info_length;
5132 ssl_dissect_hnd_hello_ext_server_name(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5133 proto_tree *tree, guint32 offset, guint32 ext_len)
5135 guint16 server_name_length;
5136 proto_tree *server_name_tree;
5143 server_name_tree = proto_tree_add_subtree(tree, tvb, offset, ext_len, hf->ett.hs_ext_server_name, NULL, "Server Name Indication extension");
5145 proto_tree_add_item(server_name_tree, hf->hf.hs_ext_server_name_list_len,
5146 tvb, offset, 2, ENC_BIG_ENDIAN);
5150 while (ext_len > 0) {
5151 proto_tree_add_item(server_name_tree, hf->hf.hs_ext_server_name_type,
5152 tvb, offset, 1, ENC_NA);
5156 server_name_length = tvb_get_ntohs(tvb, offset);
5157 proto_tree_add_item(server_name_tree, hf->hf.hs_ext_server_name_len,
5158 tvb, offset, 2, ENC_BIG_ENDIAN);
5162 if (server_name_length > 0) {
5163 proto_tree_add_item(server_name_tree, hf->hf.hs_ext_server_name,
5164 tvb, offset, server_name_length, ENC_ASCII|ENC_NA);
5165 offset += server_name_length;
5166 ext_len -= server_name_length;
5173 ssl_dissect_hnd_hello_ext_padding(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5174 proto_tree *tree, guint32 offset, guint32 ext_len)
5176 guint8 padding_length;
5177 proto_tree *padding_tree;
5184 ti = proto_tree_add_item(tree, hf->hf.hs_ext_padding_data, tvb, offset, ext_len, ENC_NA);
5185 padding_tree = proto_item_add_subtree(ti, hf->ett.hs_ext_padding);
5188 proto_tree_add_item(padding_tree, hf->hf.hs_ext_padding_len, tvb, offset, 2, ENC_NA);
5189 padding_length = tvb_get_guint8(tvb, offset);
5192 proto_tree_add_item(padding_tree, hf->hf.hs_ext_padding_data, tvb, offset, padding_length, ENC_NA);
5193 offset += padding_length;
5199 ssl_dissect_hnd_hello_ext_session_ticket(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5200 proto_tree *tree, guint32 offset, guint32 ext_len, gboolean is_client, SslDecryptSession *ssl)
5202 if (is_client && ssl && ext_len != 0) {
5203 tvb_ensure_bytes_exist(tvb, offset, ext_len);
5204 /* Save the Session Ticket such that it can be used as identifier for
5205 * restoring a previous Master Secret (in ChangeCipherSpec) */
5206 ssl->session_ticket.data = (guchar*)wmem_realloc(wmem_file_scope(),
5207 ssl->session_ticket.data, ext_len);
5208 ssl->session_ticket.data_len = ext_len;
5209 tvb_memcpy(tvb,ssl->session_ticket.data, offset, ext_len);
5211 proto_tree_add_bytes_format(tree, hf->hf.hs_ext_data,
5212 tvb, offset, ext_len, NULL,
5214 ext_len, plurality(ext_len, "", "s"));
5215 return offset + ext_len;
5219 ssl_dissect_hnd_hello_ext_cert_type(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5220 proto_tree *tree, guint32 offset, guint32 ext_len,
5221 gboolean is_client, guint16 ext_type, SslSession *session)
5223 guint8 cert_list_length;
5225 proto_tree *cert_list_tree;
5229 cert_list_length = tvb_get_guint8(tvb, offset);
5230 proto_tree_add_item(tree, hf->hf.hs_ext_cert_types_len,
5231 tvb, offset, 1, ENC_BIG_ENDIAN);
5233 if (ext_len != (guint32)cert_list_length + 1)
5236 ti = proto_tree_add_item(tree, hf->hf.hs_ext_cert_types, tvb, offset,
5237 cert_list_length, cert_list_length);
5238 proto_item_append_text(ti, " (%d)", cert_list_length);
5240 /* make this a subtree */
5241 cert_list_tree = proto_item_add_subtree(ti, hf->ett.hs_ext_cert_types);
5243 /* loop over all point formats */
5244 while (cert_list_length > 0)
5246 proto_tree_add_item(cert_list_tree, hf->hf.hs_ext_cert_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5251 cert_type = tvb_get_guint8(tvb, offset);
5252 proto_tree_add_item(tree, hf->hf.hs_ext_cert_type, tvb, offset, 1, ENC_BIG_ENDIAN);
5254 if (ext_type == SSL_HND_HELLO_EXT_CERT_TYPE || ext_type == SSL_HND_HELLO_EXT_CLIENT_CERT_TYPE) {
5255 session->client_cert_type = cert_type;
5257 if (ext_type == SSL_HND_HELLO_EXT_CERT_TYPE || ext_type == SSL_HND_HELLO_EXT_SERVER_CERT_TYPE) {
5258 session->server_cert_type = cert_type;
5266 ssl_dissect_hnd_hello_common(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5267 proto_tree *tree, guint32 offset,
5268 SslDecryptSession *ssl, gboolean from_server)
5270 nstime_t gmt_unix_time;
5271 guint8 sessid_length;
5272 proto_tree *rnd_tree;
5278 rnd = &ssl->server_random;
5280 rnd = &ssl->client_random;
5282 /* save provided random for later keyring generation */
5283 tvb_memcpy(tvb, rnd->data, offset, 32);
5286 ssl->state |= SSL_SERVER_RANDOM;
5288 ssl->state |= SSL_CLIENT_RANDOM;
5289 ssl_debug_printf("%s found %s RANDOM -> state 0x%02X\n", G_STRFUNC,
5290 from_server ? "SERVER" : "CLIENT", ssl->state);
5293 rnd_tree = proto_tree_add_subtree(tree, tvb, offset, 32,
5294 hf->ett.hs_random, NULL, "Random");
5297 gmt_unix_time.secs = tvb_get_ntohl(tvb, offset);
5298 gmt_unix_time.nsecs = 0;
5299 proto_tree_add_time(rnd_tree, hf->hf.hs_random_time,
5300 tvb, offset, 4, &gmt_unix_time);
5303 /* show the random bytes */
5304 proto_tree_add_item(rnd_tree, hf->hf.hs_random_bytes,
5305 tvb, offset, 28, ENC_NA);
5308 /* show the session id (length followed by actual Session ID) */
5309 sessid_length = tvb_get_guint8(tvb, offset);
5310 proto_tree_add_item(tree, hf->hf.hs_session_id_len,
5311 tvb, offset, 1, ENC_BIG_ENDIAN);
5315 /* save the authorative SID for later use in ChangeCipherSpec.
5316 * (D)TLS restricts the SID to 32 chars, it does not make sense to
5317 * save more, so ignore larger ones. */
5318 if (from_server && sessid_length <= 32) {
5319 tvb_memcpy(tvb, ssl->session_id.data, offset, sessid_length);
5320 ssl->session_id.data_len = sessid_length;
5323 if (sessid_length > 0) {
5324 proto_tree_add_item(tree, hf->hf.hs_session_id,
5325 tvb, offset, sessid_length, ENC_NA);
5326 offset += sessid_length;
5334 ssl_dissect_hnd_hello_ext(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
5335 packet_info* pinfo, guint32 offset, guint32 left, gboolean is_client,
5336 SslSession *session, SslDecryptSession *ssl);
5339 ssl_dissect_hnd_cli_hello(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5340 packet_info *pinfo, proto_tree *tree, guint32 offset,
5341 guint32 length, SslSession *session,
5342 SslDecryptSession *ssl, dtls_hfs_t *dtls_hfs)
5345 * ProtocolVersion client_version;
5347 * SessionID session_id;
5348 * opaque cookie<0..32>; //new field for DTLS
5349 * CipherSuite cipher_suites<2..2^16-1>;
5350 * CompressionMethod compression_methods<1..2^8-1>;
5351 * Extension client_hello_extension_list<0..2^16-1>;
5356 proto_tree *cs_tree;
5357 guint16 cipher_suite_length;
5358 guint8 compression_methods_length;
5359 guint8 compression_method;
5360 guint16 start_offset = offset;
5362 /* show the client version */
5363 proto_tree_add_item(tree, hf->hf.hs_client_version, tvb,
5364 offset, 2, ENC_BIG_ENDIAN);
5367 /* dissect fields that are also present in ClientHello */
5368 offset = ssl_dissect_hnd_hello_common(hf, tvb, tree, offset, ssl, FALSE);
5370 /* fields specific for DTLS (cookie_len, cookie) */
5371 if (dtls_hfs != NULL) {
5372 /* look for a cookie */
5373 guint8 cookie_length = tvb_get_guint8(tvb, offset);
5375 proto_tree_add_uint(tree, dtls_hfs->hf_dtls_handshake_cookie_len,
5376 tvb, offset, 1, cookie_length);
5378 if (cookie_length > 0) {
5379 proto_tree_add_item(tree, dtls_hfs->hf_dtls_handshake_cookie,
5380 tvb, offset, cookie_length, ENC_NA);
5381 offset += cookie_length;
5385 /* tell the user how many cipher suites there are */
5386 cipher_suite_length = tvb_get_ntohs(tvb, offset);
5387 ti = proto_tree_add_item(tree, hf->hf.hs_cipher_suites_len,
5388 tvb, offset, 2, ENC_BIG_ENDIAN);
5390 if (cipher_suite_length > 0) {
5391 if (cipher_suite_length % 2) {
5392 expert_add_info_format(pinfo, ti, &hf->ei.hs_cipher_suites_len_bad,
5393 "Cipher suite length (%d) must be a multiple of 2",
5394 cipher_suite_length);
5397 ti = proto_tree_add_none_format(tree,
5398 hf->hf.hs_cipher_suites,
5399 tvb, offset, cipher_suite_length,
5400 "Cipher Suites (%d suite%s)",
5401 cipher_suite_length / 2,
5402 plurality(cipher_suite_length/2, "", "s"));
5404 /* make this a subtree */
5405 cs_tree = proto_item_add_subtree(ti, hf->ett.cipher_suites);
5407 while (cipher_suite_length > 0) {
5408 proto_tree_add_item(cs_tree, hf->hf.hs_cipher_suite,
5409 tvb, offset, 2, ENC_BIG_ENDIAN);
5411 cipher_suite_length -= 2;
5414 /* tell the user how many compression methods there are */
5415 compression_methods_length = tvb_get_guint8(tvb, offset);
5416 proto_tree_add_uint(tree, hf->hf.hs_comp_methods_len,
5417 tvb, offset, 1, compression_methods_length);
5419 if (compression_methods_length > 0) {
5420 ti = proto_tree_add_none_format(tree,
5421 hf->hf.hs_comp_methods,
5422 tvb, offset, compression_methods_length,
5423 "Compression Methods (%u method%s)",
5424 compression_methods_length,
5425 plurality(compression_methods_length,
5428 /* make this a subtree */
5429 cs_tree = proto_item_add_subtree(ti, hf->ett.comp_methods);
5431 while (compression_methods_length > 0) {
5432 compression_method = tvb_get_guint8(tvb, offset);
5433 /* TODO: make reserved/private comp meth. fields selectable */
5434 if (compression_method < 64)
5435 proto_tree_add_uint(cs_tree, hf->hf.hs_comp_method,
5436 tvb, offset, 1, compression_method);
5437 else if (compression_method > 63 && compression_method < 193)
5438 proto_tree_add_uint_format_value(cs_tree, hf->hf.hs_comp_method, tvb, offset, 1,
5439 compression_method, "Reserved - to be assigned by IANA (%u)",
5440 compression_method);
5442 proto_tree_add_uint_format_value(cs_tree, hf->hf.hs_comp_method, tvb, offset, 1,
5443 compression_method, "Private use range (%u)",
5444 compression_method);
5446 compression_methods_length--;
5449 if (length > offset - start_offset) {
5450 ssl_dissect_hnd_hello_ext(hf, tvb, tree, pinfo, offset,
5451 length - (offset - start_offset), TRUE,
5457 ssl_dissect_hnd_srv_hello(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5458 packet_info* pinfo, proto_tree *tree, guint32 offset, guint32 length,
5459 SslSession *session, SslDecryptSession *ssl)
5462 * ProtocolVersion server_version;
5464 * SessionID session_id;
5465 * CipherSuite cipher_suite;
5466 * CompressionMethod compression_method;
5467 * Extension server_hello_extension_list<0..2^16-1>;
5470 guint16 start_offset = offset;
5472 /* show the server version */
5473 proto_tree_add_item(tree, hf->hf.hs_server_version, tvb,
5474 offset, 2, ENC_BIG_ENDIAN);
5477 /* dissect fields that are also present in ClientHello */
5478 offset = ssl_dissect_hnd_hello_common(hf, tvb, tree, offset, ssl, TRUE);
5481 /* store selected cipher suite for decryption */
5482 ssl->session.cipher = tvb_get_ntohs(tvb, offset);
5484 if (ssl_find_cipher(ssl->session.cipher, &ssl->cipher_suite) < 0) {
5485 ssl_debug_printf("%s can't find cipher suite 0x%04X\n",
5486 G_STRFUNC, ssl->session.cipher);
5488 /* Cipher found, save this for the delayed decoder init */
5489 ssl->state |= SSL_CIPHER;
5490 ssl_debug_printf("%s found CIPHER 0x%04X -> state 0x%02X\n",
5491 G_STRFUNC, ssl->session.cipher, ssl->state);
5495 /* now the server-selected cipher suite */
5496 proto_tree_add_item(tree, hf->hf.hs_cipher_suite,
5497 tvb, offset, 2, ENC_BIG_ENDIAN);
5501 /* store selected compression method for decryption */
5502 ssl->session.compression = tvb_get_guint8(tvb, offset);
5504 /* and the server-selected compression method */
5505 proto_tree_add_item(tree, hf->hf.hs_comp_method,
5506 tvb, offset, 1, ENC_BIG_ENDIAN);
5509 /* remaining data are extensions */
5510 if (length > offset - start_offset) {
5511 ssl_dissect_hnd_hello_ext(hf, tvb, tree, pinfo, offset,
5512 length - (offset - start_offset), FALSE,
5518 ssl_dissect_hnd_new_ses_ticket(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5519 proto_tree *tree, guint32 offset,
5520 SslDecryptSession *ssl,
5521 GHashTable *session_hash)
5523 proto_tree *subtree;
5526 /* length of session ticket, may be 0 if the server has sent the
5527 * SessionTicket extension, but decides not to use one. */
5528 ticket_len = tvb_get_ntohs(tvb, offset + 4);
5529 subtree = proto_tree_add_subtree(tree, tvb, offset, 6 + ticket_len,
5530 hf->ett.session_ticket, NULL,
5531 "TLS Session Ticket");
5533 /* ticket lifetime hint */
5534 proto_tree_add_item(subtree, hf->hf.hs_session_ticket_lifetime_hint,
5535 tvb, offset, 4, ENC_BIG_ENDIAN);
5538 /* opaque ticket (length, data) */
5539 proto_tree_add_item(subtree, hf->hf.hs_session_ticket_len,
5540 tvb, offset, 2, ENC_BIG_ENDIAN);
5542 /* Content depends on implementation, so just show data! */
5543 proto_tree_add_item(subtree, hf->hf.hs_session_ticket,
5544 tvb, offset, ticket_len, ENC_NA);
5545 /* save the session ticket to cache for ssl_finalize_decryption */
5547 tvb_ensure_bytes_exist(tvb, offset, ticket_len);
5548 ssl->session_ticket.data = (guchar*)wmem_realloc(wmem_file_scope(),
5549 ssl->session_ticket.data, ticket_len);
5550 ssl->session_ticket.data_len = ticket_len;
5551 tvb_memcpy(tvb, ssl->session_ticket.data, offset, ticket_len);
5552 /* NewSessionTicket is received after the first (client)
5553 * ChangeCipherSpec, and before the second (server) ChangeCipherSpec.
5554 * Since the second CCS has already the session key available it will
5555 * just return. To ensure that the session ticket is mapped to a
5556 * master key (from the first CCS), save the ticket here too. */
5557 ssl_save_master_key("Session Ticket", session_hash,
5558 &ssl->session_ticket, &ssl->master_secret);
5563 ssl_dissect_hnd_cert(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
5564 guint32 offset, packet_info *pinfo,
5565 const SslSession *session, SslDecryptSession *ssl _U_,
5566 GHashTable *key_hash _U_, gint is_from_server)
5568 /* opaque ASN.1Cert<1..2^24-1>;
5571 * select(certificate_type) {
5573 * // certificate type defined in RFC 7250
5574 * case RawPublicKey:
5575 * opaque ASN.1_subjectPublicKeyInfo<1..2^24-1>;
5577 * // X.509 certificate defined in RFC 5246
5579 * ASN.1Cert certificate_list<0..2^24-1>;
5583 enum { CERT_X509, CERT_RPK } cert_type;
5584 asn1_ctx_t asn1_ctx;
5585 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
5586 gnutls_datum_t subjectPublicKeyInfo = { NULL, 0 };
5589 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
5591 if ((is_from_server && session->server_cert_type == SSL_HND_CERT_TYPE_RAW_PUBLIC_KEY) ||
5592 (!is_from_server && session->client_cert_type == SSL_HND_CERT_TYPE_RAW_PUBLIC_KEY)) {
5593 cert_type = CERT_RPK;
5595 cert_type = CERT_X509;
5598 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
5599 /* Ask the pkcs1 dissector to return the public key details */
5601 asn1_ctx.private_data = &subjectPublicKeyInfo;
5604 switch (cert_type) {
5607 proto_tree_add_item(tree, hf->hf.hs_certificate_len,
5608 tvb, offset, 3, ENC_BIG_ENDIAN);
5611 dissect_x509af_SubjectPublicKeyInfo(FALSE, tvb, offset, &asn1_ctx, tree, hf->hf.hs_certificate);
5617 guint32 certificate_list_length;
5619 proto_tree *subtree;
5621 certificate_list_length = tvb_get_ntoh24(tvb, offset);
5623 proto_tree_add_uint(tree, hf->hf.hs_certificates_len,
5624 tvb, offset, 3, certificate_list_length);
5625 offset += 3; /* 24-bit length value */
5627 if (certificate_list_length > 0) {
5628 ti = proto_tree_add_none_format(tree,
5629 hf->hf.hs_certificates,
5630 tvb, offset, certificate_list_length,
5631 "Certificates (%u bytes)",
5632 certificate_list_length);
5634 /* make it a subtree */
5635 subtree = proto_item_add_subtree(ti, hf->ett.certificates);
5637 /* iterate through each certificate */
5638 while (certificate_list_length > 0) {
5639 /* get the length of the current certificate */
5640 guint32 cert_length;
5641 cert_length = tvb_get_ntoh24(tvb, offset);
5642 certificate_list_length -= 3 + cert_length;
5644 proto_tree_add_item(subtree, hf->hf.hs_certificate_len,
5645 tvb, offset, 3, ENC_BIG_ENDIAN);
5648 dissect_x509af_Certificate(FALSE, tvb, offset, &asn1_ctx, subtree, hf->hf.hs_certificate);
5649 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
5650 /* Only attempt to get the RSA modulus for the first cert. */
5651 asn1_ctx.private_data = NULL;
5654 offset += cert_length;
5661 #if defined(HAVE_LIBGNUTLS) && defined(HAVE_LIBGCRYPT)
5663 ssl_find_private_key_by_pubkey(ssl, key_hash, &subjectPublicKeyInfo);
5668 ssl_dissect_hnd_cert_req(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5669 proto_tree *tree, guint32 offset, packet_info *pinfo,
5670 const SslSession *session)
5674 * rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),
5676 * } ClientCertificateType;
5678 * opaque DistinguishedName<1..2^16-1>;
5681 * ClientCertificateType certificate_types<1..2^8-1>;
5682 * DistinguishedName certificate_authorities<3..2^16-1>;
5683 * } CertificateRequest;
5686 * As per TLSv1.2 (RFC 5246) the format has changed to:
5689 * rsa_sign(1), dss_sign(2), rsa_fixed_dh(3), dss_fixed_dh(4),
5690 * rsa_ephemeral_dh_RESERVED(5), dss_ephemeral_dh_RESERVED(6),
5691 * fortezza_dms_RESERVED(20), (255)
5692 * } ClientCertificateType;
5695 * none(0), md5(1), sha1(2), sha224(3), sha256(4), sha384(5),
5699 * enum { anonymous(0), rsa(1), dsa(2), ecdsa(3), (255) }
5700 * SignatureAlgorithm;
5703 * HashAlgorithm hash;
5704 * SignatureAlgorithm signature;
5705 * } SignatureAndHashAlgorithm;
5707 * SignatureAndHashAlgorithm
5708 * supported_signature_algorithms<2..2^16-2>;
5710 * opaque DistinguishedName<1..2^16-1>;
5713 * ClientCertificateType certificate_types<1..2^8-1>;
5714 * SignatureAndHashAlgorithm
5715 * supported_signature_algorithms<2^16-1>;
5716 * DistinguishedName certificate_authorities<0..2^16-1>;
5717 * } CertificateRequest;
5721 proto_tree *subtree;
5722 guint8 cert_types_count;
5725 asn1_ctx_t asn1_ctx;
5731 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
5733 cert_types_count = tvb_get_guint8(tvb, offset);
5734 proto_tree_add_uint(tree, hf->hf.hs_cert_types_count,
5735 tvb, offset, 1, cert_types_count);
5738 if (cert_types_count > 0) {
5739 ti = proto_tree_add_none_format(tree,
5740 hf->hf.hs_cert_types,
5741 tvb, offset, cert_types_count,
5742 "Certificate types (%u type%s)",
5744 plurality(cert_types_count, "", "s"));
5745 subtree = proto_item_add_subtree(ti, hf->ett.cert_types);
5747 while (cert_types_count > 0) {
5748 proto_tree_add_item(subtree, hf->hf.hs_cert_type,
5749 tvb, offset, 1, ENC_BIG_ENDIAN);
5755 switch (session->version) {
5756 case SSL_VER_TLSv1DOT2:
5757 case SSL_VER_DTLS1DOT2:
5758 sh_alg_length = tvb_get_ntohs(tvb, offset);
5759 if (sh_alg_length % 2) {
5760 expert_add_info_format(pinfo, NULL,
5761 &hf->ei.hs_sig_hash_alg_len_bad,
5762 "Signature Hash Algorithm length (%d) must be a multiple of 2",
5767 proto_tree_add_uint(tree, hf->hf.hs_sig_hash_alg_len,
5768 tvb, offset, 2, sh_alg_length);
5771 ret = ssl_dissect_hash_alg_list(hf, tvb, tree, pinfo, offset, sh_alg_length);
5780 dnames_length = tvb_get_ntohs(tvb, offset);
5781 proto_tree_add_uint(tree, hf->hf.hs_dnames_len,
5782 tvb, offset, 2, dnames_length);
5785 if (dnames_length > 0) {
5786 ti = proto_tree_add_none_format(tree,
5788 tvb, offset, dnames_length,
5789 "Distinguished Names (%d byte%s)",
5791 plurality(dnames_length, "", "s"));
5792 subtree = proto_item_add_subtree(ti, hf->ett.dnames);
5794 while (dnames_length > 0) {
5795 /* get the length of the current certificate */
5796 guint16 name_length;
5797 name_length = tvb_get_ntohs(tvb, offset);
5798 dnames_length -= 2 + name_length;
5800 proto_tree_add_item(subtree, hf->hf.hs_dname_len,
5801 tvb, offset, 2, ENC_BIG_ENDIAN);
5804 dissect_x509if_DistinguishedName(FALSE, tvb, offset, &asn1_ctx,
5805 subtree, hf->hf.hs_dname);
5806 offset += name_length;
5812 ssl_dissect_digitally_signed(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5813 proto_tree *tree, guint32 offset,
5814 const SslSession *session,
5815 gint hf_sig_len, gint hf_sig);
5818 ssl_dissect_hnd_cli_cert_verify(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5819 proto_tree *tree, guint32 offset,
5820 const SslSession *session)
5822 ssl_dissect_digitally_signed(hf, tvb, tree, offset, session,
5823 hf->hf.hs_client_cert_vrfy_sig_len,
5824 hf->hf.hs_client_cert_vrfy_sig);
5828 ssl_dissect_hnd_finished(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5829 proto_tree *tree, guint32 offset,
5830 const SslSession *session, ssl_hfs_t *ssl_hfs)
5834 * opaque md5_hash[16];
5835 * opaque sha_hash[20];
5840 * opaque verify_data[12];
5846 if (session->version == SSL_VER_SSLv3) {
5847 if (ssl_hfs != NULL) {
5848 proto_tree_add_item(tree, ssl_hfs->hs_md5_hash,
5849 tvb, offset, 16, ENC_NA);
5850 proto_tree_add_item(tree, ssl_hfs->hs_sha_hash,
5851 tvb, offset + 16, 20, ENC_NA);
5854 proto_tree_add_item(tree, hf->hf.hs_finished,
5855 tvb, offset, 12, ENC_NA);
5860 ssl_dissect_hnd_cert_url(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree, guint32 offset)
5862 guint16 url_hash_len;
5865 * individual_certs(0), pkipath(1), (255)
5869 * CertChainType type;
5870 * URLAndHash url_and_hash_list<1..2^16-1>;
5874 * opaque url<1..2^16-1>;
5876 * opaque SHA1Hash[20];
5880 proto_tree_add_item(tree, hf->hf.hs_ext_cert_url_type,
5881 tvb, offset, 1, ENC_NA);
5884 url_hash_len = tvb_get_ntohs(tvb, offset);
5885 proto_tree_add_item(tree, hf->hf.hs_ext_cert_url_url_hash_list_len,
5886 tvb, offset, 2, ENC_BIG_ENDIAN);
5888 while (url_hash_len-- > 0) {
5889 proto_item *urlhash_item;
5890 proto_tree *urlhash_tree;
5893 urlhash_item = proto_tree_add_item(tree, hf->hf.hs_ext_cert_url_item,
5894 tvb, offset, -1, ENC_NA);
5895 urlhash_tree = proto_item_add_subtree(urlhash_item, hf->ett.urlhash);
5897 url_len = tvb_get_ntohs(tvb, offset);
5898 proto_tree_add_item(urlhash_tree, hf->hf.hs_ext_cert_url_url_len,
5899 tvb, offset, 2, ENC_BIG_ENDIAN);
5902 proto_tree_add_item(urlhash_tree, hf->hf.hs_ext_cert_url_url,
5903 tvb, offset, url_len, ENC_ASCII|ENC_NA);
5906 proto_tree_add_item(urlhash_tree, hf->hf.hs_ext_cert_url_padding,
5907 tvb, offset, 1, ENC_NA);
5909 /* Note: RFC 6066 says that padding must be 0x01 */
5911 proto_tree_add_item(urlhash_tree, hf->hf.hs_ext_cert_url_sha1,
5912 tvb, offset, 20, ENC_NA);
5918 ssl_dissect_hnd_hello_ext_status_request(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
5919 guint32 offset, gboolean has_length)
5921 guint cert_status_type;
5923 cert_status_type = tvb_get_guint8(tvb, offset);
5924 proto_tree_add_item(tree, hf->hf.hs_ext_cert_status_type,
5925 tvb, offset, 1, ENC_NA);
5929 proto_tree_add_item(tree, hf->hf.hs_ext_cert_status_request_len,
5930 tvb, offset, 2, ENC_BIG_ENDIAN);
5934 switch (cert_status_type) {
5935 case SSL_HND_CERT_STATUS_TYPE_OCSP:
5936 case SSL_HND_CERT_STATUS_TYPE_OCSP_MULTI:
5938 guint16 responder_id_list_len;
5939 guint16 request_extensions_len;
5940 proto_item *responder_id;
5941 proto_item *request_extensions;
5943 responder_id_list_len = tvb_get_ntohs(tvb, offset);
5945 proto_tree_add_item(tree,
5946 hf->hf.hs_ext_cert_status_responder_id_list_len,
5947 tvb, offset, 2, ENC_BIG_ENDIAN);
5949 if (responder_id_list_len != 0) {
5950 expert_add_info_format(NULL, responder_id,
5951 &hf->ei.hs_ext_cert_status_undecoded,
5952 "Responder ID list is not implemented, contact Wireshark"
5953 " developers if you want this to be supported");
5954 /* Non-empty responder ID list would mess with extensions. */
5958 request_extensions_len = tvb_get_ntohs(tvb, offset);
5959 request_extensions =
5960 proto_tree_add_item(tree,
5961 hf->hf.hs_ext_cert_status_request_extensions_len, tvb, offset,
5964 if (request_extensions_len != 0)
5965 expert_add_info_format(NULL, request_extensions,
5966 &hf->ei.hs_ext_cert_status_undecoded,
5967 "Request Extensions are not implemented, contact"
5968 " Wireshark developers if you want this to be supported");
5977 ssl_dissect_hnd_hello_ext_status_request_v2(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
5982 list_len = tvb_get_ntohs(tvb, offset);
5985 while (list_len > 0) {
5986 guint32 prev_offset = offset;
5987 offset = ssl_dissect_hnd_hello_ext_status_request(hf, tvb, tree, offset, TRUE);
5988 list_len -= (offset - prev_offset);
5995 ssl_dissect_hnd_hello_ext_elliptic_curves(ssl_common_dissect_t *hf, tvbuff_t *tvb,
5996 proto_tree *tree, guint32 offset)
5998 guint16 curves_length;
5999 proto_tree *curves_tree;
6002 curves_length = tvb_get_ntohs(tvb, offset);
6003 proto_tree_add_item(tree, hf->hf.hs_ext_elliptic_curves_len,
6004 tvb, offset, 2, ENC_BIG_ENDIAN);
6007 ti = proto_tree_add_none_format(tree,
6008 hf->hf.hs_ext_elliptic_curves,
6009 tvb, offset, curves_length,
6010 "Elliptic curves (%d curve%s)",
6012 plurality(curves_length/2, "", "s"));
6014 /* make this a subtree */
6015 curves_tree = proto_item_add_subtree(ti, hf->ett.hs_ext_curves);
6017 /* loop over all curves */
6018 while (curves_length > 0)
6020 proto_tree_add_item(curves_tree, hf->hf.hs_ext_elliptic_curve, tvb, offset, 2, ENC_BIG_ENDIAN);
6029 ssl_dissect_hnd_hello_ext_ec_point_formats(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6030 proto_tree *tree, guint32 offset)
6033 proto_tree *ecpf_tree;
6036 ecpf_length = tvb_get_guint8(tvb, offset);
6037 proto_tree_add_item(tree, hf->hf.hs_ext_ec_point_formats_len,
6038 tvb, offset, 1, ENC_BIG_ENDIAN);
6041 ti = proto_tree_add_none_format(tree,
6042 hf->hf.hs_ext_elliptic_curves,
6043 tvb, offset, ecpf_length,
6044 "Elliptic curves point formats (%d)",
6047 /* make this a subtree */
6048 ecpf_tree = proto_item_add_subtree(ti, hf->ett.hs_ext_curves_point_formats);
6050 /* loop over all point formats */
6051 while (ecpf_length > 0)
6053 proto_tree_add_item(ecpf_tree, hf->hf.hs_ext_ec_point_format, tvb, offset, 1, ENC_BIG_ENDIAN);
6062 ssl_dissect_hnd_hello_ext(ssl_common_dissect_t *hf, tvbuff_t *tvb, proto_tree *tree,
6063 packet_info* pinfo, guint32 offset, guint32 left, gboolean is_client,
6064 SslSession *session, SslDecryptSession *ssl)
6066 guint16 extension_length;
6069 proto_tree *ext_tree;
6074 extension_length = tvb_get_ntohs(tvb, offset);
6075 proto_tree_add_uint(tree, hf->hf.hs_exts_len,
6076 tvb, offset, 2, extension_length);
6082 ext_type = tvb_get_ntohs(tvb, offset);
6083 ext_len = tvb_get_ntohs(tvb, offset + 2);
6085 ext_tree = proto_tree_add_subtree_format(tree, tvb, offset, 4 + ext_len, hf->ett.hs_ext, NULL,
6086 "Extension: %s", val_to_str(ext_type,
6087 tls_hello_extension_types,
6090 proto_tree_add_uint(ext_tree, hf->hf.hs_ext_type,
6091 tvb, offset, 2, ext_type);
6094 proto_tree_add_uint(ext_tree, hf->hf.hs_ext_len,
6095 tvb, offset, 2, ext_len);
6099 case SSL_HND_HELLO_EXT_STATUS_REQUEST:
6101 offset = ssl_dissect_hnd_hello_ext_status_request(hf, tvb, ext_tree, offset, FALSE);
6103 offset += ext_len; /* server must return empty extension_data */
6105 case SSL_HND_HELLO_EXT_STATUS_REQUEST_V2:
6107 offset = ssl_dissect_hnd_hello_ext_status_request_v2(hf, tvb, ext_tree, offset);
6109 offset += ext_len; /* server must return empty extension_data */
6111 case SSL_HND_HELLO_EXT_ELLIPTIC_CURVES:
6112 offset = ssl_dissect_hnd_hello_ext_elliptic_curves(hf, tvb, ext_tree, offset);
6114 case SSL_HND_HELLO_EXT_EC_POINT_FORMATS:
6115 offset = ssl_dissect_hnd_hello_ext_ec_point_formats(hf, tvb, ext_tree, offset);
6117 case SSL_HND_HELLO_EXT_SIG_HASH_ALGS:
6118 offset = ssl_dissect_hnd_hello_ext_sig_hash_algs(hf, tvb, ext_tree, pinfo, offset, ext_len);
6120 case SSL_HND_HELLO_EXT_ALPN:
6121 offset = ssl_dissect_hnd_hello_ext_alpn(hf, tvb, ext_tree, offset, ext_len, is_client, session);
6123 case SSL_HND_HELLO_EXT_NPN:
6124 offset = ssl_dissect_hnd_hello_ext_npn(hf, tvb, ext_tree, offset, ext_len);
6126 case SSL_HND_HELLO_EXT_RENEG_INFO:
6127 offset = ssl_dissect_hnd_hello_ext_reneg_info(hf, tvb, ext_tree, offset, ext_len);
6129 case SSL_HND_HELLO_EXT_SERVER_NAME:
6130 offset = ssl_dissect_hnd_hello_ext_server_name(hf, tvb, ext_tree, offset, ext_len);
6132 case SSL_HND_HELLO_EXT_HEARTBEAT:
6133 proto_tree_add_item(ext_tree, hf->hf.hs_ext_heartbeat_mode,
6134 tvb, offset, 1, ENC_BIG_ENDIAN);
6137 case SSL_HND_HELLO_EXT_PADDING:
6138 offset = ssl_dissect_hnd_hello_ext_padding(hf, tvb, ext_tree, offset, ext_len);
6140 case SSL_HND_HELLO_EXT_SESSION_TICKET:
6141 offset = ssl_dissect_hnd_hello_ext_session_ticket(hf, tvb, ext_tree, offset, ext_len, is_client, ssl);
6143 case SSL_HND_HELLO_EXT_CERT_TYPE:
6144 case SSL_HND_HELLO_EXT_SERVER_CERT_TYPE:
6145 case SSL_HND_HELLO_EXT_CLIENT_CERT_TYPE:
6146 offset = ssl_dissect_hnd_hello_ext_cert_type(hf, tvb, ext_tree,
6148 is_client, ext_type,
6151 case SSL_HND_HELLO_EXT_EXTENDED_MASTER_SECRET_TYPE:
6153 ssl->state |= (is_client ? SSL_CLIENT_EXTENDED_MASTER_SECRET : SSL_SERVER_EXTENDED_MASTER_SECRET);
6156 proto_tree_add_bytes_format(ext_tree, hf->hf.hs_ext_data,
6157 tvb, offset, ext_len, NULL,
6159 ext_len, plurality(ext_len, "", "s"));
6164 left -= 2 + 2 + ext_len;
6171 /* ClientKeyExchange algo-specific dissectors */
6174 dissect_ssl3_hnd_cli_keyex_ecdh(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6175 proto_tree *tree, guint32 offset,
6179 proto_tree *ssl_ecdh_tree;
6181 ssl_ecdh_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6182 hf->ett.keyex_params, NULL, "EC Diffie-Hellman Client Params");
6185 point_len = tvb_get_guint8(tvb, offset);
6186 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_client_keyex_point_len, tvb,
6187 offset, 1, ENC_BIG_ENDIAN);
6188 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_client_keyex_point, tvb,
6189 offset + 1, point_len, ENC_NA);
6193 dissect_ssl3_hnd_cli_keyex_dh(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6194 proto_tree *tree, guint32 offset, guint32 length)
6197 proto_tree *ssl_dh_tree;
6199 ssl_dh_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6200 hf->ett.keyex_params, NULL, "Diffie-Hellman Client Params");
6202 /* ClientDiffieHellmanPublic.dh_public (explicit) */
6203 yc_len = tvb_get_ntohs(tvb, offset);
6204 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_client_keyex_yc_len, tvb,
6205 offset, 2, ENC_BIG_ENDIAN);
6206 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_client_keyex_yc, tvb,
6207 offset + 2, yc_len, ENC_NA);
6211 dissect_ssl3_hnd_cli_keyex_rsa(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6212 proto_tree *tree, guint32 offset,
6213 guint32 length, const SslSession *session)
6216 proto_tree *ssl_rsa_tree;
6218 ssl_rsa_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6219 hf->ett.keyex_params, NULL, "RSA Encrypted PreMaster Secret");
6221 /* EncryptedPreMasterSecret.pre_master_secret */
6222 switch (session->version) {
6225 case SSL_VER_DTLS_OPENSSL:
6226 /* OpenSSL pre-0.9.8f DTLS and pre-TLS quirk: 2-octet length vector is
6227 * not present. The handshake contents represents the EPMS, see:
6228 * https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=10222 */
6233 /* TLS and DTLS include vector length before EPMS */
6234 epms_len = tvb_get_ntohs(tvb, offset);
6235 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_client_keyex_epms_len, tvb,
6236 offset, 2, ENC_BIG_ENDIAN);
6240 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_client_keyex_epms, tvb,
6241 offset, epms_len, ENC_NA);
6244 /* Used in PSK cipher suites */
6246 dissect_ssl3_hnd_cli_keyex_psk(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6247 proto_tree *tree, guint32 offset, guint32 length)
6250 proto_tree *ssl_psk_tree;
6252 ssl_psk_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6253 hf->ett.keyex_params, NULL, "PSK Client Params");
6255 identity_len = tvb_get_ntohs(tvb, offset);
6256 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_identity_len, tvb,
6257 offset, 2, ENC_BIG_ENDIAN);
6258 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_identity, tvb,
6259 offset + 2, identity_len, ENC_NA);
6262 /* Used in RSA PSK cipher suites */
6264 dissect_ssl3_hnd_cli_keyex_rsa_psk(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6265 proto_tree *tree, guint32 offset,
6268 gint identity_len, epms_len;
6269 proto_tree *ssl_psk_tree;
6271 ssl_psk_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6272 hf->ett.keyex_params, NULL, "RSA PSK Client Params");
6275 identity_len = tvb_get_ntohs(tvb, offset);
6276 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_identity_len,
6277 tvb, offset, 2, ENC_BIG_ENDIAN);
6278 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_identity,
6279 tvb, offset + 2, identity_len, ENC_NA);
6280 offset += 2 + identity_len;
6283 epms_len = tvb_get_ntohs(tvb, offset);
6284 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_epms_len, tvb,
6285 offset, 2, ENC_BIG_ENDIAN);
6286 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_client_keyex_epms, tvb,
6287 offset + 2, epms_len, ENC_NA);
6291 /* Dissects DigitallySigned (see RFC 5246 4.7 Cryptographic Attributes). */
6293 ssl_dissect_digitally_signed(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6294 proto_tree *tree, guint32 offset,
6295 const SslSession *session,
6296 gint hf_sig_len, gint hf_sig)
6299 proto_item *ti_algo;
6300 proto_tree *ssl_algo_tree;
6302 switch (session->version) {
6303 case SSL_VER_TLSv1DOT2:
6304 case SSL_VER_DTLS1DOT2:
6305 ti_algo = proto_tree_add_item(tree, hf->hf.hs_sig_hash_alg, tvb,
6306 offset, 2, ENC_BIG_ENDIAN);
6307 ssl_algo_tree = proto_item_add_subtree(ti_algo, hf->ett.hs_sig_hash_alg);
6309 /* SignatureAndHashAlgorithm { hash, signature } */
6310 proto_tree_add_item(ssl_algo_tree, hf->hf.hs_sig_hash_hash, tvb,
6311 offset, 1, ENC_BIG_ENDIAN);
6312 proto_tree_add_item(ssl_algo_tree, hf->hf.hs_sig_hash_sig, tvb,
6313 offset + 1, 1, ENC_BIG_ENDIAN);
6322 sig_len = tvb_get_ntohs(tvb, offset);
6323 proto_tree_add_item(tree, hf_sig_len, tvb, offset, 2, ENC_BIG_ENDIAN);
6324 proto_tree_add_item(tree, hf_sig, tvb, offset + 2, sig_len, ENC_NA);
6327 /* ServerKeyExchange algo-specific dissectors */
6329 /* dissects signed_params inside a ServerKeyExchange for some keyex algos */
6331 dissect_ssl3_hnd_srv_keyex_sig(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6332 proto_tree *tree, guint32 offset,
6333 const SslSession *session)
6336 * TLSv1.2 (RFC 5246 sec 7.4.8)
6338 * digitally-signed struct {
6339 * opaque handshake_messages[handshake_messages_length];
6341 * } CertificateVerify;
6343 * TLSv1.0/TLSv1.1 (RFC 5436 sec 7.4.8 and 7.4.3) works essentially the same
6344 * as TLSv1.2, but the hash algorithms are not explicit in digitally-signed.
6346 * SSLv3 (RFC 6101 sec 5.6.8) esseentially works the same as TLSv1.0 but it
6347 * does more hashing including the master secret and padding.
6349 ssl_dissect_digitally_signed(hf, tvb, tree, offset, session,
6350 hf->hf.hs_server_keyex_sig_len,
6351 hf->hf.hs_server_keyex_sig);
6355 dissect_ssl3_hnd_srv_keyex_ecdh(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6356 proto_tree *tree, guint32 offset,
6357 guint32 length, const SslSession *session,
6361 * RFC 4492 ECC cipher suites for TLS
6364 * ECCurveType curve_type;
6365 * select (curve_type) {
6366 * case explicit_prime:
6368 * case explicit_char2:
6371 * NamedCurve namedcurve;
6376 * opaque point <1..2^8-1>;
6380 * ECParameters curve_params;
6382 * } ServerECDHParams;
6384 * select (KeyExchangeAlgorithm) {
6385 * case ec_diffie_hellman:
6386 * ServerECDHParams params;
6387 * Signature signed_params;
6388 * } ServerKeyExchange;
6393 proto_tree *ssl_ecdh_tree;
6395 ssl_ecdh_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6396 hf->ett.keyex_params, NULL, "EC Diffie-Hellman Server Params");
6398 /* ECParameters.curve_type */
6399 curve_type = tvb_get_guint8(tvb, offset);
6400 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_server_keyex_curve_type, tvb,
6401 offset, 1, ENC_BIG_ENDIAN);
6403 if (curve_type != 3)
6404 return; /* only named_curves are supported */
6406 /* case curve_type == named_curve; ECParameters.namedcurve */
6407 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_server_keyex_named_curve, tvb,
6408 offset, 2, ENC_BIG_ENDIAN);
6412 point_len = tvb_get_guint8(tvb, offset);
6413 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_server_keyex_point_len, tvb,
6414 offset, 1, ENC_BIG_ENDIAN);
6415 proto_tree_add_item(ssl_ecdh_tree, hf->hf.hs_server_keyex_point, tvb,
6416 offset + 1, point_len, ENC_NA);
6417 offset += 1 + point_len;
6419 /* Signature (if non-anonymous KEX) */
6421 dissect_ssl3_hnd_srv_keyex_sig(hf, tvb, ssl_ecdh_tree, offset, session);
6426 dissect_ssl3_hnd_srv_keyex_dhe(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6427 proto_tree *tree, guint32 offset, guint32 length,
6428 const SslSession *session, gboolean anon)
6430 gint p_len, g_len, ys_len;
6431 proto_tree *ssl_dh_tree;
6433 ssl_dh_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6434 hf->ett.keyex_params, NULL, "Diffie-Hellman Server Params");
6437 p_len = tvb_get_ntohs(tvb, offset);
6438 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_server_keyex_p_len, tvb,
6439 offset, 2, ENC_BIG_ENDIAN);
6440 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_server_keyex_p, tvb,
6441 offset + 2, p_len, ENC_NA);
6442 offset += 2 + p_len;
6445 g_len = tvb_get_ntohs(tvb, offset);
6446 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_server_keyex_g_len, tvb,
6447 offset, 2, ENC_BIG_ENDIAN);
6448 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_server_keyex_g, tvb,
6449 offset + 2, g_len, ENC_NA);
6450 offset += 2 + g_len;
6453 ys_len = tvb_get_ntohs(tvb, offset);
6454 proto_tree_add_uint(ssl_dh_tree, hf->hf.hs_server_keyex_ys_len, tvb,
6456 proto_tree_add_item(ssl_dh_tree, hf->hf.hs_server_keyex_ys, tvb,
6457 offset + 2, ys_len, ENC_NA);
6458 offset += 2 + ys_len;
6460 /* Signature (if non-anonymous KEX) */
6462 dissect_ssl3_hnd_srv_keyex_sig(hf, tvb, ssl_dh_tree, offset, session);
6466 /* Only used in RSA-EXPORT cipher suites */
6468 dissect_ssl3_hnd_srv_keyex_rsa(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6469 proto_tree *tree, guint32 offset, guint32 length,
6470 const SslSession *session)
6472 gint modulus_len, exponent_len;
6473 proto_tree *ssl_rsa_tree;
6475 ssl_rsa_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6476 hf->ett.keyex_params, NULL, "RSA-EXPORT Server Params");
6479 modulus_len = tvb_get_ntohs(tvb, offset);
6480 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_server_keyex_modulus_len, tvb,
6481 offset, 2, ENC_BIG_ENDIAN);
6482 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_server_keyex_modulus, tvb,
6483 offset + 2, modulus_len, ENC_NA);
6484 offset += 2 + modulus_len;
6487 exponent_len = tvb_get_ntohs(tvb, offset);
6488 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_server_keyex_exponent_len,
6489 tvb, offset, 2, ENC_BIG_ENDIAN);
6490 proto_tree_add_item(ssl_rsa_tree, hf->hf.hs_server_keyex_exponent,
6491 tvb, offset + 2, exponent_len, ENC_NA);
6492 offset += 2 + exponent_len;
6495 dissect_ssl3_hnd_srv_keyex_sig(hf, tvb, ssl_rsa_tree, offset, session);
6498 /* Used in RSA PSK and PSK cipher suites */
6500 dissect_ssl3_hnd_srv_keyex_psk(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6501 proto_tree *tree, guint32 offset, guint32 length)
6504 proto_tree *ssl_psk_tree;
6506 hint_len = tvb_get_ntohs(tvb, offset);
6507 if ((2 + hint_len) != length) {
6508 /* Lengths don't line up (wasn't what we expected?) */
6512 ssl_psk_tree = proto_tree_add_subtree(tree, tvb, offset, length,
6513 hf->ett.keyex_params, NULL, "PSK Server Params");
6516 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_server_keyex_hint_len, tvb,
6517 offset, 2, ENC_BIG_ENDIAN);
6518 proto_tree_add_item(ssl_psk_tree, hf->hf.hs_server_keyex_hint, tvb,
6519 offset + 2, hint_len, ENC_NA);
6524 ssl_dissect_hnd_cli_keyex(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6525 proto_tree *tree, guint32 offset, guint32 length,
6526 const SslSession *session)
6528 switch (ssl_get_keyex_alg(session->cipher)) {
6529 case KEX_DH_ANON: /* RFC 5246; DHE_DSS, DHE_RSA, DH_DSS, DH_RSA, DH_ANON: ClientDiffieHellmanPublic */
6534 dissect_ssl3_hnd_cli_keyex_dh(hf, tvb, tree, offset, length);
6536 case KEX_DHE_PSK: /* RFC 4279; diffie_hellman_psk: psk_identity, ClientDiffieHellmanPublic */
6537 /* XXX: implement support for DHE_PSK */
6539 case KEX_ECDH_ANON: /* RFC 4492; ec_diffie_hellman: ClientECDiffieHellmanPublic */
6540 case KEX_ECDH_ECDSA:
6542 case KEX_ECDHE_ECDSA:
6544 dissect_ssl3_hnd_cli_keyex_ecdh(hf, tvb, tree, offset, length);
6546 case KEX_ECDHE_PSK: /* RFC 5489; ec_diffie_hellman_psk: psk_identity, ClientECDiffieHellmanPublic */
6547 /* XXX: implement support for ECDHE_PSK */
6549 case KEX_KRB5: /* RFC 2712; krb5: KerberosWrapper */
6550 /* XXX: implement support for KRB5 */
6552 case KEX_PSK: /* RFC 4279; psk: psk_identity */
6553 dissect_ssl3_hnd_cli_keyex_psk(hf, tvb, tree, offset, length);
6555 case KEX_RSA: /* RFC 5246; rsa: EncryptedPreMasterSecret */
6556 dissect_ssl3_hnd_cli_keyex_rsa(hf, tvb, tree, offset, length, session);
6558 case KEX_RSA_PSK: /* RFC 4279; rsa_psk: psk_identity, EncryptedPreMasterSecret */
6559 dissect_ssl3_hnd_cli_keyex_rsa_psk(hf, tvb, tree, offset, length);
6561 case KEX_SRP_SHA: /* RFC 5054; srp: ClientSRPPublic */
6562 case KEX_SRP_SHA_DSS:
6563 case KEX_SRP_SHA_RSA:
6564 /* XXX: implement support for SRP_SHA* */
6567 /* XXX: add info message for not supported KEX algo */
6573 ssl_dissect_hnd_srv_keyex(ssl_common_dissect_t *hf, tvbuff_t *tvb,
6574 proto_tree *tree, guint32 offset, guint32 length,
6575 const SslSession *session)
6577 switch (ssl_get_keyex_alg(session->cipher)) {
6578 case KEX_DH_ANON: /* RFC 5246; ServerDHParams */
6579 dissect_ssl3_hnd_srv_keyex_dhe(hf, tvb, tree, offset, length, session, TRUE);
6581 case KEX_DH_DSS: /* RFC 5246; not allowed */
6583 /* XXX: add error on not allowed KEX */
6585 case KEX_DHE_DSS: /* RFC 5246; dhe_dss, dhe_rsa: ServerDHParams, Signature */
6587 dissect_ssl3_hnd_srv_keyex_dhe(hf, tvb, tree, offset, length, session, FALSE);
6589 case KEX_DHE_PSK: /* RFC 4279; diffie_hellman_psk: psk_identity_hint, ServerDHParams */
6590 /* XXX: implement support for DHE_PSK */
6592 case KEX_ECDH_ANON: /* RFC 4492; ec_diffie_hellman: ServerECDHParams (without signature for anon) */
6593 dissect_ssl3_hnd_srv_keyex_ecdh(hf, tvb, tree, offset, length, session, TRUE);
6595 case KEX_ECDHE_PSK: /* RFC 5489; psk_identity_hint, ServerECDHParams */
6596 /* XXX: implement support for ECDHE_PSK */
6598 case KEX_ECDH_ECDSA: /* RFC 4492; ec_diffie_hellman: ServerECDHParams, Signature */
6600 case KEX_ECDHE_ECDSA:
6602 dissect_ssl3_hnd_srv_keyex_ecdh(hf, tvb, tree, offset, length, session, FALSE);
6604 case KEX_KRB5: /* RFC 2712; not allowed */
6605 /* XXX: add error on not allowed KEX */
6607 case KEX_PSK: /* RFC 4279; psk, rsa: psk_identity*/
6609 dissect_ssl3_hnd_srv_keyex_psk(hf, tvb, tree, offset, length);
6611 case KEX_RSA: /* only allowed if the public key in the server certificate is longer than 512 bits*/
6612 dissect_ssl3_hnd_srv_keyex_rsa(hf, tvb, tree, offset, length, session);
6614 case KEX_SRP_SHA: /* RFC 5054; srp: ServerSRPParams, Signature */
6615 case KEX_SRP_SHA_DSS:
6616 case KEX_SRP_SHA_RSA:
6617 /* XXX: implement support for SRP_SHA* */
6620 /* XXX: add info message for not supported KEX algo */
6625 #ifdef HAVE_LIBGNUTLS
6627 ssl_common_register_options(module_t *module, ssl_common_options_t *options)
6629 prefs_register_string_preference(module, "psk", "Pre-Shared-Key",
6630 "Pre-Shared-Key as HEX string. Should be 0 to 16 bytes.",
6633 prefs_register_filename_preference(module, "keylog_file", "(Pre)-Master-Secret log filename",
6634 "The name of a file which contains a list of \n"
6635 "(pre-)master secrets in one of the following formats:\n"
6637 "RSA <EPMS> <PMS>\n"
6638 "RSA Session-ID:<SSLID> Master-Key:<MS>\n"
6639 "CLIENT_RANDOM <CRAND> <MS>\n"
6640 "PMS_CLIENT_RANDOM <CRAND> <PMS>\n"
6643 "<EPMS> = First 8 bytes of the Encrypted PMS\n"
6644 "<PMS> = The Pre-Master-Secret (PMS) used to derive the MS\n"
6645 "<SSLID> = The SSL Session ID\n"
6646 "<MS> = The Master-Secret (MS)\n"
6647 "<CRAND> = The Client's random number from the ClientHello message\n"
6649 "(All fields are in hex notation)",
6650 &(options->keylog_filename));
6654 ssl_common_register_options(module_t *module _U_, ssl_common_options_t *options _U_)
6660 ssl_calculate_handshake_hash(SslDecryptSession *ssl_session, tvbuff_t *tvb, guint32 offset, guint32 length)
6662 if (ssl_session && !(ssl_session->state & SSL_MASTER_SECRET)) {
6663 guint32 old_length = ssl_session->handshake_data.data_len;
6664 ssl_debug_printf("Calculating hash with offset %d %d\n", offset, length);
6665 ssl_session->handshake_data.data = (guchar *)wmem_realloc(wmem_file_scope(), ssl_session->handshake_data.data, old_length + length);
6666 tvb_memcpy(tvb, ssl_session->handshake_data.data + old_length, offset, length);
6667 ssl_session->handshake_data.data_len += length;
6673 * Editor modelines - http://www.wireshark.org/tools/modelines.html
6678 * indent-tabs-mode: nil
6681 * vi: set shiftwidth=4 tabstop=8 expandtab:
6682 * :indentSize=4:tabSize=8:noTabs=true: