Changeset View
Standalone View
sys/net80211/ieee80211_crypto.h
| Show First 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | |||||
| #define IEEE80211_KEY_CIPHER1 0x00002000 /* cipher-specific action 1 */ | #define IEEE80211_KEY_CIPHER1 0x00002000 /* cipher-specific action 1 */ | ||||
| #define IEEE80211_KEY_NOIV 0x00004000 /* don't insert IV/MIC for !mgmt */ | #define IEEE80211_KEY_NOIV 0x00004000 /* don't insert IV/MIC for !mgmt */ | ||||
| #define IEEE80211_KEY_NOIVMGT 0x00008000 /* don't insert IV/MIC for mgmt */ | #define IEEE80211_KEY_NOIVMGT 0x00008000 /* don't insert IV/MIC for mgmt */ | ||||
| #define IEEE80211_KEY_NOMIC 0x00010000 /* don't insert MIC for !mgmt */ | #define IEEE80211_KEY_NOMIC 0x00010000 /* don't insert MIC for !mgmt */ | ||||
| #define IEEE80211_KEY_NOMICMGT 0x00020000 /* don't insert MIC for mgmt */ | #define IEEE80211_KEY_NOMICMGT 0x00020000 /* don't insert MIC for mgmt */ | ||||
| ieee80211_keyix wk_keyix; /* h/w key index */ | ieee80211_keyix wk_keyix; /* h/w key index */ | ||||
| ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */ | ieee80211_keyix wk_rxkeyix; /* optional h/w rx key index */ | ||||
| /* TODO: deprecate direct access to wk_key, wk_txmic, wk_rxmic */ | |||||
| uint8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; | uint8_t wk_key[IEEE80211_KEYBUF_SIZE+IEEE80211_MICBUF_SIZE]; | ||||
| #define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */ | #define wk_txmic wk_key+IEEE80211_KEYBUF_SIZE+0 /* XXX can't () right */ | ||||
| #define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */ | #define wk_rxmic wk_key+IEEE80211_KEYBUF_SIZE+8 /* XXX can't () right */ | ||||
| /* key receive sequence counter */ | /* key receive sequence counter */ | ||||
| uint64_t wk_keyrsc[IEEE80211_TID_SIZE]; | uint64_t wk_keyrsc[IEEE80211_TID_SIZE]; | ||||
| uint64_t wk_keytsc; /* key transmit sequence counter */ | uint64_t wk_keytsc; /* key transmit sequence counter */ | ||||
| const struct ieee80211_cipher *wk_cipher; | const struct ieee80211_cipher *wk_cipher; | ||||
| void *wk_private; /* private cipher state */ | void *wk_private; /* private cipher state */ | ||||
| ▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | void ieee80211_notify_replay_failure(struct ieee80211vap *, | ||||
| const struct ieee80211_frame *, const struct ieee80211_key *, | const struct ieee80211_frame *, const struct ieee80211_key *, | ||||
| uint64_t rsc, int tid); | uint64_t rsc, int tid); | ||||
| void ieee80211_notify_michael_failure(struct ieee80211vap *, | void ieee80211_notify_michael_failure(struct ieee80211vap *, | ||||
| const struct ieee80211_frame *, ieee80211_keyix keyix); | const struct ieee80211_frame *, ieee80211_keyix keyix); | ||||
| /* AAD assembly for CCMP/GCMP. */ | /* AAD assembly for CCMP/GCMP. */ | ||||
| uint16_t ieee80211_crypto_init_aad(const struct ieee80211_frame *, | uint16_t ieee80211_crypto_init_aad(const struct ieee80211_frame *, | ||||
| uint8_t *, int); | uint8_t *, int); | ||||
| /** | |||||
| * @brief Return the key data. | |||||
| * | |||||
| * This returns a pointer to the key data. Note it does not | |||||
| * guarantee the TX/RX MIC will be immediately after the key. | |||||
| * Callers must use ieee80211_crypto_get_key_txmic_data() | |||||
| * and ieee80211_crypto_get_key_rxmic_data() for that. | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
bz: Just commenting on the first entry. So should this happen only during a… | |||||
adrianAuthorUnsubmitted Done Inline Actionsno, this happens during transmit/receive handling. only key alloc / key set happens inside the key update begin/end session. That said, those should likely get some kind of runtime checks and printing warnings / assertions if they are called outside of it. adrian: no, this happens during transmit/receive handling. only key alloc / key set happens inside the… | |||||
bzUnsubmitted Not Done Inline ActionsOh, sorry, with full offloading key access is only needed during key operations. My fault. But then your comment isn't all right either as it would require holding the com lock for the keys to not disappear and most transmit routines probably do not want that? bz: Oh, sorry, with full offloading key access is only needed during key operations. My fault. | |||||
adrianAuthorUnsubmitted Done Inline ActionsWell, yeah, there are a lot of assumptions in net80211 when the rug can be pulled out from underneath various parallel things. A lot of things weren't once runnable in parallelable contexts! The key rug pull is one of the big reasons why there aren't dynamic keys allocated; in theory as long as the node / vap exists, the key pointers will point to something valid, even if the contents are changed from underneath them. So yeah, we should definitely add "clean up key management locking / sequencing with transmit and receive paths", but that's not part of this diff set! (And it gets spicy, because do you REALLY want to halt all traffic during key changes? Sometimes the answer is yes, sometimes the answer is no..) adrian: Well, yeah, there are a lot of assumptions in net80211 when the rug can be pulled out from… | |||||
adrianAuthorUnsubmitted Done Inline Actionshm, but re-reading my comment, I'll go turn it into more of a warning and explain things a bit. Stay tuned! adrian: hm, but re-reading my comment, I'll go turn it into more of a warning and explain things a bit. | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns NULL if no key data is available, or a pointer | |||||
| * to the key data. | |||||
| */ | |||||
| static inline const uint8_t * | |||||
| ieee80211_crypto_get_key_data(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_key); | |||||
| } | |||||
| /** | |||||
| * @brief Return the key length in bytes. | |||||
| * | |||||
| * This doesn't include any TX/RX MIC (eg from TKIP). | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns the key length (without any MIC) in bytes | |||||
| */ | |||||
| static inline const uint16_t | |||||
| ieee80211_crypto_get_key_len(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_keylen); | |||||
| } | |||||
| /** | |||||
| * @brief Return the TX MIC data. | |||||
| * | |||||
| * This returns a pointer to the TX MIC data. | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns NULL if no key data is available, or a pointer | |||||
| * to the TX MIC data. | |||||
| */ | |||||
| static inline const uint8_t * | |||||
| ieee80211_crypto_get_key_txmic_data(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_txmic); | |||||
| } | |||||
| /** | |||||
| * @brief Return the TX MIC length in bytes. | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns the TX MIC length in bytes | |||||
| */ | |||||
| static inline const uint16_t | |||||
| ieee80211_crypto_get_key_txmic_len(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_cipher->ic_miclen); | |||||
| } | |||||
| /** | |||||
| * @brief Return the RX MIC data. | |||||
| * | |||||
| * This returns a pointer to the RX MIC data. | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns NULL if no key data is available, or a pointer | |||||
| * to the RX MIC data. | |||||
| */ | |||||
| static inline const uint8_t * | |||||
| ieee80211_crypto_get_key_rxmic_data(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_rxmic); | |||||
| } | |||||
| /** | |||||
| * @brief Return the RX MIC length in bytes. | |||||
| * | |||||
| * Note: there's no locking; this needs to be called in | |||||
| * a situation where the ieee80211_key won't disappear. | |||||
| * | |||||
| * @param k ieee80211_key | |||||
| * @returns the RX MIC length in bytes | |||||
| */ | |||||
| static inline const uint16_t | |||||
| ieee80211_crypto_get_key_rxmic_len(const struct ieee80211_key *k) | |||||
| { | |||||
| return (k->wk_cipher->ic_miclen); | |||||
| } | |||||
| #endif /* defined(__KERNEL__) || defined(_KERNEL) */ | #endif /* defined(__KERNEL__) || defined(_KERNEL) */ | ||||
| #endif /* _NET80211_IEEE80211_CRYPTO_H_ */ | #endif /* _NET80211_IEEE80211_CRYPTO_H_ */ | ||||
Just commenting on the first entry. So should this happen only during a iv_key_update_begin/end session, and if so should we make sure we can assert this?