506a90737c4c09425b6bb90709afb30494a7ce03
[mech_eap.git] / wpa_supplicant / README
1 WPA Supplicant
2 ==============
3
4 Copyright (c) 2003-2011, Jouni Malinen <j@w1.fi> and contributors
5 All Rights Reserved.
6
7 This program is dual-licensed under both the GPL version 2 and BSD
8 license. Either license may be used at your option.
9
10
11
12 License
13 -------
14
15 GPL v2:
16
17 This program is free software; you can redistribute it and/or modify
18 it under the terms of the GNU General Public License version 2 as
19 published by the Free Software Foundation.
20
21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24 GNU General Public License for more details.
25
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
29
30 (this copy of the license is in COPYING file)
31
32
33 Alternatively, this software may be distributed, used, and modified
34 under the terms of BSD license:
35
36 Redistribution and use in source and binary forms, with or without
37 modification, are permitted provided that the following conditions are
38 met:
39
40 1. Redistributions of source code must retain the above copyright
41    notice, this list of conditions and the following disclaimer.
42
43 2. Redistributions in binary form must reproduce the above copyright
44    notice, this list of conditions and the following disclaimer in the
45    documentation and/or other materials provided with the distribution.
46
47 3. Neither the name(s) of the above-listed copyright holder(s) nor the
48    names of its contributors may be used to endorse or promote products
49    derived from this software without specific prior written permission.
50
51 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
52 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
53 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
54 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
55 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
56 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
57 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
58 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
59 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
60 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
61 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
62
63
64
65 Features
66 --------
67
68 Supported WPA/IEEE 802.11i features:
69 - WPA-PSK ("WPA-Personal")
70 - WPA with EAP (e.g., with RADIUS authentication server) ("WPA-Enterprise")
71   Following authentication methods are supported with an integrate IEEE 802.1X
72   Supplicant:
73   * EAP-TLS
74   * EAP-PEAP/MSCHAPv2 (both PEAPv0 and PEAPv1)
75   * EAP-PEAP/TLS (both PEAPv0 and PEAPv1)
76   * EAP-PEAP/GTC (both PEAPv0 and PEAPv1)
77   * EAP-PEAP/OTP (both PEAPv0 and PEAPv1)
78   * EAP-PEAP/MD5-Challenge (both PEAPv0 and PEAPv1)
79   * EAP-TTLS/EAP-MD5-Challenge
80   * EAP-TTLS/EAP-GTC
81   * EAP-TTLS/EAP-OTP
82   * EAP-TTLS/EAP-MSCHAPv2
83   * EAP-TTLS/EAP-TLS
84   * EAP-TTLS/MSCHAPv2
85   * EAP-TTLS/MSCHAP
86   * EAP-TTLS/PAP
87   * EAP-TTLS/CHAP
88   * EAP-SIM
89   * EAP-AKA
90   * EAP-PSK
91   * EAP-PAX
92   * EAP-SAKE
93   * EAP-IKEv2
94   * EAP-GPSK
95   * LEAP (note: requires special support from the driver for IEEE 802.11
96           authentication)
97   (following methods are supported, but since they do not generate keying
98    material, they cannot be used with WPA or IEEE 802.1X WEP keying)
99   * EAP-MD5-Challenge 
100   * EAP-MSCHAPv2
101   * EAP-GTC
102   * EAP-OTP
103 - key management for CCMP, TKIP, WEP104, WEP40
104 - RSN/WPA2 (IEEE 802.11i)
105   * pre-authentication
106   * PMKSA caching
107
108 Supported TLS/crypto libraries:
109 - OpenSSL (default)
110 - GnuTLS
111
112 Internal TLS/crypto implementation (optional):
113 - can be used in place of an external TLS/crypto library
114 - TLSv1
115 - X.509 certificate processing
116 - PKCS #1
117 - ASN.1
118 - RSA
119 - bignum
120 - minimal size (ca. 50 kB binary, parts of which are already needed for WPA;
121   TLSv1/X.509/ASN.1/RSA/bignum parts are about 25 kB on x86)
122
123
124 Requirements
125 ------------
126
127 Current hardware/software requirements:
128 - Linux kernel 2.4.x or 2.6.x with Linux Wireless Extensions v15 or newer
129 - FreeBSD 6-CURRENT
130 - NetBSD-current
131 - Microsoft Windows with WinPcap (at least WinXP, may work with other versions)
132 - drivers:
133         Linux drivers that support WPA/WPA2 configuration with the generic
134         Linux wireless extensions (WE-18 or newer). Even though there are
135         number of driver specific interface included in wpa_supplicant, please
136         note that Linux drivers are moving to use generic wireless extensions
137         and driver_wext (-Dwext on wpa_supplicant command line) should be the
138         default option to start with before falling back to driver specific
139         interface.
140
141         Host AP driver for Prism2/2.5/3 (development snapshot/v0.2.x)
142         (http://hostap.epitest.fi/)
143         Driver need to be set in Managed mode ('iwconfig wlan0 mode managed').
144         Please note that station firmware version needs to be 1.7.0 or newer
145         to work in WPA mode.
146
147         Linuxant DriverLoader (http://www.linuxant.com/driverloader/)
148         with Windows NDIS driver for your wlan card supporting WPA.
149
150         madwifi driver for cards based on Atheros chip set (ar521x)
151         (http://sourceforge.net/projects/madwifi/)
152         Please note that you will need to modify the wpa_supplicant .config
153         file to use the correct path for the madwifi driver root directory
154         (CFLAGS += -I../madwifi/wpa line in example defconfig).
155
156         Linux ndiswrapper (http://ndiswrapper.sourceforge.net/) with
157         Windows NDIS driver.
158
159         Broadcom wl.o driver (old version only)
160         This is a generic Linux driver for Broadcom IEEE 802.11a/g cards.
161         However, it is proprietary driver that is not publicly available
162         except for couple of exceptions, mainly Broadcom-based APs/wireless
163         routers that use Linux. The driver binary can be downloaded, e.g.,
164         from Linksys support site (http://www.linksys.com/support/gpl.asp)
165         for Linksys WRT54G. The GPL tarball includes cross-compiler and
166         the needed header file, wlioctl.h, for compiling wpa_supplicant.
167         This driver support in wpa_supplicant is expected to work also with
168         other devices based on Broadcom driver (assuming the driver includes
169         client mode support). Please note that the newer Broadcom driver
170         ("hybrid Linux driver") supports Linux wireless extensions and does
171         not need (or even work) with the specific driver wrapper. Use -Dwext
172         with that driver.
173
174         In theory, any driver that supports Linux wireless extensions can be
175         used with IEEE 802.1X (i.e., not WPA) when using ap_scan=0 option in
176         configuration file.
177
178         Wired Ethernet drivers (with ap_scan=0)
179
180         BSD net80211 layer (e.g., Atheros driver)
181         At the moment, this is for FreeBSD 6-CURRENT branch and NetBSD-current.
182
183         Windows NDIS
184         The current Windows port requires WinPcap (http://winpcap.polito.it/).
185         See README-Windows.txt for more information.
186
187 wpa_supplicant was designed to be portable for different drivers and
188 operating systems. Hopefully, support for more wlan cards and OSes will be
189 added in the future. See developer's documentation
190 (http://hostap.epitest.fi/wpa_supplicant/devel/) for more information about the
191 design of wpa_supplicant and porting to other drivers. One main goal
192 is to add full WPA/WPA2 support to Linux wireless extensions to allow
193 new drivers to be supported without having to implement new
194 driver-specific interface code in wpa_supplicant.
195
196 Optional libraries for layer2 packet processing:
197 - libpcap (tested with 0.7.2, most relatively recent versions assumed to work,
198         this is likely to be available with most distributions,
199         http://tcpdump.org/)
200 - libdnet (tested with v1.4, most versions assumed to work,
201         http://libdnet.sourceforge.net/)
202
203 These libraries are _not_ used in the default Linux build. Instead,
204 internal Linux specific implementation is used. libpcap/libdnet are
205 more portable and they can be used by adding CONFIG_L2_PACKET=pcap into
206 .config. They may also be selected automatically for other operating
207 systems. In case of Windows builds, WinPcap is used by default
208 (CONFIG_L2_PACKET=winpcap).
209
210
211 Optional libraries for EAP-TLS, EAP-PEAP, and EAP-TTLS:
212 - OpenSSL (tested with 0.9.7c and 0.9.7d, and 0.9.8 versions; assumed to
213   work with most relatively recent versions; this is likely to be
214   available with most distributions, http://www.openssl.org/)
215 - GnuTLS
216 - internal TLSv1 implementation
217
218 TLS options for EAP-FAST:
219 - OpenSSL 0.9.8d _with_ openssl-0.9.8d-tls-extensions.patch applied
220   (i.e., the default OpenSSL package does not include support for
221   extensions needed for EAP-FAST)
222 - internal TLSv1 implementation
223
224 One of these libraries is needed when EAP-TLS, EAP-PEAP, EAP-TTLS, or
225 EAP-FAST support is enabled. WPA-PSK mode does not require this or EAPOL/EAP
226 implementation. A configuration file, .config, for compilation is
227 needed to enable IEEE 802.1X/EAPOL and EAP methods. Note that EAP-MD5,
228 EAP-GTC, EAP-OTP, and EAP-MSCHAPV2 cannot be used alone with WPA, so
229 they should only be enabled if testing the EAPOL/EAP state
230 machines. However, there can be used as inner authentication
231 algorithms with EAP-PEAP and EAP-TTLS.
232
233 See Building and installing section below for more detailed
234 information about the wpa_supplicant build time configuration.
235
236
237
238 WPA
239 ---
240
241 The original security mechanism of IEEE 802.11 standard was not
242 designed to be strong and has proven to be insufficient for most
243 networks that require some kind of security. Task group I (Security)
244 of IEEE 802.11 working group (http://www.ieee802.org/11/) has worked
245 to address the flaws of the base standard and has in practice
246 completed its work in May 2004. The IEEE 802.11i amendment to the IEEE
247 802.11 standard was approved in June 2004 and published in July 2004.
248
249 Wi-Fi Alliance (http://www.wi-fi.org/) used a draft version of the
250 IEEE 802.11i work (draft 3.0) to define a subset of the security
251 enhancements that can be implemented with existing wlan hardware. This
252 is called Wi-Fi Protected Access<TM> (WPA). This has now become a
253 mandatory component of interoperability testing and certification done
254 by Wi-Fi Alliance. Wi-Fi provides information about WPA at its web
255 site (http://www.wi-fi.org/OpenSection/protected_access.asp).
256
257 IEEE 802.11 standard defined wired equivalent privacy (WEP) algorithm
258 for protecting wireless networks. WEP uses RC4 with 40-bit keys,
259 24-bit initialization vector (IV), and CRC32 to protect against packet
260 forgery. All these choices have proven to be insufficient: key space is
261 too small against current attacks, RC4 key scheduling is insufficient
262 (beginning of the pseudorandom stream should be skipped), IV space is
263 too small and IV reuse makes attacks easier, there is no replay
264 protection, and non-keyed authentication does not protect against bit
265 flipping packet data.
266
267 WPA is an intermediate solution for the security issues. It uses
268 Temporal Key Integrity Protocol (TKIP) to replace WEP. TKIP is a
269 compromise on strong security and possibility to use existing
270 hardware. It still uses RC4 for the encryption like WEP, but with
271 per-packet RC4 keys. In addition, it implements replay protection,
272 keyed packet authentication mechanism (Michael MIC).
273
274 Keys can be managed using two different mechanisms. WPA can either use
275 an external authentication server (e.g., RADIUS) and EAP just like
276 IEEE 802.1X is using or pre-shared keys without need for additional
277 servers. Wi-Fi calls these "WPA-Enterprise" and "WPA-Personal",
278 respectively. Both mechanisms will generate a master session key for
279 the Authenticator (AP) and Supplicant (client station).
280
281 WPA implements a new key handshake (4-Way Handshake and Group Key
282 Handshake) for generating and exchanging data encryption keys between
283 the Authenticator and Supplicant. This handshake is also used to
284 verify that both Authenticator and Supplicant know the master session
285 key. These handshakes are identical regardless of the selected key
286 management mechanism (only the method for generating master session
287 key changes).
288
289
290
291 IEEE 802.11i / WPA2
292 -------------------
293
294 The design for parts of IEEE 802.11i that were not included in WPA has
295 finished (May 2004) and this amendment to IEEE 802.11 was approved in
296 June 2004. Wi-Fi Alliance is using the final IEEE 802.11i as a new
297 version of WPA called WPA2. This includes, e.g., support for more
298 robust encryption algorithm (CCMP: AES in Counter mode with CBC-MAC)
299 to replace TKIP and optimizations for handoff (reduced number of
300 messages in initial key handshake, pre-authentication, and PMKSA caching).
301
302
303
304 wpa_supplicant
305 --------------
306
307 wpa_supplicant is an implementation of the WPA Supplicant component,
308 i.e., the part that runs in the client stations. It implements WPA key
309 negotiation with a WPA Authenticator and EAP authentication with
310 Authentication Server. In addition, it controls the roaming and IEEE
311 802.11 authentication/association of the wlan driver.
312
313 wpa_supplicant is designed to be a "daemon" program that runs in the
314 background and acts as the backend component controlling the wireless
315 connection. wpa_supplicant supports separate frontend programs and an
316 example text-based frontend, wpa_cli, is included with wpa_supplicant.
317
318 Following steps are used when associating with an AP using WPA:
319
320 - wpa_supplicant requests the kernel driver to scan neighboring BSSes
321 - wpa_supplicant selects a BSS based on its configuration
322 - wpa_supplicant requests the kernel driver to associate with the chosen
323   BSS
324 - If WPA-EAP: integrated IEEE 802.1X Supplicant completes EAP
325   authentication with the authentication server (proxied by the
326   Authenticator in the AP)
327 - If WPA-EAP: master key is received from the IEEE 802.1X Supplicant
328 - If WPA-PSK: wpa_supplicant uses PSK as the master session key
329 - wpa_supplicant completes WPA 4-Way Handshake and Group Key Handshake
330   with the Authenticator (AP)
331 - wpa_supplicant configures encryption keys for unicast and broadcast
332 - normal data packets can be transmitted and received
333
334
335
336 Building and installing
337 -----------------------
338
339 In order to be able to build wpa_supplicant, you will first need to
340 select which parts of it will be included. This is done by creating a
341 build time configuration file, .config, in the wpa_supplicant root
342 directory. Configuration options are text lines using following
343 format: CONFIG_<option>=y. Lines starting with # are considered
344 comments and are ignored. See defconfig file for an example configuration
345 and a list of available options and additional notes.
346
347 The build time configuration can be used to select only the needed
348 features and limit the binary size and requirements for external
349 libraries. The main configuration parts are the selection of which
350 driver interfaces (e.g., hostap, madwifi, ..) and which authentication
351 methods (e.g., EAP-TLS, EAP-PEAP, ..) are included.
352
353 Following build time configuration options are used to control IEEE
354 802.1X/EAPOL and EAP state machines and all EAP methods. Including
355 TLS, PEAP, or TTLS will require linking wpa_supplicant with OpenSSL
356 library for TLS implementation. Alternatively, GnuTLS or the internal
357 TLSv1 implementation can be used for TLS functionaly.
358
359 CONFIG_IEEE8021X_EAPOL=y
360 CONFIG_EAP_MD5=y
361 CONFIG_EAP_MSCHAPV2=y
362 CONFIG_EAP_TLS=y
363 CONFIG_EAP_PEAP=y
364 CONFIG_EAP_TTLS=y
365 CONFIG_EAP_GTC=y
366 CONFIG_EAP_OTP=y
367 CONFIG_EAP_SIM=y
368 CONFIG_EAP_AKA=y
369 CONFIG_EAP_PSK=y
370 CONFIG_EAP_SAKE=y
371 CONFIG_EAP_GPSK=y
372 CONFIG_EAP_PAX=y
373 CONFIG_EAP_LEAP=y
374 CONFIG_EAP_IKEV2=y
375
376 Following option can be used to include GSM SIM/USIM interface for GSM/UMTS
377 authentication algorithm (for EAP-SIM/EAP-AKA). This requires pcsc-lite
378 (http://www.linuxnet.com/) for smart card access.
379
380 CONFIG_PCSC=y
381
382 Following options can be added to .config to select which driver
383 interfaces are included.
384
385 CONFIG_DRIVER_HOSTAP=y
386 CONFIG_DRIVER_MADWIFI=y
387 CONFIG_DRIVER_WEXT=y
388 CONFIG_DRIVER_RALINK=y
389 CONFIG_DRIVER_BROADCOM=y
390 CONFIG_DRIVER_BSD=y
391 CONFIG_DRIVER_NDIS=y
392
393 Following example includes all features and driver interfaces that are
394 included in the wpa_supplicant package:
395
396 CONFIG_DRIVER_HOSTAP=y
397 CONFIG_DRIVER_MADWIFI=y
398 CONFIG_DRIVER_WEXT=y
399 CONFIG_DRIVER_BROADCOM=y
400 CONFIG_DRIVER_BSD=y
401 CONFIG_DRIVER_NDIS=y
402 CONFIG_IEEE8021X_EAPOL=y
403 CONFIG_EAP_MD5=y
404 CONFIG_EAP_MSCHAPV2=y
405 CONFIG_EAP_TLS=y
406 CONFIG_EAP_PEAP=y
407 CONFIG_EAP_TTLS=y
408 CONFIG_EAP_GTC=y
409 CONFIG_EAP_OTP=y
410 CONFIG_EAP_SIM=y
411 CONFIG_EAP_AKA=y
412 CONFIG_EAP_PSK=y
413 CONFIG_EAP_SAKE=y
414 CONFIG_EAP_GPSK=y
415 CONFIG_EAP_PAX=y
416 CONFIG_EAP_LEAP=y
417 CONFIG_EAP_IKEV2=y
418 CONFIG_PCSC=y
419
420 EAP-PEAP and EAP-TTLS will automatically include configured EAP
421 methods (MD5, OTP, GTC, MSCHAPV2) for inner authentication selection.
422
423
424 After you have created a configuration file, you can build
425 wpa_supplicant and wpa_cli with 'make' command. You may then install
426 the binaries to a suitable system directory, e.g., /usr/local/bin.
427
428 Example commands:
429
430 # build wpa_supplicant and wpa_cli
431 make
432 # install binaries (this may need root privileges)
433 cp wpa_cli wpa_supplicant /usr/local/bin
434
435
436 You will need to make a configuration file, e.g.,
437 /etc/wpa_supplicant.conf, with network configuration for the networks
438 you are going to use. Configuration file section below includes
439 explanation fo the configuration file format and includes various
440 examples. Once the configuration is ready, you can test whether the
441 configuration work by first running wpa_supplicant with following
442 command to start it on foreground with debugging enabled:
443
444 wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -d
445
446 Assuming everything goes fine, you can start using following command
447 to start wpa_supplicant on background without debugging:
448
449 wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
450
451 Please note that if you included more than one driver interface in the
452 build time configuration (.config), you may need to specify which
453 interface to use by including -D<driver name> option on the command
454 line. See following section for more details on command line options
455 for wpa_supplicant.
456
457
458
459 Command line options
460 --------------------
461
462 usage:
463   wpa_supplicant [-BddfhKLqqtuvwW] [-P<pid file>] [-g<global ctrl>] \
464         -i<ifname> -c<config file> [-C<ctrl>] [-D<driver>] [-p<driver_param>] \
465         [-b<br_ifname> [-N -i<ifname> -c<conf> [-C<ctrl>] [-D<driver>] \
466         [-p<driver_param>] [-b<br_ifname>] ...]
467
468 options:
469   -b = optional bridge interface name
470   -B = run daemon in the background
471   -c = Configuration file
472   -C = ctrl_interface parameter (only used if -c is not)
473   -i = interface name
474   -d = increase debugging verbosity (-dd even more)
475   -D = driver name (can be multiple drivers: nl80211,wext)
476   -f = Log output to default log location (normally /tmp)
477   -g = global ctrl_interface
478   -K = include keys (passwords, etc.) in debug output
479   -t = include timestamp in debug messages
480   -h = show this help text
481   -L = show license (GPL and BSD)
482   -p = driver parameters
483   -P = PID file
484   -q = decrease debugging verbosity (-qq even less)
485   -u = enable DBus control interface
486   -v = show version
487   -w = wait for interface to be added, if needed
488   -W = wait for a control interface monitor before starting
489   -N = start describing new interface
490
491 drivers:
492   hostap = Host AP driver (Intersil Prism2/2.5/3) [default]
493         (this can also be used with Linuxant DriverLoader)
494   madwifi = MADWIFI 802.11 support (Atheros, etc.) (deprecated; use wext)
495   wext = Linux wireless extensions (generic)
496   ralink = Ralink Client driver
497   broadcom = Broadcom wl.o driver
498   wired = wpa_supplicant wired Ethernet driver
499   roboswitch = wpa_supplicant Broadcom switch driver
500   bsd = BSD 802.11 support (Atheros, etc.)
501   ndis = Windows NDIS driver
502
503 In most common cases, wpa_supplicant is started with
504
505 wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
506
507 This makes the process fork into background.
508
509 The easiest way to debug problems, and to get debug log for bug
510 reports, is to start wpa_supplicant on foreground with debugging
511 enabled:
512
513 wpa_supplicant -c/etc/wpa_supplicant.conf -iwlan0 -d
514
515 If the specific driver wrapper is not known beforehand, it is possible
516 to specify multiple comma separated driver wrappers on the command
517 line. wpa_supplicant will use the first driver wrapper that is able to
518 initialize the interface.
519
520 wpa_supplicant -Dnl80211,wext -c/etc/wpa_supplicant.conf -iwlan0
521
522
523 wpa_supplicant can control multiple interfaces (radios) either by
524 running one process for each interface separately or by running just
525 one process and list of options at command line. Each interface is
526 separated with -N argument. As an example, following command would
527 start wpa_supplicant for two interfaces:
528
529 wpa_supplicant \
530         -c wpa1.conf -i wlan0 -D hostap -N \
531         -c wpa2.conf -i ath0 -D madwifi
532
533
534 If the interface is added in a Linux bridge (e.g., br0), the bridge
535 interface needs to be configured to wpa_supplicant in addition to the
536 main interface:
537
538 wpa_supplicant -cw.conf -Dmadwifi -iath0 -bbr0
539
540
541 Configuration file
542 ------------------
543
544 wpa_supplicant is configured using a text file that lists all accepted
545 networks and security policies, including pre-shared keys. See
546 example configuration file, wpa_supplicant.conf, for detailed
547 information about the configuration format and supported fields.
548
549 Changes to configuration file can be reloaded be sending SIGHUP signal
550 to wpa_supplicant ('killall -HUP wpa_supplicant'). Similarly,
551 reloading can be triggered with 'wpa_cli reconfigure' command.
552
553 Configuration file can include one or more network blocks, e.g., one
554 for each used SSID. wpa_supplicant will automatically select the best
555 betwork based on the order of network blocks in the configuration
556 file, network security level (WPA/WPA2 is preferred), and signal
557 strength.
558
559 Example configuration files for some common configurations:
560
561 1) WPA-Personal (PSK) as home network and WPA-Enterprise with EAP-TLS as work
562    network
563
564 # allow frontend (e.g., wpa_cli) to be used by all users in 'wheel' group
565 ctrl_interface=/var/run/wpa_supplicant
566 ctrl_interface_group=wheel
567 #
568 # home network; allow all valid ciphers
569 network={
570         ssid="home"
571         scan_ssid=1
572         key_mgmt=WPA-PSK
573         psk="very secret passphrase"
574 }
575 #
576 # work network; use EAP-TLS with WPA; allow only CCMP and TKIP ciphers
577 network={
578         ssid="work"
579         scan_ssid=1
580         key_mgmt=WPA-EAP
581         pairwise=CCMP TKIP
582         group=CCMP TKIP
583         eap=TLS
584         identity="user@example.com"
585         ca_cert="/etc/cert/ca.pem"
586         client_cert="/etc/cert/user.pem"
587         private_key="/etc/cert/user.prv"
588         private_key_passwd="password"
589 }
590
591
592 2) WPA-RADIUS/EAP-PEAP/MSCHAPv2 with RADIUS servers that use old peaplabel
593    (e.g., Funk Odyssey and SBR, Meetinghouse Aegis, Interlink RAD-Series)
594
595 ctrl_interface=/var/run/wpa_supplicant
596 ctrl_interface_group=wheel
597 network={
598         ssid="example"
599         scan_ssid=1
600         key_mgmt=WPA-EAP
601         eap=PEAP
602         identity="user@example.com"
603         password="foobar"
604         ca_cert="/etc/cert/ca.pem"
605         phase1="peaplabel=0"
606         phase2="auth=MSCHAPV2"
607 }
608
609
610 3) EAP-TTLS/EAP-MD5-Challenge configuration with anonymous identity for the
611    unencrypted use. Real identity is sent only within an encrypted TLS tunnel.
612
613 ctrl_interface=/var/run/wpa_supplicant
614 ctrl_interface_group=wheel
615 network={
616         ssid="example"
617         scan_ssid=1
618         key_mgmt=WPA-EAP
619         eap=TTLS
620         identity="user@example.com"
621         anonymous_identity="anonymous@example.com"
622         password="foobar"
623         ca_cert="/etc/cert/ca.pem"
624         phase2="auth=MD5"
625 }
626
627
628 4) IEEE 802.1X (i.e., no WPA) with dynamic WEP keys (require both unicast and
629    broadcast); use EAP-TLS for authentication
630
631 ctrl_interface=/var/run/wpa_supplicant
632 ctrl_interface_group=wheel
633 network={
634         ssid="1x-test"
635         scan_ssid=1
636         key_mgmt=IEEE8021X
637         eap=TLS
638         identity="user@example.com"
639         ca_cert="/etc/cert/ca.pem"
640         client_cert="/etc/cert/user.pem"
641         private_key="/etc/cert/user.prv"
642         private_key_passwd="password"
643         eapol_flags=3
644 }
645
646
647 5) Catch all example that allows more or less all configuration modes. The
648    configuration options are used based on what security policy is used in the
649    selected SSID. This is mostly for testing and is not recommended for normal
650    use.
651
652 ctrl_interface=/var/run/wpa_supplicant
653 ctrl_interface_group=wheel
654 network={
655         ssid="example"
656         scan_ssid=1
657         key_mgmt=WPA-EAP WPA-PSK IEEE8021X NONE
658         pairwise=CCMP TKIP
659         group=CCMP TKIP WEP104 WEP40
660         psk="very secret passphrase"
661         eap=TTLS PEAP TLS
662         identity="user@example.com"
663         password="foobar"
664         ca_cert="/etc/cert/ca.pem"
665         client_cert="/etc/cert/user.pem"
666         private_key="/etc/cert/user.prv"
667         private_key_passwd="password"
668         phase1="peaplabel=0"
669         ca_cert2="/etc/cert/ca2.pem"
670         client_cert2="/etc/cer/user.pem"
671         private_key2="/etc/cer/user.prv"
672         private_key2_passwd="password"
673 }
674
675
676 6) Authentication for wired Ethernet. This can be used with 'wired' or
677    'roboswitch' interface (-Dwired or -Droboswitch on command line).
678
679 ctrl_interface=/var/run/wpa_supplicant
680 ctrl_interface_group=wheel
681 ap_scan=0
682 network={
683         key_mgmt=IEEE8021X
684         eap=MD5
685         identity="user"
686         password="password"
687         eapol_flags=0
688 }
689
690
691
692 Certificates
693 ------------
694
695 Some EAP authentication methods require use of certificates. EAP-TLS
696 uses both server side and client certificates whereas EAP-PEAP and
697 EAP-TTLS only require the server side certificate. When client
698 certificate is used, a matching private key file has to also be
699 included in configuration. If the private key uses a passphrase, this
700 has to be configured in wpa_supplicant.conf ("private_key_passwd").
701
702 wpa_supplicant supports X.509 certificates in PEM and DER
703 formats. User certificate and private key can be included in the same
704 file.
705
706 If the user certificate and private key is received in PKCS#12/PFX
707 format, they need to be converted to suitable PEM/DER format for
708 wpa_supplicant. This can be done, e.g., with following commands:
709
710 # convert client certificate and private key to PEM format
711 openssl pkcs12 -in example.pfx -out user.pem -clcerts
712 # convert CA certificate (if included in PFX file) to PEM format
713 openssl pkcs12 -in example.pfx -out ca.pem -cacerts -nokeys
714
715
716
717 wpa_cli
718 -------
719
720 wpa_cli is a text-based frontend program for interacting with
721 wpa_supplicant. It is used to query current status, change
722 configuration, trigger events, and request interactive user input.
723
724 wpa_cli can show the current authentication status, selected security
725 mode, dot11 and dot1x MIBs, etc. In addition, it can configure some
726 variables like EAPOL state machine parameters and trigger events like
727 reassociation and IEEE 802.1X logoff/logon. wpa_cli provides a user
728 interface to request authentication information, like username and
729 password, if these are not included in the configuration. This can be
730 used to implement, e.g., one-time-passwords or generic token card
731 authentication where the authentication is based on a
732 challenge-response that uses an external device for generating the
733 response.
734
735 The control interface of wpa_supplicant can be configured to allow
736 non-root user access (ctrl_interface_group in the configuration
737 file). This makes it possible to run wpa_cli with a normal user
738 account.
739
740 wpa_cli supports two modes: interactive and command line. Both modes
741 share the same command set and the main difference is in interactive
742 mode providing access to unsolicited messages (event messages,
743 username/password requests).
744
745 Interactive mode is started when wpa_cli is executed without including
746 the command as a command line parameter. Commands are then entered on
747 the wpa_cli prompt. In command line mode, the same commands are
748 entered as command line arguments for wpa_cli.
749
750
751 Interactive authentication parameters request
752
753 When wpa_supplicant need authentication parameters, like username and
754 password, which are not present in the configuration file, it sends a
755 request message to all attached frontend programs, e.g., wpa_cli in
756 interactive mode. wpa_cli shows these requests with
757 "CTRL-REQ-<type>-<id>:<text>" prefix. <type> is IDENTITY, PASSWORD, or
758 OTP (one-time-password). <id> is a unique identifier for the current
759 network. <text> is description of the request. In case of OTP request,
760 it includes the challenge from the authentication server.
761
762 The reply to these requests can be given with 'identity', 'password',
763 and 'otp' commands. <id> needs to be copied from the the matching
764 request. 'password' and 'otp' commands can be used regardless of
765 whether the request was for PASSWORD or OTP. The main difference
766 between these two commands is that values given with 'password' are
767 remembered as long as wpa_supplicant is running whereas values given
768 with 'otp' are used only once and then forgotten, i.e., wpa_supplicant
769 will ask frontend for a new value for every use. This can be used to
770 implement one-time-password lists and generic token card -based
771 authentication.
772
773 Example request for password and a matching reply:
774
775 CTRL-REQ-PASSWORD-1:Password needed for SSID foobar
776 > password 1 mysecretpassword
777
778 Example request for generic token card challenge-response:
779
780 CTRL-REQ-OTP-2:Challenge 1235663 needed for SSID foobar
781 > otp 2 9876
782
783
784 wpa_cli commands
785
786   status = get current WPA/EAPOL/EAP status
787   mib = get MIB variables (dot1x, dot11)
788   help = show this usage help
789   interface [ifname] = show interfaces/select interface
790   level <debug level> = change debug level
791   license = show full wpa_cli license
792   logoff = IEEE 802.1X EAPOL state machine logoff
793   logon = IEEE 802.1X EAPOL state machine logon
794   set = set variables (shows list of variables when run without arguments)
795   pmksa = show PMKSA cache
796   reassociate = force reassociation
797   reconfigure = force wpa_supplicant to re-read its configuration file
798   preauthenticate <BSSID> = force preauthentication
799   identity <network id> <identity> = configure identity for an SSID
800   password <network id> <password> = configure password for an SSID
801   pin <network id> <pin> = configure pin for an SSID
802   otp <network id> <password> = configure one-time-password for an SSID
803   passphrase <network id> <passphrase> = configure private key passphrase
804     for an SSID
805   bssid <network id> <BSSID> = set preferred BSSID for an SSID
806   list_networks = list configured networks
807   select_network <network id> = select a network (disable others)
808   enable_network <network id> = enable a network
809   disable_network <network id> = disable a network
810   add_network = add a network
811   remove_network <network id> = remove a network
812   set_network <network id> <variable> <value> = set network variables (shows
813     list of variables when run without arguments)
814   get_network <network id> <variable> = get network variables
815   save_config = save the current configuration
816   disconnect = disconnect and wait for reassociate command before connecting
817   scan = request new BSS scan
818   scan_results = get latest scan results
819   get_capability <eap/pairwise/group/key_mgmt/proto/auth_alg> = get capabilies
820   terminate = terminate wpa_supplicant
821   quit = exit wpa_cli
822
823
824 wpa_cli command line options
825
826 wpa_cli [-p<path to ctrl sockets>] [-i<ifname>] [-hvB] [-a<action file>] \
827         [-P<pid file>] [-g<global ctrl>]  [command..]
828   -h = help (show this usage text)
829   -v = shown version information
830   -a = run in daemon mode executing the action file based on events from
831        wpa_supplicant
832   -B = run a daemon in the background
833   default path: /var/run/wpa_supplicant
834   default interface: first interface found in socket path
835
836
837 Using wpa_cli to run external program on connect/disconnect
838 -----------------------------------------------------------
839
840 wpa_cli can used to run external programs whenever wpa_supplicant
841 connects or disconnects from a network. This can be used, e.g., to
842 update network configuration and/or trigget DHCP client to update IP
843 addresses, etc.
844
845 One wpa_cli process in "action" mode needs to be started for each
846 interface. For example, the following command starts wpa_cli for the
847 default ingterface (-i can be used to select the interface in case of
848 more than one interface being used at the same time):
849
850 wpa_cli -a/sbin/wpa_action.sh -B
851
852 The action file (-a option, /sbin/wpa_action.sh in this example) will
853 be executed whenever wpa_supplicant completes authentication (connect
854 event) or detects disconnection). The action script will be called
855 with two command line arguments: interface name and event (CONNECTED
856 or DISCONNECTED). If the action script needs to get more information
857 about the current network, it can use 'wpa_cli status' to query
858 wpa_supplicant for more information.
859
860 Following example can be used as a simple template for an action
861 script:
862
863 #!/bin/sh
864
865 IFNAME=$1
866 CMD=$2
867
868 if [ "$CMD" = "CONNECTED" ]; then
869     SSID=`wpa_cli -i$IFNAME status | grep ^ssid= | cut -f2- -d=`
870     # configure network, signal DHCP client, etc.
871 fi
872
873 if [ "$CMD" = "DISCONNECTED" ]; then
874     # remove network configuration, if needed
875     SSID=
876 fi
877
878
879
880 Integrating with pcmcia-cs/cardmgr scripts
881 ------------------------------------------
882
883 wpa_supplicant needs to be running when using a wireless network with
884 WPA. It can be started either from system startup scripts or from
885 pcmcia-cs/cardmgr scripts (when using PC Cards). WPA handshake must be
886 completed before data frames can be exchanged, so wpa_supplicant
887 should be started before DHCP client.
888
889 For example, following small changes to pcmcia-cs scripts can be used
890 to enable WPA support:
891
892 Add MODE="Managed" and WPA="y" to the network scheme in
893 /etc/pcmcia/wireless.opts.
894
895 Add the following block to the end of 'start' action handler in
896 /etc/pcmcia/wireless:
897
898     if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
899         /usr/local/bin/wpa_supplicant -B -c/etc/wpa_supplicant.conf \
900                 -i$DEVICE
901     fi
902
903 Add the following block to the end of 'stop' action handler (may need
904 to be separated from other actions) in /etc/pcmcia/wireless:
905
906     if [ "$WPA" = "y" -a -x /usr/local/bin/wpa_supplicant ]; then
907         killall wpa_supplicant
908     fi
909
910 This will make cardmgr start wpa_supplicant when the card is plugged
911 in.
912
913
914
915 Dynamic interface add and operation without configuration files
916 ---------------------------------------------------------------
917
918 wpa_supplicant can be started without any configuration files or
919 network interfaces. When used in this way, a global (i.e., per
920 wpa_supplicant process) control interface is used to add and remove
921 network interfaces. Each network interface can then be configured
922 through a per-network interface control interface. For example,
923 following commands show how to start wpa_supplicant without any
924 network interfaces and then add a network interface and configure a
925 network (SSID):
926
927 # Start wpa_supplicant in the background
928 wpa_supplicant -g/var/run/wpa_supplicant-global -B
929
930 # Add a new interface (wlan0, no configuration file, driver=wext, and
931 # enable control interface)
932 wpa_cli -g/var/run/wpa_supplicant-global interface_add wlan0 \
933         "" wext /var/run/wpa_supplicant
934
935 # Configure a network using the newly added network interface:
936 wpa_cli -iwlan0 add_network
937 wpa_cli -iwlan0 set_network 0 ssid '"test"'
938 wpa_cli -iwlan0 set_network 0 key_mgmt WPA-PSK
939 wpa_cli -iwlan0 set_network 0 psk '"12345678"'
940 wpa_cli -iwlan0 set_network 0 pairwise TKIP
941 wpa_cli -iwlan0 set_network 0 group TKIP
942 wpa_cli -iwlan0 set_network 0 proto WPA
943 wpa_cli -iwlan0 enable_network 0
944
945 # At this point, the new network interface should start trying to associate
946 # with the WPA-PSK network using SSID test.
947
948 # Remove network interface
949 wpa_cli -g/var/run/wpa_supplicant-global interface_remove wlan0
950
951
952 Privilege separation
953 --------------------
954
955 To minimize the size of code that needs to be run with root privileges
956 (e.g., to control wireless interface operation), wpa_supplicant
957 supports optional privilege separation. If enabled, this separates the
958 privileged operations into a separate process (wpa_priv) while leaving
959 rest of the code (e.g., EAP authentication and WPA handshakes) into an
960 unprivileged process (wpa_supplicant) that can be run as non-root
961 user. Privilege separation restricts the effects of potential software
962 errors by containing the majority of the code in an unprivileged
963 process to avoid full system compromise.
964
965 Privilege separation is not enabled by default and it can be enabled
966 by adding CONFIG_PRIVSEP=y to the build configuration (.config). When
967 enabled, the privileged operations (driver wrapper and l2_packet) are
968 linked into a separate daemon program, wpa_priv. The unprivileged
969 program, wpa_supplicant, will be built with a special driver/l2_packet
970 wrappers that communicate with the privileged wpa_priv process to
971 perform the needed operations. wpa_priv can control what privileged
972 are allowed.
973
974 wpa_priv needs to be run with network admin privileges (usually, root
975 user). It opens a UNIX domain socket for each interface that is
976 included on the command line; any other interface will be off limits
977 for wpa_supplicant in this kind of configuration. After this,
978 wpa_supplicant can be run as a non-root user (e.g., all standard users
979 on a laptop or as a special non-privileged user account created just
980 for this purpose to limit access to user files even further).
981
982
983 Example configuration:
984 - create user group for users that are allowed to use wpa_supplicant
985   ('wpapriv' in this example) and assign users that should be able to
986   use wpa_supplicant into that group
987 - create /var/run/wpa_priv directory for UNIX domain sockets and control
988   user access by setting it accessible only for the wpapriv group:
989   mkdir /var/run/wpa_priv
990   chown root:wpapriv /var/run/wpa_priv
991   chmod 0750 /var/run/wpa_priv
992 - start wpa_priv as root (e.g., from system startup scripts) with the
993   enabled interfaces configured on the command line:
994   wpa_priv -B -P /var/run/wpa_priv.pid wext:ath0
995 - run wpa_supplicant as non-root with a user that is in wpapriv group:
996   wpa_supplicant -i ath0 -c wpa_supplicant.conf
997
998 wpa_priv does not use the network interface before wpa_supplicant is
999 started, so it is fine to include network interfaces that are not
1000 available at the time wpa_priv is started. As an alternative, wpa_priv
1001 can be started when an interface is added (hotplug/udev/etc. scripts).
1002 wpa_priv can control multiple interface with one process, but it is
1003 also possible to run multiple wpa_priv processes at the same time, if
1004 desired.