for (i = 0; i < 6; i++)
put_unaligned_le16(ppk[i], rc4key + 2 * i);
}
/* Add TKIP IV and Ext. IV at @pos. @iv0, @iv1, and @iv2 are the first octets * of the IV. Returns pointer to the octet following IVs (i.e., beginning of
* the packet payload). */
u8 *ieee80211_tkip_add_iv(u8 *pos, struct ieee80211_key_conf *keyconf, u64 pn)
{
pos = write_tkip_iv(pos, TKIP_PN_TO_IV16(pn));
*pos++ = (keyconf->keyidx << 6) | (1 << 5) /* Ext IV */;
put_unaligned_le32(TKIP_PN_TO_IV32(pn), pos); return pos + 4;
}
EXPORT_SYMBOL_GPL(ieee80211_tkip_add_iv);
/* * Update the P1K when the IV32 is different from the value it * had when we last computed it (or when not initialised yet). * This might flip-flop back and forth if packets are processed * out-of-order due to the different ACs, but then we have to * just compute the P1K more often.
*/ if (ctx->p1k_iv32 != iv32 || ctx->state == TKIP_STATE_NOT_INIT)
tkip_mixing_phase1(tk, ctx, sdata->vif.addr, iv32);
}
/* * Encrypt packet payload with TKIP using @key. @pos is a pointer to the * beginning of the buffer containing payload. This payload must include * the IV/Ext.IV and space for (taildroom) four octets for ICV. * @payload_len is the length of payload (_not_ including IV/ICV length). * @ta is the transmitter addresses.
*/ int ieee80211_tkip_encrypt_data(struct arc4_ctx *ctx, struct ieee80211_key *key, struct sk_buff *skb,
u8 *payload, size_t payload_len)
{
u8 rc4key[16];
/* Decrypt packet payload with TKIP using @key. @pos is a pointer to the * beginning of the buffer containing IEEE 802.11 header payload, i.e., * including IV, Ext. IV, real data, Michael MIC, ICV. @payload_len is the
* length of payload, including IV, Ext. IV, MIC, ICV. */ int ieee80211_tkip_decrypt_data(struct arc4_ctx *ctx, struct ieee80211_key *key,
u8 *payload, size_t payload_len, u8 *ta,
u8 *ra, int only_iv, int queue,
u32 *out_iv32, u16 *out_iv16)
{
u32 iv32;
u32 iv16;
u8 rc4key[16], keyid, *pos = payload; int res; const u8 *tk = &key->conf.key[NL80211_TKIP_DATA_OFFSET_ENCR_KEY]; struct tkip_ctx_rx *rx_ctx = &key->u.tkip.rx[queue];
if (!(keyid & (1 << 5))) return TKIP_DECRYPT_NO_EXT_IV;
if ((keyid >> 6) != key->conf.keyidx) return TKIP_DECRYPT_INVALID_KEYIDX;
/* Reject replays if the received TSC is smaller than or equal to the * last received value in a valid message, but with an exception for * the case where a new key has been set and no valid frame using that * key has yet received and the local RSC was initialized to 0. This * exception allows the very first frame sent by the transmitter to be * accepted even if that transmitter were to use TSC 0 (IEEE 802.11 * described TSC to be initialized to 1 whenever a new key is taken into * use).
*/ if (iv32 < rx_ctx->iv32 ||
(iv32 == rx_ctx->iv32 &&
(iv16 < rx_ctx->iv16 ||
(iv16 == rx_ctx->iv16 &&
(rx_ctx->iv32 || rx_ctx->iv16 ||
rx_ctx->ctx.state != TKIP_STATE_NOT_INIT))))) return TKIP_DECRYPT_REPLAY;
if (only_iv) {
res = TKIP_DECRYPT_OK;
rx_ctx->ctx.state = TKIP_STATE_PHASE1_HW_UPLOADED; goto done;
}
if (rx_ctx->ctx.state == TKIP_STATE_NOT_INIT ||
rx_ctx->iv32 != iv32) { /* IV16 wrapped around - perform TKIP phase 1 */
tkip_mixing_phase1(tk, &rx_ctx->ctx, ta, iv32);
} if (key->local->ops->update_tkip_key &&
key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE &&
rx_ctx->ctx.state != TKIP_STATE_PHASE1_HW_UPLOADED) { struct ieee80211_sub_if_data *sdata = key->sdata;
res = ieee80211_wep_decrypt_data(ctx, rc4key, 16, pos, payload_len - 12);
done: if (res == TKIP_DECRYPT_OK) { /* * Record previously received IV, will be copied into the * key information after MIC verification. It is possible * that we don't catch replays of fragments but that's ok * because the Michael MIC verification will then fail.
*/
*out_iv32 = iv32;
*out_iv16 = iv16;
}
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.