summaryrefslogtreecommitdiffstats
path: root/MdePkg/Include/Protocol/Supplicant.h
blob: d7862211258323501541c2c53815eaffa453a84a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
/** @file
  This file defines the EFI Supplicant Protocol.

  Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved.<BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

  @par Revision Reference:
  This Protocol is introduced in UEFI Specification 2.6

**/

#ifndef __EFI_SUPPLICANT_PROTOCOL_H__
#define __EFI_SUPPLICANT_PROTOCOL_H__

#include <Protocol/WiFi2.h>

///
/// The EFI Supplicant Service Binding Protocol is used to locate EFI
/// Supplicant Protocol drivers to create and destroy child of the driver to
/// communicate with other host using Supplicant protocol.
///
#define EFI_SUPPLICANT_SERVICE_BINDING_PROTOCOL_GUID \
  { \
    0x45bcd98e, 0x59ad, 0x4174, { 0x95, 0x46, 0x34, 0x4a, 0x7, 0x48, 0x58, 0x98 } \
  }

///
/// The EFI Supplicant protocol provides services to process authentication and
/// data encryption/decryption for security management.
///
#define EFI_SUPPLICANT_PROTOCOL_GUID \
  { \
    0x54fcc43e, 0xaa89, 0x4333, { 0x9a, 0x85, 0xcd, 0xea, 0x24, 0x5, 0x1e, 0x9e } \
  }

typedef struct _EFI_SUPPLICANT_PROTOCOL EFI_SUPPLICANT_PROTOCOL;

///
/// EFI_SUPPLICANT_CRYPT_MODE
///
typedef enum {
  //
  // Encrypt data provided in the fragment buffers.
  //
  EfiSupplicantEncrypt,
  //
  // Decrypt data provided in the fragment buffers.
  //
  EfiSupplicantDecrypt,
} EFI_SUPPLICANT_CRYPT_MODE;

///
/// EFI_SUPPLICANT_DATA_TYPE
///
typedef enum {
  //
  // Session Configuration
  //

  //
  // Current authentication type in use. The corresponding Data is of type
  // EFI_80211_AKM_SUITE_SELECTOR.
  //
  EfiSupplicant80211AKMSuite,
  //
  // Group data encryption type in use. The corresponding Data is of type
  // EFI_SUPPLICANT_CIPHER_SUITE_SELECTOR.
  //
  EfiSupplicant80211GroupDataCipherSuite,
  //
  // Pairwise encryption type in use. The corresponding Data is of type
  // EFI_80211_CIPHER_SUITE_SELECTOR.
  //
  EfiSupplicant80211PairwiseCipherSuite,
  //
  // PSK password. The corresponding Data is a NULL-terminated ASCII string.
  //
  EfiSupplicant80211PskPassword,
  //
  // Target SSID name. The corresponding Data is of type EFI_80211_SSID.
  //
  EfiSupplicant80211TargetSSIDName,
  //
  // Station MAC address. The corresponding Data is of type
  // EFI_80211_MAC_ADDRESS.
  //
  EfiSupplicant80211StationMac,
  //
  // Target SSID MAC address. The corresponding Data is 6 bytes MAC address.
  //
  EfiSupplicant80211TargetSSIDMac,

  //
  // Session Information
  //

  //
  // 802.11 PTK. The corresponding Data is of type EFI_SUPPLICANT_KEY.
  //
  EfiSupplicant80211PTK,
  //
  // 802.11 GTK. The corresponding Data is of type EFI_SUPPLICANT_GTK_LIST.
  //
  EfiSupplicant80211GTK,
  //
  // Supplicant state. The corresponding Data is
  // EFI_EAPOL_SUPPLICANT_PAE_STATE.
  //
  EfiSupplicantState,
  //
  // 802.11 link state. The corresponding Data is EFI_80211_LINK_STATE.
  //
  EfiSupplicant80211LinkState,
  //
  // Flag indicates key is refreshed. The corresponding Data is
  // EFI_SUPPLICANT_KEY_REFRESH.
  //
  EfiSupplicantKeyRefresh,

  //
  // Session Configuration
  //

  //
  // Supported authentication types. The corresponding Data is of type
  // EFI_80211_AKM_SUITE_SELECTOR.
  //
  EfiSupplicant80211SupportedAKMSuites,
  //
  // Supported software encryption types provided by supplicant driver. The
  // corresponding Data is of type EFI_80211_CIPHER_SUITE_SELECTOR.
  //
  EfiSupplicant80211SupportedSoftwareCipherSuites,
  //
  // Supported hardware encryption types provided by wireless UNDI driver. The
  // corresponding Data is of type EFI_80211_CIPHER_SUITE_SELECTOR.
  //
  EfiSupplicant80211SupportedHardwareCipherSuites,

  //
  // Session Information
  //

  //
  // 802.11 Integrity GTK. The corresponding Data is of type
  // EFI_SUPPLICANT_GTK_LIST.
  //
  EfiSupplicant80211IGTK,
  //
  // 802.11 PMK. The corresponding Data is 32 bytes pairwise master key.
  //
  EfiSupplicant80211PMK,
  EfiSupplicantDataTypeMaximum
} EFI_SUPPLICANT_DATA_TYPE;

///
/// EFI_80211_LINK_STATE
///
typedef enum {
  //
  // Indicates initial start state, unauthenticated, unassociated.
  //
  Ieee80211UnauthenticatedUnassociated,
  //
  // Indicates authenticated, unassociated.
  //
  Ieee80211AuthenticatedUnassociated,
  //
  // Indicates authenticated and associated, but pending RSN authentication.
  //
  Ieee80211PendingRSNAuthentication,
  //
  // Indicates authenticated and associated.
  //
  Ieee80211AuthenticatedAssociated
} EFI_80211_LINK_STATE;

///
/// EFI_SUPPLICANT_KEY_TYPE (IEEE Std 802.11 Section 6.3.19.1.2)
///
typedef enum {
  Group,
  Pairwise,
  PeerKey,
  IGTK
} EFI_SUPPLICANT_KEY_TYPE;

///
/// EFI_SUPPLICANT_KEY_DIRECTION (IEEE Std 802.11 Section 6.3.19.1.2)
///
typedef enum {
  //
  // Indicates that the keys are being installed for the receive direction.
  //
  Receive,
  //
  // Indicates that the keys are being installed for the transmit direction.
  //
  Transmit,
  //
  // Indicates that the keys are being installed for both the receive and
  // transmit directions.
  //
  Both
} EFI_SUPPLICANT_KEY_DIRECTION;

///
/// EFI_SUPPLICANT_KEY_REFRESH
///
typedef struct {
  //
  // If TRUE, indicates GTK is just refreshed after a successful call to
  // EFI_SUPPLICANT_PROTOCOL.BuildResponsePacket().
  //
  BOOLEAN    GTKRefresh;
} EFI_SUPPLICANT_KEY_REFRESH;

#define EFI_MAX_KEY_LEN  64

///
/// EFI_SUPPLICANT_KEY
///
typedef struct {
  //
  // The key value.
  //
  UINT8                           Key[EFI_MAX_KEY_LEN];
  //
  // Length in bytes of the Key. Should be up to EFI_MAX_KEY_LEN.
  //
  UINT8                           KeyLen;
  //
  // The key identifier.
  //
  UINT8                           KeyId;
  //
  // Defines whether this key is a group key, pairwise key, PeerKey, or
  // Integrity Group.
  //
  EFI_SUPPLICANT_KEY_TYPE         KeyType;
  //
  // The value is set according to the KeyType.
  //
  EFI_80211_MAC_ADDRESS           Addr;
  //
  // The Receive Sequence Count value.
  //
  UINT8                           Rsc[8];
  //
  // Length in bytes of the Rsc. Should be up to 8.
  //
  UINT8                           RscLen;
  //
  // Indicates whether the key is configured by the Authenticator or
  // Supplicant. The value true indicates Authenticator.
  //
  BOOLEAN                         IsAuthenticator;
  //
  // The cipher suite required for this association.
  //
  EFI_80211_SUITE_SELECTOR        CipherSuite;
  //
  // Indicates the direction for which the keys are to be installed.
  //
  EFI_SUPPLICANT_KEY_DIRECTION    Direction;
} EFI_SUPPLICANT_KEY;

///
/// EFI_SUPPLICANT_GTK_LIST
///
typedef struct {
  //
  // Indicates the number of GTKs that are contained in GTKList.
  //
  UINT8                 GTKCount;
  //
  // A variable-length array of GTKs of type EFI_SUPPLICANT_KEY. The number of
  // entries is specified by GTKCount.
  //
  EFI_SUPPLICANT_KEY    GTKList[1];
} EFI_SUPPLICANT_GTK_LIST;

///
/// EFI_SUPPLICANT_FRAGMENT_DATA
///
typedef struct {
  //
  // Length of data buffer in the fragment.
  //
  UINT32    FragmentLength;
  //
  // Pointer to the data buffer in the fragment.
  //
  VOID      *FragmentBuffer;
} EFI_SUPPLICANT_FRAGMENT_DATA;

/**
  BuildResponsePacket() is called during STA and AP authentication is in
  progress. Supplicant derives the PTK or session keys depend on type of
  authentication is being employed.

  @param[in]       This           Pointer to the EFI_SUPPLICANT_PROTOCOL
                                  instance.
  @param[in]       RequestBuffer  Pointer to the most recently received EAPOL
                                  packet. NULL means the supplicant need
                                  initiate the EAP authentication session and
                                  send EAPOL-Start message.
  @param[in]       RequestBufferSize
                                  Packet size in bytes for the most recently
                                  received EAPOL packet. 0 is only valid when
                                  RequestBuffer is NULL.
  @param[out]      Buffer         Pointer to the buffer to hold the built
                                  packet.
  @param[in, out]  BufferSize     Pointer to the buffer size in bytes. On
                                  input, it is the buffer size provided by the
                                  caller. On output, it is the buffer size in
                                  fact needed to contain the packet.

  @retval EFI_SUCCESS             The required EAPOL packet is built
                                  successfully.
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is
                                  TRUE:
                                  RequestBuffer is NULL, but RequestSize is
                                  NOT 0.
                                  RequestBufferSize is 0.
                                  Buffer is NULL, but RequestBuffer is NOT 0.
                                  BufferSize is NULL.
  @retval EFI_BUFFER_TOO_SMALL    BufferSize is too small to hold the response
                                  packet.
  @retval EFI_NOT_READY           Current EAPOL session state is NOT ready to
                                  build ResponsePacket.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_SUPPLICANT_BUILD_RESPONSE_PACKET)(
  IN     EFI_SUPPLICANT_PROTOCOL          *This,
  IN     UINT8                            *RequestBuffer      OPTIONAL,
  IN     UINTN                            RequestBufferSize   OPTIONAL,
  OUT UINT8                            *Buffer,
  IN OUT UINTN                            *BufferSize
  );

/**
  ProcessPacket() is called to Supplicant driver to encrypt or decrypt the data
  depending type of authentication type.

  @param[in]       This           Pointer to the EFI_SUPPLICANT_PROTOCOL
                                  instance.
  @param[in, out]  FragmentTable  Pointer to a list of fragment. The caller
                                  will take responsible to handle the original
                                  FragmentTable while it may be reallocated in
                                  Supplicant driver.
  @param[in]       FragmentCount  Number of fragment.
  @param[in]       CryptMode      Crypt mode.

  @retval EFI_SUCCESS             The operation completed successfully.
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is
                                  TRUE:
                                  FragmentTable is NULL.
                                  FragmentCount is NULL.
                                  CryptMode is invalid.
  @retval EFI_NOT_READY           Current supplicant state is NOT Authenticated.
  @retval EFI_ABORTED             Something wrong decryption the message.
  @retval EFI_UNSUPPORTED         This API is not supported.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_SUPPLICANT_PROCESS_PACKET)(
  IN     EFI_SUPPLICANT_PROTOCOL          *This,
  IN OUT EFI_SUPPLICANT_FRAGMENT_DATA     **FragmentTable,
  IN     UINT32                           *FragmentCount,
  IN     EFI_SUPPLICANT_CRYPT_MODE        CryptMode
  );

/**
  Set Supplicant configuration data.

  @param[in]  This                Pointer to the EFI_SUPPLICANT_PROTOCOL
                                  instance.
  @param[in]  DataType            The type of data.
  @param[in]  Data                Pointer to the buffer to hold the data.
  @param[in]  DataSize            Pointer to the buffer size in bytes.

  @retval EFI_SUCCESS             The Supplicant configuration data is set
                                  successfully.
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is
                                  TRUE:
                                  Data is NULL.
                                  DataSize is 0.
  @retval EFI_UNSUPPORTED         The DataType is unsupported.
  @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_SUPPLICANT_SET_DATA)(
  IN EFI_SUPPLICANT_PROTOCOL              *This,
  IN EFI_SUPPLICANT_DATA_TYPE             DataType,
  IN VOID                                 *Data,
  IN UINTN                                DataSize
  );

/**
  Get Supplicant configuration data.

  @param[in]       This           Pointer to the EFI_SUPPLICANT_PROTOCOL
                                  instance.
  @param[in]       DataType       The type of data.
  @param[out]      Data           Pointer to the buffer to hold the data.
                                  Ignored if DataSize is 0.
  @param[in, out]  DataSize       Pointer to the buffer size in bytes. On
                                  input, it is the buffer size provided by the
                                  caller. On output, it is the buffer size in
                                  fact needed to contain the packet.

  @retval EFI_SUCCESS             The Supplicant configuration data is got
                                  successfully.
  @retval EFI_INVALID_PARAMETER   One or more of the following conditions is
                                  TRUE:
                                  This is NULL.
                                  DataSize is NULL.
                                  Data is NULL if *DataSize is not zero.
  @retval EFI_UNSUPPORTED         The DataType is unsupported.
  @retval EFI_NOT_FOUND           The Supplicant configuration data is not
                                  found.
  @retval EFI_BUFFER_TOO_SMALL    The size of Data is too small for the
                                  specified configuration data and the required
                                  size is returned in DataSize.

**/
typedef
EFI_STATUS
(EFIAPI *EFI_SUPPLICANT_GET_DATA)(
  IN     EFI_SUPPLICANT_PROTOCOL          *This,
  IN     EFI_SUPPLICANT_DATA_TYPE         DataType,
  OUT UINT8                            *Data      OPTIONAL,
  IN OUT UINTN                            *DataSize
  );

///
/// The EFI_SUPPLICANT_PROTOCOL is designed to provide unified place for WIFI
/// and EAP security management. Both PSK authentication and 802.1X EAP
/// authentication can be managed via this protocol and driver or application
/// as a consumer can only focus on about packet transmitting or receiving.
///
struct _EFI_SUPPLICANT_PROTOCOL {
  EFI_SUPPLICANT_BUILD_RESPONSE_PACKET    BuildResponsePacket;
  EFI_SUPPLICANT_PROCESS_PACKET           ProcessPacket;
  EFI_SUPPLICANT_SET_DATA                 SetData;
  EFI_SUPPLICANT_GET_DATA                 GetData;
};

extern EFI_GUID  gEfiSupplicantServiceBindingProtocolGuid;
extern EFI_GUID  gEfiSupplicantProtocolGuid;

#endif