|
iPXE
|
Definitions for general secured-network routines. More...
Go to the source code of this file.
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| 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. | |
| 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. | |
| u8 * | sec80211_find_rsn (union ieee80211_ie *ie, void *ie_end, int *is_rsn, u8 **end) |
| int | sec80211_install (struct net80211_crypto **which, enum net80211_crypto_alg crypt, const void *key, int len, const void *rsc) |
| Install 802.11 cryptosystem. | |
| 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. | |
Definitions for general secured-network routines.
Definition in file sec80211.h.
| 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.
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.
| 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.
| ie | Pointer to first information element to check |
| ie_end | Pointer to end of information element space |
| is_rsn | TRUE if returned IE is RSN, FALSE if it's WPA |
| end | Pointer to byte immediately after last byte of data |
| data | Pointer 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.
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().
| u8 * sec80211_find_rsn | ( | union ieee80211_ie * | ie, |
| void * | ie_end, | ||
| int * | is_rsn, | ||
| u8 ** | end ) |
References desc, end, key, len, rsc, u32, and u8.
Referenced by rsn_pick_desc(), sec80211_detect(), wpa_handle_3_of_4(), wpa_make_rsn_ie(), and wpa_start().
| int sec80211_install | ( | struct net80211_crypto ** | which, |
| enum net80211_crypto_alg | crypt, | ||
| const void * | key, | ||
| int | len, | ||
| const void * | rsc ) |
Install 802.11 cryptosystem.
| which | Pointer to the cryptosystem structure to install in |
| crypt | Cryptosystem ID number |
| key | Encryption key to use |
| len | Length of encryption key |
| rsc | Initial receive sequence counter, if applicable |
| rc | Return 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.
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().
| 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.
References rsn_cipher_map, rsn_get_desc(), and u32.
Referenced by wpa_make_rsn_ie().
| 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.
References rsn_akm_map, rsn_get_desc(), and u32.
Referenced by wpa_make_rsn_ie().
| 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.
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().