test_suite_b.py 25 KB

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