|
iPXE
|
Backend for WPA using the TKIP encryption standard. More...
#include <string.h>#include <ipxe/net80211.h>#include <ipxe/crypto.h>#include <ipxe/hmac.h>#include <ipxe/sha1.h>#include <ipxe/md5.h>#include <ipxe/crc32.h>#include <ipxe/arc4.h>#include <ipxe/wpa.h>#include <byteswap.h>#include <errno.h>Go to the source code of this file.
Data Structures | |
| struct | tkip_dir_ctx |
| Context for one direction of TKIP, either encryption or decryption. More... | |
| struct | tkip_ctx |
| Context for TKIP encryption and decryption. More... | |
| struct | tkip_head |
| Header structure at the beginning of TKIP frame data. More... | |
Macros | |
| #define | TKIP_HEAD_LEN 8 |
| TKIP header overhead (IV + KID + ExtIV) More... | |
| #define | TKIP_FOOT_LEN 12 |
| TKIP trailer overhead (MIC + ICV) [assumes unfragmented]. More... | |
| #define | TKIP_MIC_LEN 8 |
| TKIP MIC length. More... | |
| #define | TKIP_ICV_LEN 4 |
| TKIP ICV length. More... | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
| static u16 | S (u16 v) |
| Perform S-box mapping on a 16-bit value. More... | |
| static u16 | ror16 (u16 v, int bits) |
| Rotate 16-bit value right. More... | |
| static u32 | ror32 (u32 v, int bits) |
| Rotate 32-bit value right. More... | |
| static u32 | rol32 (u32 v, int bits) |
| Rotate 32-bit value left. More... | |
| static int | tkip_init (struct net80211_crypto *crypto, const void *key, int keylen, const void *rsc) |
| Initialise TKIP state and install key. More... | |
| static void | tkip_mix_1 (struct tkip_dir_ctx *dctx, struct tkip_tk *tk, u8 *mac) |
| Perform TKIP key mixing, phase 1. More... | |
| static void | tkip_mix_2 (struct tkip_dir_ctx *dctx, struct tkip_tk *tk, void *key) |
| Perform TKIP key mixing, phase 2. More... | |
| static void | tkip_feed_michael (u32 *V, u32 word) |
| Update Michael message integrity code based on next 32-bit word of data. More... | |
| static void | tkip_michael (const void *key, const void *da, const void *sa, const void *data, size_t len, void *mic) |
| Calculate Michael message integrity code. More... | |
| static struct io_buffer * | tkip_encrypt (struct net80211_crypto *crypto, struct io_buffer *iob) |
| Encrypt a packet using TKIP. More... | |
| static struct io_buffer * | tkip_decrypt (struct net80211_crypto *crypto, struct io_buffer *eiob) |
| Decrypt a packet using TKIP. More... | |
| static void | tkip_kie_mic (const void *kck, const void *msg, size_t len, void *mic) |
| Calculate HMAC-MD5 MIC for EAPOL-Key frame. More... | |
| static int | tkip_kie_decrypt (const void *kek, const void *iv, void *msg, u16 *len) |
| Decrypt key data in EAPOL-Key frame. More... | |
Variables | |
| static const u16 | Sbox [256] |
| TKIP S-box. More... | |
| struct net80211_crypto tkip_crypto | __net80211_crypto |
| TKIP cryptosystem. More... | |
| struct wpa_kie tkip_kie | __wpa_kie |
| TKIP-style key integrity and encryption handler. More... | |
Backend for WPA using the TKIP encryption standard.
Definition in file wpa_tkip.c.
| #define TKIP_HEAD_LEN 8 |
TKIP header overhead (IV + KID + ExtIV)
Definition at line 83 of file wpa_tkip.c.
| #define TKIP_FOOT_LEN 12 |
TKIP trailer overhead (MIC + ICV) [assumes unfragmented].
Definition at line 86 of file wpa_tkip.c.
| #define TKIP_MIC_LEN 8 |
TKIP MIC length.
Definition at line 89 of file wpa_tkip.c.
| #define TKIP_ICV_LEN 4 |
TKIP ICV length.
Definition at line 92 of file wpa_tkip.c.
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
Perform S-box mapping on a 16-bit value.
| v | Value to perform S-box mapping on |
| Sv | S-box mapped value |
Definition at line 137 of file wpa_tkip.c.
References bswap_16, and Sbox.
Referenced by arc4_setkey(), arc4_xor(), ccmp_ctr_xor(), tkip_mix_1(), and tkip_mix_2().
Rotate 16-bit value right.
| v | Value to rotate |
| bits | Number of bits to rotate by |
| rotv | Rotated value |
Definition at line 149 of file wpa_tkip.c.
References bits.
Referenced by tkip_mix_2().
Rotate 32-bit value right.
| v | Value to rotate |
| bits | Number of bits to rotate by |
| rotv | Rotated value |
Definition at line 161 of file wpa_tkip.c.
References bits.
Referenced by aes_key_rotate(), des_generate(), sha256_digest(), and tkip_feed_michael().
Rotate 32-bit value left.
| v | Value to rotate |
| bits | Number of bits to rotate by |
| rotv | Rotated value |
Definition at line 173 of file wpa_tkip.c.
References bits.
Referenced by aes_key_rotate(), aes_key_sbox(), des_rol28(), des_sbox(), md4_digest(), md5_digest(), sha1_digest(), and tkip_feed_michael().
|
static |
Initialise TKIP state and install key.
| crypto | TKIP cryptosystem structure |
| key | Pointer to tkip_tk to install |
| keylen | Length of key (32 bytes) |
| rsc | Initial receive sequence counter |
Definition at line 187 of file wpa_tkip.c.
References ctx, EINVAL, key, memcpy(), net80211_crypto::priv, and rsc.
|
static |
Perform TKIP key mixing, phase 1.
| dctx | TKIP directional context |
| tk | TKIP temporal key |
| mac | MAC address of transmitter |
This recomputes the TTAK in dctx if necessary, and sets dctx->ttak_ok.
Definition at line 217 of file wpa_tkip.c.
References ETH_ALEN, mac, tkip_dir_ctx::mac, memcmp(), memcpy(), S(), tk, tkip_dir_ctx::tsc_hi, tkip_dir_ctx::ttak, and tkip_dir_ctx::ttak_ok.
Referenced by tkip_decrypt(), and tkip_encrypt().
|
static |
Perform TKIP key mixing, phase 2.
| dctx | TKIP directional context |
| tk | TKIP temporal key |
| key | ARC4 key, 16 bytes long |
Definition at line 257 of file wpa_tkip.c.
References key, memcpy(), ror16(), S(), tk, tkip_dir_ctx::tsc_lo, and tkip_dir_ctx::ttak.
Referenced by tkip_decrypt(), and tkip_encrypt().
Update Michael message integrity code based on next 32-bit word of data.
| V | Michael code state (two 32-bit words) |
| word | Next 32-bit word of data |
Definition at line 299 of file wpa_tkip.c.
References rol32(), and ror32().
Referenced by tkip_michael().
|
static |
Calculate Michael message integrity code.
| key | MIC key to use (8 bytes) |
| da | Destination link-layer address |
| sa | Source link-layer address |
| data | Start of data to calculate over |
| len | Length of header + data |
| mic | Calculated Michael MIC (8 bytes) |
Definition at line 322 of file wpa_tkip.c.
References cpu_to_le32, data, end, ETH_ALEN, key, le32_to_cpu, len, memcpy(), mic, sa, and tkip_feed_michael().
Referenced by tkip_decrypt(), and tkip_encrypt().
|
static |
Encrypt a packet using TKIP.
| crypto | TKIP cryptosystem |
| iob | I/O buffer containing cleartext packet |
| eiob | I/O buffer containing encrypted packet |
Definition at line 376 of file wpa_tkip.c.
References alloc_iob(), arc4_algorithm, cipher_encrypt, cipher_setkey(), cpu_to_le32, crc32_le(), ctx, io_buffer::data, datalen, DBGC2, hdr, head, IEEE80211_FC_PROTECTED, IEEE80211_TYP_FRAME_HEADER_LEN, iob_len(), iob_put, key, memcpy(), mic, NULL, net80211_crypto::priv, TKIP_FOOT_LEN, TKIP_HEAD_LEN, TKIP_ICV_LEN, tkip_michael(), tkip_mix_1(), and tkip_mix_2().
|
static |
Decrypt a packet using TKIP.
| crypto | TKIP cryptosystem |
| eiob | I/O buffer containing encrypted packet |
| iob | I/O buffer containing cleartext packet |
Definition at line 446 of file wpa_tkip.c.
References alloc_iob(), arc4_algorithm, cipher_decrypt, cipher_setkey(), crc32_le(), ctx, io_buffer::data, datalen, DBGC, DBGC2, free_iob(), hdr, head, IEEE80211_FC_PROTECTED, IEEE80211_TYP_FRAME_HEADER_LEN, if(), iob_len(), iob_put, key, le32_to_cpu, memcmp(), memcpy(), mic, NULL, net80211_crypto::priv, io_buffer::tail, TKIP_FOOT_LEN, TKIP_HEAD_LEN, TKIP_MIC_LEN, tkip_michael(), tkip_mix_1(), and tkip_mix_2().
|
static |
Calculate HMAC-MD5 MIC for EAPOL-Key frame.
| kck | Key Confirmation Key, 16 bytes |
| msg | Message to calculate MIC over |
| len | Number of bytes to calculate MIC over |
| mic | Calculated MIC, 16 bytes long |
Definition at line 545 of file wpa_tkip.c.
References ctx, hmac_final(), hmac_init(), hmac_update(), kck, len, md5_algorithm, MD5_BLOCK_SIZE, MD5_CTX_SIZE, memcpy(), mic, and msg().
|
static |
Decrypt key data in EAPOL-Key frame.
| kek | Key Encryption Key, 16 bytes |
| iv | Initialisation vector, 16 bytes |
| msg | Message to decrypt |
| len | Length of message |
| msg | Decrypted message in place of original |
| len | Unchanged |
| rc | Always 0 for success |
Definition at line 569 of file wpa_tkip.c.
References arc4_skip(), iv, kek, key, len, memcpy(), and msg().
|
static |
| struct net80211_crypto tkip_crypto __net80211_crypto |
TKIP cryptosystem.
Definition at line 526 of file wpa_tkip.c.
| struct wpa_kie tkip_kie __wpa_kie |
TKIP-style key integrity and encryption handler.
Definition at line 583 of file wpa_tkip.c.
1.8.15