test_suite_b.py 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586
  1. # Suite B tests
  2. # Copyright (c) 2014-2015, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import time
  7. import logging
  8. logger = logging.getLogger()
  9. import hostapd
  10. from utils import HwsimSkip, fail_test
  11. def check_suite_b_capa(dev):
  12. if "GCMP" not in dev[0].get_capability("pairwise"):
  13. raise HwsimSkip("GCMP not supported")
  14. if "BIP-GMAC-128" not in dev[0].get_capability("group_mgmt"):
  15. raise HwsimSkip("BIP-GMAC-128 not supported")
  16. if "WPA-EAP-SUITE-B" not in dev[0].get_capability("key_mgmt"):
  17. raise HwsimSkip("WPA-EAP-SUITE-B not supported")
  18. check_suite_b_tls_lib(dev)
  19. def check_suite_b_tls_lib(dev):
  20. tls = dev[0].request("GET tls_library")
  21. if tls.startswith("GnuTLS"):
  22. return
  23. if not tls.startswith("OpenSSL"):
  24. raise HwsimSkip("TLS library not supported for Suite B: " + tls)
  25. supported = False
  26. for ver in [ '1.0.2', '1.1.0' ]:
  27. if "build=OpenSSL " + ver in tls and "run=OpenSSL " + ver in tls:
  28. supported = True
  29. break
  30. if not supported:
  31. raise HwsimSkip("OpenSSL version not supported for Suite B: " + tls)
  32. def suite_b_ap_params():
  33. params = { "ssid": "test-suite-b",
  34. "wpa": "2",
  35. "wpa_key_mgmt": "WPA-EAP-SUITE-B",
  36. "rsn_pairwise": "GCMP",
  37. "group_mgmt_cipher": "BIP-GMAC-128",
  38. "ieee80211w": "2",
  39. "ieee8021x": "1",
  40. "openssl_ciphers": "SUITEB128",
  41. #"dh_file": "auth_serv/dh.conf",
  42. "eap_server": "1",
  43. "eap_user_file": "auth_serv/eap_user.conf",
  44. "ca_cert": "auth_serv/ec-ca.pem",
  45. "server_cert": "auth_serv/ec-server.pem",
  46. "private_key": "auth_serv/ec-server.key" }
  47. return params
  48. def test_suite_b(dev, apdev):
  49. """WPA2/GCMP connection at Suite B 128-bit level"""
  50. check_suite_b_capa(dev)
  51. dev[0].flush_scan_cache()
  52. params = suite_b_ap_params()
  53. hapd = hostapd.add_ap(apdev[0], params)
  54. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B", ieee80211w="2",
  55. openssl_ciphers="SUITEB128",
  56. eap="TLS", identity="tls user",
  57. ca_cert="auth_serv/ec-ca.pem",
  58. client_cert="auth_serv/ec-user.pem",
  59. private_key="auth_serv/ec-user.key",
  60. pairwise="GCMP", group="GCMP", scan_freq="2412")
  61. tls_cipher = dev[0].get_status_field("EAP TLS cipher")
  62. if tls_cipher != "ECDHE-ECDSA-AES128-GCM-SHA256" and \
  63. tls_cipher != "ECDHE-ECDSA-AES-128-GCM-AEAD":
  64. raise Exception("Unexpected TLS cipher: " + tls_cipher)
  65. bss = dev[0].get_bss(apdev[0]['bssid'])
  66. if 'flags' not in bss:
  67. raise Exception("Could not get BSS flags from BSS table")
  68. if "[WPA2-EAP-SUITE-B-GCMP]" not in bss['flags']:
  69. raise Exception("Unexpected BSS flags: " + bss['flags'])
  70. dev[0].request("DISCONNECT")
  71. dev[0].wait_disconnected(timeout=20)
  72. dev[0].dump_monitor()
  73. dev[0].request("RECONNECT")
  74. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
  75. "CTRL-EVENT-CONNECTED"], timeout=20)
  76. if ev is None:
  77. raise Exception("Roaming with the AP timed out")
  78. if "CTRL-EVENT-EAP-STARTED" in ev:
  79. raise Exception("Unexpected EAP exchange")
  80. conf = hapd.get_config()
  81. if conf['key_mgmt'] != 'WPA-EAP-SUITE-B':
  82. raise Exception("Unexpected config key_mgmt: " + conf['key_mgmt'])
  83. def suite_b_as_params():
  84. params = {}
  85. params['ssid'] = 'as'
  86. params['beacon_int'] = '2000'
  87. params['radius_server_clients'] = 'auth_serv/radius_clients.conf'
  88. params['radius_server_auth_port'] = '18129'
  89. params['eap_server'] = '1'
  90. params['eap_user_file'] = 'auth_serv/eap_user.conf'
  91. params['ca_cert'] = 'auth_serv/ec-ca.pem'
  92. params['server_cert'] = 'auth_serv/ec-server.pem'
  93. params['private_key'] = 'auth_serv/ec-server.key'
  94. params['openssl_ciphers'] = 'SUITEB128'
  95. return params
  96. def test_suite_b_radius(dev, apdev):
  97. """WPA2/GCMP (RADIUS) connection at Suite B 128-bit level"""
  98. check_suite_b_capa(dev)
  99. dev[0].flush_scan_cache()
  100. params = suite_b_as_params()
  101. hostapd.add_ap(apdev[1], params)
  102. params = { "ssid": "test-suite-b",
  103. "wpa": "2",
  104. "wpa_key_mgmt": "WPA-EAP-SUITE-B",
  105. "rsn_pairwise": "GCMP",
  106. "group_mgmt_cipher": "BIP-GMAC-128",
  107. "ieee80211w": "2",
  108. "ieee8021x": "1",
  109. 'auth_server_addr': "127.0.0.1",
  110. 'auth_server_port': "18129",
  111. 'auth_server_shared_secret': "radius",
  112. 'nas_identifier': "nas.w1.fi" }
  113. hapd = hostapd.add_ap(apdev[0], params)
  114. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B", ieee80211w="2",
  115. openssl_ciphers="SUITEB128",
  116. eap="TLS", identity="tls user",
  117. ca_cert="auth_serv/ec-ca.pem",
  118. client_cert="auth_serv/ec-user.pem",
  119. private_key="auth_serv/ec-user.key",
  120. pairwise="GCMP", group="GCMP", scan_freq="2412")
  121. def check_suite_b_192_capa(dev):
  122. if "GCMP-256" not in dev[0].get_capability("pairwise"):
  123. raise HwsimSkip("GCMP-256 not supported")
  124. if "BIP-GMAC-256" not in dev[0].get_capability("group_mgmt"):
  125. raise HwsimSkip("BIP-GMAC-256 not supported")
  126. if "WPA-EAP-SUITE-B-192" not in dev[0].get_capability("key_mgmt"):
  127. raise HwsimSkip("WPA-EAP-SUITE-B-192 not supported")
  128. check_suite_b_tls_lib(dev)
  129. def suite_b_192_ap_params():
  130. params = { "ssid": "test-suite-b",
  131. "wpa": "2",
  132. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  133. "rsn_pairwise": "GCMP-256",
  134. "group_mgmt_cipher": "BIP-GMAC-256",
  135. "ieee80211w": "2",
  136. "ieee8021x": "1",
  137. "openssl_ciphers": "SUITEB192",
  138. "eap_server": "1",
  139. "eap_user_file": "auth_serv/eap_user.conf",
  140. "ca_cert": "auth_serv/ec2-ca.pem",
  141. "server_cert": "auth_serv/ec2-server.pem",
  142. "private_key": "auth_serv/ec2-server.key" }
  143. return params
  144. def test_suite_b_192(dev, apdev):
  145. """WPA2/GCMP-256 connection at Suite B 192-bit level"""
  146. check_suite_b_192_capa(dev)
  147. dev[0].flush_scan_cache()
  148. params = suite_b_192_ap_params()
  149. hapd = hostapd.add_ap(apdev[0], params)
  150. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  151. ieee80211w="2",
  152. openssl_ciphers="SUITEB192",
  153. eap="TLS", identity="tls user",
  154. ca_cert="auth_serv/ec2-ca.pem",
  155. client_cert="auth_serv/ec2-user.pem",
  156. private_key="auth_serv/ec2-user.key",
  157. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412")
  158. tls_cipher = dev[0].get_status_field("EAP TLS cipher")
  159. if tls_cipher != "ECDHE-ECDSA-AES256-GCM-SHA384" and \
  160. tls_cipher != "ECDHE-ECDSA-AES-256-GCM-AEAD":
  161. raise Exception("Unexpected TLS cipher: " + tls_cipher)
  162. cipher = dev[0].get_status_field("mgmt_group_cipher")
  163. if cipher != "BIP-GMAC-256":
  164. raise Exception("Unexpected mgmt_group_cipher: " + cipher)
  165. bss = dev[0].get_bss(apdev[0]['bssid'])
  166. if 'flags' not in bss:
  167. raise Exception("Could not get BSS flags from BSS table")
  168. if "[WPA2-EAP-SUITE-B-192-GCMP-256]" not in bss['flags']:
  169. raise Exception("Unexpected BSS flags: " + bss['flags'])
  170. dev[0].request("DISCONNECT")
  171. dev[0].wait_disconnected(timeout=20)
  172. dev[0].dump_monitor()
  173. dev[0].request("RECONNECT")
  174. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
  175. "CTRL-EVENT-CONNECTED"], timeout=20)
  176. if ev is None:
  177. raise Exception("Roaming with the AP timed out")
  178. if "CTRL-EVENT-EAP-STARTED" in ev:
  179. raise Exception("Unexpected EAP exchange")
  180. conf = hapd.get_config()
  181. if conf['key_mgmt'] != 'WPA-EAP-SUITE-B-192':
  182. raise Exception("Unexpected config key_mgmt: " + conf['key_mgmt'])
  183. def test_suite_b_192_radius(dev, apdev):
  184. """WPA2/GCMP-256 (RADIUS) connection at Suite B 192-bit level"""
  185. check_suite_b_192_capa(dev)
  186. dev[0].flush_scan_cache()
  187. params = suite_b_as_params()
  188. params['ca_cert'] = 'auth_serv/ec2-ca.pem'
  189. params['server_cert'] = 'auth_serv/ec2-server.pem'
  190. params['private_key'] = 'auth_serv/ec2-server.key'
  191. params['openssl_ciphers'] = 'SUITEB192'
  192. hostapd.add_ap(apdev[1], params)
  193. params = { "ssid": "test-suite-b",
  194. "wpa": "2",
  195. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  196. "rsn_pairwise": "GCMP-256",
  197. "group_mgmt_cipher": "BIP-GMAC-256",
  198. "ieee80211w": "2",
  199. "ieee8021x": "1",
  200. 'auth_server_addr': "127.0.0.1",
  201. 'auth_server_port': "18129",
  202. 'auth_server_shared_secret': "radius",
  203. 'nas_identifier': "nas.w1.fi" }
  204. hapd = hostapd.add_ap(apdev[0], params)
  205. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  206. ieee80211w="2",
  207. openssl_ciphers="SUITEB192",
  208. eap="TLS", identity="tls user",
  209. ca_cert="auth_serv/ec2-ca.pem",
  210. client_cert="auth_serv/ec2-user.pem",
  211. private_key="auth_serv/ec2-user.key",
  212. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412")
  213. def test_suite_b_192_radius_and_p256_cert(dev, apdev):
  214. """Suite B 192-bit level and p256 client cert"""
  215. check_suite_b_192_capa(dev)
  216. dev[0].flush_scan_cache()
  217. params = suite_b_as_params()
  218. params['ca_cert'] = 'auth_serv/ec2-ca.pem'
  219. params['server_cert'] = 'auth_serv/ec2-server.pem'
  220. params['private_key'] = 'auth_serv/ec2-server.key'
  221. params['openssl_ciphers'] = 'SUITEB192'
  222. hostapd.add_ap(apdev[1], params)
  223. params = { "ssid": "test-suite-b",
  224. "wpa": "2",
  225. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  226. "rsn_pairwise": "GCMP-256",
  227. "group_mgmt_cipher": "BIP-GMAC-256",
  228. "ieee80211w": "2",
  229. "ieee8021x": "1",
  230. 'auth_server_addr': "127.0.0.1",
  231. 'auth_server_port': "18129",
  232. 'auth_server_shared_secret': "radius",
  233. 'nas_identifier': "nas.w1.fi" }
  234. hapd = hostapd.add_ap(apdev[0], params)
  235. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  236. ieee80211w="2",
  237. #openssl_ciphers="SUITEB192",
  238. eap="TLS", identity="tls user",
  239. ca_cert="auth_serv/ec2-ca.pem",
  240. client_cert="auth_serv/ec2-user-p256.pem",
  241. private_key="auth_serv/ec2-user-p256.key",
  242. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412",
  243. wait_connect=False)
  244. ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10)
  245. if ev is None:
  246. raise Exception("EAP-Failure not reported")
  247. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
  248. if ev is None:
  249. raise Exception("Disconnection not reported")
  250. if "reason=23" not in ev:
  251. raise Exception("Unexpected disconnection reason: " + ev);
  252. def test_suite_b_pmkid_failure(dev, apdev):
  253. """WPA2/GCMP connection at Suite B 128-bit level and PMKID derivation failure"""
  254. check_suite_b_capa(dev)
  255. dev[0].flush_scan_cache()
  256. params = suite_b_ap_params()
  257. hapd = hostapd.add_ap(apdev[0], params)
  258. with fail_test(dev[0], 1, "rsn_pmkid_suite_b"):
  259. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B",
  260. ieee80211w="2",
  261. openssl_ciphers="SUITEB128",
  262. eap="TLS", identity="tls user",
  263. ca_cert="auth_serv/ec-ca.pem",
  264. client_cert="auth_serv/ec-user.pem",
  265. private_key="auth_serv/ec-user.key",
  266. pairwise="GCMP", group="GCMP", scan_freq="2412")
  267. def test_suite_b_192_pmkid_failure(dev, apdev):
  268. """WPA2/GCMP-256 connection at Suite B 192-bit level and PMKID derivation failure"""
  269. check_suite_b_192_capa(dev)
  270. dev[0].flush_scan_cache()
  271. params = suite_b_192_ap_params()
  272. hapd = hostapd.add_ap(apdev[0], params)
  273. with fail_test(dev[0], 1, "rsn_pmkid_suite_b"):
  274. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  275. ieee80211w="2",
  276. openssl_ciphers="SUITEB192",
  277. eap="TLS", identity="tls user",
  278. ca_cert="auth_serv/ec2-ca.pem",
  279. client_cert="auth_serv/ec2-user.pem",
  280. private_key="auth_serv/ec2-user.key",
  281. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412")
  282. def test_suite_b_mic_failure(dev, apdev):
  283. """WPA2/GCMP connection at Suite B 128-bit level and MIC derivation failure"""
  284. check_suite_b_capa(dev)
  285. dev[0].flush_scan_cache()
  286. params = suite_b_ap_params()
  287. hapd = hostapd.add_ap(apdev[0], params)
  288. with fail_test(dev[0], 1, "wpa_eapol_key_mic"):
  289. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B",
  290. ieee80211w="2",
  291. openssl_ciphers="SUITEB128",
  292. eap="TLS", identity="tls user",
  293. ca_cert="auth_serv/ec-ca.pem",
  294. client_cert="auth_serv/ec-user.pem",
  295. private_key="auth_serv/ec-user.key",
  296. pairwise="GCMP", group="GCMP", scan_freq="2412",
  297. wait_connect=False)
  298. dev[0].wait_disconnected()
  299. def test_suite_b_192_mic_failure(dev, apdev):
  300. """WPA2/GCMP connection at Suite B 192-bit level and MIC derivation failure"""
  301. check_suite_b_192_capa(dev)
  302. dev[0].flush_scan_cache()
  303. params = suite_b_192_ap_params()
  304. hapd = hostapd.add_ap(apdev[0], params)
  305. with fail_test(dev[0], 1, "wpa_eapol_key_mic"):
  306. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  307. ieee80211w="2",
  308. openssl_ciphers="SUITEB192",
  309. eap="TLS", identity="tls user",
  310. ca_cert="auth_serv/ec2-ca.pem",
  311. client_cert="auth_serv/ec2-user.pem",
  312. private_key="auth_serv/ec2-user.key",
  313. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412",
  314. wait_connect=False)
  315. dev[0].wait_disconnected()
  316. def suite_b_192_rsa_ap_params():
  317. params = { "ssid": "test-suite-b",
  318. "wpa": "2",
  319. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  320. "rsn_pairwise": "GCMP-256",
  321. "group_mgmt_cipher": "BIP-GMAC-256",
  322. "ieee80211w": "2",
  323. "ieee8021x": "1",
  324. "tls_flags": "[SUITEB]",
  325. "dh_file": "auth_serv/dh_param_3072.pem",
  326. "eap_server": "1",
  327. "eap_user_file": "auth_serv/eap_user.conf",
  328. "ca_cert": "auth_serv/rsa3072-ca.pem",
  329. "server_cert": "auth_serv/rsa3072-server.pem",
  330. "private_key": "auth_serv/rsa3072-server.key" }
  331. return params
  332. def test_suite_b_192_rsa(dev, apdev):
  333. """WPA2/GCMP-256 connection at Suite B 192-bit level and RSA"""
  334. run_suite_b_192_rsa(dev, apdev)
  335. def test_suite_b_192_rsa_ecdhe(dev, apdev):
  336. """WPA2/GCMP-256 connection at Suite B 192-bit level and RSA (ECDHE)"""
  337. run_suite_b_192_rsa(dev, apdev, no_dhe=True)
  338. def test_suite_b_192_rsa_dhe(dev, apdev):
  339. """WPA2/GCMP-256 connection at Suite B 192-bit level and RSA (DHE)"""
  340. run_suite_b_192_rsa(dev, apdev, no_ecdh=True)
  341. def run_suite_b_192_rsa(dev, apdev, no_ecdh=False, no_dhe=False):
  342. check_suite_b_192_capa(dev)
  343. dev[0].flush_scan_cache()
  344. params = suite_b_192_rsa_ap_params()
  345. if no_ecdh:
  346. params["tls_flags"] = "[SUITEB-NO-ECDH]"
  347. if no_dhe:
  348. del params["dh_file"]
  349. hapd = hostapd.add_ap(apdev[0], params)
  350. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  351. ieee80211w="2",
  352. phase1="tls_suiteb=1",
  353. eap="TLS", identity="tls user",
  354. ca_cert="auth_serv/rsa3072-ca.pem",
  355. client_cert="auth_serv/rsa3072-user.pem",
  356. private_key="auth_serv/rsa3072-user.key",
  357. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412")
  358. tls_cipher = dev[0].get_status_field("EAP TLS cipher")
  359. if tls_cipher != "ECDHE-RSA-AES256-GCM-SHA384" and \
  360. tls_cipher != "DHE-RSA-AES256-GCM-SHA384" and \
  361. tls_cipher != "ECDHE-RSA-AES-256-GCM-AEAD" and \
  362. tls_cipher != "DHE-RSA-AES-256-GCM-AEAD":
  363. raise Exception("Unexpected TLS cipher: " + tls_cipher)
  364. cipher = dev[0].get_status_field("mgmt_group_cipher")
  365. if cipher != "BIP-GMAC-256":
  366. raise Exception("Unexpected mgmt_group_cipher: " + cipher)
  367. bss = dev[0].get_bss(apdev[0]['bssid'])
  368. if 'flags' not in bss:
  369. raise Exception("Could not get BSS flags from BSS table")
  370. if "[WPA2-EAP-SUITE-B-192-GCMP-256]" not in bss['flags']:
  371. raise Exception("Unexpected BSS flags: " + bss['flags'])
  372. dev[0].request("DISCONNECT")
  373. dev[0].wait_disconnected(timeout=20)
  374. dev[0].dump_monitor()
  375. dev[0].request("RECONNECT")
  376. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STARTED",
  377. "CTRL-EVENT-CONNECTED"], timeout=20)
  378. if ev is None:
  379. raise Exception("Roaming with the AP timed out")
  380. if "CTRL-EVENT-EAP-STARTED" in ev:
  381. raise Exception("Unexpected EAP exchange")
  382. conf = hapd.get_config()
  383. if conf['key_mgmt'] != 'WPA-EAP-SUITE-B-192':
  384. raise Exception("Unexpected config key_mgmt: " + conf['key_mgmt'])
  385. def test_suite_b_192_rsa_insufficient_key(dev, apdev):
  386. """WPA2/GCMP-256 connection at Suite B 192-bit level and RSA with insufficient key length"""
  387. check_suite_b_192_capa(dev)
  388. dev[0].flush_scan_cache()
  389. params = suite_b_192_rsa_ap_params()
  390. params["ca_cert"] = "auth_serv/ca.pem"
  391. params["server_cert"] = "auth_serv/server.pem"
  392. params["private_key"] = "auth_serv/server.key"
  393. hapd = hostapd.add_ap(apdev[0], params)
  394. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  395. ieee80211w="2",
  396. phase1="tls_suiteb=1",
  397. eap="TLS", identity="tls user",
  398. ca_cert="auth_serv/ca.pem",
  399. client_cert="auth_serv/user.pem",
  400. private_key="auth_serv/user.key",
  401. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412",
  402. wait_connect=False)
  403. ev = dev[0].wait_event(["CTRL-EVENT-EAP-TLS-CERT-ERROR"], timeout=10)
  404. dev[0].request("DISCONNECT")
  405. if ev is None:
  406. raise Exception("Certificate error not reported")
  407. if "reason=11" in ev and "err='Insufficient RSA modulus size'" in ev:
  408. return
  409. if "reason=7" in ev and "err='certificate uses insecure algorithm'" in ev:
  410. return
  411. raise Exception("Unexpected error reason: " + ev)
  412. def test_suite_b_192_rsa_insufficient_dh(dev, apdev):
  413. """WPA2/GCMP-256 connection at Suite B 192-bit level and RSA with insufficient DH key length"""
  414. check_suite_b_192_capa(dev)
  415. dev[0].flush_scan_cache()
  416. params = suite_b_192_rsa_ap_params()
  417. params["tls_flags"] = "[SUITEB-NO-ECDH]"
  418. params["dh_file"] = "auth_serv/dh.conf"
  419. hapd = hostapd.add_ap(apdev[0], params)
  420. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  421. ieee80211w="2",
  422. phase1="tls_suiteb=1",
  423. eap="TLS", identity="tls user",
  424. ca_cert="auth_serv/rsa3072-ca.pem",
  425. client_cert="auth_serv/rsa3072-user.pem",
  426. private_key="auth_serv/rsa3072-user.key",
  427. pairwise="GCMP-256", group="GCMP-256", scan_freq="2412",
  428. wait_connect=False)
  429. ev = dev[0].wait_event(["CTRL-EVENT-EAP-STATUS status='local TLS alert'",
  430. "CTRL-EVENT-CONNECTED"],
  431. timeout=10)
  432. dev[0].request("DISCONNECT")
  433. if ev is None:
  434. raise Exception("DH error not reported")
  435. if "CTRL-EVENT-CONNECTED" in ev:
  436. raise Exception("Unexpected connection")
  437. if "insufficient security" not in ev and "internal error" not in ev:
  438. raise Exception("Unexpected error reason: " + ev)
  439. def test_suite_b_192_rsa_radius(dev, apdev):
  440. """WPA2/GCMP-256 (RADIUS) connection at Suite B 192-bit level and RSA (ECDHE)"""
  441. check_suite_b_192_capa(dev)
  442. dev[0].flush_scan_cache()
  443. params = suite_b_as_params()
  444. params['ca_cert'] = 'auth_serv/rsa3072-ca.pem'
  445. params['server_cert'] = 'auth_serv/rsa3072-server.pem'
  446. params['private_key'] = 'auth_serv/rsa3072-server.key'
  447. del params['openssl_ciphers']
  448. params["tls_flags"] = "[SUITEB]"
  449. hostapd.add_ap(apdev[1], params)
  450. params = { "ssid": "test-suite-b",
  451. "wpa": "2",
  452. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  453. "rsn_pairwise": "GCMP-256",
  454. "group_mgmt_cipher": "BIP-GMAC-256",
  455. "ieee80211w": "2",
  456. "ieee8021x": "1",
  457. 'auth_server_addr': "127.0.0.1",
  458. 'auth_server_port': "18129",
  459. 'auth_server_shared_secret': "radius",
  460. 'nas_identifier': "nas.w1.fi" }
  461. hapd = hostapd.add_ap(apdev[0], params)
  462. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  463. ieee80211w="2",
  464. openssl_ciphers="ECDHE-RSA-AES256-GCM-SHA384",
  465. phase1="tls_suiteb=1",
  466. eap="TLS", identity="tls user",
  467. ca_cert="auth_serv/rsa3072-ca.pem",
  468. client_cert="auth_serv/rsa3072-user.pem",
  469. private_key="auth_serv/rsa3072-user.key",
  470. pairwise="GCMP-256", group="GCMP-256",
  471. group_mgmt="BIP-GMAC-256", scan_freq="2412")
  472. tls_cipher = dev[0].get_status_field("EAP TLS cipher")
  473. if tls_cipher != "ECDHE-RSA-AES256-GCM-SHA384" and \
  474. tls_cipher != "ECDHE-RSA-AES-256-GCM-AEAD":
  475. raise Exception("Unexpected TLS cipher: " + tls_cipher)
  476. def test_suite_b_192_rsa_ecdhe_radius_rsa2048_client(dev, apdev):
  477. """Suite B 192-bit level and RSA (ECDHE) and RSA2048 client"""
  478. run_suite_b_192_rsa_radius_rsa2048_client(dev, apdev, True)
  479. def test_suite_b_192_rsa_dhe_radius_rsa2048_client(dev, apdev):
  480. """Suite B 192-bit level and RSA (DHE) and RSA2048 client"""
  481. run_suite_b_192_rsa_radius_rsa2048_client(dev, apdev, False)
  482. def run_suite_b_192_rsa_radius_rsa2048_client(dev, apdev, ecdhe):
  483. check_suite_b_192_capa(dev)
  484. dev[0].flush_scan_cache()
  485. params = suite_b_as_params()
  486. params['ca_cert'] = 'auth_serv/rsa3072-ca.pem'
  487. params['server_cert'] = 'auth_serv/rsa3072-server.pem'
  488. params['private_key'] = 'auth_serv/rsa3072-server.key'
  489. del params['openssl_ciphers']
  490. if ecdhe:
  491. params["tls_flags"] = "[SUITEB]"
  492. ciphers = "ECDHE-RSA-AES256-GCM-SHA384"
  493. else:
  494. params["tls_flags"] = "[SUITEB-NO-ECDH]"
  495. params["dh_file"] = "auth_serv/dh_param_3072.pem"
  496. ciphers = "DHE-RSA-AES256-GCM-SHA384"
  497. hostapd.add_ap(apdev[1], params)
  498. params = { "ssid": "test-suite-b",
  499. "wpa": "2",
  500. "wpa_key_mgmt": "WPA-EAP-SUITE-B-192",
  501. "rsn_pairwise": "GCMP-256",
  502. "group_mgmt_cipher": "BIP-GMAC-256",
  503. "ieee80211w": "2",
  504. "ieee8021x": "1",
  505. 'auth_server_addr': "127.0.0.1",
  506. 'auth_server_port': "18129",
  507. 'auth_server_shared_secret': "radius",
  508. 'nas_identifier': "nas.w1.fi" }
  509. hapd = hostapd.add_ap(apdev[0], params)
  510. dev[0].connect("test-suite-b", key_mgmt="WPA-EAP-SUITE-B-192",
  511. ieee80211w="2",
  512. openssl_ciphers=ciphers,
  513. phase1="tls_suiteb=1",
  514. eap="TLS", identity="tls user",
  515. ca_cert="auth_serv/rsa3072-ca.pem",
  516. client_cert="auth_serv/rsa3072-user-rsa2048.pem",
  517. private_key="auth_serv/rsa3072-user-rsa2048.key",
  518. pairwise="GCMP-256", group="GCMP-256",
  519. group_mgmt="BIP-GMAC-256", scan_freq="2412",
  520. wait_connect=False)
  521. ev = dev[0].wait_event(["CTRL-EVENT-EAP-FAILURE"], timeout=10)
  522. if ev is None:
  523. raise Exception("EAP-Failure not reported")
  524. ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED"], timeout=5)
  525. if ev is None:
  526. raise Exception("Disconnection not reported")
  527. if "reason=23" not in ev:
  528. raise Exception("Unexpected disconnection reason: " + ev);