FreeBSD kernel WLAN code
ieee80211_crypto.c File Reference
#include <sys/cdefs.h>
#include "opt_wlan.h"
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_media.h>
#include <net/ethernet.h>
#include <net80211/ieee80211_var.h>
Include dependency graph for ieee80211_crypto.c:

Go to the source code of this file.

Macros

#define IEEE80211_WEP_HDRLEN   (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)
 
#define IEEE80211_WEP_MINLEN
 

Functions

 __FBSDID ("$FreeBSD$")
 
 MALLOC_DEFINE (M_80211_CRYPTO, "80211crypto", "802.11 crypto state")
 
static int _ieee80211_crypto_delkey (struct ieee80211vap *, struct ieee80211_key *)
 
static int null_key_alloc (struct ieee80211vap *vap, struct ieee80211_key *k, ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
 
static int null_key_delete (struct ieee80211vap *vap, const struct ieee80211_key *k)
 
static int null_key_set (struct ieee80211vap *vap, const struct ieee80211_key *k)
 
static void null_key_update (struct ieee80211vap *vap)
 
static __inline void cipher_detach (struct ieee80211_key *key)
 
static __inline void * cipher_attach (struct ieee80211vap *vap, struct ieee80211_key *key)
 
static __inline int dev_key_alloc (struct ieee80211vap *vap, struct ieee80211_key *key, ieee80211_keyix *keyix, ieee80211_keyix *rxkeyix)
 
static __inline int dev_key_delete (struct ieee80211vap *vap, const struct ieee80211_key *key)
 
static __inline int dev_key_set (struct ieee80211vap *vap, const struct ieee80211_key *key)
 
void ieee80211_crypto_attach (struct ieee80211com *ic)
 
void ieee80211_crypto_detach (struct ieee80211com *ic)
 
void ieee80211_crypto_vattach (struct ieee80211vap *vap)
 
void ieee80211_crypto_vdetach (struct ieee80211vap *vap)
 
void ieee80211_crypto_register (const struct ieee80211_cipher *cip)
 
void ieee80211_crypto_unregister (const struct ieee80211_cipher *cip)
 
int ieee80211_crypto_available (u_int cipher)
 
 CTASSERT ((IEEE80211_KEY_COMMON &IEEE80211_KEY_DEVICE)==0)
 
int ieee80211_crypto_newkey (struct ieee80211vap *vap, int cipher, int flags, struct ieee80211_key *key)
 
int ieee80211_crypto_delkey (struct ieee80211vap *vap, struct ieee80211_key *key)
 
void ieee80211_crypto_delglobalkeys (struct ieee80211vap *vap)
 
int ieee80211_crypto_setkey (struct ieee80211vap *vap, struct ieee80211_key *key)
 
int ieee80211_crypto_get_key_wepidx (const struct ieee80211vap *vap, const struct ieee80211_key *k)
 
uint8_t ieee80211_crypto_get_keyid (struct ieee80211vap *vap, struct ieee80211_key *k)
 
struct ieee80211_keyieee80211_crypto_get_txkey (struct ieee80211_node *ni, struct mbuf *m)
 
struct ieee80211_keyieee80211_crypto_encap (struct ieee80211_node *ni, struct mbuf *m)
 
int ieee80211_crypto_decap (struct ieee80211_node *ni, struct mbuf *m, int hdrlen, struct ieee80211_key **key)
 
int ieee80211_crypto_demic (struct ieee80211vap *vap, struct ieee80211_key *k, struct mbuf *m, int force)
 
static void load_ucastkey (void *arg, struct ieee80211_node *ni)
 
void ieee80211_crypto_reload_keys (struct ieee80211com *ic)
 
void ieee80211_crypto_set_deftxkey (struct ieee80211vap *vap, ieee80211_keyix kid)
 

Variables

static const struct ieee80211_cipherciphers [IEEE80211_CIPHER_MAX]
 
static const char * cipher_modnames [IEEE80211_CIPHER_MAX]
 

Macro Definition Documentation

◆ IEEE80211_WEP_HDRLEN

#define IEEE80211_WEP_HDRLEN   (IEEE80211_WEP_IVLEN + IEEE80211_WEP_KIDLEN)

◆ IEEE80211_WEP_MINLEN

#define IEEE80211_WEP_MINLEN
Value:
(sizeof(struct ieee80211_frame) + \
#define IEEE80211_WEP_CRCLEN
Definition: ieee80211.h:1333
#define IEEE80211_WEP_HDRLEN

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ _ieee80211_crypto_delkey()

◆ cipher_attach()

static __inline void * cipher_attach ( struct ieee80211vap vap,
struct ieee80211_key key 
)
static

Definition at line 110 of file ieee80211_crypto.c.

References ieee80211_cipher::ic_attach, and ieee80211_key::wk_cipher.

◆ cipher_detach()

static __inline void cipher_detach ( struct ieee80211_key key)
static

Definition at line 104 of file ieee80211_crypto.c.

References ieee80211_cipher::ic_detach, and ieee80211_key::wk_cipher.

Referenced by _ieee80211_crypto_delkey(), and ieee80211_crypto_newkey().

Here is the caller graph for this function:

◆ CTASSERT()

◆ dev_key_alloc()

static __inline int dev_key_alloc ( struct ieee80211vap vap,
struct ieee80211_key key,
ieee80211_keyix keyix,
ieee80211_keyix rxkeyix 
)
static

Definition at line 119 of file ieee80211_crypto.c.

References ieee80211vap::iv_key_alloc.

Referenced by ieee80211_crypto_newkey().

Here is the caller graph for this function:

◆ dev_key_delete()

static __inline int dev_key_delete ( struct ieee80211vap vap,
const struct ieee80211_key key 
)
static

Definition at line 127 of file ieee80211_crypto.c.

References ieee80211vap::iv_key_delete.

Referenced by _ieee80211_crypto_delkey().

Here is the caller graph for this function:

◆ dev_key_set()

static __inline int dev_key_set ( struct ieee80211vap vap,
const struct ieee80211_key key 
)
static

Definition at line 134 of file ieee80211_crypto.c.

References ieee80211vap::iv_key_set.

Referenced by ieee80211_crypto_reload_keys(), ieee80211_crypto_setkey(), and load_ucastkey().

Here is the caller graph for this function:

◆ ieee80211_crypto_attach()

void ieee80211_crypto_attach ( struct ieee80211com ic)

Definition at line 143 of file ieee80211_crypto.c.

References ciphers, IEEE80211_CIPHER_NONE, and ieee80211_cipher_none.

Referenced by ieee80211_ifattach().

Here is the caller graph for this function:

◆ ieee80211_crypto_available()

int ieee80211_crypto_available ( u_int  cipher)

Definition at line 232 of file ieee80211_crypto.c.

References ciphers, and IEEE80211_CIPHER_MAX.

◆ ieee80211_crypto_decap()

◆ ieee80211_crypto_delglobalkeys()

void ieee80211_crypto_delglobalkeys ( struct ieee80211vap vap)

Definition at line 471 of file ieee80211_crypto.c.

References _ieee80211_crypto_delkey(), ieee80211_key_update_begin(), ieee80211_key_update_end(), IEEE80211_WEP_NKID, and ieee80211vap::iv_nw_keys.

Referenced by ieee80211_crypto_vdetach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ieee80211_crypto_delkey()

int ieee80211_crypto_delkey ( struct ieee80211vap vap,
struct ieee80211_key key 
)

Definition at line 457 of file ieee80211_crypto.c.

References _ieee80211_crypto_delkey(), ieee80211_key_update_begin(), and ieee80211_key_update_end().

Referenced by ieee80211_ioctl_delkey(), ieee80211_ioctl_set80211(), and ieee80211_node_delucastkey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ieee80211_crypto_demic()

int ieee80211_crypto_demic ( struct ieee80211vap vap,
struct ieee80211_key k,
struct mbuf *  m,
int  force 
)

◆ ieee80211_crypto_detach()

void ieee80211_crypto_detach ( struct ieee80211com ic)

Definition at line 153 of file ieee80211_crypto.c.

Referenced by ieee80211_ifdetach().

Here is the caller graph for this function:

◆ ieee80211_crypto_encap()

struct ieee80211_key * ieee80211_crypto_encap ( struct ieee80211_node ni,
struct mbuf *  m 
)

Definition at line 588 of file ieee80211_crypto.c.

References ieee80211_cipher::ic_encap, ieee80211_crypto_get_txkey(), and ieee80211_key::wk_cipher.

Here is the call graph for this function:

◆ ieee80211_crypto_get_key_wepidx()

int ieee80211_crypto_get_key_wepidx ( const struct ieee80211vap vap,
const struct ieee80211_key k 
)

Definition at line 532 of file ieee80211_crypto.c.

References IEEE80211_WEP_NKID, and ieee80211vap::iv_nw_keys.

Referenced by null_key_alloc().

Here is the caller graph for this function:

◆ ieee80211_crypto_get_keyid()

uint8_t ieee80211_crypto_get_keyid ( struct ieee80211vap vap,
struct ieee80211_key k 
)

Definition at line 546 of file ieee80211_crypto.c.

References IEEE80211_WEP_NKID, and ieee80211vap::iv_nw_keys.

Referenced by ccmp_setiv(), none_encap(), tkip_setiv(), and wep_setiv().

Here is the caller graph for this function:

◆ ieee80211_crypto_get_txkey()

◆ ieee80211_crypto_newkey()

◆ ieee80211_crypto_register()

void ieee80211_crypto_register ( const struct ieee80211_cipher cip)

◆ ieee80211_crypto_reload_keys()

void ieee80211_crypto_reload_keys ( struct ieee80211com ic)

◆ ieee80211_crypto_set_deftxkey()

void ieee80211_crypto_set_deftxkey ( struct ieee80211vap vap,
ieee80211_keyix  kid 
)

Definition at line 800 of file ieee80211_crypto.c.

References ieee80211vap::iv_update_deftxkey.

Referenced by ieee80211_ioctl_set80211(), and ieee80211_ioctl_setkey().

Here is the caller graph for this function:

◆ ieee80211_crypto_setkey()

◆ ieee80211_crypto_unregister()

void ieee80211_crypto_unregister ( const struct ieee80211_cipher cip)

◆ ieee80211_crypto_vattach()

◆ ieee80211_crypto_vdetach()

void ieee80211_crypto_vdetach ( struct ieee80211vap vap)

Definition at line 186 of file ieee80211_crypto.c.

References ieee80211_crypto_delglobalkeys().

Referenced by ieee80211_vap_detach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_ucastkey()

static void load_ucastkey ( void *  arg,
struct ieee80211_node ni 
)
static

Definition at line 751 of file ieee80211_crypto.c.

References dev_key_set(), IEEE80211_KEY_DEVKEY, IEEE80211_S_RUN, ieee80211vap::iv_state, ieee80211_node::ni_ucastkey, ieee80211_node::ni_vap, and ieee80211_key::wk_flags.

Referenced by ieee80211_crypto_reload_keys().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_80211_CRYPTO  ,
"80211crypto"  ,
"802.11 crypto state"   
)

◆ null_key_alloc()

static int null_key_alloc ( struct ieee80211vap vap,
struct ieee80211_key k,
ieee80211_keyix keyix,
ieee80211_keyix rxkeyix 
)
static

Definition at line 64 of file ieee80211_crypto.c.

References ieee80211_crypto_get_key_wepidx(), IEEE80211_KEY_GROUP, IEEE80211_KEYIX_NONE, IEEE80211_WEP_NKID, ieee80211vap::iv_nw_keys, and ieee80211_key::wk_flags.

Referenced by ieee80211_crypto_vattach().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ null_key_delete()

static int null_key_delete ( struct ieee80211vap vap,
const struct ieee80211_key k 
)
static

Definition at line 89 of file ieee80211_crypto.c.

Referenced by ieee80211_crypto_vattach().

Here is the caller graph for this function:

◆ null_key_set()

static int null_key_set ( struct ieee80211vap vap,
const struct ieee80211_key k 
)
static

Definition at line 94 of file ieee80211_crypto.c.

Referenced by ieee80211_crypto_vattach().

Here is the caller graph for this function:

◆ null_key_update()

static void null_key_update ( struct ieee80211vap vap)
static

Definition at line 98 of file ieee80211_crypto.c.

Referenced by ieee80211_crypto_vattach().

Here is the caller graph for this function:

Variable Documentation

◆ cipher_modnames

const char* cipher_modnames[IEEE80211_CIPHER_MAX]
static
Initial value:
= {
[IEEE80211_CIPHER_WEP] = "wlan_wep",
[IEEE80211_CIPHER_TKIP] = "wlan_tkip",
[IEEE80211_CIPHER_AES_OCB] = "wlan_aes_ocb",
[IEEE80211_CIPHER_AES_CCM] = "wlan_ccmp",
[IEEE80211_CIPHER_CKIP] = "wlan_ckip",
[IEEE80211_CIPHER_NONE] = "wlan_none",
}
#define IEEE80211_CIPHER_WEP
#define IEEE80211_CIPHER_NONE
#define IEEE80211_CIPHER_CKIP
#define IEEE80211_CIPHER_AES_CCM
#define IEEE80211_CIPHER_AES_OCB
#define IEEE80211_CIPHER_TKIPMIC
#define IEEE80211_CIPHER_TKIP

Definition at line 238 of file ieee80211_crypto.c.

Referenced by ieee80211_crypto_newkey().

◆ ciphers