iPXE
|
The WEP wireless encryption method (insecure!) More...
#include <ipxe/net80211.h>
#include <ipxe/sec80211.h>
#include <ipxe/crypto.h>
#include <ipxe/arc4.h>
#include <ipxe/crc32.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
Go to the source code of this file.
Data Structures | |
struct | wep_ctx |
Context for WEP encryption and decryption. More... | |
Macros | |
#define | WEP_IV_LEN 3 |
Length of WEP initialisation vector. More... | |
#define | WEP_KID_LEN 1 |
Length of WEP key ID byte. More... | |
#define | WEP_ICV_LEN 4 |
Length of WEP ICV checksum. More... | |
#define | WEP_MAX_KEY 16 |
Maximum length of WEP key. More... | |
#define | WEP_HEADER_LEN 4 |
Amount of data placed before the encrypted bytes. More... | |
#define | WEP_TRAILER_LEN 4 |
Amount of data placed after the encrypted bytes. More... | |
#define | WEP_OVERHEAD 8 |
Total WEP overhead bytes. More... | |
Functions | |
FILE_LICENCE (GPL2_OR_LATER) | |
static int | wep_init (struct net80211_crypto *crypto, const void *key, int keylen, const void *rsc __unused) |
Initialize WEP algorithm. More... | |
static struct io_buffer * | wep_encrypt (struct net80211_crypto *crypto, struct io_buffer *iob) |
Encrypt packet using WEP. More... | |
static struct io_buffer * | wep_decrypt (struct net80211_crypto *crypto, struct io_buffer *eiob) |
Decrypt packet using WEP. More... | |
static int | trivial_init (struct net80211_device *dev) |
Initialize trivial 802.11 security handshaker. More... | |
static int | trivial_change_key (struct net80211_device *dev) |
Check for key change on trivial 802.11 security handshaker. More... | |
Variables | |
struct net80211_crypto wep_crypto | __net80211_crypto |
WEP cryptosystem for 802.11. More... | |
struct net80211_handshaker trivial_handshaker | __net80211_handshaker |
Trivial 802.11 security handshaker. More... | |
The WEP wireless encryption method (insecure!)
The data field in a WEP-encrypted packet contains a 3-byte initialisation vector, one-byte Key ID field (only the bottom two bits are ever used), encrypted data, and a 4-byte encrypted CRC of the plaintext data, called the ICV. To decrypt it, the IV is prepended to the shared key and the data stream (including ICV) is run through the ARC4 stream cipher; if the ICV matches a CRC32 calculated on the plaintext, the packet is valid.
For efficiency and code-size reasons, this file assumes it is running on a little-endian machine.
Definition in file wep.c.
#define WEP_HEADER_LEN 4 |
#define WEP_TRAILER_LEN 4 |
FILE_LICENCE | ( | GPL2_OR_LATER | ) |
|
static |
Initialize WEP algorithm.
crypto | 802.11 cryptographic algorithm |
key | WEP key to use |
keylen | Length of WEP key |
rsc | Initial receive sequence counter (unused) |
rc | Return status code |
Standard key lengths are 5 and 13 bytes; 16-byte keys are occasionally supported as an extension to the standard.
Definition at line 98 of file wep.c.
References ctx, key, wep_ctx::keylen, memcpy(), net80211_crypto::priv, WEP_IV_LEN, and WEP_MAX_KEY.
Referenced by trivial_change_key().
|
static |
Encrypt packet using WEP.
crypto | 802.11 cryptographic algorithm |
iob | I/O buffer of plaintext packet |
eiob | Newly allocated I/O buffer for encrypted packet, or NULL |
If memory allocation fails, NULL
is returned.
Definition at line 118 of file wep.c.
References alloc_iob(), arc4_algorithm, cipher_encrypt, cipher_setkey(), crc32_le(), ctx, io_buffer::data, datalen, hdr, IEEE80211_FC_PROTECTED, IEEE80211_TYP_FRAME_HEADER_LEN, iob_len(), iob_put, iv, memcpy(), NULL, net80211_crypto::priv, random(), WEP_HEADER_LEN, WEP_ICV_LEN, WEP_IV_LEN, and WEP_OVERHEAD.
|
static |
Decrypt packet using WEP.
crypto | 802.11 cryptographic algorithm |
eiob | I/O buffer of encrypted packet |
iob | Newly allocated I/O buffer for plaintext packet, or NULL |
If a consistency check for the decryption fails (usually indicating an invalid key), NULL
is returned.
Definition at line 167 of file wep.c.
References alloc_iob(), arc4_algorithm, cipher_decrypt, cipher_setkey(), crc32_le(), ctx, io_buffer::data, datalen, DBGC, free_iob(), hdr, IEEE80211_FC_PROTECTED, IEEE80211_TYP_FRAME_HEADER_LEN, iob_len(), iob_put, iv, memcpy(), NULL, net80211_crypto::priv, WEP_HEADER_LEN, WEP_ICV_LEN, WEP_IV_LEN, and WEP_OVERHEAD.
|
static |
Initialize trivial 802.11 security handshaker.
dev | 802.11 device |
ctx | Security handshaker |
This simply fetches a WEP key from netX/key, and if it exists, installs WEP cryptography on the 802.11 device. No real handshaking is performed.
Definition at line 229 of file wep.c.
References net80211_device::associating, net80211_device::crypto, net80211_wlan::crypto, DBGC, EACCES, EINVAL, fetch_raw_setting(), key, len, NET80211_CRYPT_NONE, NET80211_CRYPT_WEP, net80211_device::netdev, netdev_settings(), NULL, rc, sec80211_install(), and WEP_MAX_KEY.
|
static |
Check for key change on trivial 802.11 security handshaker.
dev | 802.11 device |
ctx | Security handshaker |
Definition at line 271 of file wep.c.
References net80211_device::crypto, EINVAL, fetch_raw_setting(), net80211_crypto::init, key, len, net80211_device::netdev, netdev_settings(), NULL, wep_init(), and WEP_MAX_KEY.
struct net80211_crypto wep_crypto __net80211_crypto |
WEP cryptosystem for 802.11.
struct net80211_handshaker trivial_handshaker __net80211_handshaker |
Trivial 802.11 security handshaker.