3 * Wi-Fi Device Provisioning Protocol (DPP)
5 * Copyright 2017-2020 Richard Sharpe <realrichardsharpe@gmail.com>
6 * Copyright 2017-2020 The WiFi Alliance
8 * SPDX-License-Identifier: GPL-2.0-or-later
12 * Code and constants based on Device_Provisioning_Protocol_Specification_v1.2.9
17 #include <epan/packet.h>
18 #include "packet-tcp.h"
19 #include <epan/to_str.h>
20 #include <epan/expert.h>
22 #include "packet-wifi-dpp.h"
23 #include "packet-ieee80211.h"
25 extern const value_string wfa_subtype_vals
[];
27 void proto_register_wifi_dpp(void);
28 void proto_reg_handoff_wifi_dpp(void);
30 static dissector_handle_t wifi_dpp_handle
;
31 static dissector_handle_t wifi_dpp_tcp_handle
;
32 static dissector_handle_t wifi_dpp_ie_handle
;
33 static dissector_handle_t wifi_dpp_pubact_handle
;
35 #define WIFI_DPP_TCP_PORT (7871)
36 static unsigned wifi_dpp_tcp_port
= WIFI_DPP_TCP_PORT
;
40 DPP_STATUS_NOT_COMPATIBLE
= 1,
41 DPP_STATUS_AUTH_FAILURE
= 2,
42 DPP_STATUS_UNWRAP_FAILURE
= 3,
43 DPP_STATUS_BAD_GROUP
= 4,
44 DPP_STATUS_CONFIGURE_FAILURE
= 5,
45 DPP_STATUS_RESPONSE_PENDING
= 6,
46 DPP_STATUS_INVALID_CONNECTOR
= 7,
47 DPP_STATUS_NO_MATCH
= 8,
48 DPP_STATUS_CONFIG_REJECTED
= 9,
49 DPP_STATUS_NO_AP
= 10,
50 DPP_STATUS_CONFIGURE_PENDING
= 11,
51 DPP_STATUS_CSR_NEEDED
= 12,
52 DPP_STATUS_CSR_BAD
= 13
55 static const value_string dpp_status_codes
[] = {
56 { DPP_STATUS_OK
, "OK" },
57 { DPP_STATUS_NOT_COMPATIBLE
, "Not Compatible" },
58 { DPP_STATUS_AUTH_FAILURE
, "Auth Failure" },
59 { DPP_STATUS_UNWRAP_FAILURE
, "Unwrap Failure" },
60 { DPP_STATUS_BAD_GROUP
, "Bad Group" },
61 { DPP_STATUS_CONFIGURE_FAILURE
, "Configure Failure" },
62 { DPP_STATUS_RESPONSE_PENDING
, "Response Pending" },
63 { DPP_STATUS_INVALID_CONNECTOR
, "Invalid Connector" },
64 { DPP_STATUS_NO_MATCH
, "No Match" },
65 { DPP_STATUS_CONFIG_REJECTED
, "Enrollee rejected the config" },
66 { DPP_STATUS_NO_AP
, "Enrollee failed to discover an AP" },
67 { DPP_STATUS_CONFIGURE_PENDING
, "Configuration response is not ready yet. The enrollee needs to request again." },
68 { DPP_STATUS_CSR_NEEDED
, "Configuration requires a Certificate Signing Request. Enrollee needs to request again." },
69 { DPP_STATUS_CSR_BAD
, "The Certificate Signing Request was invalid." },
70 { DPP_STATUS_OK
, "OK" },
71 { DPP_STATUS_NOT_COMPATIBLE
, "Not Compatible" },
72 { DPP_STATUS_AUTH_FAILURE
, "Auth Failure" },
73 { DPP_STATUS_UNWRAP_FAILURE
, "Unwrap Failure" },
74 { DPP_STATUS_BAD_GROUP
, "Bad Group" },
75 { DPP_STATUS_CONFIGURE_FAILURE
, "Configure Failure" },
76 { DPP_STATUS_RESPONSE_PENDING
, "Response Pending" },
82 DPP_INITIATOR_BOOTSTRAPPING_KEY_HASH
= 0x1001,
83 DPP_RESPONDER_BOOTSTRAPPING_KEY_HASH
= 0x1002,
84 DPP_INITIATOR_PROTOCOL_KEY
= 0x1003,
85 DPP_WRAPPED_DATA
= 0x1004,
86 DPP_INITIATOR_NONCE
= 0x1005,
87 DPP_INITIATOR_CAPABILITIES
= 0x1006,
88 DPP_RESPONDER_NONCE
= 0x1007,
89 DPP_RESPONDER_CAPABILITIES
= 0x1008,
90 DPP_RESPONDER_PROTOCOL_KEY
= 0x1009,
91 DPP_INITIATOR_AUTHENTICATING_TAG
= 0x100A,
92 DPP_RESPONDER_AUTHENTICATING_TAG
= 0x100B,
93 DPP_CONFIGURATION_OBJECT
= 0x100C,
94 DPP_CONNECTOR
= 0x100D,
95 DPP_CONFIGURATION_ATTRIBUTES_OBJECT
= 0x100E,
96 DPP_BOOTSTRAPPING_KEY
= 0x100F,
97 DPP_FINITE_CYCLIC_GROUP
= 0x1012,
98 DPP_ENCRYPTED_KEY
= 0x1013,
99 DPP_ENROLLEE_NONCE
= 0x1014,
100 DPP_CODE_IDENTIFIER
= 0x1015,
101 DPP_TRANSACTION_ID
= 0x1016,
102 DPP_BOOTSTRAPPING_INFO
= 0x1017,
103 DPP_CHANNEL
= 0x1018,
104 DPP_PROTOCOL_VERSION
= 0x1019,
105 DPP_ENVELOPEDATA
= 0x101A,
106 DPP_SENDCONNSTATUS
= 0x101B,
107 DPP_CONNSTATUS
= 0x101C,
108 DPP_RECONFIG_FLAGS
= 0x101D,
109 DPP_C_SIGN_KEY_HASH
= 0x101E,
110 DPP_CSR_ATTRIBUTES_REQUEST
= 0x101F,
111 DPP_A_NONCE
= 0x1020,
112 DPP_E_PRIME_ID
= 0x1021
115 static const value_string dpp_ie_attr_ids
[] = {
116 { DPP_STATUS
, "DPP Status" },
117 { DPP_INITIATOR_BOOTSTRAPPING_KEY_HASH
, "DPP Initiator Bootstrapping Key Hash" },
118 { DPP_RESPONDER_BOOTSTRAPPING_KEY_HASH
, "DPP Responder Bootstrapping Key Hash" },
119 { DPP_INITIATOR_PROTOCOL_KEY
, "DPP Initiator Protocol Key" },
120 { DPP_WRAPPED_DATA
, "DPP Primary Wrapped Data" },
121 { DPP_INITIATOR_NONCE
, "DPP Initiator Nonce" },
122 { DPP_INITIATOR_CAPABILITIES
, "DPP Initiator Capabilities" },
123 { DPP_RESPONDER_NONCE
, "DPP Responder Nonce" },
124 { DPP_RESPONDER_CAPABILITIES
, "DPP Responder Capabilities" },
125 { DPP_RESPONDER_PROTOCOL_KEY
, "DPP Responder Protocol Key" },
126 { DPP_INITIATOR_AUTHENTICATING_TAG
, "DPP Initiator Authenticating Tag" },
127 { DPP_RESPONDER_AUTHENTICATING_TAG
, "DPP Responder Authenticating Tag" },
128 { DPP_CONFIGURATION_OBJECT
, "DPP Configuration Object" },
129 { DPP_CONNECTOR
, "DPP Connector" },
130 { DPP_CONFIGURATION_ATTRIBUTES_OBJECT
, "DPP Configuration Attributes Object" },
131 { DPP_BOOTSTRAPPING_KEY
, "DPP Bootstrapping Key" },
132 { DPP_FINITE_CYCLIC_GROUP
, "DPP Finite Cyclic Group" },
133 { DPP_ENCRYPTED_KEY
, "DPP Encrypted Key" },
134 { DPP_CODE_IDENTIFIER
, "DPP Code Identifier" },
135 { DPP_TRANSACTION_ID
, "DPP Transaction ID" },
136 { DPP_BOOTSTRAPPING_INFO
, "DPP Bootstrapping Info" },
137 { DPP_CHANNEL
, "DPP Channel" },
138 { DPP_PROTOCOL_VERSION
, "DPP Protocol Version" },
139 { DPP_ENVELOPEDATA
, "DPP Enveloped Data" },
140 { DPP_SENDCONNSTATUS
, "DPP Send Conn Status" },
141 { DPP_CONNSTATUS
, "DPP Conn Status" },
142 { DPP_RECONFIG_FLAGS
, "DPP Reconfig Flags" },
143 { DPP_C_SIGN_KEY_HASH
, "DPP C-sign key Hash" },
144 { DPP_CSR_ATTRIBUTES_REQUEST
, "DPP CSR Attributes Request" },
145 { DPP_A_NONCE
, "DPP A-NONCE" },
146 { DPP_E_PRIME_ID
, "DPP E'-id" },
151 DPP_AUTHENTICATION_REQUEST
= 0,
152 DPP_AUTHENTICATION_RESPONSE
= 1,
153 DPP_AUTHENTICATION_CONFIRM
= 2,
154 DPP_PEER_DISCOVERY_REQUEST
= 5,
155 DPP_PEER_DISCOVERY_RESPONSE
= 6,
156 DPP_PKEX_EXCHANGE_REQUEST
= 7,
157 DPP_PKEX_EXCHANGE_RESPONSE
= 8,
158 DPP_PKEX_COMMIT_REVEAL_REQUEST
= 9,
159 DPP_PKEX_COMMIT_REVEAL_RESPONSE
= 10,
160 DPP_CONFIGURATION_RESULT
= 11,
161 DPP_CONNECTION_STATUS_RESULT
= 12,
162 DPP_PRESENCE_ANNOUNCEMENT
= 13,
163 DPP_RECONFIG_ANNOUNCEMENT
= 14,
164 DPP_RECONFIG_AUTH_REQUEST
= 15,
165 DPP_RECONFIG_AUTH_RESPONSE
= 16,
166 DPP_RECONFIG_AUTH_CONFIRM
= 17
169 static const value_string dpp_public_action_subtypes
[] = {
170 { DPP_AUTHENTICATION_REQUEST
, "Authentication Request" },
171 { DPP_AUTHENTICATION_RESPONSE
, "Authentication Response" },
172 { DPP_AUTHENTICATION_CONFIRM
, "Authentication Confirm" },
173 { DPP_PEER_DISCOVERY_REQUEST
, "Peer Discovery Request" },
174 { DPP_PEER_DISCOVERY_RESPONSE
, "Peer Discovery Response" },
175 { DPP_PKEX_EXCHANGE_REQUEST
, "PKEX Exchange Request" },
176 { DPP_PKEX_EXCHANGE_RESPONSE
, "PKEX Exchange Response" },
177 { DPP_PKEX_COMMIT_REVEAL_REQUEST
, "PKEX Commit-Reveal Request" },
178 { DPP_PKEX_COMMIT_REVEAL_RESPONSE
, "PKEX Commit-Reveal Response" },
179 { DPP_CONFIGURATION_RESULT
, "Configuration Result" },
180 { DPP_CONNECTION_STATUS_RESULT
, "Connection Status Result" },
181 { DPP_PRESENCE_ANNOUNCEMENT
, "Presence Announcement" },
182 { DPP_RECONFIG_ANNOUNCEMENT
, "Reconfig Announcement" },
183 { DPP_RECONFIG_AUTH_REQUEST
, "Reconfig Authentication Request" },
184 { DPP_RECONFIG_AUTH_RESPONSE
, "Reconfig Authentication Response" },
185 { DPP_RECONFIG_AUTH_CONFIRM
, "Reconfig Authentication Confirm" },
190 * This table and the one above share values ... but this one is truncated.
192 static const value_string dpp_action_subtypes
[] = {
193 { DPP_AUTHENTICATION_REQUEST
, "Authentication Request" },
194 { DPP_AUTHENTICATION_RESPONSE
, "Authentication Response" },
195 { DPP_AUTHENTICATION_CONFIRM
, "Authentication Confirm" },
196 { DPP_PEER_DISCOVERY_REQUEST
, "Peer Discovery Request" },
197 { DPP_PEER_DISCOVERY_RESPONSE
, "Peer Discovery Response" },
201 static const range_string dpp_protocol_version_rvals
[] = {
202 { 0, 0, "Reserved" },
204 { 2, 255, "Reserved" },
208 static int proto_wifi_dpp
;
210 static int ett_wifi_dpp_ie_generic
;
211 static int ett_wifi_dpp_attributes
;
212 static int ett_wifi_dpp_pa
;
213 static int ett_wifi_dpp_attribute
;
214 static int ett_wifi_dpp_attr_header
;
215 static int ett_wifi_dpp_attr_value
;
217 static int hf_wifi_dpp_ie_attr_id
;
218 static int hf_wifi_dpp_ie_attr_len
;
219 static int hf_wifi_dpp_ie_generic
; /* Remove eventually */
220 static int hf_wifi_dpp_action_dialog_token
;
221 static int hf_wifi_dpp_action_subtype
;
222 static int hf_wifi_dpp_crypto_suite
;
223 static int hf_wifi_dpp_public_action_subtype
;
224 static int hf_wifi_dpp_init_hash
;
225 static int hf_wifi_dpp_resp_hash
;
226 static int hf_wifi_dpp_status
;
227 static int hf_wifi_dpp_key_x
;
228 static int hf_wifi_dpp_key_y
;
229 static int hf_wifi_dpp_trans_id
;
230 static int hf_wifi_dpp_finite_cyclic_group
;
231 static int hf_wifi_dpp_capabilities
;
232 static int hf_wifi_dpp_code_identifier
;
233 static int hf_wifi_dpp_enc_key_attribute
;
234 static int hf_wifi_dpp_primary_wrapped_data
;
235 static int hf_wifi_dpp_connector_attr
;
236 static int hf_wifi_dpp_initiator_nonce
;
237 static int hf_wifi_dpp_operating_class
;
238 static int hf_wifi_dpp_channel
;
239 static int hf_wifi_dpp_protocol_version
;
240 static int hf_wifi_dpp_a_nonce
;
241 static int hf_wifi_dpp_e_prime_id
;
242 static int hf_wifi_dpp_unknown_anqp_item
;
244 static int hf_wifi_dpp_tcp_pdu_length
;
245 static int hf_wifi_dpp_tcp_pdu_action_field
;
246 static int hf_wifi_dpp_tcp_oui
;
247 static int hf_wifi_dpp_tcp_oui_type
;
248 static int hf_wifi_dpp_tcp_dialog_token
;
249 static int hf_wifi_dpp_tcp_adv_proto_elt
;
250 static int hf_wifi_dpp_tcp_vendor_specific
;
251 static int hf_wifi_dpp_tcp_vendor_spec_len
;
252 static int hf_wifi_dpp_tcp_config
;
253 static int hf_wifi_dpp_tcp_query_req_len
;
254 static int hf_wifi_dpp_tcp_status_code
;
255 static int hf_wifi_dpp_gas_query_resp_frag_id
;
256 static int hf_wifi_dpp_tcp_comeback_delay
;
257 static int hf_wifi_dpp_tcp_query_resp_len
;
260 dissect_wifi_dpp(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void *data _U_
)
264 proto_tree_add_item(tree
, hf_wifi_dpp_unknown_anqp_item
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), ENC_NA
);
265 return tvb_captured_length(tvb
);
269 dissect_wifi_dpp_ie(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
, void *data _U_
)
272 unsigned remaining_len
= tvb_reported_length(tvb
);
274 ie
= proto_tree_add_subtree(tree
, tvb
, 0, remaining_len
, ett_wifi_dpp_ie_generic
, NULL
, "Generic DPP IE");
275 proto_tree_add_item(ie
, hf_wifi_dpp_ie_generic
, tvb
, 0, remaining_len
,
277 return tvb_captured_length(tvb
);
281 dissect_wifi_dpp_attributes(packet_info
*pinfo _U_
, proto_tree
*tree
,
282 tvbuff_t
*tvb
, int offset _U_
)
284 proto_item
*si
= NULL
;
286 proto_tree
*attr
, *specific_attr
, *attr_hdr
;
287 uint16_t attribute_id
;
288 uint16_t attribute_len
;
289 unsigned attributes_len
= 0;
290 unsigned remaining_len
= tvb_reported_length_remaining(tvb
, offset
);
292 while (remaining_len
) {
293 attribute_id
= tvb_get_uint16(tvb
, offset
, ENC_LITTLE_ENDIAN
);
294 attribute_len
= tvb_get_uint16(tvb
, offset
+ 2, ENC_LITTLE_ENDIAN
);
295 attr
= proto_tree_add_subtree_format(tree
, tvb
, offset
,
296 attribute_len
+ 4, ett_wifi_dpp_attribute
,
298 val_to_str(attribute_id
,
301 attr_hdr
= proto_tree_add_subtree(attr
, tvb
, offset
, 4,
302 ett_wifi_dpp_attr_header
, NULL
,
305 proto_tree_add_item(attr_hdr
, hf_wifi_dpp_ie_attr_id
, tvb
, offset
, 2,
308 proto_tree_add_item(attr_hdr
, hf_wifi_dpp_ie_attr_len
, tvb
, offset
, 2,
312 specific_attr
= proto_tree_add_subtree(attr
, tvb
, offset
, attribute_len
,
313 ett_wifi_dpp_attr_value
,
314 NULL
, "Attribute Value");
316 switch (attribute_id
) {
318 status
= tvb_get_uint8(tvb
, offset
);
319 proto_item_append_text(si
, ": %s", val_to_str(status
,
322 proto_tree_add_item(specific_attr
, hf_wifi_dpp_status
, tvb
, offset
, attribute_len
, ENC_LITTLE_ENDIAN
);
325 case DPP_INITIATOR_BOOTSTRAPPING_KEY_HASH
:
326 proto_tree_add_item(specific_attr
, hf_wifi_dpp_init_hash
, tvb
, offset
, attribute_len
, ENC_NA
);
329 case DPP_RESPONDER_BOOTSTRAPPING_KEY_HASH
:
330 proto_tree_add_item(specific_attr
, hf_wifi_dpp_resp_hash
, tvb
, offset
, attribute_len
, ENC_NA
);
333 case DPP_RESPONDER_PROTOCOL_KEY
:
334 case DPP_INITIATOR_PROTOCOL_KEY
:
335 // This is two protocol keys of equal length, X then Y.
336 proto_tree_add_item(specific_attr
, hf_wifi_dpp_key_x
, tvb
, offset
, attribute_len
/2, ENC_NA
);
337 proto_tree_add_item(specific_attr
, hf_wifi_dpp_key_y
, tvb
, offset
+ attribute_len
/2, attribute_len
/2, ENC_NA
);
340 case DPP_TRANSACTION_ID
:
341 proto_tree_add_item(specific_attr
, hf_wifi_dpp_trans_id
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
344 case DPP_FINITE_CYCLIC_GROUP
:
345 case DPP_RESPONDER_CAPABILITIES
:
346 proto_tree_add_item(specific_attr
, hf_wifi_dpp_finite_cyclic_group
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
349 case DPP_INITIATOR_CAPABILITIES
:
350 proto_tree_add_item(specific_attr
, hf_wifi_dpp_capabilities
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
353 case DPP_CODE_IDENTIFIER
:
354 proto_tree_add_item(specific_attr
, hf_wifi_dpp_code_identifier
, tvb
, offset
, attribute_len
, ENC_UTF_8
);
357 case DPP_ENCRYPTED_KEY
:
358 proto_tree_add_item(specific_attr
, hf_wifi_dpp_enc_key_attribute
, tvb
, offset
, attribute_len
, ENC_NA
);
361 case DPP_WRAPPED_DATA
:
362 proto_tree_add_item(specific_attr
, hf_wifi_dpp_primary_wrapped_data
, tvb
, offset
, attribute_len
, ENC_NA
);
366 proto_tree_add_item(specific_attr
, hf_wifi_dpp_connector_attr
, tvb
,
367 offset
, attribute_len
, ENC_NA
);
370 case DPP_INITIATOR_NONCE
:
371 proto_tree_add_item(specific_attr
, hf_wifi_dpp_initiator_nonce
, tvb
,
372 offset
, attribute_len
, ENC_NA
);
376 proto_tree_add_item(specific_attr
, hf_wifi_dpp_operating_class
, tvb
,
378 proto_tree_add_item(specific_attr
, hf_wifi_dpp_channel
, tvb
, offset
+ 1,
382 case DPP_PROTOCOL_VERSION
:
383 proto_tree_add_item(specific_attr
, hf_wifi_dpp_protocol_version
, tvb
,
388 proto_tree_add_item(specific_attr
, hf_wifi_dpp_a_nonce
, tvb
, offset
,
389 attribute_len
, ENC_NA
);
393 proto_tree_add_item(specific_attr
, hf_wifi_dpp_e_prime_id
, tvb
, offset
,
394 attribute_len
, ENC_NA
);
397 case DPP_INITIATOR_AUTHENTICATING_TAG
:
399 case DPP_RESPONDER_AUTHENTICATING_TAG
:
401 case DPP_CONFIGURATION_OBJECT
:
403 case DPP_CONFIGURATION_ATTRIBUTES_OBJECT
:
405 case DPP_BOOTSTRAPPING_KEY
:
407 case DPP_ENROLLEE_NONCE
:
410 proto_tree_add_item(specific_attr
, hf_wifi_dpp_ie_generic
, tvb
, offset
, attribute_len
, ENC_NA
);
414 offset
+= attribute_len
;
415 attributes_len
+= attribute_len
+ 4;
416 remaining_len
-= (attribute_len
+ 4);
420 return attributes_len
; // We return the attribute length plus hdr!
424 dissect_wifi_dpp_config_proto(packet_info
*pinfo _U_
, proto_tree
*tree
,
425 tvbuff_t
*tvb
, int offset _U_
)
427 proto_item
*dpp_item
;
428 proto_tree
*dpp_tree
, *attr_tree
;
429 unsigned remaining_len
= tvb_reported_length_remaining(tvb
, offset
);
431 dpp_item
= proto_tree_add_item(tree
, proto_wifi_dpp
, tvb
, offset
, -1, ENC_NA
);
432 dpp_tree
= proto_item_add_subtree(dpp_item
, ett_wifi_dpp_pa
);
433 proto_item_append_text(dpp_item
, " Configuration");
435 attr_tree
= proto_tree_add_subtree_format(dpp_tree
, tvb
, offset
,
437 ett_wifi_dpp_attributes
, NULL
,
440 offset
= dissect_wifi_dpp_attributes(pinfo
, attr_tree
, tvb
, offset
);
446 dissect_wifi_dpp_public_action(tvbuff_t
*tvb
, packet_info
*pinfo
,
447 proto_tree
*tree
, void *data _U_
)
450 unsigned remaining_len
;
451 proto_item
*dpp_item
;
452 proto_tree
*dpp_tree
, *attr_tree
;
453 uint16_t attributes_len
;
456 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "wifi_dpp");
458 /* The Crypto suite comes before the DPP frame type */
459 subtype
= tvb_get_uint8(tvb
, offset
+ 1);
460 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", DPP - %s",
461 val_to_str(subtype
, dpp_public_action_subtypes
,
464 remaining_len
= tvb_reported_length_remaining(tvb
, offset
);
466 dpp_item
= proto_tree_add_item(tree
, proto_wifi_dpp
, tvb
, offset
, -1, ENC_NA
);
467 dpp_tree
= proto_item_add_subtree(dpp_item
, ett_wifi_dpp_pa
);
468 proto_item_append_text(dpp_item
, ": %s", val_to_str(subtype
,
469 dpp_public_action_subtypes
,
471 proto_tree_add_item(dpp_tree
, hf_wifi_dpp_crypto_suite
, tvb
, offset
, 1,
476 proto_tree_add_item(dpp_tree
, hf_wifi_dpp_public_action_subtype
, tvb
, offset
,
477 1, ENC_LITTLE_ENDIAN
);
478 offset
++; /* Skip the OUI Subtype/DPP Request type */
481 attr_tree
= proto_tree_add_subtree_format(dpp_tree
, tvb
, offset
,
483 ett_wifi_dpp_attributes
, NULL
, "DPP Attributes");
485 attributes_len
= dissect_wifi_dpp_attributes(pinfo
, attr_tree
, tvb
, offset
);
486 offset
+= attributes_len
;
493 dissect_wifi_dpp_tcp_pdu(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
494 proto_tree
*tree
, void *data _U_
)
500 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "dpp");
503 * We get a length, followed by Action field, OUI, OUI type and then a
506 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_pdu_length
, tvb
, offset
, 4,
510 action
= tvb_get_uint8(tvb
, offset
);
511 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_pdu_action_field
, tvb
, offset
, 1,
515 if (action
== 0x09) {
516 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui
, tvb
, offset
, 3, ENC_NA
);
519 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui_type
, tvb
, offset
, 1, ENC_NA
);
522 newtvb
= tvb_new_subset_remaining(tvb
, offset
);
524 offset
+= dissect_wifi_dpp_public_action(newtvb
, pinfo
, tree
, NULL
);
525 } else if (action
== 0x0a) {
526 col_append_str(pinfo
->cinfo
, COL_INFO
, ", DPP - Configuration Request");
528 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_dialog_token
, tvb
, offset
, 1,
532 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_adv_proto_elt
, tvb
, offset
, 3,
536 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_vendor_specific
, tvb
, offset
, 1,
539 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_vendor_spec_len
, tvb
, offset
, 1,
543 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui
, tvb
, offset
, 3, ENC_NA
);
546 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui_type
, tvb
, offset
, 1, ENC_NA
);
549 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_config
, tvb
, offset
, 1, ENC_NA
);
552 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_query_req_len
, tvb
, offset
, 2,
556 offset
+= dissect_wifi_dpp_config_proto(pinfo
, tree
, tvb
, offset
);
557 } else if (action
== 0x0b || action
== 0x0d) {
560 col_append_str(pinfo
->cinfo
, COL_INFO
, ", DPP - Configuration Response");
562 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_dialog_token
, tvb
, offset
, 1,
566 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_status_code
, tvb
, offset
, 2,
570 if (action
== 0x0d) {
571 proto_tree_add_item(tree
, hf_wifi_dpp_gas_query_resp_frag_id
, tvb
, offset
,
576 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_comeback_delay
, tvb
, offset
, 2,
580 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_adv_proto_elt
, tvb
, offset
, 3,
584 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_vendor_specific
, tvb
, offset
, 1,
587 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_vendor_spec_len
, tvb
, offset
, 1,
591 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui
, tvb
, offset
, 3, ENC_NA
);
594 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_oui_type
, tvb
, offset
, 1, ENC_NA
);
597 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_config
, tvb
, offset
, 1, ENC_NA
);
600 qr_len
= tvb_get_letohs(tvb
, offset
);
601 proto_tree_add_item(tree
, hf_wifi_dpp_tcp_query_resp_len
, tvb
, offset
, 2,
606 offset
+= dissect_wifi_dpp_config_proto(pinfo
, tree
, tvb
, offset
);
614 get_wifi_dpp_tcp_len(packet_info
*pinfo _U_
, tvbuff_t
*tvb
, int offset
,
619 pkt_len
= tvb_get_ntohl(tvb
, offset
);
625 * We need 4 bytes for the length ...
627 #define DPP_TCP_HEADER_LEN 4
629 dissect_wifi_dpp_tcp_pdus(tvbuff_t
*tvb
, packet_info
*pinfo _U_
,
630 proto_tree
*tree
, void *data _U_
)
632 if (!tvb_bytes_exist(tvb
, 0, DPP_TCP_HEADER_LEN
))
635 tcp_dissect_pdus(tvb
, pinfo
, tree
, true, DPP_TCP_HEADER_LEN
,
636 get_wifi_dpp_tcp_len
, dissect_wifi_dpp_tcp_pdu
, data
);
637 return tvb_reported_length(tvb
);
641 proto_register_wifi_dpp(void)
643 static module_t
*wifi_dpp_module
;
644 static hf_register_info hf
[] = {
645 { &hf_wifi_dpp_status
,
646 { "Wi-Fi DPP Status", "dpp.status",
647 FT_UINT8
, BASE_HEX
, VALS(dpp_status_codes
), 0x0, NULL
, HFILL
}},
648 { &hf_wifi_dpp_init_hash
,
649 { "Wi-Fi DPP Initiator Hash", "dpp.init.hash",
650 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
651 { &hf_wifi_dpp_resp_hash
,
652 { "Wi-Fi DPP Responder Hash", "dpp.resp.hash",
653 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
654 { &hf_wifi_dpp_key_x
,
655 { "Wi-Fi DPP Key X value", "dpp.key.x",
656 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
657 { &hf_wifi_dpp_key_y
,
658 { "Wi-Fi DPP Key Y value", "dpp.key.y",
659 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
660 { &hf_wifi_dpp_trans_id
,
661 { "Wi-Fi DPP Transaction ID", "dpp.trans_id",
662 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
663 { &hf_wifi_dpp_finite_cyclic_group
,
664 { "Wi-Fi DPP Finite Cyclic Group", "dpp.finite_cyclic_group",
665 FT_UINT16
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
666 { &hf_wifi_dpp_capabilities
,
667 { "Wi-Fi DPP Capabilities", "dpp.capabilities",
668 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
669 { &hf_wifi_dpp_code_identifier
,
670 { "Wi-Fi DPP Code Identifier", "dpp.code_identifier",
671 FT_STRING
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
672 { &hf_wifi_dpp_enc_key_attribute
,
673 { "Wi-Fi DPP Encrypted Key Attribute", "dpp.pkex.enckey",
674 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
675 { &hf_wifi_dpp_primary_wrapped_data
,
676 { "Wi-Fi DPP Primary Wrapped Data", "dpp.primary.wrapped_data",
677 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
678 { &hf_wifi_dpp_connector_attr
,
679 { "Wi-Fi DPP Connector Attribute", "dpp.connector_data",
680 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
681 { &hf_wifi_dpp_initiator_nonce
,
682 { "Wi-Fi DPP Initiator Nonce", "dpp.initiator_nonce",
683 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
684 { &hf_wifi_dpp_operating_class
,
685 { "Operating Class", "dpp.operating_class",
686 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
687 { &hf_wifi_dpp_channel
,
688 { "Channel", "dpp.channel",
689 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
690 { &hf_wifi_dpp_protocol_version
,
691 { "Protocol Version", "dpp.protocol_version",
692 FT_UINT8
, BASE_DEC
|BASE_RANGE_STRING
, RVALS(dpp_protocol_version_rvals
),
694 { &hf_wifi_dpp_a_nonce
,
695 { "A-NONCE", "dpp.a_nonce",
696 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
697 { &hf_wifi_dpp_e_prime_id
,
698 { "E'-id", "dpp.e_prime_id",
699 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
700 { &hf_wifi_dpp_ie_attr_id
,
701 { "Wi-Fi DPP IE Attribute ID", "dpp.ie.attr_id",
702 FT_UINT16
, BASE_HEX
, VALS(dpp_ie_attr_ids
), 0x0, NULL
, HFILL
}},
703 { &hf_wifi_dpp_ie_attr_len
,
704 { "Wi-Fi DPP IE Attribute Len", "dpp.ie.attr_len",
705 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
706 { &hf_wifi_dpp_ie_generic
,
707 { "Wi-Fi DPP IE generic", "dpp.ie.generic",
708 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
709 { &hf_wifi_dpp_action_subtype
,
710 { "Wi-Fi DPP Action Subtype", "dpp.action.subtype",
711 FT_UINT8
, BASE_DEC
, VALS(dpp_action_subtypes
), 0x0, NULL
, HFILL
}},
712 { &hf_wifi_dpp_action_dialog_token
,
713 { "Wi-Fi DPP Action Dialog Token", "dpp.action.dialog_token",
714 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
715 { &hf_wifi_dpp_crypto_suite
,
716 { "Wi-Fi DPP Cryptographic Suite", "dpp.public_action.crypto_suite",
717 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
718 { &hf_wifi_dpp_public_action_subtype
,
719 { "Wi-Fi DPP Public Action Subtype", "dpp.public_action.subtype",
720 FT_UINT8
, BASE_DEC
, VALS(dpp_public_action_subtypes
), 0x0, NULL
, HFILL
}},
721 { &hf_wifi_dpp_unknown_anqp_item
,
722 { "Wi-fi DPP Unknown ANQP Item", "dpp.unknown_anqp_item",
723 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
725 { &hf_wifi_dpp_tcp_pdu_length
,
726 { "DPP TCP PDU length", "dpp.tcp.length",
727 FT_UINT32
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
729 { &hf_wifi_dpp_tcp_pdu_action_field
,
730 { "DPP TCP PDU Action type", "dpp.tcp.action_type",
731 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
733 { &hf_wifi_dpp_tcp_oui
,
734 { "DPP TCP PDU OUI", "dpp.tcp.oui",
735 FT_UINT24
, BASE_OUI
, NULL
, 0x0, NULL
, HFILL
}},
737 { &hf_wifi_dpp_tcp_oui_type
,
738 { "DPP TCP PDU OUI type", "dpp.tcp.oui_type",
739 FT_UINT8
, BASE_DEC
, VALS(wfa_subtype_vals
), 0, NULL
, HFILL
}},
741 { &hf_wifi_dpp_tcp_dialog_token
,
742 { "DPP TCP PDU Dialog Token", "dpp.tcp.dialog_token",
743 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
745 { &hf_wifi_dpp_tcp_adv_proto_elt
,
746 { "DPP TCP PDU Advertisement Protocol Element",
747 "dpp.tcp.adv_proto_elt",
748 FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
750 { &hf_wifi_dpp_tcp_vendor_specific
,
751 { "DPP TCP PDU Vendor Specific tag", "dpp.tcp.vendor_spec_tag",
752 FT_UINT8
, BASE_HEX
, NULL
, 0x0, NULL
, HFILL
}},
754 { &hf_wifi_dpp_tcp_vendor_spec_len
,
755 { "DPP TCP PDU Vendor Specific len", "dpp.tcp.vendor_spec_len",
756 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
758 { &hf_wifi_dpp_tcp_config
,
759 { "DPP TCP PDU Configuration", "dpp.tcp.config",
760 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
762 { &hf_wifi_dpp_tcp_query_req_len
,
763 { "DPP TCP PDU Query Req len", "dpp.tcp.query_req_len",
764 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
766 { &hf_wifi_dpp_gas_query_resp_frag_id
,
767 { "DPP TCP PDU GAS Query Response Fragment ID",
768 "dpp.tp.query_resp_frag_id",
769 FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
771 { &hf_wifi_dpp_tcp_status_code
,
772 { "DPP TCP PDU Status Code", "dpp.tcp.status_code",
773 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
775 { &hf_wifi_dpp_tcp_comeback_delay
,
776 { "DPP TCP PDU Comeback Delay", "dpp.tcp.comeback_delay",
777 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
779 { &hf_wifi_dpp_tcp_query_resp_len
,
780 { "DPP TCP PDU Query Resp Len", "dpp.tcp.query_resp_len",
781 FT_UINT16
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
783 static int *ett
[] = {
784 &ett_wifi_dpp_ie_generic
,
785 &ett_wifi_dpp_attributes
,
787 &ett_wifi_dpp_attribute
,
788 &ett_wifi_dpp_attr_header
,
789 &ett_wifi_dpp_attr_value
,
792 proto_wifi_dpp
= proto_register_protocol("Wi-Fi Device Provisioning Protocol", "Wi-Fi DPP", "dpp");
793 proto_register_field_array(proto_wifi_dpp
, hf
, array_length(hf
));
794 proto_register_subtree_array(ett
, array_length(ett
));
796 /* Register the dissector handles */
797 wifi_dpp_handle
= register_dissector("dpp", dissect_wifi_dpp
, proto_wifi_dpp
);
798 wifi_dpp_tcp_handle
= register_dissector("dpp.tcp", dissect_wifi_dpp_tcp_pdus
, proto_wifi_dpp
);
799 wifi_dpp_ie_handle
= register_dissector("dpp.ie", dissect_wifi_dpp_ie
, proto_wifi_dpp
);
800 wifi_dpp_pubact_handle
= register_dissector("dpp.public_action", dissect_wifi_dpp_public_action
, proto_wifi_dpp
);
802 /* Register the preferred TCP port? Is there one? */
803 wifi_dpp_module
= prefs_register_protocol(proto_wifi_dpp
, NULL
);
804 prefs_register_uint_preference(wifi_dpp_module
, "tcp.port", "DPP TCP Port",
805 "The TCP port DPP over TCP uses",
806 10, &wifi_dpp_tcp_port
);
810 proto_reg_handoff_wifi_dpp(void)
812 static bool initialized
= false;
813 static int current_port
;
815 dissector_add_uint("wlan.anqp.wifi_alliance.subtype", WFA_SUBTYPE_DPP
, wifi_dpp_handle
);
816 dissector_add_uint("wlan.ie.wifi_alliance.subtype", WFA_SUBTYPE_DPP
, wifi_dpp_ie_handle
);
817 dissector_add_uint("wlan.pa.wifi_alliance.subtype", WFA_SUBTYPE_DPP
, wifi_dpp_pubact_handle
);
820 * Register the TCP port
825 dissector_delete_uint("tcp.port", current_port
, wifi_dpp_tcp_handle
);
828 current_port
= wifi_dpp_tcp_port
;
829 dissector_add_uint("tcp.port", current_port
, wifi_dpp_tcp_handle
);
838 * indent-tabs-mode: nil
841 * ex: set shiftwidth=2 tabstop=8 expandtab:
842 * :indentSize=2:tabSize=8:noTabs=true: