1214503Srpaulohostapd - user space IEEE 802.11 AP and IEEE 802.1X/WPA/WPA2/EAP
2214503Srpaulo	  Authenticator and RADIUS authentication server
3214503Srpaulo================================================================
4214503Srpaulo
5281806SrpauloCopyright (c) 2002-2015, Jouni Malinen <j@w1.fi> and contributors
6214503SrpauloAll Rights Reserved.
7214503Srpaulo
8252726SrpauloThis program is licensed under the BSD license (the one with
9252726Srpauloadvertisement clause removed).
10214503Srpaulo
11252726SrpauloIf you are submitting changes to the project, please see CONTRIBUTIONS
12252726Srpaulofile for more instructions.
13214503Srpaulo
14214503Srpaulo
15252726Srpaulo
16214503SrpauloLicense
17214503Srpaulo-------
18214503Srpaulo
19252726SrpauloThis software may be distributed, used, and modified under the terms of
20252726SrpauloBSD license:
21214503Srpaulo
22214503SrpauloRedistribution and use in source and binary forms, with or without
23214503Srpaulomodification, are permitted provided that the following conditions are
24214503Srpaulomet:
25214503Srpaulo
26214503Srpaulo1. Redistributions of source code must retain the above copyright
27214503Srpaulo   notice, this list of conditions and the following disclaimer.
28214503Srpaulo
29214503Srpaulo2. Redistributions in binary form must reproduce the above copyright
30214503Srpaulo   notice, this list of conditions and the following disclaimer in the
31214503Srpaulo   documentation and/or other materials provided with the distribution.
32214503Srpaulo
33214503Srpaulo3. Neither the name(s) of the above-listed copyright holder(s) nor the
34214503Srpaulo   names of its contributors may be used to endorse or promote products
35214503Srpaulo   derived from this software without specific prior written permission.
36214503Srpaulo
37214503SrpauloTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38214503Srpaulo"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39214503SrpauloLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40214503SrpauloA PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41214503SrpauloOWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42214503SrpauloSPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43214503SrpauloLIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44214503SrpauloDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45214503SrpauloTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46214503Srpaulo(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47214503SrpauloOF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48214503Srpaulo
49214503Srpaulo
50214503Srpaulo
51214503SrpauloIntroduction
52214503Srpaulo============
53214503Srpaulo
54214503SrpauloOriginally, hostapd was an optional user space component for Host AP
55214503Srpaulodriver. It adds more features to the basic IEEE 802.11 management
56214503Srpauloincluded in the kernel driver: using external RADIUS authentication
57214503Srpauloserver for MAC address based access control, IEEE 802.1X Authenticator
58214503Srpauloand dynamic WEP keying, RADIUS accounting, WPA/WPA2 (IEEE 802.11i/RSN)
59214503SrpauloAuthenticator and dynamic TKIP/CCMP keying.
60214503Srpaulo
61214503SrpauloThe current version includes support for other drivers, an integrated
62214503SrpauloEAP server (i.e., allow full authentication without requiring
63214503Srpauloan external RADIUS authentication server), and RADIUS authentication
64214503Srpauloserver for EAP authentication.
65214503Srpaulo
66214503Srpaulo
67214503SrpauloRequirements
68214503Srpaulo------------
69214503Srpaulo
70214503SrpauloCurrent hardware/software requirements:
71214503Srpaulo- drivers:
72214503Srpaulo	Host AP driver for Prism2/2.5/3.
73214503Srpaulo	(http://hostap.epitest.fi/)
74214503Srpaulo	Please note that station firmware version needs to be 1.7.0 or newer
75214503Srpaulo	to work in WPA mode.
76214503Srpaulo
77214503Srpaulo	mac80211-based drivers that support AP mode (with driver=nl80211).
78214503Srpaulo	This includes drivers for Atheros (ath9k) and Broadcom (b43)
79214503Srpaulo	chipsets.
80214503Srpaulo
81214503Srpaulo	Any wired Ethernet driver for wired IEEE 802.1X authentication
82214503Srpaulo	(experimental code)
83214503Srpaulo
84214503Srpaulo	FreeBSD -current (with some kernel mods that have not yet been
85214503Srpaulo	committed when hostapd v0.3.0 was released)
86214503Srpaulo	BSD net80211 layer (e.g., Atheros driver)
87214503Srpaulo
88214503Srpaulo
89214503SrpauloBuild configuration
90214503Srpaulo-------------------
91214503Srpaulo
92214503SrpauloIn order to be able to build hostapd, you will need to create a build
93214503Srpaulotime configuration file, .config that selects which optional
94214503Srpaulocomponents are included. See defconfig file for example configuration
95214503Srpauloand list of available options.
96214503Srpaulo
97214503Srpaulo
98214503Srpaulo
99214503SrpauloIEEE 802.1X
100214503Srpaulo===========
101214503Srpaulo
102214503SrpauloIEEE Std 802.1X-2001 is a standard for port-based network access
103214503Srpaulocontrol. In case of IEEE 802.11 networks, a "virtual port" is used
104214503Srpaulobetween each associated station and the AP. IEEE 802.11 specifies
105214503Srpaulominimal authentication mechanism for stations, whereas IEEE 802.1X
106214503Srpaulointroduces a extensible mechanism for authenticating and authorizing
107214503Srpaulousers.
108214503Srpaulo
109214503SrpauloIEEE 802.1X uses elements called Supplicant, Authenticator, Port
110214503SrpauloAccess Entity, and Authentication Server. Supplicant is a component in
111214503Srpauloa station and it performs the authentication with the Authentication
112214503SrpauloServer. An access point includes an Authenticator that relays the packets
113214503Srpaulobetween a Supplicant and an Authentication Server. In addition, it has a
114214503SrpauloPort Access Entity (PAE) with Authenticator functionality for
115214503Srpaulocontrolling the virtual port authorization, i.e., whether to accept
116214503Srpaulopackets from or to the station.
117214503Srpaulo
118214503SrpauloIEEE 802.1X uses Extensible Authentication Protocol (EAP). The frames
119214503Srpaulobetween a Supplicant and an Authenticator are sent using EAP over LAN
120214503Srpaulo(EAPOL) and the Authenticator relays these frames to the Authentication
121214503SrpauloServer (and similarly, relays the messages from the Authentication
122214503SrpauloServer to the Supplicant). The Authentication Server can be colocated with the
123214503SrpauloAuthenticator, in which case there is no need for additional protocol
124214503Srpaulofor EAP frame transmission. However, a more common configuration is to
125214503Srpaulouse an external Authentication Server and encapsulate EAP frame in the
126214503Srpauloframes used by that server. RADIUS is suitable for this, but IEEE
127214503Srpaulo802.1X would also allow other mechanisms.
128214503Srpaulo
129214503SrpauloHost AP driver includes PAE functionality in the kernel driver. It
130214503Srpaulois a relatively simple mechanism for denying normal frames going to
131214503Srpauloor coming from an unauthorized port. PAE allows IEEE 802.1X related
132214503Srpauloframes to be passed between the Supplicant and the Authenticator even
133214503Srpauloon an unauthorized port.
134214503Srpaulo
135214503SrpauloUser space daemon, hostapd, includes Authenticator functionality. It
136214503Srpauloreceives 802.1X (EAPOL) frames from the Supplicant using the wlan#ap
137214503Srpaulodevice that is also used with IEEE 802.11 management frames. The
138214503Srpauloframes to the Supplicant are sent using the same device.
139214503Srpaulo
140214503SrpauloThe normal configuration of the Authenticator would use an external
141214503SrpauloAuthentication Server. hostapd supports RADIUS encapsulation of EAP
142214503Srpaulopackets, so the Authentication Server should be a RADIUS server, like
143214503SrpauloFreeRADIUS (http://www.freeradius.org/). The Authenticator in hostapd
144214503Srpaulorelays the frames between the Supplicant and the Authentication
145214503SrpauloServer. It also controls the PAE functionality in the kernel driver by
146214503Srpaulocontrolling virtual port authorization, i.e., station-AP
147214503Srpauloconnection, based on the IEEE 802.1X state.
148214503Srpaulo
149214503SrpauloWhen a station would like to use the services of an access point, it
150214503Srpaulowill first perform IEEE 802.11 authentication. This is normally done
151214503Srpaulowith open systems authentication, so there is no security. After
152214503Srpaulothis, IEEE 802.11 association is performed. If IEEE 802.1X is
153214503Srpauloconfigured to be used, the virtual port for the station is set in
154214503SrpauloUnauthorized state and only IEEE 802.1X frames are accepted at this
155214503Srpaulopoint. The Authenticator will then ask the Supplicant to authenticate
156214503Srpaulowith the Authentication Server. After this is completed successfully,
157214503Srpaulothe virtual port is set to Authorized state and frames from and to the
158214503Srpaulostation are accepted.
159214503Srpaulo
160214503SrpauloHost AP configuration for IEEE 802.1X
161214503Srpaulo-------------------------------------
162214503Srpaulo
163214503SrpauloThe user space daemon has its own configuration file that can be used to
164214503Srpaulodefine AP options. Distribution package contains an example
165214503Srpauloconfiguration file (hostapd/hostapd.conf) that can be used as a basis
166214503Srpaulofor configuration. It includes examples of all supported configuration
167214503Srpaulooptions and short description of each option. hostapd should be started
168214503Srpaulowith full path to the configuration file as the command line argument,
169214503Srpauloe.g., './hostapd /etc/hostapd.conf'. If you have more that one wireless
170214503SrpauloLAN card, you can use one hostapd process for multiple interfaces by
171214503Srpaulogiving a list of configuration files (one per interface) in the command
172214503Srpauloline.
173214503Srpaulo
174214503Srpaulohostapd includes a minimal co-located IEEE 802.1X server which can be
175214503Srpauloused to test IEEE 802.1X authentication. However, it should not be
176214503Srpauloused in normal use since it does not provide any security. This can be
177214503Srpauloconfigured by setting ieee8021x and minimal_eap options in the
178214503Srpauloconfiguration file.
179214503Srpaulo
180214503SrpauloAn external Authentication Server (RADIUS) is configured with
181214503Srpauloauth_server_{addr,port,shared_secret} options. In addition,
182214503Srpauloieee8021x and own_ip_addr must be set for this mode. With such
183214503Srpauloconfiguration, the co-located Authentication Server is not used and EAP
184214503Srpauloframes will be relayed using EAPOL between the Supplicant and the
185214503SrpauloAuthenticator and RADIUS encapsulation between the Authenticator and
186214503Srpaulothe Authentication Server. Other than this, the functionality is similar
187214503Srpauloto the case with the co-located Authentication Server.
188214503Srpaulo
189214503SrpauloAuthentication Server and Supplicant
190214503Srpaulo------------------------------------
191214503Srpaulo
192214503SrpauloAny RADIUS server supporting EAP should be usable as an IEEE 802.1X
193214503SrpauloAuthentication Server with hostapd Authenticator. FreeRADIUS
194214503Srpaulo(http://www.freeradius.org/) has been successfully tested with hostapd
195214503SrpauloAuthenticator and both Xsupplicant (http://www.open1x.org) and Windows
196214503SrpauloXP Supplicants. EAP/TLS was used with Xsupplicant and
197214503SrpauloEAP/MD5-Challenge with Windows XP.
198214503Srpaulo
199214503Srpaulohttp://www.missl.cs.umd.edu/wireless/eaptls/ has useful information
200214503Srpauloabout using EAP/TLS with FreeRADIUS and Xsupplicant (just replace
201214503SrpauloCisco access point with Host AP driver, hostapd daemon, and a Prism2
202214503Srpaulocard ;-). http://www.freeradius.org/doc/EAP-MD5.html has information
203214503Srpauloabout using EAP/MD5 with FreeRADIUS, including instructions for WinXP
204214503Srpauloconfiguration. http://www.denobula.com/EAPTLS.pdf has a HOWTO on
205214503SrpauloEAP/TLS use with WinXP Supplicant.
206214503Srpaulo
207214503SrpauloAutomatic WEP key configuration
208214503Srpaulo-------------------------------
209214503Srpaulo
210214503SrpauloEAP/TLS generates a session key that can be used to send WEP keys from
211214503Srpauloan AP to authenticated stations. The Authenticator in hostapd can be
212214503Srpauloconfigured to automatically select a random default/broadcast key
213214503Srpaulo(shared by all authenticated stations) with wep_key_len_broadcast
214214503Srpaulooption (5 for 40-bit WEP or 13 for 104-bit WEP). In addition,
215214503Srpaulowep_key_len_unicast option can be used to configure individual unicast
216214503Srpaulokeys for stations. This requires support for individual keys in the
217214503Srpaulostation driver.
218214503Srpaulo
219214503SrpauloWEP keys can be automatically updated by configuring rekeying. This
220214503Srpaulowill improve security of the network since same WEP key will only be
221214503Srpauloused for a limited period of time. wep_rekey_period option sets the
222214503Srpaulointerval for rekeying in seconds.
223214503Srpaulo
224214503Srpaulo
225214503SrpauloWPA/WPA2
226214503Srpaulo========
227214503Srpaulo
228214503SrpauloFeatures
229214503Srpaulo--------
230214503Srpaulo
231214503SrpauloSupported WPA/IEEE 802.11i features:
232214503Srpaulo- WPA-PSK ("WPA-Personal")
233214503Srpaulo- WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
234214503Srpaulo- key management for CCMP, TKIP, WEP104, WEP40
235214503Srpaulo- RSN/WPA2 (IEEE 802.11i), including PMKSA caching and pre-authentication
236214503Srpaulo
237214503SrpauloWPA
238214503Srpaulo---
239214503Srpaulo
240214503SrpauloThe original security mechanism of IEEE 802.11 standard was not
241214503Srpaulodesigned to be strong and has proved to be insufficient for most
242214503Srpaulonetworks that require some kind of security. Task group I (Security)
243214503Srpauloof IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
244214503Srpauloto address the flaws of the base standard and has in practice
245214503Srpaulocompleted its work in May 2004. The IEEE 802.11i amendment to the IEEE
246214503Srpaulo802.11 standard was approved in June 2004 and this amendment is likely
247214503Srpauloto be published in July 2004.
248214503Srpaulo
249214503SrpauloWi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
250214503SrpauloIEEE 802.11i work (draft 3.0) to define a subset of the security
251214503Srpauloenhancements that can be implemented with existing wlan hardware. This
252214503Srpaulois called Wi-Fi Protected Access<TM> (WPA). This has now become a
253214503Srpaulomandatory component of interoperability testing and certification done
254214503Srpauloby Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
255214503Srpaulosite (http://www.wi-fi.org/OpenSection/protected_access.asp).
256214503Srpaulo
257214503SrpauloIEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
258214503Srpaulofor protecting wireless networks. WEP uses RC4 with 40-bit keys,
259214503Srpaulo24-bit initialization vector (IV), and CRC32 to protect against packet
260214503Srpauloforgery. All these choices have proven to be insufficient: key space is
261214503Srpaulotoo small against current attacks, RC4 key scheduling is insufficient
262214503Srpaulo(beginning of the pseudorandom stream should be skipped), IV space is
263214503Srpaulotoo small and IV reuse makes attacks easier, there is no replay
264214503Srpauloprotection, and non-keyed authentication does not protect against bit
265214503Srpauloflipping packet data.
266214503Srpaulo
267214503SrpauloWPA is an intermediate solution for the security issues. It uses
268214503SrpauloTemporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
269214503Srpaulocompromise on strong security and possibility to use existing
270214503Srpaulohardware. It still uses RC4 for the encryption like WEP, but with
271214503Srpauloper-packet RC4 keys. In addition, it implements replay protection,
272214503Srpaulokeyed packet authentication mechanism (Michael MIC).
273214503Srpaulo
274214503SrpauloKeys can be managed using two different mechanisms. WPA can either use
275214503Srpauloan external authentication server (e.g., RADIUS) and EAP just like
276214503SrpauloIEEE 802.1X is using or pre-shared keys without need for additional
277214503Srpauloservers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
278214503Srpaulorespectively. Both mechanisms will generate a master session key for
279214503Srpaulothe Authenticator (AP) and Supplicant (client station).
280214503Srpaulo
281214503SrpauloWPA implements a new key handshake (4-Way Handshake and Group Key
282214503SrpauloHandshake) for generating and exchanging data encryption keys between
283214503Srpaulothe Authenticator and Supplicant. This handshake is also used to
284214503Srpauloverify that both Authenticator and Supplicant know the master session
285214503Srpaulokey. These handshakes are identical regardless of the selected key
286214503Srpaulomanagement mechanism (only the method for generating master session
287214503Srpaulokey changes).
288214503Srpaulo
289214503Srpaulo
290214503SrpauloIEEE 802.11i / WPA2
291214503Srpaulo-------------------
292214503Srpaulo
293214503SrpauloThe design for parts of IEEE 802.11i that were not included in WPA has
294214503Srpaulofinished (May 2004) and this amendment to IEEE 802.11 was approved in
295214503SrpauloJune 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
296214503Srpauloversion of WPA called WPA2. This includes, e.g., support for more
297214503Srpaulorobust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
298214503Srpauloto replace TKIP and optimizations for handoff (reduced number of
299214503Srpaulomessages in initial key handshake, pre-authentication, and PMKSA caching).
300214503Srpaulo
301214503SrpauloSome wireless LAN vendors are already providing support for CCMP in
302214503Srpaulotheir WPA products. There is no "official" interoperability
303214503Srpaulocertification for CCMP and/or mixed modes using both TKIP and CCMP, so
304214503Srpaulosome interoperability issues can be expected even though many
305214503Srpaulocombinations seem to be working with equipment from different vendors.
306214503SrpauloTesting for WPA2 is likely to start during the second half of 2004.
307214503Srpaulo
308214503Srpaulohostapd configuration for WPA/WPA2
309214503Srpaulo----------------------------------
310214503Srpaulo
311214503SrpauloTODO
312214503Srpaulo
313214503Srpaulo# Enable WPA. Setting this variable configures the AP to require WPA (either
314214503Srpaulo# WPA-PSK or WPA-RADIUS/EAP based on other configuration). For WPA-PSK, either
315214503Srpaulo# wpa_psk or wpa_passphrase must be set and wpa_key_mgmt must include WPA-PSK.
316214503Srpaulo# For WPA-RADIUS/EAP, ieee8021x must be set (but without dynamic WEP keys),
317214503Srpaulo# RADIUS authentication server must be configured, and WPA-EAP must be included
318214503Srpaulo# in wpa_key_mgmt.
319214503Srpaulo# This field is a bit field that can be used to enable WPA (IEEE 802.11i/D3.0)
320214503Srpaulo# and/or WPA2 (full IEEE 802.11i/RSN):
321214503Srpaulo# bit0 = WPA
322214503Srpaulo# bit1 = IEEE 802.11i/RSN (WPA2)
323214503Srpaulo#wpa=1
324214503Srpaulo
325214503Srpaulo# WPA pre-shared keys for WPA-PSK. This can be either entered as a 256-bit
326214503Srpaulo# secret in hex format (64 hex digits), wpa_psk, or as an ASCII passphrase
327214503Srpaulo# (8..63 characters) that will be converted to PSK. This conversion uses SSID
328214503Srpaulo# so the PSK changes when ASCII passphrase is used and the SSID is changed.
329214503Srpaulo#wpa_psk=0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
330214503Srpaulo#wpa_passphrase=secret passphrase
331214503Srpaulo
332214503Srpaulo# Set of accepted key management algorithms (WPA-PSK, WPA-EAP, or both). The
333214503Srpaulo# entries are separated with a space.
334214503Srpaulo#wpa_key_mgmt=WPA-PSK WPA-EAP
335214503Srpaulo
336214503Srpaulo# Set of accepted cipher suites (encryption algorithms) for pairwise keys
337214503Srpaulo# (unicast packets). This is a space separated list of algorithms:
338214503Srpaulo# CCMP = AES in Counter mode with CBC-MAC [RFC 3610, IEEE 802.11i]
339214503Srpaulo# TKIP = Temporal Key Integrity Protocol [IEEE 802.11i]
340214503Srpaulo# Group cipher suite (encryption algorithm for broadcast and multicast frames)
341214503Srpaulo# is automatically selected based on this configuration. If only CCMP is
342214503Srpaulo# allowed as the pairwise cipher, group cipher will also be CCMP. Otherwise,
343214503Srpaulo# TKIP will be used as the group cipher.
344214503Srpaulo#wpa_pairwise=TKIP CCMP
345214503Srpaulo
346214503Srpaulo# Time interval for rekeying GTK (broadcast/multicast encryption keys) in
347214503Srpaulo# seconds.
348214503Srpaulo#wpa_group_rekey=600
349214503Srpaulo
350214503Srpaulo# Time interval for rekeying GMK (master key used internally to generate GTKs
351214503Srpaulo# (in seconds).
352214503Srpaulo#wpa_gmk_rekey=86400
353214503Srpaulo
354214503Srpaulo# Enable IEEE 802.11i/RSN/WPA2 pre-authentication. This is used to speed up
355214503Srpaulo# roaming be pre-authenticating IEEE 802.1X/EAP part of the full RSN
356214503Srpaulo# authentication and key handshake before actually associating with a new AP.
357214503Srpaulo#rsn_preauth=1
358214503Srpaulo#
359214503Srpaulo# Space separated list of interfaces from which pre-authentication frames are
360214503Srpaulo# accepted (e.g., 'eth0' or 'eth0 wlan0wds0'. This list should include all
361214503Srpaulo# interface that are used for connections to other APs. This could include
362214503Srpaulo# wired interfaces and WDS links. The normal wireless data interface towards
363214503Srpaulo# associated stations (e.g., wlan0) should not be added, since
364214503Srpaulo# pre-authentication is only used with APs other than the currently associated
365214503Srpaulo# one.
366214503Srpaulo#rsn_preauth_interfaces=eth0
367