]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/test_tnc.py
9790a3b0aa632a9c8fd0f50feca4b0cb8d1692fb
[thirdparty/hostap.git] / tests / hwsim / test_tnc.py
1 # -*- coding: utf-8 -*-
2 # TNC tests
3 # Copyright (c) 2014, Jouni Malinen <j@w1.fi>
4 #
5 # This software may be distributed under the terms of the BSD license.
6 # See README for more details.
7
8 import os.path
9
10 import hostapd
11 from test_ap_eap import int_eap_server_params
12
13 def test_tnc_peap_soh(dev, apdev):
14 """TNC PEAP-SoH"""
15 params = int_eap_server_params()
16 params["tnc"] = "1"
17 hostapd.add_ap(apdev[0]['ifname'], params)
18
19 dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
20 eap="PEAP", identity="user", password="password",
21 ca_cert="auth_serv/ca.pem",
22 phase1="peapver=0 tnc=soh cryptobinding=0",
23 phase2="auth=MSCHAPV2",
24 wait_connect=False)
25 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
26 if ev is None:
27 raise Exception("Connection timed out")
28
29 dev[1].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
30 eap="PEAP", identity="user", password="password",
31 ca_cert="auth_serv/ca.pem",
32 phase1="peapver=0 tnc=soh1 cryptobinding=1",
33 phase2="auth=MSCHAPV2",
34 wait_connect=False)
35 ev = dev[1].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
36 if ev is None:
37 raise Exception("Connection timed out")
38
39 dev[2].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
40 eap="PEAP", identity="user", password="password",
41 ca_cert="auth_serv/ca.pem",
42 phase1="peapver=0 tnc=soh2 cryptobinding=2",
43 phase2="auth=MSCHAPV2",
44 wait_connect=False)
45 ev = dev[2].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
46 if ev is None:
47 raise Exception("Connection timed out")
48
49 def test_tnc_ttls(dev, apdev):
50 """TNC TTLS"""
51 params = int_eap_server_params()
52 params["tnc"] = "1"
53 hostapd.add_ap(apdev[0]['ifname'], params)
54
55 if not os.path.exists("tnc/libhostap_imc.so"):
56 logger.info("No IMC installed - skip")
57 return "skip"
58
59 dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
60 eap="TTLS", identity="DOMAIN\mschapv2 user",
61 anonymous_identity="ttls", password="password",
62 phase2="auth=MSCHAPV2",
63 ca_cert="auth_serv/ca.pem",
64 wait_connect=False)
65 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
66 if ev is None:
67 raise Exception("Connection timed out")
68
69 def test_tnc_fast(dev, apdev):
70 """TNC FAST"""
71 params = int_eap_server_params()
72 params["tnc"] = "1"
73 params["pac_opaque_encr_key"] ="000102030405060708090a0b0c0d0e00"
74 params["eap_fast_a_id"] = "101112131415161718191a1b1c1d1e00"
75 params["eap_fast_a_id_info"] = "test server2"
76
77 hostapd.add_ap(apdev[0]['ifname'], params)
78
79 if not os.path.exists("tnc/libhostap_imc.so"):
80 logger.info("No IMC installed - skip")
81 return "skip"
82
83 dev[0].connect("test-wpa2-eap", key_mgmt="WPA-EAP",
84 eap="FAST", identity="user",
85 anonymous_identity="FAST", password="password",
86 phase2="auth=GTC",
87 phase1="fast_provisioning=2",
88 pac_file="blob://fast_pac_auth_tnc",
89 ca_cert="auth_serv/ca.pem",
90 wait_connect=False)
91 ev = dev[0].wait_event(["CTRL-EVENT-CONNECTED"], timeout=10)
92 if ev is None:
93 raise Exception("Connection timed out")