| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
dot11decrypt_int.h
Go to the documentation of this file.
1
8
9#ifndef _DOT11DECRYPT_INT_H
10#define _DOT11DECRYPT_INT_H
11
12/****************************************************************************/
13/* File includes */
14
15#include "dot11decrypt_system.h"
16
17#include "ws_attributes.h"
18#include <wsutil/wsgcrypt.h>
19
20/****************************************************************************/
21
22/****************************************************************************/
23/* Definitions */
24
25/* IEEE 802.11 packet type values */
26#define DOT11DECRYPT_TYPE_MANAGEMENT 0
27#define DOT11DECRYPT_TYPE_CONTROL 1
28#define DOT11DECRYPT_TYPE_DATA 2
29
30/* IEEE 802.11 packet subtype values */
31#define DOT11DECRYPT_SUBTYPE_ASSOC_REQ 0
32#define DOT11DECRYPT_SUBTYPE_ASSOC_RESP 1
33#define DOT11DECRYPT_SUBTYPE_REASSOC_REQ 2
34#define DOT11DECRYPT_SUBTYPE_REASSOC_RESP 3
35#define DOT11DECRYPT_SUBTYPE_PROBE_REQ 4
36#define DOT11DECRYPT_SUBTYPE_PROBE_RESP 5
37#define DOT11DECRYPT_SUBTYPE_MEASUREMENT_PILOT 6
38#define DOT11DECRYPT_SUBTYPE_BEACON 8
39#define DOT11DECRYPT_SUBTYPE_ATIM 9
40#define DOT11DECRYPT_SUBTYPE_DISASS 10
41#define DOT11DECRYPT_SUBTYPE_AUTHENTICATION 11
42#define DOT11DECRYPT_SUBTYPE_DEAUTHENTICATION 12
43#define DOT11DECRYPT_SUBTYPE_ACTION 13
44#define DOT11DECRYPT_SUBTYPE_ACTION_NO_ACK 14
45
46/* IEEE 802.11 cipher suite selectors */
47#define DOT11DECRYPT_CIPHER_USE_GROUP 0
48#define DOT11DECRYPT_CIPHER_WEP40 1
49#define DOT11DECRYPT_CIPHER_TKIP 2
50#define DOT11DECRYPT_CIPHER_CCMP 4
51#define DOT11DECRYPT_CIPHER_WEP104 5
52#define DOT11DECRYPT_CIPHER_BIP_CMAC 6
53#define DOT11DECRYPT_CIPHER_GROUP_NA 7
54#define DOT11DECRYPT_CIPHER_GCMP 8
55#define DOT11DECRYPT_CIPHER_GCMP256 9
56#define DOT11DECRYPT_CIPHER_CCMP256 10
57#define DOT11DECRYPT_CIPHER_BIP_GMAC 11
58#define DOT11DECRYPT_CIPHER_BIP_GMAC256 12
59#define DOT11DECRYPT_CIPHER_BIP_CMAC256 13
60
61/*
62 * Min length of encrypted data (WEP=9bytes, TKIP=21bytes, CCMP=17bytes, GCMP=25bytes)
63 * WEP = 4 octets of IV, 1 octet of data, 4 octets of ICV.
64 * TKIP = 4 octets of IV/Key ID, 4 octets of Extended IV, 1 octet of data,
65 * 8 octets of MIC, 4 octets of ICV.
66 * CCMP = 8 octets of CCMP header, 1 octet of data, 8 octets of MIC.
67 * GCMP = 8 octets of GCMP header, 1 octet of data, 16 octets of MIC.
68 */
69#define DOT11DECRYPT_CRYPTED_DATA_MINLEN 9
70
71#define DOT11DECRYPT_TA_OFFSET 10
72
73/* */
74/****************************************************************************/
75
76/****************************************************************************/
77/* Macro definitions */
78
82#define DOT11DECRYPT_TYPE(FrameControl_0) (uint8_t)((FrameControl_0 >> 2) & 0x3)
83#define DOT11DECRYPT_SUBTYPE(FrameControl_0) (uint8_t)((FrameControl_0 >> 4) & 0xF)
84#define DOT11DECRYPT_DS_BITS(FrameControl_1) (uint8_t)(FrameControl_1 & 0x3)
85#define DOT11DECRYPT_TO_DS(FrameControl_1) (uint8_t)(FrameControl_1 & 0x1)
86#define DOT11DECRYPT_FROM_DS(FrameControl_1) (uint8_t)((FrameControl_1 >> 1) & 0x1)
87#define DOT11DECRYPT_WEP(FrameControl_1) (uint8_t)((FrameControl_1 >> 6) & 0x1)
88
92#define DOT11DECRYPT_EXTIV(KeyID) ((KeyID >> 5) & 0x1)
93
94#define DOT11DECRYPT_KEY_INDEX(KeyID) ((KeyID >> 6) & 0x3)
95
96/* Macros to get various bits of an EAPOL frame */
97#define DOT11DECRYPT_EAP_KEY_DESCR_VER(KeyInfo_1) ((unsigned char)(KeyInfo_1 & 0x3))
98#define DOT11DECRYPT_EAP_KEY(KeyInfo_1) ((KeyInfo_1 >> 3) & 0x1)
99#define DOT11DECRYPT_EAP_INST(KeyInfo_1) ((KeyInfo_1 >> 6) & 0x1)
100#define DOT11DECRYPT_EAP_ACK(KeyInfo_1) ((KeyInfo_1 >> 7) & 0x1)
101#define DOT11DECRYPT_EAP_MIC(KeyInfo_0) (KeyInfo_0 & 0x1)
102#define DOT11DECRYPT_EAP_SEC(KeyInfo_0) ((KeyInfo_0 >> 1) & 0x1)
103
104/* Note: copied from net80211/ieee80211.h */
105#define DOT11DECRYPT_FC1_DIR_MASK 0x03
106#define IEEE80211_FC1_DIR_NODS 0x00 /* STA->STA */
107#define IEEE80211_FC1_DIR_TODS 0x01 /* STA->AP */
108#define IEEE80211_FC1_DIR_FROMDS 0x02 /* AP ->STA */
109#define DOT11DECRYPT_FC1_DIR_DSTODS 0x03 /* AP ->AP */
110#define DOT11DECRYPT_FC0_SUBTYPE_QOS 0x80
111#define DOT11DECRYPT_FC0_TYPE_DATA 0x08
112#define DOT11DECRYPT_FC0_TYPE_MASK 0x0c
113#define DOT11DECRYPT_SEQ_FRAG_MASK 0x000f
114#define DOT11DECRYPT_QOS_HAS_SEQ(wh) \
115 (((wh)->fc[0] & \
116 (DOT11DECRYPT_FC0_TYPE_MASK | DOT11DECRYPT_FC0_SUBTYPE_QOS)) == \
117 (DOT11DECRYPT_FC0_TYPE_DATA | DOT11DECRYPT_FC0_SUBTYPE_QOS))
118
119#define DOT11DECRYPT_ADDR_COPY(dst,src) memcpy(dst, src, DOT11DECRYPT_MAC_LEN)
120
121#define DOT11DECRYPT_IS_4ADDRESS(wh) \
122 ((wh->fc[1] & DOT11DECRYPT_FC1_DIR_MASK) == DOT11DECRYPT_FC1_DIR_DSTODS)
123#define DOT11DECRYPT_IS_QOS_DATA(wh) DOT11DECRYPT_QOS_HAS_SEQ(wh)
124
125/****************************************************************************/
126
127/****************************************************************************/
128/* Structure definitions */
129
130/*
131 * XXX - According to the thread at
132 * https://lists.wireshark.org/archives/wireshark-dev/200612/msg00384.html we
133 * shouldn't have to worry about packing our structs, since the largest
134 * elements are 8 bits wide.
135 */
136#ifdef _MSC_VER /* MS Visual C++ */
137#pragma pack(push)
138#pragma pack(1)
139#endif
140
144 typedef struct _DOT11DECRYPT_MAC_FRAME {
145 unsigned char fc[2];
146 unsigned char dur[2];
147 unsigned char addr1[DOT11DECRYPT_MAC_LEN];
148 unsigned char addr2[DOT11DECRYPT_MAC_LEN];
149 unsigned char addr3[DOT11DECRYPT_MAC_LEN];
150 unsigned char seq[2];
151} DOT11DECRYPT_MAC_FRAME, *PDOT11DECRYPT_MAC_FRAME;
152
156 typedef struct _DOT11DECRYPT_MAC_FRAME_ADDR4 {
157 unsigned char fc[2];
158 unsigned char dur[2];
159 unsigned char addr1[DOT11DECRYPT_MAC_LEN];
160 unsigned char addr2[DOT11DECRYPT_MAC_LEN];
161 unsigned char addr3[DOT11DECRYPT_MAC_LEN];
162 unsigned char seq[2];
163 unsigned char addr4[DOT11DECRYPT_MAC_LEN];
164} DOT11DECRYPT_MAC_FRAME_ADDR4, *PDOT11DECRYPT_MAC_FRAME_ADDR4;
165
169 typedef struct _DOT11DECRYPT_MAC_FRAME_QOS {
170 unsigned char fc[2];
171 unsigned char dur[2];
172 unsigned char addr1[DOT11DECRYPT_MAC_LEN];
173 unsigned char addr2[DOT11DECRYPT_MAC_LEN];
174 unsigned char addr3[DOT11DECRYPT_MAC_LEN];
175 unsigned char seq[2];
176 unsigned char qos[2];
177} DOT11DECRYPT_MAC_FRAME_QOS, *PDOT11DECRYPT_MAC_FRAME_QOS;
178
182 typedef struct _DOT11DECRYPT_MAC_FRAME_ADDR4_QOS {
183 unsigned char fc[2];
184 unsigned char dur[2];
185 unsigned char addr1[DOT11DECRYPT_MAC_LEN];
186 unsigned char addr2[DOT11DECRYPT_MAC_LEN];
187 unsigned char addr3[DOT11DECRYPT_MAC_LEN];
188 unsigned char seq[2];
189 unsigned char addr4[DOT11DECRYPT_MAC_LEN];
190 unsigned char qos[2];
191} DOT11DECRYPT_MAC_FRAME_ADDR4_QOS, *PDOT11DECRYPT_MAC_FRAME_ADDR4_QOS;
192
193#ifdef _MSC_VER /* MS Visual C++ */
194#pragma pack(pop)
195#endif
196
197/******************************************************************************/
198
215 int Dot11DecryptCcmpDecrypt(
216 uint8_t *m,
217 int mac_header_len,
218 int len,
219 uint8_t *TK1,
220 int tk_len,
221 int mic_len,
222 const uint8_t *ap_mld_mac,
223 const uint8_t *sta_mld_mac);
224
239 int Dot11DecryptGcmpDecrypt(
240 uint8_t *m,
241 int mac_header_len,
242 int len,
243 uint8_t *TK1,
244 int tk_len,
245 const uint8_t *ap_mld_mac,
246 const uint8_t *sta_mld_mac);
247
259 int Dot11DecryptTkipDecrypt(
260 uint8_t *mpdu,
261 size_t mac_header_len,
262 size_t mpdu_len,
263 unsigned char TK[DOT11DECRYPT_TK_LEN]);
264
282WS_DLL_PUBLIC int Dot11DecryptWepDecrypt(
283 const unsigned char *seed,
284 size_t seed_len,
285 unsigned char *cypher_text,
286 size_t data_len);
287
288#endif
Dot11DecryptGcmpDecrypt
int Dot11DecryptGcmpDecrypt(uint8_t *m, int mac_header_len, int len, uint8_t *TK1, int tk_len, const uint8_t *ap_mld_mac, const uint8_t *sta_mld_mac)
Decrypt GCMP encrypted MPDU.
Definition dot11decrypt_gcmp.c:54
DOT11DECRYPT_MAC_FRAME_ADDR4
struct _DOT11DECRYPT_MAC_FRAME_ADDR4 DOT11DECRYPT_MAC_FRAME_ADDR4
IEEE 802.11 MAC frame header with Address 4 field (WDS / mesh, both To DS and From DS set).
Dot11DecryptCcmpDecrypt
int Dot11DecryptCcmpDecrypt(uint8_t *m, int mac_header_len, int len, uint8_t *TK1, int tk_len, int mic_len, const uint8_t *ap_mld_mac, const uint8_t *sta_mld_mac)
Decrypt CCMP encrypted MPDU.
Definition dot11decrypt_ccmp.c:76
Dot11DecryptTkipDecrypt
int Dot11DecryptTkipDecrypt(uint8_t *mpdu, size_t mac_header_len, size_t mpdu_len, unsigned char TK[16])
Decrypt TKIP encrypted MPDU.
Definition dot11decrypt_tkip.c:187
DOT11DECRYPT_MAC_FRAME_ADDR4_QOS
struct _DOT11DECRYPT_MAC_FRAME_ADDR4_QOS DOT11DECRYPT_MAC_FRAME_ADDR4_QOS
IEEE 802.11 MAC frame header with both Address 4 and QoS Control fields (WDS QoS data frames).
DOT11DECRYPT_MAC_FRAME
struct _DOT11DECRYPT_MAC_FRAME DOT11DECRYPT_MAC_FRAME
IEEE 802.11 MAC frame header without Address 4 field.
DOT11DECRYPT_MAC_FRAME_QOS
struct _DOT11DECRYPT_MAC_FRAME_QOS DOT11DECRYPT_MAC_FRAME_QOS
IEEE 802.11 MAC frame header without Address 4 field, with QoS Control field (QoS data frames).
Dot11DecryptWepDecrypt
WS_DLL_PUBLIC int Dot11DecryptWepDecrypt(const unsigned char *seed, size_t seed_len, unsigned char *cypher_text, size_t data_len)
Decrypt WEP-encrypted 802.11 payload using RC4 stream cipher.
Definition dot11decrypt_wep.c:14
dot11decrypt_system.h
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS
IEEE 802.11 MAC frame header with both Address 4 and QoS Control fields (WDS QoS data frames).
Definition dot11decrypt_int.h:182
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::addr4
unsigned char addr4[6]
Definition dot11decrypt_int.h:189
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::qos
unsigned char qos[2]
Definition dot11decrypt_int.h:190
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::addr2
unsigned char addr2[6]
Definition dot11decrypt_int.h:186
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::addr3
unsigned char addr3[6]
Definition dot11decrypt_int.h:187
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::dur
unsigned char dur[2]
Definition dot11decrypt_int.h:184
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::seq
unsigned char seq[2]
Definition dot11decrypt_int.h:188
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::fc
unsigned char fc[2]
Definition dot11decrypt_int.h:183
_DOT11DECRYPT_MAC_FRAME_ADDR4_QOS::addr1
unsigned char addr1[6]
Definition dot11decrypt_int.h:185
_DOT11DECRYPT_MAC_FRAME_ADDR4
IEEE 802.11 MAC frame header with Address 4 field (WDS / mesh, both To DS and From DS set).
Definition dot11decrypt_int.h:156
_DOT11DECRYPT_MAC_FRAME_ADDR4::seq
unsigned char seq[2]
Definition dot11decrypt_int.h:162
_DOT11DECRYPT_MAC_FRAME_ADDR4::addr3
unsigned char addr3[6]
Definition dot11decrypt_int.h:161
_DOT11DECRYPT_MAC_FRAME_ADDR4::addr2
unsigned char addr2[6]
Definition dot11decrypt_int.h:160
_DOT11DECRYPT_MAC_FRAME_ADDR4::addr4
unsigned char addr4[6]
Definition dot11decrypt_int.h:163
_DOT11DECRYPT_MAC_FRAME_ADDR4::addr1
unsigned char addr1[6]
Definition dot11decrypt_int.h:159
_DOT11DECRYPT_MAC_FRAME_ADDR4::fc
unsigned char fc[2]
Definition dot11decrypt_int.h:157
_DOT11DECRYPT_MAC_FRAME_ADDR4::dur
unsigned char dur[2]
Definition dot11decrypt_int.h:158
_DOT11DECRYPT_MAC_FRAME_QOS
IEEE 802.11 MAC frame header without Address 4 field, with QoS Control field (QoS data frames).
Definition dot11decrypt_int.h:169
_DOT11DECRYPT_MAC_FRAME_QOS::seq
unsigned char seq[2]
Definition dot11decrypt_int.h:175
_DOT11DECRYPT_MAC_FRAME_QOS::fc
unsigned char fc[2]
Definition dot11decrypt_int.h:170
_DOT11DECRYPT_MAC_FRAME_QOS::addr3
unsigned char addr3[6]
Definition dot11decrypt_int.h:174
_DOT11DECRYPT_MAC_FRAME_QOS::addr2
unsigned char addr2[6]
Definition dot11decrypt_int.h:173
_DOT11DECRYPT_MAC_FRAME_QOS::dur
unsigned char dur[2]
Definition dot11decrypt_int.h:171
_DOT11DECRYPT_MAC_FRAME_QOS::addr1
unsigned char addr1[6]
Definition dot11decrypt_int.h:172
_DOT11DECRYPT_MAC_FRAME_QOS::qos
unsigned char qos[2]
Definition dot11decrypt_int.h:176
_DOT11DECRYPT_MAC_FRAME
IEEE 802.11 MAC frame header without Address 4 field.
Definition dot11decrypt_int.h:144
_DOT11DECRYPT_MAC_FRAME::addr2
unsigned char addr2[6]
Definition dot11decrypt_int.h:148
_DOT11DECRYPT_MAC_FRAME::addr1
unsigned char addr1[6]
Definition dot11decrypt_int.h:147
_DOT11DECRYPT_MAC_FRAME::seq
unsigned char seq[2]
Definition dot11decrypt_int.h:150
_DOT11DECRYPT_MAC_FRAME::fc
unsigned char fc[2]
Definition dot11decrypt_int.h:145
_DOT11DECRYPT_MAC_FRAME::dur
unsigned char dur[2]
Definition dot11decrypt_int.h:146
_DOT11DECRYPT_MAC_FRAME::addr3
unsigned char addr3[6]
Definition dot11decrypt_int.h:149
wsgcrypt.h