2 .\" Copyright (c) 2004 Bruce M. Simpson <bms@spc.org>
3 .\" Copyright (c) 2004 Darron Broad <darron@kewl.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" $FreeBSD: src/share/man/man9/ieee80211_crypto.9,v 1.6 2010/03/29 17:39:38 trasz Exp $
28 .\" $Id: ieee80211_crypto.9,v 1.3 2004/03/04 10:42:56 bruce Exp $
31 .Dt IEEE80211_CRYPTO 9
35 .Nd 802.11 cryptographic support
39 .In netproto/802_11/ieee80211_var.h
43 .Fn ieee80211_crypto_register "const struct ieee80211_cipher *"
46 .Fn ieee80211_crypto_unregister "const struct ieee80211_cipher *"
49 .Fn ieee80211_crypto_available "int cipher"
53 .Fo ieee80211_notify_replay_failure
54 .Fa "struct ieee80211vap *"
55 .Fa "const struct ieee80211_frame *"
56 .Fa "const struct ieee80211_key *"
62 .Fo ieee80211_notify_michael_failure
63 .Fa "struct ieee80211vap *"
64 .Fa "const struct ieee80211_frame *"
69 .Fo ieee80211_crypto_newkey
70 .Fa "struct ieee80211vap *"
73 .Fa "struct ieee80211_key *"
77 .Fn ieee80211_crypto_setkey "struct ieee80211vap *" "struct ieee80211_key *"
80 .Fn ieee80211_crypto_delkey "struct ieee80211vap *" "struct ieee80211_key *"
83 .Fn ieee80211_key_update_begin "struct ieee80211vap *"
86 .Fn ieee80211_key_update_end "struct ieee80211vap *"
89 .Fn ieee80211_crypto_delglobalkeys "struct ieee80211vap *"
92 .Fn ieee80211_crypto_reload_keys "struct ieee80211com *"
95 .Ft struct ieee80211_key *
96 .Fn ieee80211_crypto_encap "struct ieee80211_node *" "struct mbuf *"
98 .Ft struct ieee80211_key *
99 .Fn ieee80211_crypto_decap "struct ieee80211_node *" "struct mbuf *" "int flags"
102 .Fo ieee80211_crypto_demic
103 .Fa "struct ieee80211vap *"
104 .Fa "struct ieee80211_key *"
110 .Fo ieee80211_crypto_enmic
111 .Fa "struct ieee80211vap *"
112 .Fa "struct ieee80211_key *"
119 layer includes comprehensive cryptographic support for 802.11 protocols.
120 Software implementations of ciphers required by
121 WPA and 802.11i are provided as well as encap/decap processing of 802.11 frames.
122 Software ciphers are written as kernel modules and
123 register with the core crypto support.
124 The cryptographic framework supports hardware acceleration of ciphers
125 by drivers with automatic fall-back to software implementations when a
126 driver is unable to provide necessary hardware services.
127 .Sh CRYPTO CIPHER MODULES
129 cipher modules register their services using
130 .Fn ieee80211_crypto_register
131 and supply a template that describes their operation.
134 structure defines protocol-related state such as the number of bytes
135 of space in the 802.11 header to reserve/remove during encap/decap
136 and entry points for setting up keys and doing cryptographic operations.
138 Cipher modules can associate private state to each key through the
141 If state is setup by the module it will be called before a key is destroyed
142 so it can reclaim resources.
144 Crypto modules can notify the system of two events.
145 When a packet replay event is recognized
146 .Fn ieee80211_notify_replay_failure
147 can be used to signal the event.
150 Michael failure is detected
151 .Fn ieee80211_notify_michael_failure
153 Drivers may also use these routines to signal events detected by the
155 .Sh CRYPTO KEY MANAGEMENT
158 layer implements a per-vap 4-element
162 for protocols such as WPA, 802.1x, and 802.11i.
163 The global key table is designed to support legacy WEP operation
164 and Multicast/Group keys,
165 though some applications also use it to implement WPA in station mode.
166 Keys in the global table are identified by a key index in the range 0-3.
167 Per-station keys are identified by the MAC address of the station and
168 are typically used for unicast PTK bindings.
173 operations for managing both global and per-station keys.
174 Drivers typically do not participate in software key management;
175 they are involved only when providing hardware acceleration of
176 cryptographic operations.
178 .Fn ieee80211_crypto_newkey
179 is used to allocate a new
181 key or reconfigure an existing key.
182 The cipher must be specified along with any fixed key index.
185 layer will handle allocating cipher and driver resources to support the key.
187 Once a key is allocated it's contents can be set using
188 .Fn ieee80211_crypto_setkey
190 .Fn ieee80211_crypto_delkey
191 (with any cipher and driver resources reclaimed).
193 .Fn ieee80211_crypto_delglobalkeys
194 is used to reclaim all keys in the global key table for a vap; it
195 typically is used only within the
199 .Fn ieee80211_crypto_reload_keys
200 handles hardware key state reloading from software key state, such
201 as required after a suspend/resume cycle.
202 .Sh DRIVER CRYPTO SUPPORT
203 Drivers identify ciphers they have hardware support for through the
208 If hardware support is available then a driver should also fill in the
215 created for use with the device.
216 In addition the methods
217 .Dv iv_key_update_begin
219 .Dv iv_key_update_end
220 can be setup to handle synchronization requirements
221 for updating hardware key state.
225 allocates a software key and the driver can accelerate the
226 cipher operations the
228 method will be invoked.
229 Drivers may return a token that is associated with outbound traffic
230 (for use in encrypting frames).
231 Otherwise, e.g. if hardware resources are not available, the driver will
232 not return a token and
234 will arrange to do the work in software and pass frames
235 to the driver that are already prepared for transmission.
237 For receive, drivers mark frames with the
239 mbuf flag to indicate the hardware has decrypted the payload.
241 .Dv IEEE80211_FC1_WEP
242 bit marked in their 802.11 header and are not tagged with
244 then decryption is done in software.
245 For more complicated scenarios the software key state is consulted; e.g.
246 to decide if Michael verification needs to be done in software after
247 the hardware has handled TKIP decryption.
249 Drivers that manage complicated key data structures, e.g. faulting
250 software keys into a hardware key cache, can safely manipulate software
251 key state by bracketing their work with calls to
252 .Fn ieee80211_key_update_begin
254 .Fn ieee80211_key_update_end .
255 These calls also synchronize hardware key state update
256 when receive traffic is active.