Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net80211/ieee80211_crypto.h
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Lines | |||||
* the cipher is expected to honor this and do the necessary work. | * the cipher is expected to honor this and do the necessary work. | ||||
* Ciphers such as TKIP may also support mixed hardware/software | * Ciphers such as TKIP may also support mixed hardware/software | ||||
* encrypt/decrypt and MIC processing. | * encrypt/decrypt and MIC processing. | ||||
*/ | */ | ||||
typedef uint16_t ieee80211_keyix; /* h/w key index */ | typedef uint16_t ieee80211_keyix; /* h/w key index */ | ||||
struct ieee80211_key { | struct ieee80211_key { | ||||
uint8_t wk_keylen; /* key length in bytes */ | uint8_t wk_keylen; /* key length in bytes */ | ||||
uint8_t wk_pad; | uint8_t wk_pad; /* .. some drivers use this. Fix that. */ | ||||
uint16_t wk_flags; | uint8_t wk_pad1[2]; | ||||
#define IEEE80211_KEY_XMIT 0x0001 /* key used for xmit */ | uint32_t wk_flags; | ||||
#define IEEE80211_KEY_RECV 0x0002 /* key used for recv */ | #define IEEE80211_KEY_XMIT 0x00000001 /* key used for xmit */ | ||||
#define IEEE80211_KEY_GROUP 0x0004 /* key used for WPA group operation */ | #define IEEE80211_KEY_RECV 0x00000002 /* key used for recv */ | ||||
#define IEEE80211_KEY_NOREPLAY 0x0008 /* ignore replay failures */ | #define IEEE80211_KEY_GROUP 0x00000004 /* key used for WPA group operation */ | ||||
#define IEEE80211_KEY_SWENCRYPT 0x0010 /* host-based encrypt */ | #define IEEE80211_KEY_NOREPLAY 0x00000008 /* ignore replay failures */ | ||||
#define IEEE80211_KEY_SWDECRYPT 0x0020 /* host-based decrypt */ | #define IEEE80211_KEY_SWENCRYPT 0x00000010 /* host-based encrypt */ | ||||
#define IEEE80211_KEY_SWENMIC 0x0040 /* host-based enmic */ | #define IEEE80211_KEY_SWDECRYPT 0x00000020 /* host-based decrypt */ | ||||
#define IEEE80211_KEY_SWDEMIC 0x0080 /* host-based demic */ | #define IEEE80211_KEY_SWENMIC 0x00000040 /* host-based enmic */ | ||||
#define IEEE80211_KEY_DEVKEY 0x0100 /* device key request completed */ | #define IEEE80211_KEY_SWDEMIC 0x00000080 /* host-based demic */ | ||||
#define IEEE80211_KEY_CIPHER0 0x1000 /* cipher-specific action 0 */ | #define IEEE80211_KEY_DEVKEY 0x00000100 /* device key request completed */ | ||||
#define IEEE80211_KEY_CIPHER1 0x2000 /* cipher-specific action 1 */ | #define IEEE80211_KEY_CIPHER0 0x00001000 /* cipher-specific action 0 */ | ||||
#define IEEE80211_KEY_CIPHER1 0x00002000 /* cipher-specific action 1 */ | |||||
#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_NOMIC 0x00010000 /* 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 */ | ||||
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 */ | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | |||||
uint8_t ieee80211_crypto_get_keyid(struct ieee80211vap *vap, | uint8_t ieee80211_crypto_get_keyid(struct ieee80211vap *vap, | ||||
struct ieee80211_key *k); | struct ieee80211_key *k); | ||||
struct ieee80211_key *ieee80211_crypto_get_txkey(struct ieee80211_node *, | struct ieee80211_key *ieee80211_crypto_get_txkey(struct ieee80211_node *, | ||||
struct mbuf *); | struct mbuf *); | ||||
struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *, | struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *, | ||||
struct mbuf *); | struct mbuf *); | ||||
struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *, | struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *, | ||||
struct mbuf *, int); | struct mbuf *, int); | ||||
int ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, | |||||
/* | struct mbuf *, int); | ||||
* Check and remove any MIC. | |||||
*/ | |||||
static __inline int | |||||
ieee80211_crypto_demic(struct ieee80211vap *vap, struct ieee80211_key *k, | |||||
struct mbuf *m, int force) | |||||
{ | |||||
const struct ieee80211_cipher *cip = k->wk_cipher; | |||||
return (cip->ic_miclen > 0 ? cip->ic_demic(k, m, force) : 1); | |||||
} | |||||
/* | /* | ||||
* Add any MIC. | * Add any MIC. | ||||
*/ | */ | ||||
static __inline int | static __inline int | ||||
ieee80211_crypto_enmic(struct ieee80211vap *vap, | ieee80211_crypto_enmic(struct ieee80211vap *vap, | ||||
struct ieee80211_key *k, struct mbuf *m, int force) | struct ieee80211_key *k, struct mbuf *m, int force) | ||||
{ | { | ||||
const struct ieee80211_cipher *cip = k->wk_cipher; | const struct ieee80211_cipher *cip = k->wk_cipher; | ||||
Show All 28 Lines |