testing_tools.doxygen 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. /**
  2. \page testing_tools Testing and development tools
  3. [ \ref eapol_test "eapol_test" |
  4. \ref preauth_test "preauth_test" |
  5. \ref driver_test "driver_test" |
  6. \ref unit_tests "Unit tests" ]
  7. %wpa_supplicant source tree includes number of testing and development
  8. tools that make it easier to test the programs without having to setup
  9. a full test setup with wireless cards. In addition, these tools can be
  10. used to implement automatic tests suites.
  11. \section eapol_test eapol_test - EAP peer and RADIUS client testing
  12. eapol_test is a program that links together the same EAP peer
  13. implementation that %wpa_supplicant is using and the RADIUS
  14. authentication client code from hostapd. In addition, it has minimal
  15. glue code to combine these two components in similar ways to IEEE
  16. 802.1X/EAPOL Authenticator state machines. In other words, it
  17. integrates IEEE 802.1X Authenticator (normally, an access point) and
  18. IEEE 802.1X Supplicant (normally, a wireless client) together to
  19. generate a single program that can be used to test EAP methods without
  20. having to setup an access point and a wireless client.
  21. The main uses for eapol_test are in interoperability testing of EAP
  22. methods against RADIUS servers and in development testing for new EAP
  23. methods. It can be easily used to automate EAP testing for
  24. interoperability and regression since the program can be run from
  25. shell scripts without require additional test components apart from a
  26. RADIUS server. For example, the automated EAP tests described in
  27. eap_testing.txt are implemented with eapol_test. Similarly, eapol_test
  28. could be used to implement an automated regression test suite for a
  29. RADIUS authentication server.
  30. eapol_test uses the same build time configuration file, .config, as
  31. %wpa_supplicant. This file is used to select which EAP methods are
  32. included in eapol_test. This program is not built with the default
  33. Makefile target, so a separate make command needs to be used to
  34. compile the tool:
  35. \verbatim
  36. make eapol_test
  37. \endverbatim
  38. The resulting eapol_test binary has following command like options:
  39. \verbatim
  40. usage:
  41. eapol_test [-nWS] -c<conf> [-a<AS IP>] [-p<AS port>] [-s<AS secret>] \
  42. [-r<count>] [-t<timeout>] [-C<Connect-Info>] \
  43. [-M<client MAC address>]
  44. eapol_test scard
  45. eapol_test sim <PIN> <num triplets> [debug]
  46. options:
  47. -c<conf> = configuration file
  48. -a<AS IP> = IP address of the authentication server, default 127.0.0.1
  49. -p<AS port> = UDP port of the authentication server, default 1812
  50. -s<AS secret> = shared secret with the authentication server, default 'radius'
  51. -r<count> = number of re-authentications
  52. -W = wait for a control interface monitor before starting
  53. -S = save configuration after authentiation
  54. -n = no MPPE keys expected
  55. -t<timeout> = sets timeout in seconds (default: 30 s)
  56. -C<Connect-Info> = RADIUS Connect-Info (default: CONNECT 11Mbps 802.11b)
  57. -M<client MAC address> = Set own MAC address (Calling-Station-Id,
  58. default: 02:00:00:00:00:01)
  59. \endverbatim
  60. As an example,
  61. \verbatim
  62. eapol_test -ctest.conf -a127.0.0.1 -p1812 -ssecret -r1
  63. \endverbatim
  64. tries to complete EAP authentication based on the network
  65. configuration from test.conf against the RADIUS server running on the
  66. local host. A re-authentication is triggered to test fast
  67. re-authentication. The configuration file uses the same format for
  68. network blocks as %wpa_supplicant.
  69. \section preauth_test preauth_test - WPA2 pre-authentication and EAP peer testing
  70. preauth_test is similar to eapol_test in the sense that in combines
  71. EAP peer implementation with something else, in this case, with WPA2
  72. pre-authentication. This tool can be used to test pre-authentication
  73. based on the code that %wpa_supplicant is using. As such, it tests
  74. both the %wpa_supplicant implementation and the functionality of an
  75. access point.
  76. preauth_test is built with:
  77. \verbatim
  78. make preauth_test
  79. \endverbatim
  80. and it uses following command line arguments:
  81. \verbatim
  82. usage: preauth_test <conf> <target MAC address> <ifname>
  83. \endverbatim
  84. For example,
  85. \verbatim
  86. preauth_test test.conf 02:11:22:33:44:55 eth0
  87. \endverbatim
  88. would use network configuration from test.conf to try to complete
  89. pre-authentication with AP using BSSID 02:11:22:33:44:55. The
  90. pre-authentication packets would be sent using the eth0 interface.
  91. \section driver_test driver_test - driver interface for testing wpa_supplicant
  92. %wpa_supplicant was designed to support number of different ways to
  93. communicate with a network device driver. This design uses \ref
  94. driver_wrapper "driver interface API" and number of driver interface
  95. implementations. One of these is driver_test.c, i.e., a test driver
  96. interface that is actually not using any drivers. Instead, it provides
  97. a mechanism for running %wpa_supplicant without having to have a
  98. device driver or wireless LAN hardware for that matter.
  99. driver_test can be used to talk directly with hostapd's driver_test
  100. component to create a test setup where one or more clients and access
  101. points can be tested within one test host and without having to have
  102. multiple wireless cards. This makes it easier to test the core code in
  103. %wpa_supplicant, and hostapd for that matter. Since driver_test uses
  104. the same driver API than any other driver interface implementation,
  105. the core code of %wpa_supplicant and hostapd can be tested with the
  106. same coverage as one would get when using real wireless cards. The
  107. only area that is not tested is the driver interface implementation
  108. (driver_*.c).
  109. Having the possibility to use simulated network components makes it
  110. much easier to do development testing while adding new features and to
  111. reproduce reported bugs. As such, it is often easiest to just do most
  112. of the development and bug fixing without using real hardware. Once
  113. the driver_test setup has been used to implement a new feature or fix
  114. a bug, the end result can be verified with wireless LAN cards. In many
  115. cases, this may even be unnecessary, depending on what area the
  116. feature/bug is relating to. Of course, changes to driver interfaces
  117. will still require use of real hardware.
  118. Since multiple components can be run within a single host, testing of
  119. complex network configuration, e.g., large number of clients
  120. association with an access point, becomes quite easy. All the tests
  121. can also be automated without having to resort to complex test setup
  122. using remote access to multiple computers.
  123. driver_test can be included in the %wpa_supplicant build in the same
  124. way as any other driver interface, i.e., by adding the following line
  125. into .config:
  126. \verbatim
  127. CONFIG_DRIVER_TEST=y
  128. \endverbatim
  129. When running %wpa_supplicant, the test interface is selected by using
  130. \a -Dtest command line argument. The interface name (\a -i argument)
  131. can be selected arbitrarily, i.e., it does not need to match with any
  132. existing network interface. The interface name is used to generate a
  133. MAC address, so when using multiple clients, each should use a
  134. different interface, e.g., \a sta1, \a sta2, and so on.
  135. %wpa_supplicant and hostapd are configured in the same way as they
  136. would be for normal use. Following example shows a simple test setup
  137. for WPA-PSK.
  138. hostapd is configured with following psk-test.conf configuration file:
  139. \verbatim
  140. driver=test
  141. interface=ap1
  142. logger_stdout=-1
  143. logger_stdout_level=0
  144. debug=2
  145. dump_file=/tmp/hostapd.dump
  146. test_socket=/tmp/Test/ap1
  147. ssid=jkm-test-psk
  148. wpa=1
  149. wpa_key_mgmt=WPA-PSK
  150. wpa_pairwise=TKIP
  151. wpa_passphrase=12345678
  152. \endverbatim
  153. and started with following command:
  154. \verbatim
  155. hostapd psk-test.conf
  156. \endverbatim
  157. %wpa_supplicant uses following configuration file:
  158. \verbatim
  159. driver_param=test_socket=/tmp/Test/ap1
  160. network={
  161. ssid="jkm-test-psk"
  162. key_mgmt=WPA-PSK
  163. psk="12345678"
  164. }
  165. \endverbatim
  166. %wpa_supplicant can then be started with following command:
  167. \verbatim
  168. wpa_supplicant -Dtest -cpsk-test.conf -ista1 -ddK
  169. \endverbatim
  170. If run without debug information, i.e., with
  171. \verbatim
  172. wpa_supplicant -Dtest -cpsk-test.conf -ista1
  173. \endverbatim
  174. %wpa_supplicant completes authentication and prints following events:
  175. \verbatim
  176. Trying to associate with 02:b8:a6:62:08:5a (SSID='jkm-test-psk' freq=0 MHz)
  177. Associated with 02:b8:a6:62:08:5a
  178. WPA: Key negotiation completed with 02:b8:a6:62:08:5a [PTK=TKIP GTK=TKIP]
  179. CTRL-EVENT-CONNECTED - Connection to 02:b8:a6:62:08:5a completed (auth)
  180. \endverbatim
  181. If test setup is using multiple clients, it is possible to run
  182. multiple %wpa_supplicant processes. Alternatively, the support for
  183. multiple interfaces can be used with just one process to save some
  184. resources on single-CPU systems. For example, following command runs
  185. two clients:
  186. \verbatim
  187. ./wpa_supplicant -Dtest -cpsk-test.conf -ista1 \
  188. -N -Dtest -cpsk-test.conf -ista2
  189. \endverbatim
  190. This shows following event log:
  191. \verbatim
  192. Trying to associate with 02:b8:a6:62:08:5a (SSID='jkm-test-psk' freq=0 MHz)
  193. Associated with 02:b8:a6:62:08:5a
  194. WPA: Key negotiation completed with 02:b8:a6:62:08:5a [PTK=TKIP GTK=TKIP]
  195. CTRL-EVENT-CONNECTED - Connection to 02:b8:a6:62:08:5a completed (auth)
  196. Trying to associate with 02:b8:a6:62:08:5a (SSID='jkm-test-psk' freq=0 MHz)
  197. Associated with 02:b8:a6:62:08:5a
  198. WPA: Key negotiation completed with 02:b8:a6:62:08:5a [PTK=TKIP GTK=TKIP]
  199. CTRL-EVENT-CONNECTED - Connection to 02:b8:a6:62:08:5a completed (auth)
  200. \endverbatim
  201. hostapd shows this with following events:
  202. \verbatim
  203. ap1: STA 02:b5:64:63:30:63 IEEE 802.11: associated
  204. ap1: STA 02:b5:64:63:30:63 WPA: pairwise key handshake completed (WPA)
  205. ap1: STA 02:b5:64:63:30:63 WPA: group key handshake completed (WPA)
  206. ap1: STA 02:2a:c4:18:5b:f3 IEEE 802.11: associated
  207. ap1: STA 02:2a:c4:18:5b:f3 WPA: pairwise key handshake completed (WPA)
  208. ap1: STA 02:2a:c4:18:5b:f3 WPA: group key handshake completed (WPA)
  209. \endverbatim
  210. By default, driver_param is simulating a driver that uses the WPA/RSN
  211. IE generated by %wpa_supplicant. Driver-generated IE and AssocInfo
  212. events can be tested by adding \a use_associnfo=1 to the \a driver_param
  213. line in the configuration file. For example:
  214. \verbatim
  215. driver_param=test_socket=/tmp/Test/ap1 use_associnfo=1
  216. \endverbatim
  217. \section unit_tests Unit tests
  218. Number of the components (.c files) used in %wpa_supplicant define
  219. their own unit tests for automated validation of the basic
  220. functionality. Most of the tests for cryptographic algorithms are
  221. using standard test vectors to validate functionality. These tests can
  222. be useful especially when verifying port to a new CPU target.
  223. In most cases, these tests are implemented in the end of the same file
  224. with functions that are normally commented out, but ca be included by
  225. defining a pre-processor variable when building the file separately.
  226. The details of the needed build options are included in the Makefile
  227. (test-* targets). All automated unit tests can be run with
  228. \verbatim
  229. make tests
  230. \endverbatim
  231. This make target builds and runs each test and terminates with zero
  232. exit code if all tests were completed successfully.
  233. */