void ieee80211_wep_init(struct ieee80211_local *local)
{ /* start WEP IV from a random value */
get_random_bytes(&local->wep_iv, IEEE80211_WEP_IV_LEN);
}
staticinlinebool ieee80211_wep_weak_iv(u32 iv, int keylen)
{ /* *Fluhrer,Mantin,andShamirhavereportedweaknessesinthe *keyschedulingalgorithmofRC4.AtleastIVs(KeyByte+3, *0xff,N)canbeusedtospeedupattacks,soavoidusingthem.
*/ if ((iv & 0xff00) == 0xff00) {
u8 B = (iv >> 16) & 0xff; if (B >= 3 && B < 3 + keylen) returntrue;
} returnfalse;
}
staticvoid ieee80211_wep_get_iv(struct ieee80211_local *local, int keylen, int keyidx, u8 *iv)
{
local->wep_iv++; if (ieee80211_wep_weak_iv(local->wep_iv, keylen))
local->wep_iv += 0x0100;
/* the HW only needs room for the IV, but not the actual IV */ if (info->control.hw_key &&
(info->control.hw_key->flags & IEEE80211_KEY_FLAG_PUT_IV_SPACE)) return newhdr + hdrlen;
/* Perform WEP encryption using given key. data buffer must have tailroom *for4-byteICV.data_lenmustnotincludethisICV.Note:thisfunction
* does _not_ add IV. data = RC4(data | CRC32(data)) */ int ieee80211_wep_encrypt_data(struct arc4_ctx *ctx, u8 *rc4key,
size_t klen, u8 *data, size_t data_len)
{
__le32 icv;
/* Perform WEP encryption on given skb. 4 bytes of extra space (IV) in the *beginningofthebuffer4bytesofextraspace(ICV)intheendofthe *bufferwillbeadded.BothIVandICVwillbetransmitted,sothe *payloadlengthincreaseswith8bytes. * *WEPframepayload:IV+TXkeyidx,RC4(data),ICV=RC4(CRC32(data))
*/ int ieee80211_wep_encrypt(struct ieee80211_local *local, struct sk_buff *skb, const u8 *key, int keylen, int keyidx)
{
u8 *iv;
size_t len;
u8 rc4key[3 + WLAN_KEY_LEN_WEP104];
if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN)) return -1;
iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); if (!iv) return -1;
len = skb->len - (iv + IEEE80211_WEP_IV_LEN - skb->data);
/* Prepend 24-bit IV to RC4 key */
memcpy(rc4key, iv, 3);
/* Copy rest of the WEP key (the secret part) */
memcpy(rc4key + 3, key, keylen);
/* Add room for ICV */
skb_put(skb, IEEE80211_WEP_ICV_LEN);
/* Perform WEP decryption using given key. data buffer includes encrypted *payload,including4-byteICV,but_not_IV.data_lenmustnotincludeICV.
* Return 0 on success and -1 on ICV mismatch. */ int ieee80211_wep_decrypt_data(struct arc4_ctx *ctx, u8 *rc4key,
size_t klen, u8 *data, size_t data_len)
{
__le32 crc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.