From d45a241933b2749455c7149fe79d2f57b6f293f3 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Tue, 16 Apr 2019 22:37:18 +0300 Subject: [PATCH] tests: OWE invalid Association Response frame contents Signed-off-by: Jouni Malinen --- tests/hwsim/test_owe.py | 88 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/tests/hwsim/test_owe.py b/tests/hwsim/test_owe.py index fcf259b4e..ee0318204 100644 --- a/tests/hwsim/test_owe.py +++ b/tests/hwsim/test_owe.py @@ -4,10 +4,12 @@ # This software may be distributed under the terms of the BSD license. # See README for more details. +import binascii import logging logger = logging.getLogger() import time import os +import struct import hostapd from wpasupplicant import WpaSupplicant @@ -539,3 +541,89 @@ def test_owe_local_errors(dev, apdev): time.sleep(0.5) dev[0].request("REMOVE_NETWORK all") dev[0].dump_monitor() + +def hapd_auth(hapd): + for i in range(0, 10): + req = hapd.mgmt_rx() + if req is None: + raise Exception("MGMT RX wait timed out") + if req['subtype'] == 11: + break + req = None + if not req: + raise Exception("Authentication frame not received") + + resp = {} + resp['fc'] = req['fc'] + resp['da'] = req['sa'] + resp['sa'] = req['da'] + resp['bssid'] = req['bssid'] + resp['payload'] = struct.pack(' no DH Params + tests += [binascii.unhexlify('ff0120')] + # OWE: Unexpected Diffie-Hellman group in response: 18 + tests += [binascii.unhexlify('ff03201200')] + # OWE: Invalid peer DH public key + tests += [binascii.unhexlify('ff23201300' + 31*'00' + '01')] + # OWE: Invalid peer DH public key + tests += [binascii.unhexlify('ff24201300' + 33*'ee')] + for extra in tests: + dev[0].connect("owe", key_mgmt="OWE", owe_group="19", ieee80211w="2", + scan_freq="2412", wait_connect=False) + hapd_auth(hapd) + hapd_assoc(hapd, extra) + dev[0].wait_disconnected() + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor() + + # OWE: Empty public key (this ends up getting padded to a valid point) + dev[0].connect("owe", key_mgmt="OWE", owe_group="19", ieee80211w="2", + scan_freq="2412", wait_connect=False) + hapd_auth(hapd) + hapd_assoc(hapd, binascii.unhexlify('ff03201300')) + ev = dev[0].wait_event(["CTRL-EVENT-DISCONNECTED", "PMKSA-CACHE-ADDED"], + timeout=5) + if ev is None: + raise Exception("No result reported for empty public key") + dev[0].request("REMOVE_NETWORK all") + dev[0].dump_monitor()