From 7e26f1bc896a5bcd77fc992196e0b5584c7535fc Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 2 Dec 2018 01:20:30 +0200 Subject: [PATCH] tests: DPP peer introduction local failures Signed-off-by: Jouni Malinen --- tests/hwsim/test_dpp.py | 165 ++++++++++++++++++++++++++++++---------- 1 file changed, 126 insertions(+), 39 deletions(-) diff --git a/tests/hwsim/test_dpp.py b/tests/hwsim/test_dpp.py index 228c93fc1..5d5d73376 100644 --- a/tests/hwsim/test_dpp.py +++ b/tests/hwsim/test_dpp.py @@ -1806,25 +1806,25 @@ def run_dpp_akm(dev, apdev, pmk_len): if val != "DPP": raise Exception("Unexpected key_mgmt: " + val) +params1_csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee" +params1_ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ" +params1_ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932" +params1_sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ" +params1_sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380" + def test_dpp_network_introduction(dev, apdev): """DPP network introduction""" check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee" - ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ" - ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932" - sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ" - sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380" - params = { "ssid": "dpp", "wpa": "2", "wpa_key_mgmt": "DPP", "ieee80211w": "2", "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign, - "dpp_netaccesskey": ap_netaccesskey } + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey } try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1832,9 +1832,9 @@ def test_dpp_network_introduction(dev, apdev): id = dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", - dpp_csign=csign, - dpp_connector=sta_connector, - dpp_netaccesskey=sta_netaccesskey) + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey) val = dev[0].get_status_field("key_mgmt") if val != "DPP": raise Exception("Unexpected key_mgmt: " + val) @@ -1846,21 +1846,15 @@ def test_dpp_and_sae_akm(dev, apdev): if "SAE" not in dev[1].get_capability("auth_alg"): raise HwsimSkip("SAE not supported") - csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee" - ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ" - ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932" - sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ" - sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380" - params = { "ssid": "dpp+sae", "wpa": "2", "wpa_key_mgmt": "DPP SAE", "ieee80211w": "2", "rsn_pairwise": "CCMP", "sae_password": "sae-password", - "dpp_connector": ap_connector, - "dpp_csign": csign, - "dpp_netaccesskey": ap_netaccesskey } + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey } try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -1868,9 +1862,9 @@ def test_dpp_and_sae_akm(dev, apdev): id = dev[0].connect("dpp+sae", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", - dpp_csign=csign, - dpp_connector=sta_connector, - dpp_netaccesskey=sta_netaccesskey) + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey) val = dev[0].get_status_field("key_mgmt") if val != "DPP": raise Exception("Unexpected key_mgmt for DPP: " + val) @@ -4554,20 +4548,14 @@ def test_dpp_proto_network_introduction(dev, apdev): check_dpp_capab(dev[0]) check_dpp_capab(dev[1]) - csign = "3059301306072a8648ce3d020106082a8648ce3d03010703420004d02e5bd81a120762b5f0f2994777f5d40297238a6c294fd575cdf35fabec44c050a6421c401d98d659fd2ed13c961cc8287944dd3202f516977800d3ab2f39ee" - ap_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6ImFwIn1dLCJuZXRBY2Nlc3NLZXkiOnsia3R5IjoiRUMiLCJjcnYiOiJQLTI1NiIsIngiOiIwOHF4TlNYRzRWemdCV3BjVUdNSmc1czNvbElOVFJsRVQ1aERpNkRKY3ZjIiwieSI6IlVhaGFYQXpKRVpRQk1YaHRUQnlZZVlrOWtJYjk5UDA3UV9NcW9TVVZTVEkifX0.a5_nfMVr7Qe1SW0ZL3u6oQRm5NUCYUSfixDAJOUFN3XUfECBZ6E8fm8xjeSfdOytgRidTz0CTlIRjzPQo82dmQ" - ap_netaccesskey = "30770201010420f6531d17f29dfab655b7c9e923478d5a345164c489aadd44a3519c3e9dcc792da00a06082a8648ce3d030107a14403420004d3cab13525c6e15ce0056a5c506309839b37a2520d4d19444f98438ba0c972f751a85a5c0cc911940131786d4c1c9879893d9086fdf4fd3b43f32aa125154932" - sta_connector = "eyJ0eXAiOiJkcHBDb24iLCJraWQiOiJzOEFrYjg5bTV4UGhoYk5UbTVmVVo0eVBzNU5VMkdxYXNRY3hXUWhtQVFRIiwiYWxnIjoiRVMyNTYifQ.eyJncm91cHMiOlt7Imdyb3VwSWQiOiIqIiwibmV0Um9sZSI6InN0YSJ9XSwibmV0QWNjZXNzS2V5Ijp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiZWMzR3NqQ3lQMzVBUUZOQUJJdEltQnN4WXVyMGJZX1dES1lfSE9zUGdjNCIsInkiOiJTRS1HVllkdWVnTFhLMU1TQXZNMEx2QWdLREpTNWoyQVhCbE9PMTdUSTRBIn19.PDK9zsGlK-e1pEOmNxVeJfCS8pNeay6ckIS1TXCQsR64AR-9wFPCNVjqOxWvVKltehyMFqVAtOcv0IrjtMJFqQ" - sta_netaccesskey = "30770201010420bc33380c26fd2168b69cd8242ed1df07ba89aa4813f8d4e8523de6ca3f8dd28ba00a06082a8648ce3d030107a1440342000479cdc6b230b23f7e40405340048b48981b3162eaf46d8fd60ca63f1ceb0f81ce484f8655876e7a02d72b531202f3342ef020283252e63d805c194e3b5ed32380" - params = { "ssid": "dpp", "wpa": "2", "wpa_key_mgmt": "DPP", "ieee80211w": "2", "rsn_pairwise": "CCMP", - "dpp_connector": ap_connector, - "dpp_csign": csign, - "dpp_netaccesskey": ap_netaccesskey } + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey } try: hapd = hostapd.add_ap(apdev[0], params) except: @@ -4576,8 +4564,10 @@ def test_dpp_proto_network_introduction(dev, apdev): for test in [ 60, 61, 80, 82 ]: dev[0].set("dpp_test", str(test)) dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", - dpp_csign=csign, dpp_connector=sta_connector, - dpp_netaccesskey=sta_netaccesskey, wait_connect=False) + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) ev = dev[0].wait_event(["DPP-TX"], timeout=10) if ev is None or "type=5" not in ev: @@ -4605,8 +4595,10 @@ def test_dpp_proto_network_introduction(dev, apdev): for test in [ 62, 63, 64, 77, 78, 79 ]: hapd.set("dpp_test", str(test)) dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", - dpp_csign=csign, dpp_connector=sta_connector, - dpp_netaccesskey=sta_netaccesskey, wait_connect=False) + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) ev = dev[0].wait_event(["DPP-INTRO"], timeout=10) if ev is None: @@ -4629,8 +4621,8 @@ def test_dpp_proto_network_introduction(dev, apdev): hapd.set("dpp_test", "0") dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", ieee80211w="2", - dpp_csign=csign, dpp_connector=sta_connector, - dpp_netaccesskey=sta_netaccesskey) + dpp_csign=params1_csign, dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey) def test_dpp_qr_code_no_chan_list_unicast(dev, apdev): """DPP QR Code and no channel list (unicast)""" @@ -5448,3 +5440,98 @@ def run_dpp_peer_intro_failures(dev, apdev): raise Exception("Introduction failure not reported") dev[0].request("DISCONNECT") dev[0].dump_monitor() + +def test_dpp_peer_intro_local_failures(dev, apdev): + """DPP peer introduction local failures""" + check_dpp_capab(dev[0]) + check_dpp_capab(dev[1]) + + params = { "ssid": "dpp", + "wpa": "2", + "wpa_key_mgmt": "DPP", + "ieee80211w": "2", + "rsn_pairwise": "CCMP", + "dpp_connector": params1_ap_connector, + "dpp_csign": params1_csign, + "dpp_netaccesskey": params1_ap_netaccesskey } + try: + hapd = hostapd.add_ap(apdev[0], params) + except: + raise HwsimSkip("DPP not supported") + + tests = [ "dpp_derive_pmk", + "dpp_hkdf_expand;dpp_derive_pmk", + "dpp_derive_pmkid" ] + for func in tests: + with fail_test(dev[0], 1, func): + dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", + ieee80211w="2", + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) + ev = dev[0].wait_event(["DPP-INTRO"], timeout=10) + if ev is None or "fail=peer_connector_validation_failed" not in ev: + raise Exception("Introduction failure not reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor() + + tests = [ (1, "base64_gen_decode;dpp_peer_intro"), + (1, "json_parse;dpp_peer_intro"), + (50, "json_parse;dpp_peer_intro"), + (1, "=dpp_peer_intro"), + (1, "dpp_parse_jwk") ] + for count,func in tests: + with alloc_fail(dev[0], count, func): + dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", + ieee80211w="2", + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) + ev = dev[0].wait_event(["DPP-INTRO"], timeout=10) + if ev is None or "fail=peer_connector_validation_failed" not in ev: + raise Exception("Introduction failure not reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor() + + parts = params1_ap_connector.split('.') + for ap_connector in [ '.'.join(parts[0:2]), '.'.join(parts[0:1]) ]: + hapd.set("dpp_connector", ap_connector) + dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", + ieee80211w="2", + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) + ev = dev[0].wait_event(["DPP-TX-STATUS"], timeout=10) + if ev is None: + raise Exception("No TX status reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor() + + hapd.set("dpp_netaccesskey", "00") + dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", + ieee80211w="2", + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) + ev = dev[0].wait_event(["DPP-TX-STATUS"], timeout=10) + if ev is None: + raise Exception("No TX status reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor() + + hapd.set("dpp_csign", "00") + dev[0].connect("dpp", key_mgmt="DPP", scan_freq="2412", + ieee80211w="2", + dpp_csign=params1_csign, + dpp_connector=params1_sta_connector, + dpp_netaccesskey=params1_sta_netaccesskey, + wait_connect=False) + ev = dev[0].wait_event(["DPP-TX-STATUS"], timeout=10) + if ev is None: + raise Exception("No TX status reported") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor()