2 * Routines for PEAP (Protected Extensible Authentication Protocol)
3 * draft-kamath-pppext-peapv0
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
18 #include <epan/expert.h>
19 #include <wsutil/pint.h>
20 #include <epan/proto_data.h>
22 void proto_register_peap(void);
23 void proto_reg_handoff_peap(void);
25 static int proto_peap
;
28 static dissector_handle_t peap_handle
;
29 static dissector_handle_t eap_handle
;
32 From draft-kamath-pppext-peapv0, sec 1.1
35 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
36 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 | Code | Identifier | Length | <-- NOT sent
38 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 This matches the format of an EAP header but...
43 * 'Code', 'Identifier' and 'Length' are NOT sent over the wire
44 * 'Code' and 'Identifier' are extracted from the *outer* EAP header
45 * 'Length' is derived from the PEAP packet (ie. TLS data frame)
46 * ...when 'Type' is 33, the full EAP header is sent
49 #define EAP_TLS_FLAGS_OFFSET 5
50 #define EAP_TLS_FLAGS_VERSION 0x07 /* mask */
53 dissect_peap(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
58 tvbuff_t
*eap_tvb
, *eap_len_tvb
, *next_tvb
;
59 unsigned char *eap_len_buf
;
60 uint32_t tls_group
= pinfo
->curr_proto_layer_num
<< 16;
62 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "PEAP");
63 col_clear(pinfo
->cinfo
, COL_INFO
);
65 len
= tvb_reported_length(tvb
);
67 eap_tvb
= (tvbuff_t
*)p_get_proto_data(pinfo
->pool
, pinfo
, proto_eap
, PROTO_DATA_EAP_TVB
| tls_group
);
68 version
= tvb_get_uint8(eap_tvb
, EAP_TLS_FLAGS_OFFSET
) & EAP_TLS_FLAGS_VERSION
;
69 if (version
> 0) { /* FIXME support v1 and v2 */
74 && tvb_get_bits(tvb
, offset
, 16, ENC_BIG_ENDIAN
) == tvb_get_bits(eap_tvb
, 0, 16, ENC_BIG_ENDIAN
)
75 && tvb_get_uint16(tvb
, offset
+ 2, ENC_BIG_ENDIAN
) <= tvb_get_uint16(eap_tvb
, 2, ENC_BIG_ENDIAN
)
77 (tvb_get_uint8(eap_tvb
, 0) == EAP_REQUEST
&& tvb_get_uint8(tvb
, offset
+ 4) == EAP_TYPE_ID
)
78 || tvb_get_uint8(tvb
, offset
+ 4) == EAP_TYPE_MSAUTH_TLV
80 eap_len_buf
= (unsigned char *)wmem_alloc(pinfo
->pool
, 2);
81 eap_len_tvb
= tvb_new_child_real_data(tvb
, eap_len_buf
, 2, 2);
82 phton16(eap_len_buf
, 4 + len
);
84 next_tvb
= tvb_new_composite();
85 tvb_composite_append(next_tvb
, tvb_new_subset_length(eap_tvb
, 0, 2));
86 tvb_composite_append(next_tvb
, eap_len_tvb
);
87 tvb_composite_append(next_tvb
, tvb_new_subset_length(tvb
, offset
, 4 + len
));
88 tvb_composite_finalize(next_tvb
);
90 add_new_data_source(pinfo
, next_tvb
, "Pseudo EAP");
95 call_dissector(eap_handle
, next_tvb
, pinfo
, tree
);
102 proto_register_peap(void)
104 proto_peap
= proto_register_protocol("Protected Extensible Authentication Protocol",
106 peap_handle
= register_dissector("peap", dissect_peap
, proto_peap
);
110 proto_reg_handoff_peap(void)
112 proto_eap
= proto_get_id_by_filter_name("eap");
113 eap_handle
= find_dissector_add_dependency("eap", proto_peap
);
121 * indent-tabs-mode: nil
124 * ex: set shiftwidth=2 tabstop=8 expandtab:
125 * :indentSize=2:tabSize=8:noTabs=true: