iPXE
sec80211.c File Reference

General secured-network routines required whenever any secure network support at all is compiled in. More...

#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/ieee80211.h>
#include <ipxe/net80211.h>
#include <ipxe/sec80211.h>

Go to the source code of this file.

Data Structures

struct  descriptor_map
 Mapping from net80211 crypto/secprot types to RSN OUI descriptors. More...

Macros

#define ENOTSUP_WEP   __einfo_error ( EINFO_ENOTSUP_WEP )
#define EINFO_ENOTSUP_WEP
#define ENOTSUP_TKIP   __einfo_error ( EINFO_ENOTSUP_TKIP )
#define EINFO_ENOTSUP_TKIP
#define ENOTSUP_CCMP   __einfo_error ( EINFO_ENOTSUP_CCMP )
#define EINFO_ENOTSUP_CCMP
#define ENOTSUP_CRYPT(crypt)
#define END_MAGIC   0xFFFFFFFF
 Magic number in oui_type showing end of list.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
 FILE_SECBOOT (FORBIDDEN)
int sec80211_install (struct net80211_crypto **which, enum net80211_crypto_alg crypt, const void *key, int len, const void *rsc)
 Install 802.11 cryptosystem.
static struct descriptor_maprsn_pick_desc (u8 **rsnp, u8 *rsn_end, struct descriptor_map *map, void *tbl_start, void *tbl_end)
 Determine net80211 crypto or handshaking type value to return for RSN info.
int sec80211_detect_ie (int is_rsn, u8 *start, u8 *end, enum net80211_security_proto *secprot, enum net80211_crypto_alg *crypt)
 Find the RSN or WPA information element in the provided beacon frame.
int sec80211_detect (struct io_buffer *iob, enum net80211_security_proto *secprot, enum net80211_crypto_alg *crypt)
 Detect the cryptosystem and handshaking protocol used by an 802.11 network.
static u32 rsn_get_desc (unsigned id, int rsnie, struct descriptor_map *map)
 Determine RSN descriptor for specified net80211 ID.
u32 sec80211_rsn_get_crypto_desc (enum net80211_crypto_alg crypt, int rsnie)
 Determine RSN descriptor for specified net80211 cryptosystem number.
u32 sec80211_rsn_get_akm_desc (enum net80211_security_proto secprot, int rsnie)
 Determine RSN descriptor for specified net80211 handshaker number.
enum net80211_crypto_alg sec80211_rsn_get_net80211_crypt (u32 desc)
 Determine net80211 cryptosystem number from RSN descriptor.

Variables

static struct descriptor_map rsn_cipher_map []
 Mapping between net80211 cryptosystems and 802.11i cipher IDs.
static struct descriptor_map rsn_akm_map []
 Mapping between net80211 handshakers and 802.11i AKM IDs.

Detailed Description

General secured-network routines required whenever any secure network support at all is compiled in.

This involves things like installing keys, determining the type of security used by a probed network, and some small helper functions that take advantage of static data in this file.

Definition in file sec80211.c.

Macro Definition Documentation

◆ ENOTSUP_WEP

#define ENOTSUP_WEP   __einfo_error ( EINFO_ENOTSUP_WEP )

Definition at line 40 of file sec80211.c.

◆ EINFO_ENOTSUP_WEP

#define EINFO_ENOTSUP_WEP
Value:
( 0x10 | NET80211_CRYPT_WEP ), "WEP not supported" )
#define __einfo_uniqify(einfo_base, uniq, desc)
Declare disambiguated error.
Definition errno.h:224
#define EINFO_ENOTSUP
Definition errno.h:634
@ NET80211_CRYPT_WEP
Network protected with WEP (awful RC4-based system).
Definition net80211.h:145

Definition at line 41 of file sec80211.c.

41#define EINFO_ENOTSUP_WEP __einfo_uniqify ( EINFO_ENOTSUP, \
42 ( 0x10 | NET80211_CRYPT_WEP ), "WEP not supported" )

◆ ENOTSUP_TKIP

#define ENOTSUP_TKIP   __einfo_error ( EINFO_ENOTSUP_TKIP )

Definition at line 43 of file sec80211.c.

◆ EINFO_ENOTSUP_TKIP

#define EINFO_ENOTSUP_TKIP
Value:
( 0x10 | NET80211_CRYPT_TKIP ), "TKIP not supported" )
@ NET80211_CRYPT_TKIP
Network protected with TKIP (better RC4-based system).
Definition net80211.h:163

Definition at line 44 of file sec80211.c.

44#define EINFO_ENOTSUP_TKIP __einfo_uniqify ( EINFO_ENOTSUP, \
45 ( 0x10 | NET80211_CRYPT_TKIP ), "TKIP not supported" )

◆ ENOTSUP_CCMP

#define ENOTSUP_CCMP   __einfo_error ( EINFO_ENOTSUP_CCMP )

Definition at line 46 of file sec80211.c.

◆ EINFO_ENOTSUP_CCMP

#define EINFO_ENOTSUP_CCMP
Value:
( 0x10 | NET80211_CRYPT_CCMP ), "CCMP not supported" )
@ NET80211_CRYPT_CCMP
Network protected with CCMP (AES-based system).
Definition net80211.h:174

Definition at line 47 of file sec80211.c.

47#define EINFO_ENOTSUP_CCMP __einfo_uniqify ( EINFO_ENOTSUP, \
48 ( 0x10 | NET80211_CRYPT_CCMP ), "CCMP not supported" )

◆ ENOTSUP_CRYPT

#define ENOTSUP_CRYPT ( crypt)
Value:
EUNIQ ( EINFO_ENOTSUP, ( 0x10 | (crypt) ), \
#define EUNIQ(einfo_base, uniq,...)
Disambiguate a base error based on non-constant information.
Definition errno.h:269
#define ENOTSUP_CCMP
Definition sec80211.c:46
#define ENOTSUP_WEP
Definition sec80211.c:40
#define ENOTSUP_TKIP
Definition sec80211.c:43

Definition at line 49 of file sec80211.c.

49#define ENOTSUP_CRYPT( crypt ) \
50 EUNIQ ( EINFO_ENOTSUP, ( 0x10 | (crypt) ), \
51 ENOTSUP_WEP, ENOTSUP_TKIP, ENOTSUP_CCMP )

Referenced by sec80211_install().

◆ END_MAGIC

#define END_MAGIC   0xFFFFFFFF

Magic number in oui_type showing end of list.

Definition at line 63 of file sec80211.c.

Referenced by rsn_get_desc(), and sec80211_rsn_get_net80211_crypt().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER )

◆ FILE_SECBOOT()

FILE_SECBOOT ( FORBIDDEN )

◆ sec80211_install()

int sec80211_install ( struct net80211_crypto ** which,
enum net80211_crypto_alg crypt,
const void * key,
int len,
const void * rsc )

Install 802.11 cryptosystem.

Parameters
whichPointer to the cryptosystem structure to install in
cryptCryptosystem ID number
keyEncryption key to use
lenLength of encryption key
rscInitial receive sequence counter, if applicable
Return values
rcReturn status code

The encryption key will not be accessed via the provided pointer after this function returns, so you may keep it on the stack.

which must point to either dev->crypto (for the normal case of installing a unicast cryptosystem) or dev->gcrypto (to install a cryptosystem that will be used only for decrypting group-source frames).

Definition at line 114 of file sec80211.c.

117{
118 struct net80211_crypto *crypto = *which;
119 struct net80211_crypto *tbl_crypto;
120
121 /* Remove old crypto if it exists */
122 free ( *which );
123 *which = NULL;
124
125 if ( crypt == NET80211_CRYPT_NONE ) {
126 DBG ( "802.11-Sec not installing null cryptography\n" );
127 return 0;
128 }
129
130 /* Find cryptosystem to use */
131 for_each_table_entry ( tbl_crypto, NET80211_CRYPTOS ) {
132 if ( tbl_crypto->algorithm == crypt ) {
133 crypto = zalloc ( sizeof ( *crypto ) +
134 tbl_crypto->priv_len );
135 if ( ! crypto ) {
136 DBG ( "802.11-Sec out of memory\n" );
137 return -ENOMEM;
138 }
139
140 memcpy ( crypto, tbl_crypto, sizeof ( *crypto ) );
141 crypto->priv = ( ( void * ) crypto +
142 sizeof ( *crypto ) );
143 break;
144 }
145 }
146
147 if ( ! crypto ) {
148 DBG ( "802.11-Sec no support for cryptosystem %d\n", crypt );
149 return -ENOTSUP_CRYPT ( crypt );
150 }
151
152 *which = crypto;
153
154 DBG ( "802.11-Sec installing cryptosystem %d as %p with key of "
155 "length %d\n", crypt, crypto, len );
156
157 return crypto->init ( crypto, key, len, rsc );
158}
#define NULL
NULL pointer (VOID *).
Definition Base.h:321
union @162305117151260234136356364136041353210355154177 key
ring len
Length.
Definition dwmac.h:226
#define DBG(...)
Print a debugging message.
Definition compiler.h:523
#define ENOMEM
Not enough space.
Definition errno.h:578
void * memcpy(void *dest, const void *src, size_t len) __nonnull
void * zalloc(size_t size)
Allocate cleared memory.
Definition malloc.c:718
@ NET80211_CRYPT_NONE
No security, an "Open" network.
Definition net80211.h:131
#define NET80211_CRYPTOS
Definition net80211.h:769
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
#define ENOTSUP_CRYPT(crypt)
Definition sec80211.c:49
Interface to an 802.11 cryptosystem.
Definition net80211.h:690
void * priv
Private data for the algorithm to store key and state info.
Definition net80211.h:766
enum net80211_crypto_alg algorithm
The cryptographic algorithm implemented.
Definition net80211.h:692
int(* init)(struct net80211_crypto *crypto, const void *key, int keylen, const void *rsc)
Initialize cryptosystem using a given key.
Definition net80211.h:707
int priv_len
Length of private data requested to be allocated.
Definition net80211.h:763
#define for_each_table_entry(pointer, table)
Iterate through all entries within a linker table.
Definition tables.h:386
u8 rsc[8]
Receive sequence counter for GTK.
Definition wpa.h:42

References net80211_crypto::algorithm, DBG, ENOMEM, ENOTSUP_CRYPT, for_each_table_entry, free, net80211_crypto::init, key, len, memcpy(), NET80211_CRYPT_NONE, NET80211_CRYPTOS, NULL, net80211_crypto::priv, net80211_crypto::priv_len, rsc, and zalloc().

Referenced by trivial_init(), wpa_install_gtk(), and wpa_install_ptk().

◆ rsn_pick_desc()

struct descriptor_map * rsn_pick_desc ( u8 ** rsnp,
u8 * rsn_end,
struct descriptor_map * map,
void * tbl_start,
void * tbl_end )
static

Determine net80211 crypto or handshaking type value to return for RSN info.

Parameters
rsnpPointer to next descriptor count field in RSN IE
rsn_endPointer to end of RSN IE
mapDescriptor map to use
tbl_startStart of linker table to examine for iPXE support
tbl_endEnd of linker table to examine for iPXE support
Return values
rsnpUpdated to point to first byte after descriptors
map_entDescriptor map entry of translation to use

The entries in the linker table must be either net80211_crypto or net80211_handshaker structures, and tbl_stride must be set to sizeof() the appropriate one.

This function expects rsnp to point at a two-byte descriptor count followed by a list of four-byte cipher or AKM descriptors; it will return NULL if the input packet is malformed, and otherwise set rsnp to the first byte it has not looked at. It will return the first cipher in the list that is supported by the current build of iPXE, or the first of all if none are supported.

We play rather fast and loose with type checking, because this function is only called from two well-defined places in the RSN-checking code. Don't try to use it for anything else.

Definition at line 187 of file sec80211.c.

190{
191 int ndesc;
192 int ok = 0;
193 struct descriptor_map *map_ent, *map_ret = NULL;
194 u8 *rsn = *rsnp;
195 void *tblp;
196 size_t tbl_stride = ( map == rsn_cipher_map ?
197 sizeof ( struct net80211_crypto ) :
198 sizeof ( struct net80211_handshaker ) );
199
200 if ( map != rsn_cipher_map && map != rsn_akm_map )
201 return NULL;
202
203 /* Determine which types we support */
204 for ( tblp = tbl_start; tblp < tbl_end; tblp += tbl_stride ) {
205 struct net80211_crypto *crypto = tblp;
206 struct net80211_handshaker *hs = tblp;
207
208 if ( map == rsn_cipher_map )
209 ok |= ( 1 << crypto->algorithm );
210 else
211 ok |= ( 1 << hs->protocol );
212 }
213
214 /* RSN sanity checks */
215 if ( rsn + 2 > rsn_end ) {
216 DBG ( "RSN detect: malformed descriptor count\n" );
217 return NULL;
218 }
219
220 ndesc = *( u16 * ) rsn;
221 rsn += 2;
222
223 if ( ! ndesc ) {
224 DBG ( "RSN detect: no descriptors\n" );
225 return NULL;
226 }
227
228 /* Determine which net80211 crypto types are listed */
229 while ( ndesc-- ) {
230 u32 desc;
231
232 if ( rsn + 4 > rsn_end ) {
233 DBG ( "RSN detect: malformed descriptor (%d left)\n",
234 ndesc );
235 return NULL;
236 }
237
238 desc = *( u32 * ) rsn;
239 rsn += 4;
240
241 for ( map_ent = map; map_ent->oui_type != END_MAGIC; map_ent++ )
242 if ( map_ent->oui_type == ( desc & OUI_TYPE_MASK ) )
243 break;
244
245 /* Use first cipher as a fallback */
246 if ( ! map_ret )
247 map_ret = map_ent;
248
249 /* Once we find one we support, use it */
250 if ( ok & ( 1 << map_ent->net80211_type ) ) {
251 map_ret = map_ent;
252 break;
253 }
254 }
255
256 if ( ndesc > 0 )
257 rsn += 4 * ndesc;
258
259 *rsnp = rsn;
260 return map_ret;
261}
#define u8
Definition igbvf_osdep.h:40
static __always_inline int struct dma_mapping * map
Definition dma.h:184
return
Definition natsemi.h:326
if(natsemi->flags &NATSEMI_64BIT) return 1
static struct descriptor_map rsn_cipher_map[]
Mapping between net80211 cryptosystems and 802.11i cipher IDs.
Definition sec80211.c:66
Mapping from net80211 crypto/secprot types to RSN OUI descriptors.
Definition sec80211.c:54
#define ok(success)
Definition test.h:46
u32 oui_type
OUI + type byte.
Definition wpa.h:7

References DBG, end, ieee80211_ie_bound(), IEEE80211_IE_RSN, IEEE80211_IE_VENDOR, ieee80211_next_ie(), IEEE80211_RSN_VERSION, IEEE80211_WPA_OUI_VEN, if(), map, NULL, ok, oui_type, return, rsn_cipher_map, sec80211_find_rsn(), u16, and u8.

Referenced by sec80211_detect_ie().

◆ sec80211_detect_ie()

int sec80211_detect_ie ( int is_rsn,
u8 * start,
u8 * end,
enum net80211_security_proto * secprot,
enum net80211_crypto_alg * crypt )

Find the RSN or WPA information element in the provided beacon frame.

Parameters
iePointer to first information element to check
ie_endPointer to end of information element space
Return values
is_rsnTRUE if returned IE is RSN, FALSE if it's WPA
endPointer to byte immediately after last byte of data
dataPointer to first byte of data (the `version' field)

If both an RSN and a WPA information element are found, this function will return the first one seen, which by ordering rules should always prefer the newer RSN IE.

If no RSN or WPA infomration element is found, returns NULL and leaves is_rsn and end in an undefined state.

This function will not return a pointer to an information element that states it extends past the tail of the io_buffer, or whose version field is incorrect. */ u8 * sec80211_find_rsn ( union ieee80211_ie *ie, void *ie_end, int *is_rsn, u8 **end ) { u8 *rsn = NULL;

if ( ! ieee80211_ie_bound ( ie, ie_end ) ) return NULL;

while ( ie ) { if ( ie->id == IEEE80211_IE_VENDOR && ie->vendor.oui == IEEE80211_WPA_OUI_VEN ) { DBG ( "RSN detect: old-style WPA IE found\n" ); rsn = &ie->vendor.data[0]; end = rsn + ie->len - 4; is_rsn = 0; } else if ( ie->id == IEEE80211_IE_RSN ) { DBG ( "RSN detect: 802.11i RSN IE found\n" ); rsn = ( u8 * ) &ie->rsn.version; end = rsn + ie->len; is_rsn = 1; }

if ( rsn && ( *end > ( u8 * ) ie_end || rsn >= *end || ( u16 * ) rsn != IEEE80211_RSN_VERSION ) ) { DBG ( "RSN detect: malformed RSN IE or unknown " "version, keep trying\n" ); rsn = NULL; }

if ( rsn ) break;

ie = ieee80211_next_ie ( ie, ie_end ); }

if ( ! ie ) { DBG ( "RSN detect: no RSN IE found\n" ); return NULL; }

return rsn; }

/** Detect crypto and AKM types from RSN information element

@v is_rsn If TRUE, IE is a new-style RSN information element @v start Pointer to first byte of version field @v end Pointer to first byte not in the RSN IE @ret secprot Security handshaking protocol used by network @ret crypt Cryptosystem used by network @ret rc Return status code

If the IE cannot be parsed, returns an error indication and leaves secprot and crypt unchanged.

Definition at line 341 of file sec80211.c.

344{
347 struct descriptor_map *map;
348 u8 *rsn = start;
349
350 /* Set some defaults */
353
354 rsn += 2; /* version - already checked */
355 rsn += 4; /* group cipher - we don't use it here */
356
357 if ( rsn >= end )
358 goto done;
359
360 /* Pick crypto algorithm */
364 if ( ! map )
365 goto invalid_rsn;
366
367 cr = map->net80211_type;
368
369 if ( rsn >= end )
370 goto done;
371
372 /* Pick handshaking algorithm */
373 map = rsn_pick_desc ( &rsn, end, rsn_akm_map,
376 if ( ! map )
377 goto invalid_rsn;
378
379 sp = map->net80211_type;
380
381 done:
382 DBG ( "RSN detect: OK, crypto type %d, secprot type %d\n", cr, sp );
383 *secprot = sp;
384 *crypt = cr;
385 return 0;
386
387 invalid_rsn:
388 DBG ( "RSN detect: invalid RSN IE\n" );
389 return -EINVAL;
390}
struct bofm_section_header done
Definition bofm_test.c:46
uint32_t start
Starting offset.
Definition netvsc.h:1
#define EINVAL
Invalid argument.
Definition errno.h:472
net80211_security_proto
An 802.11 security handshaking protocol.
Definition net80211.h:96
@ NET80211_SECPROT_EAP
Full EAP 802.1X handshaking.
Definition net80211.h:121
net80211_crypto_alg
An 802.11 data encryption algorithm.
Definition net80211.h:129
#define NET80211_HANDSHAKERS
Definition net80211.h:675
uint32_t end
Ending offset.
Definition netvsc.h:7
uint16_t sp
Definition registers.h:13
static struct descriptor_map rsn_akm_map[]
Mapping between net80211 handshakers and 802.11i AKM IDs.
Definition sec80211.c:84
static struct descriptor_map * rsn_pick_desc(u8 **rsnp, u8 *rsn_end, struct descriptor_map *map, void *tbl_start, void *tbl_end)
Determine net80211 crypto or handshaking type value to return for RSN info.
Definition sec80211.c:187
@ cr
Definition sis900.h:22
#define table_end(table)
Get end of linker table.
Definition tables.h:309
#define table_start(table)
Get start of linker table.
Definition tables.h:283

References cr, DBG, done, EINVAL, end, map, NET80211_CRYPT_CCMP, NET80211_CRYPT_TKIP, NET80211_CRYPTOS, NET80211_HANDSHAKERS, NET80211_SECPROT_EAP, rsn_akm_map, rsn_cipher_map, rsn_pick_desc(), sp, start, table_end, table_start, and u8.

Referenced by sec80211_detect(), and wpa_handle_3_of_4().

◆ sec80211_detect()

int sec80211_detect ( struct io_buffer * iob,
enum net80211_security_proto * secprot,
enum net80211_crypto_alg * crypt )

Detect the cryptosystem and handshaking protocol used by an 802.11 network.

@v iob I/O buffer containing beacon frame @ret secprot Security handshaking protocol used by network @ret crypt Cryptosystem used by network @ret rc Return status code

This function uses weak linkage, as it must be called from generic contexts but should only be linked in if some encryption is supported; you must test its address against NULL before calling it. If it does not exist, any network with the PRIVACY bit set in beacon->capab should be considered unknown.

Definition at line 407 of file sec80211.c.

410{
411 struct ieee80211_frame *hdr = iob->data;
412 struct ieee80211_beacon *beacon =
413 ( struct ieee80211_beacon * ) hdr->data;
414 u8 *rsn, *rsn_end;
415 int is_rsn, rc;
416
417 *crypt = NET80211_CRYPT_UNKNOWN;
418 *secprot = NET80211_SECPROT_UNKNOWN;
419
420 /* Find RSN or WPA IE */
421 if ( ! ( rsn = sec80211_find_rsn ( beacon->info_element, iob->tail,
422 &is_rsn, &rsn_end ) ) ) {
423 /* No security IE at all; either WEP or no security. */
424 *secprot = NET80211_SECPROT_NONE;
425
426 if ( beacon->capability & IEEE80211_CAPAB_PRIVACY )
427 *crypt = NET80211_CRYPT_WEP;
428 else
429 *crypt = NET80211_CRYPT_NONE;
430
431 return 0;
432 }
433
434 /* Determine type of security */
435 if ( ( rc = sec80211_detect_ie ( is_rsn, rsn, rsn_end, secprot,
436 crypt ) ) == 0 )
437 return 0;
438
439 /* If we get here, the RSN IE was invalid */
440
441 *crypt = NET80211_CRYPT_UNKNOWN;
442 *secprot = NET80211_SECPROT_UNKNOWN;
443 DBG ( "Failed to handle RSN IE:\n" );
444 DBG_HD ( rsn, rsn_end - rsn );
445 return rc;
446}
struct golan_inbox_hdr hdr
Message header.
Definition CIB_PRM.h:0
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBG_HD(...)
Definition compiler.h:525
#define IEEE80211_CAPAB_PRIVACY
Set if the network is encrypted (by any method).
Definition ieee80211.h:401
#define ieee80211_beacon
Definition ieee80211.h:1069
@ NET80211_SECPROT_UNKNOWN
Dummy value used when the handshaking type can't be detected.
Definition net80211.h:124
@ NET80211_SECPROT_NONE
No security handshaking.
Definition net80211.h:102
@ NET80211_CRYPT_UNKNOWN
Dummy value used when the cryptosystem can't be detected.
Definition net80211.h:177
int sec80211_detect_ie(int is_rsn, u8 *start, u8 *end, enum net80211_security_proto *secprot, enum net80211_crypto_alg *crypt)
Find the RSN or WPA information element in the provided beacon frame.
Definition sec80211.c:341
u8 * sec80211_find_rsn(union ieee80211_ie *ie, void *ie_end, int *is_rsn, u8 **end)
An 802.11 data or management frame without QoS or WDS header fields.
Definition ieee80211.h:301
void * data
Start of data.
Definition iobuf.h:113
void * tail
End of data.
Definition iobuf.h:115

References io_buffer::data, DBG, DBG_HD, hdr, ieee80211_beacon, IEEE80211_CAPAB_PRIVACY, NET80211_CRYPT_NONE, NET80211_CRYPT_UNKNOWN, NET80211_CRYPT_WEP, NET80211_SECPROT_NONE, NET80211_SECPROT_UNKNOWN, rc, sec80211_detect_ie(), sec80211_find_rsn(), io_buffer::tail, and u8.

◆ rsn_get_desc()

u32 rsn_get_desc ( unsigned id,
int rsnie,
struct descriptor_map * map )
static

Determine RSN descriptor for specified net80211 ID.

@v id net80211 ID value @v rsnie Whether to return a new-format (RSN IE) descriptor @v map Map to use in translation @ret desc RSN descriptor, or 0 on error

If rsnie is false, returns an old-format (WPA vendor IE) descriptor.

Definition at line 460 of file sec80211.c.

461{
463
464 for ( ; map->oui_type != END_MAGIC; map++ ) {
465 if ( map->net80211_type == id )
466 return map->oui_type | vendor;
467 }
468
469 return 0;
470}
static unsigned short vendor
Definition davicom.c:128
#define IEEE80211_WPA_OUI
Organization part for OUIs in old WPA IE.
Definition ieee80211.h:866
#define IEEE80211_RSN_OUI
Organization part for OUIs in standard RSN IE.
Definition ieee80211.h:863
#define END_MAGIC
Magic number in oui_type showing end of list.
Definition sec80211.c:63
#define u32
Definition vga.h:21

References END_MAGIC, IEEE80211_RSN_OUI, IEEE80211_WPA_OUI, map, u32, and vendor.

Referenced by sec80211_rsn_get_akm_desc(), and sec80211_rsn_get_crypto_desc().

◆ sec80211_rsn_get_crypto_desc()

u32 sec80211_rsn_get_crypto_desc ( enum net80211_crypto_alg crypt,
int rsnie )

Determine RSN descriptor for specified net80211 cryptosystem number.

@v crypt Cryptosystem number @v rsnie Whether to return a new-format (RSN IE) descriptor @ret desc RSN descriptor

If rsnie is false, returns an old-format (WPA vendor IE) descriptor.

Definition at line 482 of file sec80211.c.

483{
484 return rsn_get_desc ( crypt, rsnie, rsn_cipher_map );
485}
static u32 rsn_get_desc(unsigned id, int rsnie, struct descriptor_map *map)
Determine RSN descriptor for specified net80211 ID.
Definition sec80211.c:460

References rsn_cipher_map, rsn_get_desc(), and u32.

Referenced by wpa_make_rsn_ie().

◆ sec80211_rsn_get_akm_desc()

u32 sec80211_rsn_get_akm_desc ( enum net80211_security_proto secprot,
int rsnie )

Determine RSN descriptor for specified net80211 handshaker number.

@v secprot Handshaker number @v rsnie Whether to return a new-format (RSN IE) descriptor @ret desc RSN descriptor

If rsnie is false, returns an old-format (WPA vendor IE) descriptor.

Definition at line 497 of file sec80211.c.

499{
500 return rsn_get_desc ( secprot, rsnie, rsn_akm_map );
501}

References rsn_akm_map, rsn_get_desc(), and u32.

Referenced by wpa_make_rsn_ie().

◆ sec80211_rsn_get_net80211_crypt()

enum net80211_crypto_alg sec80211_rsn_get_net80211_crypt ( u32 desc)

Determine net80211 cryptosystem number from RSN descriptor.

@v desc RSN descriptor @ret crypt net80211 cryptosystem enumeration value

Definition at line 509 of file sec80211.c.

510{
512
513 for ( ; map->oui_type != END_MAGIC; map++ ) {
514 if ( map->oui_type == ( desc & OUI_TYPE_MASK ) )
515 break;
516 }
517
518 return map->net80211_type;
519}
struct ena_llq_option desc
Descriptor counts.
Definition ena.h:9
#define OUI_TYPE_MASK
Definition ieee80211.h:854

References desc, END_MAGIC, map, OUI_TYPE_MASK, rsn_cipher_map, and u32.

Referenced by wpa_handle_3_of_4(), and wpa_make_rsn_ie().

Variable Documentation

◆ rsn_cipher_map

struct descriptor_map rsn_cipher_map[]
static
Initial value:
= {
{ .net80211_type = NET80211_CRYPT_WEP,
{ .net80211_type = NET80211_CRYPT_WEP,
{ .net80211_type = NET80211_CRYPT_TKIP,
.oui_type = IEEE80211_RSN_CTYPE_TKIP },
{ .net80211_type = NET80211_CRYPT_CCMP,
.oui_type = IEEE80211_RSN_CTYPE_CCMP },
{ .net80211_type = NET80211_CRYPT_UNKNOWN,
.oui_type = END_MAGIC },
}
#define IEEE80211_RSN_CTYPE_WEP104
802.11 RSN IE: cipher type for 104-bit WEP
Definition ieee80211.h:879
#define IEEE80211_RSN_CTYPE_TKIP
802.11 RSN IE: cipher type for TKIP ("WPA")
Definition ieee80211.h:882
#define IEEE80211_RSN_CTYPE_CCMP
802.11 RSN IE: cipher type for CCMP ("WPA2")
Definition ieee80211.h:885
#define IEEE80211_RSN_CTYPE_WEP40
802.11 RSN IE: cipher type for 40-bit WEP
Definition ieee80211.h:876

Mapping between net80211 cryptosystems and 802.11i cipher IDs.

Definition at line 66 of file sec80211.c.

66 {
67 { .net80211_type = NET80211_CRYPT_WEP,
68 .oui_type = IEEE80211_RSN_CTYPE_WEP40 },
69
70 { .net80211_type = NET80211_CRYPT_WEP,
71 .oui_type = IEEE80211_RSN_CTYPE_WEP104 },
72
73 { .net80211_type = NET80211_CRYPT_TKIP,
74 .oui_type = IEEE80211_RSN_CTYPE_TKIP },
75
76 { .net80211_type = NET80211_CRYPT_CCMP,
77 .oui_type = IEEE80211_RSN_CTYPE_CCMP },
78
79 { .net80211_type = NET80211_CRYPT_UNKNOWN,
80 .oui_type = END_MAGIC },
81};

Referenced by rsn_pick_desc(), sec80211_detect_ie(), sec80211_rsn_get_crypto_desc(), and sec80211_rsn_get_net80211_crypt().

◆ rsn_akm_map

struct descriptor_map rsn_akm_map[]
static
Initial value:
= {
{ .net80211_type = NET80211_SECPROT_EAP,
{ .net80211_type = NET80211_SECPROT_PSK,
.oui_type = IEEE80211_RSN_ATYPE_PSK },
{ .net80211_type = NET80211_SECPROT_UNKNOWN,
.oui_type = END_MAGIC },
}
#define IEEE80211_RSN_ATYPE_PSK
802.11 RSN IE: auth method type for using a pre-shared key
Definition ieee80211.h:898
#define IEEE80211_RSN_ATYPE_8021X
802.11 RSN IE: auth method type for using an 802.1X server
Definition ieee80211.h:895
@ NET80211_SECPROT_PSK
Pre-shared key handshaking.
Definition net80211.h:112

Mapping between net80211 handshakers and 802.11i AKM IDs.

Definition at line 84 of file sec80211.c.

84 {
85 { .net80211_type = NET80211_SECPROT_EAP,
86 .oui_type = IEEE80211_RSN_ATYPE_8021X },
87
88 { .net80211_type = NET80211_SECPROT_PSK,
89 .oui_type = IEEE80211_RSN_ATYPE_PSK },
90
91 { .net80211_type = NET80211_SECPROT_UNKNOWN,
92 .oui_type = END_MAGIC },
93};

Referenced by sec80211_detect_ie(), and sec80211_rsn_get_akm_desc().