/src/wireshark/epan/dissectors/packet-btsmp.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-btsmp.c |
2 | | * Routines for Bluetooth Security Manager Protocol dissection |
3 | | * |
4 | | * Copyright 2012, Allan M. Madsen <allan.m@madsen.dk> |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * Wireshark - Network traffic analyzer |
11 | | * By Gerald Combs <gerald@wireshark.org> |
12 | | * Copyright 1998 Gerald Combs |
13 | | * |
14 | | * SPDX-License-Identifier: GPL-2.0-or-later |
15 | | */ |
16 | | |
17 | | #include "config.h" |
18 | | |
19 | | #include <epan/packet.h> |
20 | | #include "packet-bluetooth.h" |
21 | | #include "packet-btl2cap.h" |
22 | | |
23 | | /* Initialize the protocol and registered fields */ |
24 | | static int proto_btsmp; |
25 | | |
26 | | static int hf_btsmp_opcode; |
27 | | static int hf_btsmp_io_capabilities; |
28 | | static int hf_btsmp_oob_data_flags; |
29 | | static int hf_btsmp_reason; |
30 | | static int hf_btsmp_cfm_value; |
31 | | static int hf_btsmp_random; |
32 | | static int hf_btsmp_long_term_key; |
33 | | static int hf_btsmp_id_resolving_key; |
34 | | static int hf_btsmp_signature_key; |
35 | | static int hf_btsmp_bonding_flags; |
36 | | static int hf_btsmp_mitm_flag; |
37 | | static int hf_btsmp_secure_connection_flag; |
38 | | static int hf_btsmp_keypress_flag; |
39 | | static int hf_btsmp_ct2_flag; |
40 | | static int hf_btsmp_reserved_flag; |
41 | | static int hf_btsmp_max_enc_key_size; |
42 | | static int hf_btsmp_key_dist_enc; |
43 | | static int hf_btsmp_key_dist_id; |
44 | | static int hf_btsmp_key_dist_sign; |
45 | | static int hf_btsmp_key_dist_linkkey; |
46 | | static int hf_btsmp_key_dist_reserved; |
47 | | static int hf_btsmp_ediv; |
48 | | static int hf_btsmp_authreq; |
49 | | static int hf_btsmp_initiator_key_distribution; |
50 | | static int hf_btsmp_responder_key_distribution; |
51 | | static int hf_bd_addr; |
52 | | static int hf_address_type; |
53 | | static int hf_btsmp_public_key_x; |
54 | | static int hf_btsmp_public_key_y; |
55 | | static int hf_btsmp_dhkey_check; |
56 | | static int hf_btsmp_notification_type; |
57 | | |
58 | | static int * const hfx_btsmp_key_distribution[] = { |
59 | | &hf_btsmp_key_dist_reserved, |
60 | | &hf_btsmp_key_dist_linkkey, |
61 | | &hf_btsmp_key_dist_sign, |
62 | | &hf_btsmp_key_dist_id, |
63 | | &hf_btsmp_key_dist_enc, |
64 | | NULL |
65 | | }; |
66 | | |
67 | | static int * const hfx_btsmp_authreq[] = { |
68 | | &hf_btsmp_reserved_flag, |
69 | | &hf_btsmp_ct2_flag, |
70 | | &hf_btsmp_keypress_flag, |
71 | | &hf_btsmp_secure_connection_flag, |
72 | | &hf_btsmp_mitm_flag, |
73 | | &hf_btsmp_bonding_flags, |
74 | | NULL |
75 | | }; |
76 | | |
77 | | |
78 | | /* Initialize the subtree pointers */ |
79 | | static int ett_btsmp; |
80 | | static int ett_btsmp_auth_req; |
81 | | static int ett_btsmp_key_dist; |
82 | | |
83 | | static dissector_handle_t btsmp_handle; |
84 | | |
85 | | /* Opcodes */ |
86 | | static const value_string opcode_vals[] = { |
87 | | {0x01, "Pairing Request"}, |
88 | | {0x02, "Pairing Response"}, |
89 | | {0x03, "Pairing Confirm"}, |
90 | | {0x04, "Pairing Random"}, |
91 | | {0x05, "Pairing Failed"}, |
92 | | {0x06, "Encryption Information"}, |
93 | | {0x07, "Central Identification"}, |
94 | | {0x08, "Identity Information"}, |
95 | | {0x09, "Identity Address Information"}, |
96 | | {0x0A, "Signing Information"}, |
97 | | {0x0B, "Security Request"}, |
98 | | {0x0C, "Pairing Public Key"}, |
99 | | {0x0D, "Pairing DHKey Check"}, |
100 | | {0x0E, "Pairing Keypress Notification"}, |
101 | | {0x0, NULL} |
102 | | }; |
103 | | |
104 | | /* IO capabilities */ |
105 | | static const value_string io_capability_vals[] = { |
106 | | {0x00, "Display Only"}, |
107 | | {0x01, "Display Yes/No"}, |
108 | | {0x02, "Keyboard Only"}, |
109 | | {0x03, "No Input, No Output"}, |
110 | | {0x04, "Keyboard, Display"}, |
111 | | {0x0, NULL} |
112 | | }; |
113 | | |
114 | | /* OOB Data present Flag */ |
115 | | static const value_string oob_data_flag_vals[] = { |
116 | | {0x00, "OOB Auth. Data Not Present"}, |
117 | | {0x01, "OOB Auth. Data From Remote Device Present"}, |
118 | | {0x0, NULL} |
119 | | }; |
120 | | |
121 | | /* Bonding flags */ |
122 | | static const value_string bonding_flag_vals[] = { |
123 | | {0x00, "No Bonding"}, |
124 | | {0x01, "Bonding"}, |
125 | | {0x0, NULL} |
126 | | }; |
127 | | |
128 | | /* Reason codes */ |
129 | | static const value_string reason_vals[] = { |
130 | | {0x01, "Passkey Entry Failed"}, |
131 | | {0x02, "OOB Not Available"}, |
132 | | {0x03, "Authentication Requirements"}, |
133 | | {0x04, "Confirm Value Failed"}, |
134 | | {0x05, "Pairing Not Supported"}, |
135 | | {0x06, "Encryption Key Size"}, |
136 | | {0x07, "Command Not Supported"}, |
137 | | {0x08, "Unspecified Reason"}, |
138 | | {0x09, "Repeated Attempts"}, |
139 | | {0x0A, "Invalid Parameters"}, |
140 | | {0x0B, "DHKey Check Failed"}, |
141 | | {0x0C, "Numeric Comparison Failed"}, |
142 | | {0x0D, "BR/EDR pairing in progress"}, |
143 | | {0x0E, "Cross-transport Key Derivation/Generation not allowed"}, |
144 | | {0x0, NULL} |
145 | | }; |
146 | | |
147 | | static const value_string notification_type_vals[] = { |
148 | | {0x00, "Passkey Entry Started"}, |
149 | | {0x01, "Passkey Digit Entered"}, |
150 | | {0x02, "Passkey Digit Erased"}, |
151 | | {0x03, "Passkey Cleared"}, |
152 | | {0x04, "Passkey Entry Completed"}, |
153 | | {0x0, NULL} |
154 | | }; |
155 | | |
156 | | /* X coordinate of debug public key. Little-endian. */ |
157 | | static const uint8_t debug_public_key_x[32] = { |
158 | | 0xe6, 0x9d, 0x35, 0x0e, 0x48, 0x01, 0x03, 0xcc, |
159 | | 0xdb, 0xfd, 0xf4, 0xac, 0x11, 0x91, 0xf4, 0xef, |
160 | | 0xb9, 0xa5, 0xf9, 0xe9, 0xa7, 0x83, 0x2c, 0x5e, |
161 | | 0x2c, 0xbe, 0x97, 0xf2, 0xd2, 0x03, 0xb0, 0x20, |
162 | | }; |
163 | | |
164 | | /* Y coordinate of debug public key. Little-endian. */ |
165 | | static const uint8_t debug_public_key_y[32] = { |
166 | | 0x8b, 0xd2, 0x89, 0x15, 0xd0, 0x8e, 0x1c, 0x74, |
167 | | 0x24, 0x30, 0xed, 0x8f, 0xc2, 0x45, 0x63, 0x76, |
168 | | 0x5c, 0x15, 0x52, 0x5a, 0xbf, 0x9a, 0x32, 0x63, |
169 | | 0x6d, 0xeb, 0x2a, 0x65, 0x49, 0x9c, 0x80, 0xdc |
170 | | }; |
171 | | |
172 | | void proto_register_btsmp(void); |
173 | | void proto_reg_handoff_btsmp(void); |
174 | | |
175 | | static int |
176 | | dissect_btsmp_auth_req(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree) |
177 | 8 | { |
178 | 8 | uint8_t value; |
179 | 8 | const uint8_t *ph; |
180 | | |
181 | 8 | col_append_str(pinfo->cinfo, COL_INFO, "AuthReq: "); |
182 | 8 | proto_tree_add_bitmask(tree, tvb, offset, hf_btsmp_authreq, ett_btsmp_auth_req, hfx_btsmp_authreq, ENC_LITTLE_ENDIAN); |
183 | | |
184 | 8 | value = tvb_get_uint8(tvb, offset); |
185 | | |
186 | 8 | ph = val_to_str_const(value & 0x03, bonding_flag_vals, "<unknown>"); |
187 | 8 | col_append_sep_str(pinfo->cinfo, COL_INFO, "", ph); |
188 | | |
189 | 8 | if (value & 0x04) |
190 | 6 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "MITM"); |
191 | 8 | if (value & 0x08) |
192 | 5 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "SecureConnection"); |
193 | 8 | if (value & 0x10) |
194 | 5 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "Keypress"); |
195 | 8 | if (value & 0xE0) |
196 | 6 | col_append_sep_str(pinfo->cinfo, COL_INFO, ", ", "Reserved"); |
197 | | |
198 | 8 | return offset + 1; |
199 | 8 | } |
200 | | |
201 | | static int |
202 | | dissect_btsmp_key_dist(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, bool initiator) |
203 | 6 | { |
204 | 6 | uint8_t value; |
205 | 6 | bool next = false; |
206 | | |
207 | 6 | if (initiator) { |
208 | 3 | col_append_str(pinfo->cinfo, COL_INFO, " | Initiator Key(s): "); |
209 | 3 | proto_tree_add_bitmask(tree, tvb, offset, hf_btsmp_initiator_key_distribution, ett_btsmp_key_dist, hfx_btsmp_key_distribution, ENC_LITTLE_ENDIAN); |
210 | 3 | } else { |
211 | 3 | col_append_str(pinfo->cinfo, COL_INFO, " | Responder Key(s): "); |
212 | 3 | proto_tree_add_bitmask(tree, tvb, offset, hf_btsmp_responder_key_distribution, ett_btsmp_key_dist, hfx_btsmp_key_distribution, ENC_LITTLE_ENDIAN); |
213 | 3 | } |
214 | | |
215 | 6 | value = tvb_get_uint8(tvb, offset); |
216 | | |
217 | 6 | if (value & 0x01) { |
218 | 4 | col_append_str(pinfo->cinfo, COL_INFO, "LTK"); |
219 | 4 | next = true; |
220 | 4 | } |
221 | 6 | if (value & 0x02) { |
222 | 2 | col_append_sep_str(pinfo->cinfo, COL_INFO, next ? ", " : "", "IRK"); |
223 | 2 | next = true; |
224 | 2 | } |
225 | 6 | if (value & 0x04) { |
226 | 3 | col_append_sep_str(pinfo->cinfo, COL_INFO, next ? ", " : "", "CSRK"); |
227 | 3 | next = true; |
228 | 3 | } |
229 | 6 | if (value & 0x08) { |
230 | 4 | col_append_sep_str(pinfo->cinfo, COL_INFO, next ? ", " : "", "Linkkey"); |
231 | 4 | next = true; |
232 | 4 | } |
233 | 6 | if (value & 0xF0) { |
234 | 6 | col_append_sep_str(pinfo->cinfo, COL_INFO, next ? ", " : "", "Reserved"); |
235 | 6 | } |
236 | 6 | if (!next) { |
237 | 0 | col_append_str(pinfo->cinfo, COL_INFO, "<none>"); |
238 | 0 | } |
239 | | |
240 | 6 | return offset + 1; |
241 | 6 | } |
242 | | |
243 | | static int |
244 | | dissect_btsmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) |
245 | 10 | { |
246 | 10 | int offset = 0; |
247 | 10 | proto_item *ti; |
248 | 10 | proto_tree *st; |
249 | 10 | uint8_t opcode; |
250 | 10 | uint32_t interface_id; |
251 | 10 | uint32_t adapter_id; |
252 | 10 | int previous_proto; |
253 | | |
254 | 10 | interface_id = HCI_INTERFACE_DEFAULT; |
255 | 10 | adapter_id = HCI_ADAPTER_DEFAULT; |
256 | 10 | previous_proto = (GPOINTER_TO_INT(wmem_list_frame_data(wmem_list_frame_prev(wmem_list_tail(pinfo->layers))))); |
257 | 10 | if (data && previous_proto == proto_btl2cap) { |
258 | 10 | btl2cap_data_t *l2cap_data; |
259 | | |
260 | 10 | l2cap_data = (btl2cap_data_t *) data; |
261 | 10 | if (l2cap_data) { |
262 | 10 | interface_id = l2cap_data->interface_id; |
263 | 10 | adapter_id = l2cap_data->adapter_id; |
264 | 10 | } |
265 | 10 | } |
266 | | |
267 | 10 | ti = proto_tree_add_item(tree, proto_btsmp, tvb, 0, tvb_captured_length(tvb), ENC_NA); |
268 | 10 | st = proto_item_add_subtree(ti, ett_btsmp); |
269 | | |
270 | 10 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "SMP"); |
271 | | |
272 | 10 | switch (pinfo->p2p_dir) { |
273 | 0 | case P2P_DIR_SENT: |
274 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Sent "); |
275 | 0 | break; |
276 | 0 | case P2P_DIR_RECV: |
277 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Rcvd "); |
278 | 0 | break; |
279 | 10 | default: |
280 | 10 | col_set_str(pinfo->cinfo, COL_INFO, "UnknownDirection "); |
281 | 10 | break; |
282 | 10 | } |
283 | | |
284 | 10 | if (tvb_reported_length(tvb) < 1) |
285 | 0 | return false; |
286 | | |
287 | 10 | proto_tree_add_item(st, hf_btsmp_opcode, tvb, 0, 1, ENC_LITTLE_ENDIAN); |
288 | 10 | opcode = tvb_get_uint8(tvb, 0); |
289 | 10 | offset++; |
290 | | |
291 | 10 | col_append_str(pinfo->cinfo, COL_INFO, val_to_str_const(opcode, opcode_vals, "<unknown>")); |
292 | | |
293 | 10 | switch (opcode) { |
294 | 3 | case 0x01: /* Pairing Request */ |
295 | 3 | case 0x02: /* Pairing Response */ |
296 | 3 | { |
297 | 3 | col_append_str(pinfo->cinfo, COL_INFO, ": "); |
298 | | |
299 | 3 | proto_tree_add_item(st, hf_btsmp_io_capabilities, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
300 | 3 | offset++; |
301 | 3 | proto_tree_add_item(st, hf_btsmp_oob_data_flags, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
302 | 3 | offset++; |
303 | | |
304 | 3 | offset = dissect_btsmp_auth_req(tvb, offset, pinfo, st); |
305 | | |
306 | 3 | proto_tree_add_item(st, hf_btsmp_max_enc_key_size, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
307 | 3 | offset++; |
308 | | |
309 | 3 | offset = dissect_btsmp_key_dist(tvb, offset, pinfo, st, true); |
310 | 3 | offset = dissect_btsmp_key_dist(tvb, offset, pinfo, st, false); |
311 | 3 | break; |
312 | 3 | } |
313 | | |
314 | 0 | case 0x03: /* Pairing Confirm */ |
315 | 0 | proto_tree_add_item(st, hf_btsmp_cfm_value, tvb, offset, 16, ENC_NA); |
316 | 0 | offset += 16; |
317 | 0 | break; |
318 | | |
319 | 0 | case 0x04: /* Pairing Random */ |
320 | 0 | proto_tree_add_item(st, hf_btsmp_random, tvb, offset, 16, ENC_NA); |
321 | 0 | offset += 16; |
322 | 0 | break; |
323 | | |
324 | 0 | case 0x05: /* Pairing Failed */ |
325 | 0 | proto_tree_add_item(st, hf_btsmp_reason, tvb, offset, 1, ENC_LITTLE_ENDIAN); |
326 | 0 | col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", val_to_str_const(tvb_get_uint8(tvb, offset), reason_vals, "<unknown>")); |
327 | 0 | offset++; |
328 | 0 | break; |
329 | | |
330 | 1 | case 0x06: /* Encryption Information */ |
331 | 1 | proto_tree_add_item(st, hf_btsmp_long_term_key, tvb, offset, 16, ENC_NA); |
332 | 1 | offset += 16; |
333 | 1 | break; |
334 | | |
335 | 0 | case 0x07: /* Central Identification */ |
336 | 0 | proto_tree_add_item(st, hf_btsmp_ediv, tvb, offset, 2, ENC_LITTLE_ENDIAN); |
337 | 0 | offset += 2; |
338 | 0 | proto_tree_add_item(st, hf_btsmp_random, tvb, offset, 8, ENC_NA); |
339 | 0 | offset += 8; |
340 | 0 | break; |
341 | | |
342 | 0 | case 0x08: /* Identity Information */ |
343 | 0 | proto_tree_add_item(st, hf_btsmp_id_resolving_key, tvb, offset, 16, ENC_NA); |
344 | 0 | offset += 16; |
345 | 0 | break; |
346 | | |
347 | 0 | case 0x09: /* Identity Address Information */ |
348 | 0 | proto_tree_add_item(st, hf_address_type, tvb, offset, 1, ENC_NA); |
349 | 0 | offset += 1; |
350 | |
|
351 | 0 | offset = dissect_bd_addr(hf_bd_addr, pinfo, st, tvb, offset, false, interface_id, adapter_id, NULL); |
352 | 0 | break; |
353 | | |
354 | 0 | case 0x0A: /* Signing Information */ |
355 | 0 | proto_tree_add_item(st, hf_btsmp_signature_key, tvb, offset, 16, ENC_NA); |
356 | 0 | offset += 16; |
357 | 0 | break; |
358 | | |
359 | 5 | case 0x0B: /* Security Request */ |
360 | 5 | col_append_str(pinfo->cinfo, COL_INFO, ": "); |
361 | 5 | offset = dissect_btsmp_auth_req(tvb, offset, pinfo, st); |
362 | 5 | break; |
363 | | |
364 | 0 | case 0x0C: /* Pairing Public Key */ { |
365 | 0 | proto_item *sub_item; |
366 | |
|
367 | 0 | sub_item = proto_tree_add_item(st, hf_btsmp_public_key_x, tvb, offset, 32, ENC_NA); |
368 | 0 | if (tvb_memeql(tvb, offset, debug_public_key_x, 32) == 0) |
369 | 0 | proto_item_append_text(sub_item, " (Debug Key)"); |
370 | 0 | offset += 32; |
371 | |
|
372 | 0 | sub_item = proto_tree_add_item(st, hf_btsmp_public_key_y, tvb, offset, 32, ENC_NA); |
373 | 0 | if (tvb_memeql(tvb, offset, debug_public_key_y, 32) == 0) |
374 | 0 | proto_item_append_text(sub_item, " (Debug Key)"); |
375 | 0 | offset += 32; |
376 | |
|
377 | 0 | break;} |
378 | 0 | case 0x0D: /* Pairing DHKey Check" */ |
379 | 0 | proto_tree_add_item(st, hf_btsmp_dhkey_check, tvb, offset, 16, ENC_NA); |
380 | 0 | offset += 16; |
381 | |
|
382 | 0 | break; |
383 | 0 | case 0x0E: /* Pairing Keypress Notification */ |
384 | 0 | proto_tree_add_item(st, hf_btsmp_notification_type, tvb, offset, 1, ENC_NA); |
385 | 0 | col_append_fstr(pinfo->cinfo, COL_INFO, ": %s", val_to_str_const(tvb_get_uint8(tvb, offset), notification_type_vals, "<unknown>")); |
386 | 0 | offset += 1; |
387 | |
|
388 | 0 | break; |
389 | 1 | default: |
390 | 1 | break; |
391 | 10 | } |
392 | | |
393 | 9 | return offset; |
394 | 10 | } |
395 | | |
396 | | void |
397 | | proto_register_btsmp(void) |
398 | 14 | { |
399 | 14 | static hf_register_info hf[] = { |
400 | 14 | {&hf_btsmp_opcode, |
401 | 14 | {"Opcode", "btsmp.opcode", |
402 | 14 | FT_UINT8, BASE_HEX, VALS(opcode_vals), 0x0, |
403 | 14 | NULL, HFILL} |
404 | 14 | }, |
405 | 14 | {&hf_btsmp_reason, |
406 | 14 | {"Reason", "btsmp.reason", |
407 | 14 | FT_UINT8, BASE_HEX, VALS(reason_vals), 0x0, |
408 | 14 | NULL, HFILL} |
409 | 14 | }, |
410 | 14 | {&hf_btsmp_io_capabilities, |
411 | 14 | {"IO Capability", "btsmp.io_capability", |
412 | 14 | FT_UINT8, BASE_HEX, VALS(io_capability_vals), 0x0, |
413 | 14 | NULL, HFILL} |
414 | 14 | }, |
415 | 14 | {&hf_btsmp_oob_data_flags, |
416 | 14 | {"OOB Data Flags", "btsmp.oob_data_flags", |
417 | 14 | FT_UINT8, BASE_HEX, VALS(oob_data_flag_vals), 0x0, |
418 | 14 | NULL, HFILL} |
419 | 14 | }, |
420 | 14 | {&hf_btsmp_cfm_value, |
421 | 14 | {"Confirm Value", "btsmp.cfm_value", |
422 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
423 | 14 | NULL, HFILL} |
424 | 14 | }, |
425 | 14 | {&hf_btsmp_random, |
426 | 14 | {"Random Value", "btsmp.random_value", |
427 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
428 | 14 | NULL, HFILL} |
429 | 14 | }, |
430 | 14 | {&hf_btsmp_long_term_key, |
431 | 14 | {"Long Term Key", "btsmp.long_term_key", |
432 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
433 | 14 | NULL, HFILL} |
434 | 14 | }, |
435 | 14 | {&hf_btsmp_id_resolving_key, |
436 | 14 | {"Identity Resolving Key", "btsmp.id_resolving_key", |
437 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
438 | 14 | NULL, HFILL} |
439 | 14 | }, |
440 | 14 | {&hf_btsmp_signature_key, |
441 | 14 | {"Signature Key", "btsmp.signature_key", |
442 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
443 | 14 | NULL, HFILL} |
444 | 14 | }, |
445 | 14 | {&hf_btsmp_bonding_flags, |
446 | 14 | {"Bonding Flags", "btsmp.bonding_flags", |
447 | 14 | FT_UINT8, BASE_HEX, VALS(bonding_flag_vals), 0x03, |
448 | 14 | NULL, HFILL} |
449 | 14 | }, |
450 | 14 | {&hf_btsmp_mitm_flag, |
451 | 14 | {"MITM Flag", "btsmp.mitm_flag", |
452 | 14 | FT_BOOLEAN, 8, NULL, 0x04, |
453 | 14 | NULL, HFILL} |
454 | 14 | }, |
455 | 14 | {&hf_btsmp_secure_connection_flag, |
456 | 14 | {"Secure Connection Flag", "btsmp.sc_flag", |
457 | 14 | FT_BOOLEAN, 8, NULL, 0x08, |
458 | 14 | NULL, HFILL} |
459 | 14 | }, |
460 | 14 | {&hf_btsmp_keypress_flag, |
461 | 14 | {"Keypress Flag", "btsmp.keypress_flag", |
462 | 14 | FT_BOOLEAN, 8, NULL, 0x10, |
463 | 14 | NULL, HFILL} |
464 | 14 | }, |
465 | 14 | {&hf_btsmp_ct2_flag, |
466 | 14 | {"CT2 Flag", "btsmp.ct2_flag", |
467 | 14 | FT_BOOLEAN, 8, NULL, 0x20, |
468 | 14 | NULL, HFILL} |
469 | 14 | }, |
470 | 14 | {&hf_btsmp_reserved_flag, |
471 | 14 | {"Reserved", "btsmp.reserved_flags", |
472 | 14 | FT_UINT8, BASE_HEX, NULL, 0xC0, |
473 | 14 | NULL, HFILL} |
474 | 14 | }, |
475 | 14 | {&hf_btsmp_max_enc_key_size, |
476 | 14 | {"Max Encryption Key Size", "btsmp.max_enc_key_size", |
477 | 14 | FT_UINT8, BASE_DEC, NULL, 0x00, |
478 | 14 | NULL, HFILL} |
479 | 14 | }, |
480 | 14 | {&hf_btsmp_key_dist_enc, |
481 | 14 | {"Encryption Key (LTK)", "btsmp.key_dist_enc", |
482 | 14 | FT_BOOLEAN, 8, NULL, 0x01, |
483 | 14 | NULL, HFILL} |
484 | 14 | }, |
485 | 14 | {&hf_btsmp_key_dist_id, |
486 | 14 | {"Id Key (IRK)", "btsmp.key_dist_id", |
487 | 14 | FT_BOOLEAN, 8, NULL, 0x02, |
488 | 14 | NULL, HFILL} |
489 | 14 | }, |
490 | 14 | {&hf_btsmp_key_dist_sign, |
491 | 14 | {"Signature Key (CSRK)", "btsmp.key_dist_sign", |
492 | 14 | FT_BOOLEAN, 8, NULL, 0x04, |
493 | 14 | NULL, HFILL} |
494 | 14 | }, |
495 | 14 | {&hf_btsmp_key_dist_linkkey, |
496 | 14 | {"Link Key", "btsmp.key_dist_linkkey", |
497 | 14 | FT_BOOLEAN, 8, NULL, 0x08, |
498 | 14 | NULL, HFILL} |
499 | 14 | }, |
500 | 14 | {&hf_btsmp_key_dist_reserved, |
501 | 14 | {"Reserved", "btsmp.key_dist_reserved", |
502 | 14 | FT_UINT8, BASE_HEX, NULL, 0xF0, |
503 | 14 | NULL, HFILL} |
504 | 14 | }, |
505 | 14 | {&hf_btsmp_ediv, |
506 | 14 | {"Encrypted Diversifier (EDIV)", "btsmp.ediv", |
507 | 14 | FT_UINT16, BASE_HEX, NULL, 0x00, |
508 | 14 | NULL, HFILL} |
509 | 14 | }, |
510 | 14 | {&hf_btsmp_authreq, |
511 | 14 | {"AuthReq", "btsmp.authreq", |
512 | 14 | FT_UINT8, BASE_HEX, NULL, 0x00, |
513 | 14 | NULL, HFILL} |
514 | 14 | }, |
515 | 14 | {&hf_btsmp_initiator_key_distribution, |
516 | 14 | {"Initiator Key Distribution", "btsmp.initiator_key_distribution", |
517 | 14 | FT_UINT8, BASE_HEX, NULL, 0x00, |
518 | 14 | NULL, HFILL} |
519 | 14 | }, |
520 | 14 | {&hf_btsmp_responder_key_distribution, |
521 | 14 | {"Responder Key Distribution", "btsmp.responder_key_distribution", |
522 | 14 | FT_UINT8, BASE_HEX, NULL, 0x00, |
523 | 14 | NULL, HFILL} |
524 | 14 | }, |
525 | 14 | {&hf_bd_addr, |
526 | 14 | { "BD_ADDR", "btsmp.bd_addr", |
527 | 14 | FT_ETHER, BASE_NONE, NULL, 0x0, |
528 | 14 | "Bluetooth Device Address", HFILL} |
529 | 14 | }, |
530 | 14 | { &hf_address_type, |
531 | 14 | { "Address Type", "btsmp.address_type", |
532 | 14 | FT_UINT8, BASE_HEX, VALS(bluetooth_address_type_vals), 0x0, |
533 | 14 | NULL, HFILL } |
534 | 14 | }, |
535 | 14 | {&hf_btsmp_public_key_x, |
536 | 14 | {"Public Key X", "btsmp.public_key_x", |
537 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
538 | 14 | NULL, HFILL} |
539 | 14 | }, |
540 | 14 | {&hf_btsmp_public_key_y, |
541 | 14 | {"Public Key Y", "btsmp.public_key_y", |
542 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
543 | 14 | NULL, HFILL} |
544 | 14 | }, |
545 | 14 | {&hf_btsmp_dhkey_check, |
546 | 14 | {"DHKey Check", "btsmp.dhkey_check", |
547 | 14 | FT_BYTES, BASE_NONE, NULL, 0x0, |
548 | 14 | NULL, HFILL} |
549 | 14 | }, |
550 | 14 | {&hf_btsmp_notification_type, |
551 | 14 | {"Notification Type", "btsmp.notification_type", |
552 | 14 | FT_UINT8, BASE_HEX, VALS(notification_type_vals), 0x0, |
553 | 14 | NULL, HFILL} |
554 | 14 | }, |
555 | 14 | }; |
556 | | |
557 | | /* Setup protocol subtree array */ |
558 | 14 | static int *ett[] = { |
559 | 14 | &ett_btsmp, |
560 | 14 | &ett_btsmp_auth_req, |
561 | 14 | &ett_btsmp_key_dist |
562 | 14 | }; |
563 | | |
564 | | /* Register the protocol name and description */ |
565 | 14 | proto_btsmp = proto_register_protocol("Bluetooth Security Manager Protocol", |
566 | 14 | "BT SMP", "btsmp"); |
567 | | |
568 | 14 | btsmp_handle = register_dissector("btsmp", dissect_btsmp, proto_btsmp); |
569 | | |
570 | | /* Required function calls to register the header fields and subtrees used */ |
571 | 14 | proto_register_field_array(proto_btsmp, hf, array_length(hf)); |
572 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
573 | 14 | } |
574 | | |
575 | | void |
576 | | proto_reg_handoff_btsmp(void) |
577 | 14 | { |
578 | 14 | dissector_add_uint("btl2cap.cid", BTL2CAP_FIXED_CID_SMP, btsmp_handle); |
579 | 14 | dissector_add_uint("btl2cap.cid", BTL2CAP_FIXED_CID_BR_EDR_SM, btsmp_handle); |
580 | 14 | } |
581 | | |
582 | | /* |
583 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
584 | | * |
585 | | * Local variables: |
586 | | * c-basic-offset: 4 |
587 | | * tab-width: 8 |
588 | | * indent-tabs-mode: nil |
589 | | * End: |
590 | | * |
591 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
592 | | * :indentSize=4:tabSize=8:noTabs=true: |
593 | | */ |