tests: Use 'b' prefix to mark Bytes literals explicitly for python3
Signed-off-by: Masashi Honma <masashi.honma@gmail.com> Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
d5e6ffd661
commit
15dfcb69df
14 changed files with 415 additions and 415 deletions
|
@ -2061,81 +2061,81 @@ def test_ap_ft_rrb(dev, apdev):
|
||||||
|
|
||||||
_dst_ll = binascii.unhexlify(apdev[0]['bssid'].replace(':',''))
|
_dst_ll = binascii.unhexlify(apdev[0]['bssid'].replace(':',''))
|
||||||
_src_ll = binascii.unhexlify(dev[0].own_addr().replace(':',''))
|
_src_ll = binascii.unhexlify(dev[0].own_addr().replace(':',''))
|
||||||
proto = '\x89\x0d'
|
proto = b'\x89\x0d'
|
||||||
ehdr = _dst_ll + _src_ll + proto
|
ehdr = _dst_ll + _src_ll + proto
|
||||||
|
|
||||||
# Too short RRB frame
|
# Too short RRB frame
|
||||||
pkt = ehdr + '\x01'
|
pkt = ehdr + b'\x01'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# RRB discarded frame wikth unrecognized type
|
# RRB discarded frame wikth unrecognized type
|
||||||
pkt = ehdr + '\x02' + '\x02' + '\x01\x00' + _src_ll
|
pkt = ehdr + b'\x02' + b'\x02' + b'\x01\x00' + _src_ll
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# RRB frame too short for action frame
|
# RRB frame too short for action frame
|
||||||
pkt = ehdr + '\x01' + '\x02' + '\x01\x00' + _src_ll
|
pkt = ehdr + b'\x01' + b'\x02' + b'\x01\x00' + _src_ll
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Too short RRB frame (not enough room for Action Frame body)
|
# Too short RRB frame (not enough room for Action Frame body)
|
||||||
pkt = ehdr + '\x01' + '\x02' + '\x00\x00' + _src_ll
|
pkt = ehdr + b'\x01' + b'\x02' + b'\x00\x00' + _src_ll
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Unexpected Action frame category
|
# Unexpected Action frame category
|
||||||
pkt = ehdr + '\x01' + '\x02' + '\x0e\x00' + _src_ll + '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\x02' + b'\x0e\x00' + _src_ll + b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Unexpected Action in RRB Request
|
# Unexpected Action in RRB Request
|
||||||
pkt = ehdr + '\x01' + '\x00' + '\x0e\x00' + _src_ll + '\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\x00' + b'\x0e\x00' + _src_ll + b'\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Target AP address in RRB Request does not match with own address
|
# Target AP address in RRB Request does not match with own address
|
||||||
pkt = ehdr + '\x01' + '\x00' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\x00' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Not enough room for status code in RRB Response
|
# Not enough room for status code in RRB Response
|
||||||
pkt = ehdr + '\x01' + '\x01' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\x01' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# RRB discarded frame with unknown packet_type
|
# RRB discarded frame with unknown packet_type
|
||||||
pkt = ehdr + '\x01' + '\x02' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\x02' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# RRB Response with non-zero status code; no STA match
|
# RRB Response with non-zero status code; no STA match
|
||||||
pkt = ehdr + '\x01' + '\x01' + '\x10\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + '\xff\xff'
|
pkt = ehdr + b'\x01' + b'\x01' + b'\x10\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + b'\xff\xff'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# RRB Response with zero status code and extra data; STA match
|
# RRB Response with zero status code and extra data; STA match
|
||||||
pkt = ehdr + '\x01' + '\x01' + '\x11\x00' + _src_ll + '\x06\x01' + _src_ll + '\x00\x00\x00\x00\x00\x00' + '\x00\x00' + '\x00'
|
pkt = ehdr + b'\x01' + b'\x01' + b'\x11\x00' + _src_ll + b'\x06\x01' + _src_ll + b'\x00\x00\x00\x00\x00\x00' + b'\x00\x00' + b'\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Too short PMK-R1 pull
|
# Too short PMK-R1 pull
|
||||||
pkt = ehdr + '\x01' + '\xc8' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\xc8' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Too short PMK-R1 resp
|
# Too short PMK-R1 resp
|
||||||
pkt = ehdr + '\x01' + '\xc9' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\xc9' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# Too short PMK-R1 push
|
# Too short PMK-R1 push
|
||||||
pkt = ehdr + '\x01' + '\xca' + '\x0e\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
pkt = ehdr + b'\x01' + b'\xca' + b'\x0e\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
# No matching R0KH address found for PMK-R0 pull response
|
# No matching R0KH address found for PMK-R0 pull response
|
||||||
pkt = ehdr + '\x01' + '\xc9' + '\x5a\x00' + _src_ll + '\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + 76*'\00'
|
pkt = ehdr + b'\x01' + b'\xc9' + b'\x5a\x00' + _src_ll + b'\x06\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' + 76 * b'\00'
|
||||||
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
if "OK" not in dev[0].request("DATA_TEST_FRAME " + binascii.hexlify(pkt).decode()):
|
||||||
raise Exception("DATA_TEST_FRAME failed")
|
raise Exception("DATA_TEST_FRAME failed")
|
||||||
|
|
||||||
|
|
|
@ -3011,7 +3011,7 @@ def test_ap_hs20_fetch_osu(dev, apdev):
|
||||||
raise Exception("GET_HS20_ICON with too many output bytes to fit the buffer succeeded")
|
raise Exception("GET_HS20_ICON with too many output bytes to fit the buffer succeeded")
|
||||||
if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 0 0"):
|
if "FAIL" not in dev[2].request("GET_HS20_ICON " + bssid + " w1fi_logo 0 0"):
|
||||||
raise Exception("GET_HS20_ICON 0..0 succeeded")
|
raise Exception("GET_HS20_ICON 0..0 succeeded")
|
||||||
icon = ""
|
icon = b''
|
||||||
pos = 0
|
pos = 0
|
||||||
while True:
|
while True:
|
||||||
if pos > 100000:
|
if pos > 100000:
|
||||||
|
@ -3253,7 +3253,7 @@ def test_ap_hs20_fetch_osu_single_ssid2(dev, apdev):
|
||||||
os.rmdir(dir)
|
os.rmdir(dir)
|
||||||
|
|
||||||
def get_icon(dev, bssid, iconname):
|
def get_icon(dev, bssid, iconname):
|
||||||
icon = ""
|
icon = b''
|
||||||
pos = 0
|
pos = 0
|
||||||
while True:
|
while True:
|
||||||
if pos > 100000:
|
if pos > 100000:
|
||||||
|
@ -3330,13 +3330,13 @@ def test_ap_hs20_req_operator_icon(dev, apdev):
|
||||||
params['operator_icon'] = [ "w1fi_logo", "unknown_logo", "test_logo" ]
|
params['operator_icon'] = [ "w1fi_logo", "unknown_logo", "test_logo" ]
|
||||||
hostapd.add_ap(apdev[0], params)
|
hostapd.add_ap(apdev[0], params)
|
||||||
|
|
||||||
value = struct.pack('<HH', 128, 80) + "zxx"
|
value = struct.pack('<HH', 128, 80) + b"zxx"
|
||||||
value += struct.pack('B', 9) + "image/png"
|
value += struct.pack('B', 9) + b"image/png"
|
||||||
value += struct.pack('B', 9) + "w1fi_logo"
|
value += struct.pack('B', 9) + b"w1fi_logo"
|
||||||
|
|
||||||
value += struct.pack('<HH', 500, 300) + "fi\0"
|
value += struct.pack('<HH', 500, 300) + b"fi\0"
|
||||||
value += struct.pack('B', 9) + "image/png"
|
value += struct.pack('B', 9) + b"image/png"
|
||||||
value += struct.pack('B', 9) + "test_logo"
|
value += struct.pack('B', 9) + b"test_logo"
|
||||||
|
|
||||||
dev[0].scan_for_bss(bssid, freq="2412")
|
dev[0].scan_for_bss(bssid, freq="2412")
|
||||||
|
|
||||||
|
@ -3578,11 +3578,11 @@ def test_ap_hs20_fetch_osu_proto(dev, apdev):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
tests = [ ( "Empty provider list (no OSU SSID field)", '' ),
|
tests = [ ( "Empty provider list (no OSU SSID field)", b'' ),
|
||||||
( "HS 2.0: Not enough room for OSU SSID",
|
( "HS 2.0: Not enough room for OSU SSID",
|
||||||
binascii.unhexlify('01') ),
|
binascii.unhexlify('01') ),
|
||||||
( "HS 2.0: Invalid OSU SSID Length 33",
|
( "HS 2.0: Invalid OSU SSID Length 33",
|
||||||
binascii.unhexlify('21') + 33*'A' ),
|
binascii.unhexlify('21') + 33*b'A' ),
|
||||||
( "HS 2.0: Not enough room for Number of OSU Providers",
|
( "HS 2.0: Not enough room for Number of OSU Providers",
|
||||||
binascii.unhexlify('0130') ),
|
binascii.unhexlify('0130') ),
|
||||||
( "Truncated OSU Provider",
|
( "Truncated OSU Provider",
|
||||||
|
@ -4135,8 +4135,8 @@ def _test_ap_hs20_proxyarp(dev, apdev):
|
||||||
addr0 = dev[0].p2p_interface_addr()
|
addr0 = dev[0].p2p_interface_addr()
|
||||||
addr1 = dev[1].p2p_interface_addr()
|
addr1 = dev[1].p2p_interface_addr()
|
||||||
|
|
||||||
src_ll_opt0 = "\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
||||||
src_ll_opt1 = "\x01\x01" + binascii.unhexlify(addr1.replace(':',''))
|
src_ll_opt1 = b"\x01\x01" + binascii.unhexlify(addr1.replace(':',''))
|
||||||
|
|
||||||
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
||||||
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
||||||
|
@ -4258,7 +4258,7 @@ def _test_ap_hs20_proxyarp_dgaf(dev, apdev, disabled):
|
||||||
|
|
||||||
addr0 = dev[0].p2p_interface_addr()
|
addr0 = dev[0].p2p_interface_addr()
|
||||||
|
|
||||||
src_ll_opt0 = "\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
||||||
|
|
||||||
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
||||||
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
||||||
|
@ -4329,7 +4329,7 @@ def test_ap_hs20_proxyarp_enable_dgaf(dev, apdev):
|
||||||
def ip_checksum(buf):
|
def ip_checksum(buf):
|
||||||
sum = 0
|
sum = 0
|
||||||
if len(buf) & 0x01:
|
if len(buf) & 0x01:
|
||||||
buf += '\x00'
|
buf += b'\x00'
|
||||||
for i in range(0, len(buf), 2):
|
for i in range(0, len(buf), 2):
|
||||||
val, = struct.unpack('H', buf[i:i+2])
|
val, = struct.unpack('H', buf[i:i+2])
|
||||||
sum += val
|
sum += val
|
||||||
|
@ -4353,7 +4353,7 @@ def ipv6_solicited_node_mcaddr(target):
|
||||||
def build_icmpv6(ipv6_addrs, type, code, payload):
|
def build_icmpv6(ipv6_addrs, type, code, payload):
|
||||||
start = struct.pack("BB", type, code)
|
start = struct.pack("BB", type, code)
|
||||||
end = payload
|
end = payload
|
||||||
icmp = start + '\x00\x00' + end
|
icmp = start + b'\x00\x00' + end
|
||||||
pseudo = ipv6_addrs + struct.pack(">LBBBB", len(icmp), 0, 0, 0, 58)
|
pseudo = ipv6_addrs + struct.pack(">LBBBB", len(icmp), 0, 0, 0, 58)
|
||||||
csum = ip_checksum(pseudo + icmp)
|
csum = ip_checksum(pseudo + icmp)
|
||||||
return start + csum + end
|
return start + csum + end
|
||||||
|
@ -4362,7 +4362,7 @@ def build_ra(src_ll, ip_src, ip_dst, cur_hop_limit=0, router_lifetime=0,
|
||||||
reachable_time=0, retrans_timer=0, opt=None):
|
reachable_time=0, retrans_timer=0, opt=None):
|
||||||
link_mc = binascii.unhexlify("3333ff000002")
|
link_mc = binascii.unhexlify("3333ff000002")
|
||||||
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
||||||
proto = '\x86\xdd'
|
proto = b'\x86\xdd'
|
||||||
ehdr = link_mc + _src_ll + proto
|
ehdr = link_mc + _src_ll + proto
|
||||||
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
||||||
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
||||||
|
@ -4383,14 +4383,14 @@ def build_ra(src_ll, ip_src, ip_dst, cur_hop_limit=0, router_lifetime=0,
|
||||||
def build_ns(src_ll, ip_src, ip_dst, target, opt=None):
|
def build_ns(src_ll, ip_src, ip_dst, target, opt=None):
|
||||||
link_mc = binascii.unhexlify("3333ff000002")
|
link_mc = binascii.unhexlify("3333ff000002")
|
||||||
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
||||||
proto = '\x86\xdd'
|
proto = b'\x86\xdd'
|
||||||
ehdr = link_mc + _src_ll + proto
|
ehdr = link_mc + _src_ll + proto
|
||||||
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
||||||
if ip_dst is None:
|
if ip_dst is None:
|
||||||
ip_dst = ipv6_solicited_node_mcaddr(target)
|
ip_dst = ipv6_solicited_node_mcaddr(target)
|
||||||
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
||||||
|
|
||||||
reserved = '\x00\x00\x00\x00'
|
reserved = b'\x00\x00\x00\x00'
|
||||||
_target = socket.inet_pton(socket.AF_INET6, target)
|
_target = socket.inet_pton(socket.AF_INET6, target)
|
||||||
if opt:
|
if opt:
|
||||||
payload = reserved + _target + opt
|
payload = reserved + _target + opt
|
||||||
|
@ -4415,7 +4415,7 @@ def send_ns(dev, src_ll=None, target=None, ip_src=None, ip_dst=None, opt=None,
|
||||||
cmd = "DATA_TEST_FRAME "
|
cmd = "DATA_TEST_FRAME "
|
||||||
|
|
||||||
if opt is None:
|
if opt is None:
|
||||||
opt = "\x01\x01" + binascii.unhexlify(src_ll.replace(':',''))
|
opt = b"\x01\x01" + binascii.unhexlify(src_ll.replace(':',''))
|
||||||
|
|
||||||
pkt = build_ns(src_ll=src_ll, ip_src=ip_src, ip_dst=ip_dst, target=target,
|
pkt = build_ns(src_ll=src_ll, ip_src=ip_src, ip_dst=ip_dst, target=target,
|
||||||
opt=opt)
|
opt=opt)
|
||||||
|
@ -4425,7 +4425,7 @@ def send_ns(dev, src_ll=None, target=None, ip_src=None, ip_dst=None, opt=None,
|
||||||
def build_na(src_ll, ip_src, ip_dst, target, opt=None, flags=0):
|
def build_na(src_ll, ip_src, ip_dst, target, opt=None, flags=0):
|
||||||
link_mc = binascii.unhexlify("3333ff000002")
|
link_mc = binascii.unhexlify("3333ff000002")
|
||||||
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
||||||
proto = '\x86\xdd'
|
proto = b'\x86\xdd'
|
||||||
ehdr = link_mc + _src_ll + proto
|
ehdr = link_mc + _src_ll + proto
|
||||||
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
_ip_src = socket.inet_pton(socket.AF_INET6, ip_src)
|
||||||
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
_ip_dst = socket.inet_pton(socket.AF_INET6, ip_dst)
|
||||||
|
@ -4464,42 +4464,42 @@ def build_dhcp_ack(dst_ll, src_ll, ip_src, ip_dst, yiaddr, chaddr,
|
||||||
udp_checksum=True):
|
udp_checksum=True):
|
||||||
_dst_ll = binascii.unhexlify(dst_ll.replace(':',''))
|
_dst_ll = binascii.unhexlify(dst_ll.replace(':',''))
|
||||||
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
||||||
proto = '\x08\x00'
|
proto = b'\x08\x00'
|
||||||
ehdr = _dst_ll + _src_ll + proto
|
ehdr = _dst_ll + _src_ll + proto
|
||||||
_ip_src = socket.inet_pton(socket.AF_INET, ip_src)
|
_ip_src = socket.inet_pton(socket.AF_INET, ip_src)
|
||||||
_ip_dst = socket.inet_pton(socket.AF_INET, ip_dst)
|
_ip_dst = socket.inet_pton(socket.AF_INET, ip_dst)
|
||||||
_subnet_mask = socket.inet_pton(socket.AF_INET, subnet_mask)
|
_subnet_mask = socket.inet_pton(socket.AF_INET, subnet_mask)
|
||||||
|
|
||||||
_ciaddr = '\x00\x00\x00\x00'
|
_ciaddr = b'\x00\x00\x00\x00'
|
||||||
_yiaddr = socket.inet_pton(socket.AF_INET, yiaddr)
|
_yiaddr = socket.inet_pton(socket.AF_INET, yiaddr)
|
||||||
_siaddr = '\x00\x00\x00\x00'
|
_siaddr = b'\x00\x00\x00\x00'
|
||||||
_giaddr = '\x00\x00\x00\x00'
|
_giaddr = b'\x00\x00\x00\x00'
|
||||||
_chaddr = binascii.unhexlify(chaddr.replace(':','') + "00000000000000000000")
|
_chaddr = binascii.unhexlify(chaddr.replace(':','') + "00000000000000000000")
|
||||||
payload = struct.pack('>BBBBL3BB', 2, 1, 6, 0, 12345, 0, 0, 0, 0)
|
payload = struct.pack('>BBBBL3BB', 2, 1, 6, 0, 12345, 0, 0, 0, 0)
|
||||||
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + 192*'\x00'
|
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + 192*b'\x00'
|
||||||
# magic
|
# magic
|
||||||
if wrong_magic:
|
if wrong_magic:
|
||||||
payload += '\x63\x82\x53\x00'
|
payload += b'\x63\x82\x53\x00'
|
||||||
else:
|
else:
|
||||||
payload += '\x63\x82\x53\x63'
|
payload += b'\x63\x82\x53\x63'
|
||||||
if truncated_opt:
|
if truncated_opt:
|
||||||
payload += '\x22\xff\x00'
|
payload += b'\x22\xff\x00'
|
||||||
# Option: DHCP Message Type = ACK
|
# Option: DHCP Message Type = ACK
|
||||||
payload += '\x35\x01\x05'
|
payload += b'\x35\x01\x05'
|
||||||
# Pad Option
|
# Pad Option
|
||||||
payload += '\x00'
|
payload += b'\x00'
|
||||||
# Option: Subnet Mask
|
# Option: Subnet Mask
|
||||||
payload += '\x01\x04' + _subnet_mask
|
payload += b'\x01\x04' + _subnet_mask
|
||||||
# Option: Time Offset
|
# Option: Time Offset
|
||||||
payload += struct.pack('>BBL', 2, 4, 0)
|
payload += struct.pack('>BBL', 2, 4, 0)
|
||||||
# End Option
|
# End Option
|
||||||
payload += '\xff'
|
payload += b'\xff'
|
||||||
# Pad Option
|
# Pad Option
|
||||||
payload += '\x00\x00\x00\x00'
|
payload += b'\x00\x00\x00\x00'
|
||||||
|
|
||||||
if no_dhcp:
|
if no_dhcp:
|
||||||
payload = struct.pack('>BBBBL3BB', 2, 1, 6, 0, 12345, 0, 0, 0, 0)
|
payload = struct.pack('>BBBBL3BB', 2, 1, 6, 0, 12345, 0, 0, 0, 0)
|
||||||
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + 192*'\x00'
|
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + 192*b'\x00'
|
||||||
|
|
||||||
if udp_checksum:
|
if udp_checksum:
|
||||||
pseudohdr = _ip_src + _ip_dst + struct.pack('>BBH', 0, 17,
|
pseudohdr = _ip_src + _ip_dst + struct.pack('>BBH', 0, 17,
|
||||||
|
@ -4515,7 +4515,7 @@ def build_dhcp_ack(dst_ll, src_ll, ip_src, ip_dst, yiaddr, chaddr,
|
||||||
else:
|
else:
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
ipv4 = start + csum + _ip_src + _ip_dst
|
ipv4 = start + csum + _ip_src + _ip_dst
|
||||||
|
|
||||||
|
@ -4525,7 +4525,7 @@ def build_arp(dst_ll, src_ll, opcode, sender_mac, sender_ip,
|
||||||
target_mac, target_ip):
|
target_mac, target_ip):
|
||||||
_dst_ll = binascii.unhexlify(dst_ll.replace(':',''))
|
_dst_ll = binascii.unhexlify(dst_ll.replace(':',''))
|
||||||
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
_src_ll = binascii.unhexlify(src_ll.replace(':',''))
|
||||||
proto = '\x08\x06'
|
proto = b'\x08\x06'
|
||||||
ehdr = _dst_ll + _src_ll + proto
|
ehdr = _dst_ll + _src_ll + proto
|
||||||
|
|
||||||
_sender_mac = binascii.unhexlify(sender_mac.replace(':',''))
|
_sender_mac = binascii.unhexlify(sender_mac.replace(':',''))
|
||||||
|
@ -5038,8 +5038,8 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False):
|
||||||
addr1 = dev[1].p2p_interface_addr()
|
addr1 = dev[1].p2p_interface_addr()
|
||||||
addr2 = dev[2].p2p_interface_addr()
|
addr2 = dev[2].p2p_interface_addr()
|
||||||
|
|
||||||
src_ll_opt0 = "\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
||||||
src_ll_opt1 = "\x01\x01" + binascii.unhexlify(addr1.replace(':',''))
|
src_ll_opt1 = b"\x01\x01" + binascii.unhexlify(addr1.replace(':',''))
|
||||||
|
|
||||||
# DAD NS
|
# DAD NS
|
||||||
send_ns(dev[0], ip_src="::", target="aaaa:bbbb:cccc::2")
|
send_ns(dev[0], ip_src="::", target="aaaa:bbbb:cccc::2")
|
||||||
|
@ -5050,13 +5050,13 @@ def _test_proxyarp_open_ipv6(dev, apdev, params, ebtables=False):
|
||||||
opt='')
|
opt='')
|
||||||
# test frame with bogus option
|
# test frame with bogus option
|
||||||
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
||||||
opt="\x70\x01\x01\x02\x03\x04\x05\x05")
|
opt=b"\x70\x01\x01\x02\x03\x04\x05\x05")
|
||||||
# test frame with truncated source link-layer address option
|
# test frame with truncated source link-layer address option
|
||||||
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
||||||
opt="\x01\x01\x01\x02\x03\x04")
|
opt=b"\x01\x01\x01\x02\x03\x04")
|
||||||
# test frame with foreign source link-layer address option
|
# test frame with foreign source link-layer address option
|
||||||
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
send_ns(dev[0], ip_src="aaaa:bbbb:cccc::2", target="aaaa:bbbb:cccc::2",
|
||||||
opt="\x01\x01\x01\x02\x03\x04\x05\x06")
|
opt=b"\x01\x01\x01\x02\x03\x04\x05\x06")
|
||||||
|
|
||||||
send_ns(dev[1], ip_src="aaaa:bbbb:dddd::2", target="aaaa:bbbb:dddd::2")
|
send_ns(dev[1], ip_src="aaaa:bbbb:dddd::2", target="aaaa:bbbb:dddd::2")
|
||||||
|
|
||||||
|
@ -5288,7 +5288,7 @@ def run_proxyarp_errors(dev, apdev, params):
|
||||||
wait_fail_trigger(dev[0], "GET_FAIL")
|
wait_fail_trigger(dev[0], "GET_FAIL")
|
||||||
|
|
||||||
with alloc_fail(hapd, 1, "sta_ip6addr_add"):
|
with alloc_fail(hapd, 1, "sta_ip6addr_add"):
|
||||||
src_ll_opt0 = "\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
src_ll_opt0 = b"\x01\x01" + binascii.unhexlify(addr0.replace(':',''))
|
||||||
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
pkt = build_ns(src_ll=addr0, ip_src="aaaa:bbbb:cccc::2",
|
||||||
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
ip_dst="ff02::1:ff00:2", target="aaaa:bbbb:cccc::2",
|
||||||
opt=src_ll_opt0)
|
opt=src_ll_opt0)
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ def build_eapol(msg):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def sha1_prf(key, label, data, outlen):
|
def sha1_prf(key, label, data, outlen):
|
||||||
res = ''
|
res = b''
|
||||||
counter = 0
|
counter = 0
|
||||||
while outlen > 0:
|
while outlen > 0:
|
||||||
m = hmac.new(key, label.encode(), hashlib.sha1)
|
m = hmac.new(key, label.encode(), hashlib.sha1)
|
||||||
|
@ -1296,7 +1296,7 @@ def rsn_eapol_key_set(msg, key_info, key_len, nonce, data):
|
||||||
msg['length'] = 95 + len(data)
|
msg['length'] = 95 + len(data)
|
||||||
else:
|
else:
|
||||||
msg['rsn_key_data_len'] = 0
|
msg['rsn_key_data_len'] = 0
|
||||||
msg['rsn_key_data'] = ''
|
msg['rsn_key_data'] = b''
|
||||||
msg['length'] = 95
|
msg['length'] = 95
|
||||||
|
|
||||||
def recv_eapol(hapd):
|
def recv_eapol(hapd):
|
||||||
|
@ -1577,7 +1577,7 @@ def test_ap_wpa2_psk_ext_eapol_key_info(dev, apdev):
|
||||||
reply_eapol("4/4", hapd, addr, msg, 0x030a, None, None, kck)
|
reply_eapol("4/4", hapd, addr, msg, 0x030a, None, None, kck)
|
||||||
hapd_connected(hapd)
|
hapd_connected(hapd)
|
||||||
|
|
||||||
def build_eapol_key_1_4(anonce, replay_counter=1, key_data='', key_len=16):
|
def build_eapol_key_1_4(anonce, replay_counter=1, key_data=b'', key_len=16):
|
||||||
msg = {}
|
msg = {}
|
||||||
msg['version'] = 2
|
msg['version'] = 2
|
||||||
msg['type'] = 3
|
msg['type'] = 3
|
||||||
|
@ -1626,15 +1626,15 @@ def aes_wrap(kek, plain):
|
||||||
b = enc(struct.pack('>Q', a) + r[i - 1])
|
b = enc(struct.pack('>Q', a) + r[i - 1])
|
||||||
a = struct.unpack('>Q', b[:8])[0] ^ (n * j + i)
|
a = struct.unpack('>Q', b[:8])[0] ^ (n * j + i)
|
||||||
r[i - 1] =b[8:]
|
r[i - 1] =b[8:]
|
||||||
return struct.pack('>Q', a) + ''.join(r)
|
return struct.pack('>Q', a) + b''.join(r)
|
||||||
|
|
||||||
def pad_key_data(plain):
|
def pad_key_data(plain):
|
||||||
pad_len = len(plain) % 8
|
pad_len = len(plain) % 8
|
||||||
if pad_len:
|
if pad_len:
|
||||||
pad_len = 8 - pad_len
|
pad_len = 8 - pad_len
|
||||||
plain += '\xdd'
|
plain += b'\xdd'
|
||||||
pad_len -= 1
|
pad_len -= 1
|
||||||
plain += pad_len * '\0'
|
plain += pad_len * b'\x00'
|
||||||
return plain
|
return plain
|
||||||
|
|
||||||
def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
@ -1658,7 +1658,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid AES wrap data length 0")
|
logger.debug("Invalid AES wrap data length 0")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '', replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, b'', replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 0"])
|
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 0"])
|
||||||
|
@ -1667,7 +1667,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid AES wrap data length 1")
|
logger.debug("Invalid AES wrap data length 1")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '1', replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, b'1', replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 1"])
|
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 1"])
|
||||||
|
@ -1676,7 +1676,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid AES wrap data length 9")
|
logger.debug("Invalid AES wrap data length 9")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '123456789', replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, b'123456789', replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 9"])
|
ev = dev[0].wait_event(["WPA: Unsupported AES-WRAP len 9"])
|
||||||
|
@ -1685,7 +1685,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid AES wrap data payload")
|
logger.debug("Invalid AES wrap data payload")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter)
|
||||||
# do not increment counter to test replay protection
|
# do not increment counter to test replay protection
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
ev = dev[0].wait_event(["WPA: AES unwrap failed"])
|
ev = dev[0].wait_event(["WPA: AES unwrap failed"])
|
||||||
|
@ -1694,7 +1694,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Replay Count not increasing")
|
logger.debug("Replay Count not increasing")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
ev = dev[0].wait_event(["WPA: EAPOL-Key Replay Counter did not increase"])
|
ev = dev[0].wait_event(["WPA: EAPOL-Key Replay Counter did not increase"])
|
||||||
|
@ -1703,7 +1703,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Missing Ack bit in key info")
|
logger.debug("Missing Ack bit in key info")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
key_info=0x134a)
|
key_info=0x134a)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1713,7 +1713,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Unexpected Request bit in key info")
|
logger.debug("Unexpected Request bit in key info")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
key_info=0x1bca)
|
key_info=0x1bca)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1723,7 +1723,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Unsupported key descriptor version 0")
|
logger.debug("Unsupported key descriptor version 0")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13c8)
|
replay_counter=counter, key_info=0x13c8)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1733,7 +1733,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Key descriptor version 1 not allowed with CCMP")
|
logger.debug("Key descriptor version 1 not allowed with CCMP")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13c9)
|
replay_counter=counter, key_info=0x13c9)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1743,7 +1743,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid AES wrap payload with key descriptor version 2")
|
logger.debug("Invalid AES wrap payload with key descriptor version 2")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13ca)
|
replay_counter=counter, key_info=0x13ca)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1753,7 +1753,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Key descriptor version 3 workaround")
|
logger.debug("Key descriptor version 3 workaround")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13cb)
|
replay_counter=counter, key_info=0x13cb)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1769,7 +1769,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Unsupported key descriptor version 4")
|
logger.debug("Unsupported key descriptor version 4")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13cc)
|
replay_counter=counter, key_info=0x13cc)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1779,7 +1779,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Unsupported key descriptor version 7")
|
logger.debug("Unsupported key descriptor version 7")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '0123456789abcdef',
|
msg = build_eapol_key_3_4(anonce, kck, b'0123456789abcdef',
|
||||||
replay_counter=counter, key_info=0x13cf)
|
replay_counter=counter, key_info=0x13cf)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1789,7 +1789,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Too short EAPOL header length")
|
logger.debug("Too short EAPOL header length")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
extra_len=-1)
|
extra_len=-1)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1798,26 +1798,26 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
raise Exception("Key data overflow not reported")
|
raise Exception("Key data overflow not reported")
|
||||||
|
|
||||||
logger.debug("Too long EAPOL header length")
|
logger.debug("Too long EAPOL header length")
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
extra_len=1)
|
extra_len=1)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
|
||||||
logger.debug("Unsupported descriptor type 0")
|
logger.debug("Unsupported descriptor type 0")
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
descr_type=0)
|
descr_type=0)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
|
||||||
logger.debug("WPA descriptor type 0")
|
logger.debug("WPA descriptor type 0")
|
||||||
msg = build_eapol_key_3_4(anonce, kck, '12345678', replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, b'12345678', replay_counter=counter,
|
||||||
descr_type=254)
|
descr_type=254)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
|
||||||
logger.debug("Non-zero key index for pairwise key")
|
logger.debug("Non-zero key index for pairwise key")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
wrapped = aes_wrap(kek, 16*'z')
|
wrapped = aes_wrap(kek, 16*b'z')
|
||||||
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter,
|
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter,
|
||||||
key_info=0x13ea)
|
key_info=0x13ea)
|
||||||
counter += 1
|
counter += 1
|
||||||
|
@ -1828,7 +1828,7 @@ def test_ap_wpa2_psk_supp_proto(dev, apdev):
|
||||||
|
|
||||||
logger.debug("Invalid Key Data plaintext payload --> disconnect")
|
logger.debug("Invalid Key Data plaintext payload --> disconnect")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
wrapped = aes_wrap(kek, 16*'z')
|
wrapped = aes_wrap(kek, 16*b'z')
|
||||||
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
@ -1855,7 +1855,7 @@ def test_ap_wpa2_psk_supp_proto_no_ie(dev, apdev):
|
||||||
|
|
||||||
logger.debug("No IEs in msg 3/4 --> disconnect")
|
logger.debug("No IEs in msg 3/4 --> disconnect")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
wrapped = aes_wrap(kek, 16*'\0')
|
wrapped = aes_wrap(kek, 16*b'\x00')
|
||||||
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter)
|
msg = build_eapol_key_3_4(anonce, kck, wrapped, replay_counter=counter)
|
||||||
counter += 1
|
counter += 1
|
||||||
send_eapol(dev[0], bssid, build_eapol(msg))
|
send_eapol(dev[0], bssid, build_eapol(msg))
|
||||||
|
|
|
@ -612,11 +612,11 @@ def test_ap_wps_reg_override_ap_settings(dev, apdev):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# Override AP Settings with values that point to another AP
|
# Override AP Settings with values that point to another AP
|
||||||
data = build_wsc_attr(ATTR_NETWORK_INDEX, '\x01')
|
data = build_wsc_attr(ATTR_NETWORK_INDEX, b'\x01')
|
||||||
data += build_wsc_attr(ATTR_SSID, "test")
|
data += build_wsc_attr(ATTR_SSID, b"test")
|
||||||
data += build_wsc_attr(ATTR_AUTH_TYPE, '\x00\x01')
|
data += build_wsc_attr(ATTR_AUTH_TYPE, b'\x00\x01')
|
||||||
data += build_wsc_attr(ATTR_ENCR_TYPE, '\x00\x01')
|
data += build_wsc_attr(ATTR_ENCR_TYPE, b'\x00\x01')
|
||||||
data += build_wsc_attr(ATTR_NETWORK_KEY, '')
|
data += build_wsc_attr(ATTR_NETWORK_KEY, b'')
|
||||||
data += build_wsc_attr(ATTR_MAC_ADDR, binascii.unhexlify(apdev[1]['bssid'].replace(':', '')))
|
data += build_wsc_attr(ATTR_MAC_ADDR, binascii.unhexlify(apdev[1]['bssid'].replace(':', '')))
|
||||||
with open(ap_settings, "w") as f:
|
with open(ap_settings, "w") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
@ -4322,164 +4322,164 @@ RGV2aWNlIEEQSQAGADcqAAEg
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
logger.info("Too short WLANEvent")
|
logger.info("Too short WLANEvent")
|
||||||
data = '\x00'
|
data = b'\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("Invalid WLANEventMAC")
|
logger.info("Invalid WLANEventMAC")
|
||||||
data = '\x00qwertyuiopasdfghjklzxcvbnm'
|
data = b'\x00qwertyuiopasdfghjklzxcvbnm'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("Unknown WLANEventType")
|
logger.info("Unknown WLANEventType")
|
||||||
data = '\xff02:00:00:00:00:00'
|
data = b'\xff02:00:00:00:00:00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("Probe Request notification without any attributes")
|
logger.info("Probe Request notification without any attributes")
|
||||||
data = '\x0102:00:00:00:00:00'
|
data = b'\x0102:00:00:00:00:00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("Probe Request notification with invalid attribute")
|
logger.info("Probe Request notification with invalid attribute")
|
||||||
data = '\x0102:00:00:00:00:00\xff'
|
data = b'\x0102:00:00:00:00:00\xff'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message without any attributes")
|
logger.info("EAP message without any attributes")
|
||||||
data = '\x0202:00:00:00:00:00'
|
data = b'\x0202:00:00:00:00:00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message with invalid attribute")
|
logger.info("EAP message with invalid attribute")
|
||||||
data = '\x0202:00:00:00:00:00\xff'
|
data = b'\x0202:00:00:00:00:00\xff'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message from new STA and not M1")
|
logger.info("EAP message from new STA and not M1")
|
||||||
data = '\x0202:ff:ff:ff:ff:ff' + '\x10\x22\x00\x01\x05'
|
data = b'\x0202:ff:ff:ff:ff:ff' + b'\x10\x22\x00\x01\x05'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1")
|
logger.info("EAP message: M1")
|
||||||
data = '\x0202:00:00:00:00:00'
|
data = b'\x0202:00:00:00:00:00'
|
||||||
data += '\x10\x22\x00\x01\x04'
|
data += b'\x10\x22\x00\x01\x04'
|
||||||
data += '\x10\x47\x00\x10' + 16*'\x00'
|
data += b'\x10\x47\x00\x10' + 16 * b'\x00'
|
||||||
data += '\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
data += b'\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
||||||
data += '\x10\x1a\x00\x10' + 16*'\x00'
|
data += b'\x10\x1a\x00\x10' + 16 * b'\x00'
|
||||||
data += '\x10\x32\x00\xc0' + 192*'\x00'
|
data += b'\x10\x32\x00\xc0' + 192 * b'\x00'
|
||||||
data += '\x10\x04\x00\x02\x00\x00'
|
data += b'\x10\x04\x00\x02\x00\x00'
|
||||||
data += '\x10\x10\x00\x02\x00\x00'
|
data += b'\x10\x10\x00\x02\x00\x00'
|
||||||
data += '\x10\x0d\x00\x01\x00'
|
data += b'\x10\x0d\x00\x01\x00'
|
||||||
data += '\x10\x08\x00\x02\x00\x00'
|
data += b'\x10\x08\x00\x02\x00\x00'
|
||||||
data += '\x10\x44\x00\x01\x00'
|
data += b'\x10\x44\x00\x01\x00'
|
||||||
data += '\x10\x21\x00\x00'
|
data += b'\x10\x21\x00\x00'
|
||||||
data += '\x10\x23\x00\x00'
|
data += b'\x10\x23\x00\x00'
|
||||||
data += '\x10\x24\x00\x00'
|
data += b'\x10\x24\x00\x00'
|
||||||
data += '\x10\x42\x00\x00'
|
data += b'\x10\x42\x00\x00'
|
||||||
data += '\x10\x54\x00\x08' + 8*'\x00'
|
data += b'\x10\x54\x00\x08' + 8 * b'\x00'
|
||||||
data += '\x10\x11\x00\x00'
|
data += b'\x10\x11\x00\x00'
|
||||||
data += '\x10\x3c\x00\x01\x00'
|
data += b'\x10\x3c\x00\x01\x00'
|
||||||
data += '\x10\x02\x00\x02\x00\x00'
|
data += b'\x10\x02\x00\x02\x00\x00'
|
||||||
data += '\x10\x12\x00\x02\x00\x00'
|
data += b'\x10\x12\x00\x02\x00\x00'
|
||||||
data += '\x10\x09\x00\x02\x00\x00'
|
data += b'\x10\x09\x00\x02\x00\x00'
|
||||||
data += '\x10\x2d\x00\x04\x00\x00\x00\x00'
|
data += b'\x10\x2d\x00\x04\x00\x00\x00\x00'
|
||||||
m1 = data
|
m1 = data
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: WSC_ACK")
|
logger.info("EAP message: WSC_ACK")
|
||||||
data = '\x0202:00:00:00:00:00' + '\x10\x22\x00\x01\x0d'
|
data = b'\x0202:00:00:00:00:00' + b'\x10\x22\x00\x01\x0d'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1")
|
logger.info("EAP message: M1")
|
||||||
send_wlanevent(url, uuid, m1)
|
send_wlanevent(url, uuid, m1)
|
||||||
|
|
||||||
logger.info("EAP message: WSC_NACK")
|
logger.info("EAP message: WSC_NACK")
|
||||||
data = '\x0202:00:00:00:00:00' + '\x10\x22\x00\x01\x0e'
|
data = b'\x0202:00:00:00:00:00' + b'\x10\x22\x00\x01\x0e'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 - Too long attribute values")
|
logger.info("EAP message: M1 - Too long attribute values")
|
||||||
data = '\x0202:00:00:00:00:00'
|
data = b'\x0202:00:00:00:00:00'
|
||||||
data += '\x10\x11\x00\x21' + 33*'\x00'
|
data += b'\x10\x11\x00\x21' + 33 * b'\x00'
|
||||||
data += '\x10\x45\x00\x21' + 33*'\x00'
|
data += b'\x10\x45\x00\x21' + 33 * b'\x00'
|
||||||
data += '\x10\x42\x00\x21' + 33*'\x00'
|
data += b'\x10\x42\x00\x21' + 33 * b'\x00'
|
||||||
data += '\x10\x24\x00\x21' + 33*'\x00'
|
data += b'\x10\x24\x00\x21' + 33 * b'\x00'
|
||||||
data += '\x10\x23\x00\x21' + 33*'\x00'
|
data += b'\x10\x23\x00\x21' + 33 * b'\x00'
|
||||||
data += '\x10\x21\x00\x41' + 65*'\x00'
|
data += b'\x10\x21\x00\x41' + 65 * b'\x00'
|
||||||
data += '\x10\x49\x00\x09\x00\x37\x2a\x05\x02\x00\x00\x05\x00'
|
data += b'\x10\x49\x00\x09\x00\x37\x2a\x05\x02\x00\x00\x05\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing UUID-E")
|
logger.info("EAP message: M1 missing UUID-E")
|
||||||
data = '\x0202:00:00:00:00:00'
|
data = b'\x0202:00:00:00:00:00'
|
||||||
data += '\x10\x22\x00\x01\x04'
|
data += b'\x10\x22\x00\x01\x04'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing MAC Address")
|
logger.info("EAP message: M1 missing MAC Address")
|
||||||
data += '\x10\x47\x00\x10' + 16*'\x00'
|
data += b'\x10\x47\x00\x10' + 16 * b'\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Enrollee Nonce")
|
logger.info("EAP message: M1 missing Enrollee Nonce")
|
||||||
data += '\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
data += b'\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Public Key")
|
logger.info("EAP message: M1 missing Public Key")
|
||||||
data += '\x10\x1a\x00\x10' + 16*'\x00'
|
data += b'\x10\x1a\x00\x10' + 16 * b'\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Authentication Type flags")
|
logger.info("EAP message: M1 missing Authentication Type flags")
|
||||||
data += '\x10\x32\x00\xc0' + 192*'\x00'
|
data += b'\x10\x32\x00\xc0' + 192 * b'\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Encryption Type Flags")
|
logger.info("EAP message: M1 missing Encryption Type Flags")
|
||||||
data += '\x10\x04\x00\x02\x00\x00'
|
data += b'\x10\x04\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Connection Type flags")
|
logger.info("EAP message: M1 missing Connection Type flags")
|
||||||
data += '\x10\x10\x00\x02\x00\x00'
|
data += b'\x10\x10\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Config Methods")
|
logger.info("EAP message: M1 missing Config Methods")
|
||||||
data += '\x10\x0d\x00\x01\x00'
|
data += b'\x10\x0d\x00\x01\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Wi-Fi Protected Setup State")
|
logger.info("EAP message: M1 missing Wi-Fi Protected Setup State")
|
||||||
data += '\x10\x08\x00\x02\x00\x00'
|
data += b'\x10\x08\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Manufacturer")
|
logger.info("EAP message: M1 missing Manufacturer")
|
||||||
data += '\x10\x44\x00\x01\x00'
|
data += b'\x10\x44\x00\x01\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Model Name")
|
logger.info("EAP message: M1 missing Model Name")
|
||||||
data += '\x10\x21\x00\x00'
|
data += b'\x10\x21\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Model Number")
|
logger.info("EAP message: M1 missing Model Number")
|
||||||
data += '\x10\x23\x00\x00'
|
data += b'\x10\x23\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Serial Number")
|
logger.info("EAP message: M1 missing Serial Number")
|
||||||
data += '\x10\x24\x00\x00'
|
data += b'\x10\x24\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Primary Device Type")
|
logger.info("EAP message: M1 missing Primary Device Type")
|
||||||
data += '\x10\x42\x00\x00'
|
data += b'\x10\x42\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Device Name")
|
logger.info("EAP message: M1 missing Device Name")
|
||||||
data += '\x10\x54\x00\x08' + 8*'\x00'
|
data += b'\x10\x54\x00\x08' + 8 * b'\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing RF Bands")
|
logger.info("EAP message: M1 missing RF Bands")
|
||||||
data += '\x10\x11\x00\x00'
|
data += b'\x10\x11\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Association State")
|
logger.info("EAP message: M1 missing Association State")
|
||||||
data += '\x10\x3c\x00\x01\x00'
|
data += b'\x10\x3c\x00\x01\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Device Password ID")
|
logger.info("EAP message: M1 missing Device Password ID")
|
||||||
data += '\x10\x02\x00\x02\x00\x00'
|
data += b'\x10\x02\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing Configuration Error")
|
logger.info("EAP message: M1 missing Configuration Error")
|
||||||
data += '\x10\x12\x00\x02\x00\x00'
|
data += b'\x10\x12\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("EAP message: M1 missing OS Version")
|
logger.info("EAP message: M1 missing OS Version")
|
||||||
data += '\x10\x09\x00\x02\x00\x00'
|
data += b'\x10\x09\x00\x02\x00\x00'
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
|
||||||
logger.info("Check max concurrent requests")
|
logger.info("Check max concurrent requests")
|
||||||
|
@ -4586,10 +4586,10 @@ RGV2aWNlIEEQSQAGADcqAAEg
|
||||||
raise Exception("Unexpected HTTP response: %d" % resp.status)
|
raise Exception("Unexpected HTTP response: %d" % resp.status)
|
||||||
|
|
||||||
with alloc_fail(dev[0], 1, "xml_get_first_item"):
|
with alloc_fail(dev[0], 1, "xml_get_first_item"):
|
||||||
send_wlanevent(url, uuid, '')
|
send_wlanevent(url, uuid, b'')
|
||||||
|
|
||||||
with alloc_fail(dev[0], 1, "wpabuf_alloc_ext_data;xml_get_base64_item"):
|
with alloc_fail(dev[0], 1, "wpabuf_alloc_ext_data;xml_get_base64_item"):
|
||||||
send_wlanevent(url, uuid, 'foo')
|
send_wlanevent(url, uuid, b'foo')
|
||||||
|
|
||||||
for func in [ "wps_init",
|
for func in [ "wps_init",
|
||||||
"wps_process_manufacturer",
|
"wps_process_manufacturer",
|
||||||
|
@ -4608,28 +4608,28 @@ RGV2aWNlIEEQSQAGADcqAAEg
|
||||||
send_wlanevent(url2, uuid, m1, no_response=True)
|
send_wlanevent(url2, uuid, m1, no_response=True)
|
||||||
|
|
||||||
logger.info("EAP message: M1")
|
logger.info("EAP message: M1")
|
||||||
data = '\x0202:11:22:00:00:00'
|
data = b'\x0202:11:22:00:00:00'
|
||||||
data += '\x10\x22\x00\x01\x04'
|
data += b'\x10\x22\x00\x01\x04'
|
||||||
data += '\x10\x47\x00\x10' + 16*'\x00'
|
data += b'\x10\x47\x00\x10' + 16 * b'\x00'
|
||||||
data += '\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
data += b'\x10\x20\x00\x06\x02\x00\x00\x00\x00\x00'
|
||||||
data += '\x10\x1a\x00\x10' + 16*'\x00'
|
data += b'\x10\x1a\x00\x10' + 16 * b'\x00'
|
||||||
data += '\x10\x32\x00\xc0' + 192*'\x00'
|
data += b'\x10\x32\x00\xc0' + 192 * b'\x00'
|
||||||
data += '\x10\x04\x00\x02\x00\x00'
|
data += b'\x10\x04\x00\x02\x00\x00'
|
||||||
data += '\x10\x10\x00\x02\x00\x00'
|
data += b'\x10\x10\x00\x02\x00\x00'
|
||||||
data += '\x10\x0d\x00\x01\x00'
|
data += b'\x10\x0d\x00\x01\x00'
|
||||||
data += '\x10\x08\x00\x02\x00\x00'
|
data += b'\x10\x08\x00\x02\x00\x00'
|
||||||
data += '\x10\x44\x00\x01\x00'
|
data += b'\x10\x44\x00\x01\x00'
|
||||||
data += '\x10\x21\x00\x00'
|
data += b'\x10\x21\x00\x00'
|
||||||
data += '\x10\x23\x00\x00'
|
data += b'\x10\x23\x00\x00'
|
||||||
data += '\x10\x24\x00\x00'
|
data += b'\x10\x24\x00\x00'
|
||||||
data += '\x10\x42\x00\x00'
|
data += b'\x10\x42\x00\x00'
|
||||||
data += '\x10\x54\x00\x08' + 8*'\x00'
|
data += b'\x10\x54\x00\x08' + 8 * b'\x00'
|
||||||
data += '\x10\x11\x00\x00'
|
data += b'\x10\x11\x00\x00'
|
||||||
data += '\x10\x3c\x00\x01\x00'
|
data += b'\x10\x3c\x00\x01\x00'
|
||||||
data += '\x10\x02\x00\x02\x00\x00'
|
data += b'\x10\x02\x00\x02\x00\x00'
|
||||||
data += '\x10\x12\x00\x02\x00\x00'
|
data += b'\x10\x12\x00\x02\x00\x00'
|
||||||
data += '\x10\x09\x00\x02\x00\x00'
|
data += b'\x10\x09\x00\x02\x00\x00'
|
||||||
data += '\x10\x2d\x00\x04\x00\x00\x00\x00'
|
data += b'\x10\x2d\x00\x04\x00\x00\x00\x00'
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
with alloc_fail(dev[0], 1, "wps_er_add_sta_data"):
|
with alloc_fail(dev[0], 1, "wps_er_add_sta_data"):
|
||||||
send_wlanevent(url, uuid, data)
|
send_wlanevent(url, uuid, data)
|
||||||
|
@ -4920,7 +4920,7 @@ def test_ap_wps_er_http_client(dev, apdev):
|
||||||
|
|
||||||
class WPSAPHTTPServer_req_as_resp(WPSAPHTTPServer):
|
class WPSAPHTTPServer_req_as_resp(WPSAPHTTPServer):
|
||||||
def handle_upnp_info(self):
|
def handle_upnp_info(self):
|
||||||
self.wfile.write("GET / HTTP/1.1\r\n\r\n")
|
self.wfile.write(b"GET / HTTP/1.1\r\n\r\n")
|
||||||
run_wps_er_proto_test(dev[0], WPSAPHTTPServer_req_as_resp,
|
run_wps_er_proto_test(dev[0], WPSAPHTTPServer_req_as_resp,
|
||||||
no_event_url=True)
|
no_event_url=True)
|
||||||
|
|
||||||
|
@ -6185,7 +6185,7 @@ def get_wsc_msg(dev):
|
||||||
if msg['eap_type'] == 254:
|
if msg['eap_type'] == 254:
|
||||||
if len(data) < 3 + 4:
|
if len(data) < 3 + 4:
|
||||||
raise Exception("Truncated EAP expanded header")
|
raise Exception("Truncated EAP expanded header")
|
||||||
msg['eap_vendor_id'], msg['eap_vendor_type'] = struct.unpack('>LL', '\0' + data[0:7])
|
msg['eap_vendor_id'], msg['eap_vendor_type'] = struct.unpack('>LL', b'\x00' + data[0:7])
|
||||||
data = data[7:]
|
data = data[7:]
|
||||||
else:
|
else:
|
||||||
raise Exception("Unexpected EAP type")
|
raise Exception("Unexpected EAP type")
|
||||||
|
@ -6273,7 +6273,7 @@ group_5_prime = 0xFFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC
|
||||||
group_5_generator = 2
|
group_5_generator = 2
|
||||||
|
|
||||||
def wsc_kdf(key, label, bits):
|
def wsc_kdf(key, label, bits):
|
||||||
result = ''
|
result = b''
|
||||||
i = 1
|
i = 1
|
||||||
while len(result) * 8 < bits:
|
while len(result) * 8 < bits:
|
||||||
data = struct.pack('>L', i) + label.encode() + struct.pack('>L', bits)
|
data = struct.pack('>L', i) + label.encode() + struct.pack('>L', bits)
|
||||||
|
@ -6309,7 +6309,7 @@ def build_attr_encr_settings(authkey, keywrapkey, data):
|
||||||
m = hmac.new(authkey, data, hashlib.sha256)
|
m = hmac.new(authkey, data, hashlib.sha256)
|
||||||
kwa = m.digest()[0:8]
|
kwa = m.digest()[0:8]
|
||||||
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = pad_len * struct.pack('B', pad_len)
|
ps = pad_len * struct.pack('B', pad_len)
|
||||||
|
@ -6391,12 +6391,12 @@ def wsc_dev_pw_hash(authkey, dev_pw, e_pk, r_pk):
|
||||||
|
|
||||||
# Note: Secret values are supposed to be random, but hardcoded values are
|
# Note: Secret values are supposed to be random, but hardcoded values are
|
||||||
# fine for testing.
|
# fine for testing.
|
||||||
s1 = 16*'\x77'
|
s1 = 16*b'\x77'
|
||||||
m = hmac.new(authkey, s1 + psk1 + e_pk + r_pk, hashlib.sha256)
|
m = hmac.new(authkey, s1 + psk1 + e_pk + r_pk, hashlib.sha256)
|
||||||
hash1 = m.digest()
|
hash1 = m.digest()
|
||||||
logger.debug("Hash1: " + binascii.hexlify(hash1).decode())
|
logger.debug("Hash1: " + binascii.hexlify(hash1).decode())
|
||||||
|
|
||||||
s2 = 16*'\x88'
|
s2 = 16*b'\x88'
|
||||||
m = hmac.new(authkey, s2 + psk2 + e_pk + r_pk, hashlib.sha256)
|
m = hmac.new(authkey, s2 + psk2 + e_pk + r_pk, hashlib.sha256)
|
||||||
hash2 = m.digest()
|
hash2 = m.digest()
|
||||||
logger.debug("Hash2: " + binascii.hexlify(hash2).decode())
|
logger.debug("Hash2: " + binascii.hexlify(hash2).decode())
|
||||||
|
@ -6523,8 +6523,8 @@ def test_wps_ext(dev, apdev):
|
||||||
wsc_start_id = msg['eap_identifier']
|
wsc_start_id = msg['eap_identifier']
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -6599,12 +6599,12 @@ def test_wps_ext(dev, apdev):
|
||||||
# Do not send WSC_Done yet to allow exchangw with STA complete before the
|
# Do not send WSC_Done yet to allow exchangw with STA complete before the
|
||||||
# AP disconnects.
|
# AP disconnects.
|
||||||
|
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
|
|
||||||
eap_id = wsc_start_id
|
eap_id = wsc_start_id
|
||||||
logger.debug("Send WSC/Start to STA")
|
logger.debug("Send WSC/Start to STA")
|
||||||
wsc_start = build_eap_wsc(1, eap_id, "", opcode=WSC_Start)
|
wsc_start = build_eap_wsc(1, eap_id, b'', opcode=WSC_Start)
|
||||||
send_wsc_msg(dev[0], bssid, wsc_start)
|
send_wsc_msg(dev[0], bssid, wsc_start)
|
||||||
eap_id = (eap_id + 1) % 256
|
eap_id = (eap_id + 1) % 256
|
||||||
|
|
||||||
|
@ -6700,8 +6700,8 @@ def wps_start_kwa(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -6753,7 +6753,7 @@ def test_wps_ext_kwa_proto_no_kwa(dev, apdev):
|
||||||
r_s1,keywrapkey,authkey,raw_m3_attrs,eap_id,bssid,attrs = wps_start_kwa(dev, apdev)
|
r_s1,keywrapkey,authkey,raw_m3_attrs,eap_id,bssid,attrs = wps_start_kwa(dev, apdev)
|
||||||
data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
||||||
# Encrypted Settings without KWA
|
# Encrypted Settings without KWA
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = pad_len * struct.pack('B', pad_len)
|
ps = pad_len * struct.pack('B', pad_len)
|
||||||
|
@ -6771,7 +6771,7 @@ def test_wps_ext_kwa_proto_data_after_kwa(dev, apdev):
|
||||||
kwa = m.digest()[0:8]
|
kwa = m.digest()[0:8]
|
||||||
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
||||||
data += build_wsc_attr(ATTR_VENDOR_EXT, "1234567890")
|
data += build_wsc_attr(ATTR_VENDOR_EXT, "1234567890")
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = pad_len * struct.pack('B', pad_len)
|
ps = pad_len * struct.pack('B', pad_len)
|
||||||
|
@ -6786,7 +6786,7 @@ def test_wps_ext_kwa_proto_kwa_mismatch(dev, apdev):
|
||||||
data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
||||||
# Encrypted Settings and KWA with incorrect value
|
# Encrypted Settings and KWA with incorrect value
|
||||||
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, 8*'\x00')
|
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, 8*'\x00')
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = pad_len * struct.pack('B', pad_len)
|
ps = pad_len * struct.pack('B', pad_len)
|
||||||
|
@ -6803,8 +6803,8 @@ def wps_run_cred_proto(dev, apdev, m8_cred, connect=False, no_connect=False):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -6909,7 +6909,7 @@ def wps_run_cred_proto(dev, apdev, m8_cred, connect=False, no_connect=False):
|
||||||
def build_cred(nw_idx='\x01', ssid='test-wps-conf', auth_type='\x00\x20',
|
def build_cred(nw_idx='\x01', ssid='test-wps-conf', auth_type='\x00\x20',
|
||||||
encr_type='\x00\x08', nw_key="12345678",
|
encr_type='\x00\x08', nw_key="12345678",
|
||||||
mac_addr='\x00\x00\x00\x00\x00\x00'):
|
mac_addr='\x00\x00\x00\x00\x00\x00'):
|
||||||
attrs = ''
|
attrs = b''
|
||||||
if nw_idx is not None:
|
if nw_idx is not None:
|
||||||
attrs += build_wsc_attr(ATTR_NETWORK_INDEX, nw_idx)
|
attrs += build_wsc_attr(ATTR_NETWORK_INDEX, nw_idx)
|
||||||
if ssid is not None:
|
if ssid is not None:
|
||||||
|
@ -6993,7 +6993,7 @@ def test_wps_ext_cred_proto_invalid_encr_type(dev, apdev):
|
||||||
def test_wps_ext_cred_proto_missing_cred(dev, apdev):
|
def test_wps_ext_cred_proto_missing_cred(dev, apdev):
|
||||||
"""WPS and Credential: Missing Credential"""
|
"""WPS and Credential: Missing Credential"""
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
m8_cred = ''
|
m8_cred = b''
|
||||||
wps_run_cred_proto(dev, apdev, m8_cred)
|
wps_run_cred_proto(dev, apdev, m8_cred)
|
||||||
|
|
||||||
def test_wps_ext_proto_m2_no_public_key(dev, apdev):
|
def test_wps_ext_proto_m2_no_public_key(dev, apdev):
|
||||||
|
@ -7005,8 +7005,8 @@ def test_wps_ext_proto_m2_no_public_key(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7043,8 +7043,8 @@ def test_wps_ext_proto_m2_invalid_public_key(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7060,7 +7060,7 @@ def test_wps_ext_proto_m2_invalid_public_key(dev, apdev):
|
||||||
logger.debug("Send M2 to STA")
|
logger.debug("Send M2 to STA")
|
||||||
m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id,
|
m2, raw_m2_attrs = build_m2(authkey, raw_m1_attrs, eap_id,
|
||||||
m1_attrs[ATTR_ENROLLEE_NONCE],
|
m1_attrs[ATTR_ENROLLEE_NONCE],
|
||||||
r_nonce, uuid_r, 192*'\xff')
|
r_nonce, uuid_r, 192*b'\xff')
|
||||||
send_wsc_msg(dev[0], bssid, m2)
|
send_wsc_msg(dev[0], bssid, m2)
|
||||||
eap_id = (eap_id + 1) % 256
|
eap_id = (eap_id + 1) % 256
|
||||||
|
|
||||||
|
@ -7081,8 +7081,8 @@ def test_wps_ext_proto_m2_public_key_oom(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7120,8 +7120,8 @@ def test_wps_ext_proto_nack_m3(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7163,8 +7163,8 @@ def test_wps_ext_proto_nack_m5(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7222,8 +7222,8 @@ def wps_nack_m3(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7321,7 +7321,7 @@ def test_wps_ext_proto_nack_m3_invalid_attr(dev, apdev):
|
||||||
"""WPS and NACK M3 invalid attribute"""
|
"""WPS and NACK M3 invalid attribute"""
|
||||||
eap_id, e_nonce, r_nonce, bssid = wps_nack_m3(dev, apdev)
|
eap_id, e_nonce, r_nonce, bssid = wps_nack_m3(dev, apdev)
|
||||||
logger.debug("Send NACK to STA")
|
logger.debug("Send NACK to STA")
|
||||||
attrs = '\x10\x10\x00'
|
attrs = b'\x10\x10\x00'
|
||||||
msg = build_eap_wsc(1, eap_id, attrs, opcode=WSC_NACK)
|
msg = build_eap_wsc(1, eap_id, attrs, opcode=WSC_NACK)
|
||||||
send_wsc_msg(dev[0], bssid, msg)
|
send_wsc_msg(dev[0], bssid, msg)
|
||||||
dev[0].request("WPS_CANCEL")
|
dev[0].request("WPS_CANCEL")
|
||||||
|
@ -7392,7 +7392,7 @@ def test_wps_ext_proto_ack_m3_invalid_attr(dev, apdev):
|
||||||
"""WPS and ACK M3 invalid attribute"""
|
"""WPS and ACK M3 invalid attribute"""
|
||||||
eap_id, e_nonce, r_nonce, bssid = wps_nack_m3(dev, apdev)
|
eap_id, e_nonce, r_nonce, bssid = wps_nack_m3(dev, apdev)
|
||||||
logger.debug("Send ACK to STA")
|
logger.debug("Send ACK to STA")
|
||||||
attrs = '\x10\x10\x00'
|
attrs = b'\x10\x10\x00'
|
||||||
msg = build_eap_wsc(1, eap_id, attrs, opcode=WSC_ACK)
|
msg = build_eap_wsc(1, eap_id, attrs, opcode=WSC_ACK)
|
||||||
send_wsc_msg(dev[0], bssid, msg)
|
send_wsc_msg(dev[0], bssid, msg)
|
||||||
dev[0].request("WPS_CANCEL")
|
dev[0].request("WPS_CANCEL")
|
||||||
|
@ -7417,8 +7417,8 @@ def wps_to_m3_helper(dev, apdev):
|
||||||
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
wps_ext_eap_wsc(dev[0], hapd, bssid, "EAP-WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Receive M1 from STA")
|
logger.debug("Receive M1 from STA")
|
||||||
|
@ -7531,7 +7531,7 @@ def test_wps_ext_proto_m4_missing_r_snonce1(dev, apdev):
|
||||||
attrs += build_wsc_attr(ATTR_R_HASH1, r_hash1)
|
attrs += build_wsc_attr(ATTR_R_HASH1, r_hash1)
|
||||||
attrs += build_wsc_attr(ATTR_R_HASH2, r_hash2)
|
attrs += build_wsc_attr(ATTR_R_HASH2, r_hash2)
|
||||||
#data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
#data = build_wsc_attr(ATTR_R_SNONCE1, r_s1)
|
||||||
data = ''
|
data = b''
|
||||||
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
||||||
attrs += build_attr_authenticator(authkey, m3, attrs)
|
attrs += build_attr_authenticator(authkey, m3, attrs)
|
||||||
m4 = build_eap_wsc(1, eap_id, attrs)
|
m4 = build_eap_wsc(1, eap_id, attrs)
|
||||||
|
@ -7562,7 +7562,7 @@ def test_wps_ext_proto_m4_invalid_pad_string(dev, apdev):
|
||||||
m = hmac.new(authkey, data, hashlib.sha256)
|
m = hmac.new(authkey, data, hashlib.sha256)
|
||||||
kwa = m.digest()[0:8]
|
kwa = m.digest()[0:8]
|
||||||
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = (pad_len - 1) * struct.pack('B', pad_len) + struct.pack('B', pad_len - 1)
|
ps = (pad_len - 1) * struct.pack('B', pad_len) + struct.pack('B', pad_len - 1)
|
||||||
|
@ -7599,7 +7599,7 @@ def test_wps_ext_proto_m4_invalid_pad_value(dev, apdev):
|
||||||
m = hmac.new(authkey, data, hashlib.sha256)
|
m = hmac.new(authkey, data, hashlib.sha256)
|
||||||
kwa = m.digest()[0:8]
|
kwa = m.digest()[0:8]
|
||||||
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
data += build_wsc_attr(ATTR_KEY_WRAP_AUTH, kwa)
|
||||||
iv = 16*'\x99'
|
iv = 16*b'\x99'
|
||||||
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
aes = AES.new(keywrapkey, AES.MODE_CBC, iv)
|
||||||
pad_len = 16 - len(data) % 16
|
pad_len = 16 - len(data) % 16
|
||||||
ps = (pad_len - 1) * struct.pack('B', pad_len) + struct.pack('B', 255)
|
ps = (pad_len - 1) * struct.pack('B', pad_len) + struct.pack('B', 255)
|
||||||
|
@ -7654,7 +7654,7 @@ def test_wps_ext_proto_m6_missing_r_snonce2(dev, apdev):
|
||||||
attrs += build_attr_msg_type(WPS_M6)
|
attrs += build_attr_msg_type(WPS_M6)
|
||||||
attrs += build_wsc_attr(ATTR_ENROLLEE_NONCE, e_nonce)
|
attrs += build_wsc_attr(ATTR_ENROLLEE_NONCE, e_nonce)
|
||||||
#data = build_wsc_attr(ATTR_R_SNONCE2, r_s2)
|
#data = build_wsc_attr(ATTR_R_SNONCE2, r_s2)
|
||||||
data = ''
|
data = b''
|
||||||
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
||||||
attrs += build_attr_authenticator(authkey, m5, attrs)
|
attrs += build_attr_authenticator(authkey, m5, attrs)
|
||||||
m6 = build_eap_wsc(1, eap_id, attrs)
|
m6 = build_eap_wsc(1, eap_id, attrs)
|
||||||
|
@ -7763,8 +7763,8 @@ def wps_run_ap_settings_proto(dev, apdev, ap_settings, success):
|
||||||
e_pk = m1_attrs[ATTR_PUBLIC_KEY]
|
e_pk = m1_attrs[ATTR_PUBLIC_KEY]
|
||||||
|
|
||||||
appin = '12345670'
|
appin = '12345670'
|
||||||
uuid_r = 16*'\x33'
|
uuid_r = 16*b'\x33'
|
||||||
r_nonce = 16*'\x44'
|
r_nonce = 16*b'\x44'
|
||||||
own_private, r_pk = wsc_dh_init()
|
own_private, r_pk = wsc_dh_init()
|
||||||
authkey,keywrapkey = wsc_dh_kdf(e_pk, own_private, mac_addr, e_nonce,
|
authkey,keywrapkey = wsc_dh_kdf(e_pk, own_private, mac_addr, e_nonce,
|
||||||
r_nonce)
|
r_nonce)
|
||||||
|
@ -7947,8 +7947,8 @@ def test_wps_ext_m3_missing_e_hash1(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -7992,8 +7992,8 @@ def test_wps_ext_m3_missing_e_hash2(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8037,8 +8037,8 @@ def test_wps_ext_m5_missing_e_snonce1(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8074,7 +8074,7 @@ def test_wps_ext_m5_missing_e_snonce1(dev, apdev):
|
||||||
attrs += build_attr_msg_type(WPS_M5)
|
attrs += build_attr_msg_type(WPS_M5)
|
||||||
attrs += build_wsc_attr(ATTR_REGISTRAR_NONCE, r_nonce)
|
attrs += build_wsc_attr(ATTR_REGISTRAR_NONCE, r_nonce)
|
||||||
#data = build_wsc_attr(ATTR_E_SNONCE1, e_s1)
|
#data = build_wsc_attr(ATTR_E_SNONCE1, e_s1)
|
||||||
data = ''
|
data = b''
|
||||||
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
||||||
attrs += build_attr_authenticator(authkey, raw_m4_attrs, attrs)
|
attrs += build_attr_authenticator(authkey, raw_m4_attrs, attrs)
|
||||||
raw_m5_attrs = attrs
|
raw_m5_attrs = attrs
|
||||||
|
@ -8097,8 +8097,8 @@ def test_wps_ext_m5_e_snonce1_mismatch(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8155,8 +8155,8 @@ def test_wps_ext_m7_missing_e_snonce2(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8206,7 +8206,7 @@ def test_wps_ext_m7_missing_e_snonce2(dev, apdev):
|
||||||
attrs += build_attr_msg_type(WPS_M7)
|
attrs += build_attr_msg_type(WPS_M7)
|
||||||
attrs += build_wsc_attr(ATTR_REGISTRAR_NONCE, r_nonce)
|
attrs += build_wsc_attr(ATTR_REGISTRAR_NONCE, r_nonce)
|
||||||
#data = build_wsc_attr(ATTR_E_SNONCE2, e_s2)
|
#data = build_wsc_attr(ATTR_E_SNONCE2, e_s2)
|
||||||
data = ''
|
data = b''
|
||||||
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
attrs += build_attr_encr_settings(authkey, keywrapkey, data)
|
||||||
attrs += build_attr_authenticator(authkey, raw_m6_attrs, attrs)
|
attrs += build_attr_authenticator(authkey, raw_m6_attrs, attrs)
|
||||||
m7 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
m7 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
||||||
|
@ -8229,8 +8229,8 @@ def test_wps_ext_m7_e_snonce2_mismatch(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8333,8 +8333,8 @@ def test_wps_ext_m3_m1(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8378,8 +8378,8 @@ def test_wps_ext_m5_m3(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8437,8 +8437,8 @@ def test_wps_ext_m3_m2(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8480,8 +8480,8 @@ def test_wps_ext_m3_m5(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8525,8 +8525,8 @@ def test_wps_ext_m3_m7(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8570,8 +8570,8 @@ def test_wps_ext_m3_done(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8612,8 +8612,8 @@ def test_wps_ext_m2_nack_invalid(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8631,7 +8631,7 @@ def test_wps_ext_m2_nack_invalid(dev, apdev):
|
||||||
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
||||||
|
|
||||||
logger.debug("Send WSC_NACK to AP")
|
logger.debug("Send WSC_NACK to AP")
|
||||||
attrs = '\x10\x00\x00'
|
attrs = b'\x10\x00\x00'
|
||||||
nack = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_NACK)
|
nack = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_NACK)
|
||||||
send_wsc_msg(hapd, addr, nack)
|
send_wsc_msg(hapd, addr, nack)
|
||||||
|
|
||||||
|
@ -8651,8 +8651,8 @@ def test_wps_ext_m2_nack_no_msg_type(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8690,8 +8690,8 @@ def test_wps_ext_m2_nack_invalid_msg_type(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8729,8 +8729,8 @@ def test_wps_ext_m2_nack_e_nonce_mismatch(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8748,7 +8748,7 @@ def test_wps_ext_m2_nack_e_nonce_mismatch(dev, apdev):
|
||||||
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
||||||
|
|
||||||
logger.debug("Send WSC_NACK to AP")
|
logger.debug("Send WSC_NACK to AP")
|
||||||
nack,attrs = build_nack(msg['eap_identifier'], 16*'\x00', r_nonce,
|
nack,attrs = build_nack(msg['eap_identifier'], 16*b'\x00', r_nonce,
|
||||||
eap_code=2)
|
eap_code=2)
|
||||||
send_wsc_msg(hapd, addr, nack)
|
send_wsc_msg(hapd, addr, nack)
|
||||||
|
|
||||||
|
@ -8768,8 +8768,8 @@ def test_wps_ext_m2_nack_no_config_error(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8807,8 +8807,8 @@ def test_wps_ext_m2_ack_invalid(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8826,7 +8826,7 @@ def test_wps_ext_m2_ack_invalid(dev, apdev):
|
||||||
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
||||||
|
|
||||||
logger.debug("Send WSC_ACK to AP")
|
logger.debug("Send WSC_ACK to AP")
|
||||||
attrs = '\x10\x00\x00'
|
attrs = b'\x10\x00\x00'
|
||||||
ack = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_ACK)
|
ack = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_ACK)
|
||||||
send_wsc_msg(hapd, addr, ack)
|
send_wsc_msg(hapd, addr, ack)
|
||||||
|
|
||||||
|
@ -8846,8 +8846,8 @@ def test_wps_ext_m2_ack(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8884,8 +8884,8 @@ def test_wps_ext_m2_ack_no_msg_type(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8923,8 +8923,8 @@ def test_wps_ext_m2_ack_invalid_msg_type(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8962,8 +8962,8 @@ def test_wps_ext_m2_ack_e_nonce_mismatch(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -8981,7 +8981,7 @@ def test_wps_ext_m2_ack_e_nonce_mismatch(dev, apdev):
|
||||||
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
e_s1,e_s2,e_hash1,e_hash2 = wsc_dev_pw_hash(authkey, pin, e_pk, r_pk)
|
||||||
|
|
||||||
logger.debug("Send WSC_ACK to AP")
|
logger.debug("Send WSC_ACK to AP")
|
||||||
ack,attrs = build_ack(msg['eap_identifier'], 16*'\x00', r_nonce,
|
ack,attrs = build_ack(msg['eap_identifier'], 16*b'\x00', r_nonce,
|
||||||
eap_code=2)
|
eap_code=2)
|
||||||
send_wsc_msg(hapd, addr, ack)
|
send_wsc_msg(hapd, addr, ack)
|
||||||
|
|
||||||
|
@ -9001,7 +9001,7 @@ def test_wps_ext_m1_invalid(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
attrs = '\x10\x00\x00'
|
attrs = b'\x10\x00\x00'
|
||||||
m1 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
m1 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
||||||
send_wsc_msg(hapd, addr, m1)
|
send_wsc_msg(hapd, addr, m1)
|
||||||
|
|
||||||
|
@ -9024,7 +9024,7 @@ def test_wps_ext_m1_missing_msg_type(dev, apdev):
|
||||||
m1 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
m1 = build_eap_wsc(2, msg['eap_identifier'], attrs)
|
||||||
send_wsc_msg(hapd, addr, m1)
|
send_wsc_msg(hapd, addr, m1)
|
||||||
|
|
||||||
wps_wait_ap_nack(hapd, dev[0], 16*'\x00', 16*'\x00')
|
wps_wait_ap_nack(hapd, dev[0], 16*b'\x00', 16*b'\x00')
|
||||||
|
|
||||||
def wps_ext_wsc_done(dev, apdev):
|
def wps_ext_wsc_done(dev, apdev):
|
||||||
pin = "12345670"
|
pin = "12345670"
|
||||||
|
@ -9038,8 +9038,8 @@ def wps_ext_wsc_done(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -9105,7 +9105,7 @@ def test_wps_ext_wsc_done_invalid(dev, apdev):
|
||||||
hapd, msg, e_nonce, r_nonce = wps_ext_wsc_done(dev, apdev)
|
hapd, msg, e_nonce, r_nonce = wps_ext_wsc_done(dev, apdev)
|
||||||
|
|
||||||
logger.debug("Send WSC_Done to AP")
|
logger.debug("Send WSC_Done to AP")
|
||||||
attrs = '\x10\x00\x00'
|
attrs = b'\x10\x00\x00'
|
||||||
wsc_done = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_Done)
|
wsc_done = build_eap_wsc(2, msg['eap_identifier'], attrs, opcode=WSC_Done)
|
||||||
send_wsc_msg(hapd, dev[0].own_addr(), wsc_done)
|
send_wsc_msg(hapd, dev[0].own_addr(), wsc_done)
|
||||||
|
|
||||||
|
@ -9184,8 +9184,8 @@ def test_wps_ext_m7_no_encr_settings(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
|
@ -9257,14 +9257,14 @@ def test_wps_ext_m1_workaround(dev, apdev):
|
||||||
raise Exception("Unexpected Op-Code for WSC/Start")
|
raise Exception("Unexpected Op-Code for WSC/Start")
|
||||||
|
|
||||||
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
mac_addr = binascii.unhexlify(dev[0].own_addr().replace(':', ''))
|
||||||
uuid_e = 16*'\x11'
|
uuid_e = 16*b'\x11'
|
||||||
e_nonce = 16*'\x22'
|
e_nonce = 16*b'\x22'
|
||||||
own_private, e_pk = wsc_dh_init()
|
own_private, e_pk = wsc_dh_init()
|
||||||
|
|
||||||
logger.debug("Send M1 to AP")
|
logger.debug("Send M1 to AP")
|
||||||
m1, raw_m1_attrs = build_m1(msg['eap_identifier'], uuid_e, mac_addr,
|
m1, raw_m1_attrs = build_m1(msg['eap_identifier'], uuid_e, mac_addr,
|
||||||
e_nonce, e_pk, manufacturer='Apple TEST',
|
e_nonce, e_pk, manufacturer='Apple TEST',
|
||||||
model_name='AirPort', config_methods='\xff\xff')
|
model_name='AirPort', config_methods=b'\xff\xff')
|
||||||
send_wsc_msg(hapd, addr, m1)
|
send_wsc_msg(hapd, addr, m1)
|
||||||
|
|
||||||
logger.debug("Receive M2 from AP")
|
logger.debug("Receive M2 from AP")
|
||||||
|
|
|
@ -259,14 +259,14 @@ def test_dbus_properties(dev, apdev):
|
||||||
if val != res:
|
if val != res:
|
||||||
raise Exception("WFDIEs value changed")
|
raise Exception("WFDIEs value changed")
|
||||||
try:
|
try:
|
||||||
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray('\x00'))
|
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(b'\x00'))
|
||||||
raise Exception("Invalid WFDIEs value accepted")
|
raise Exception("Invalid WFDIEs value accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
if "InvalidArgs" not in str(e):
|
if "InvalidArgs" not in str(e):
|
||||||
raise Exception("Unexpected error message: " + str(e))
|
raise Exception("Unexpected error message: " + str(e))
|
||||||
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(''))
|
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(b''))
|
||||||
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(val))
|
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(val))
|
||||||
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(''))
|
dbus_set(dbus, wpas_obj, "WFDIEs", dbus.ByteArray(b''))
|
||||||
res = dbus_get(dbus, wpas_obj, "WFDIEs", byte_arrays=True)
|
res = dbus_get(dbus, wpas_obj, "WFDIEs", byte_arrays=True)
|
||||||
if len(res) != 0:
|
if len(res) != 0:
|
||||||
raise Exception("WFDIEs not cleared properly")
|
raise Exception("WFDIEs not cleared properly")
|
||||||
|
@ -314,7 +314,7 @@ def test_dbus_properties(dev, apdev):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
wpas_obj.Set(WPAS_DBUS_SERVICE, "WFDIEs",
|
wpas_obj.Set(WPAS_DBUS_SERVICE, "WFDIEs",
|
||||||
dbus.ByteArray('', variant_level=2),
|
dbus.ByteArray(b'', variant_level=2),
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
raise Exception("Invalid Set accepted")
|
raise Exception("Invalid Set accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -443,7 +443,7 @@ def _test_dbus_get_set_wps(dev, apdev):
|
||||||
if val[0] != 0x00 or val[1] != 0x05 != val[2] != 0x00 or val[3] != 0x50 or val[4] != 0xf2 or val[5] != 0x04 or val[6] != 0x00 or val[7] != 0x01:
|
if val[0] != 0x00 or val[1] != 0x05 != val[2] != 0x00 or val[3] != 0x50 or val[4] != 0xf2 or val[5] != 0x04 or val[6] != 0x00 or val[7] != 0x01:
|
||||||
raise Exception("DeviceType mismatch after Set")
|
raise Exception("DeviceType mismatch after Set")
|
||||||
|
|
||||||
val2 = '\x01\x02\x03\x04\x05\x06\x07\x08'
|
val2 = b'\x01\x02\x03\x04\x05\x06\x07\x08'
|
||||||
if_obj.Set(WPAS_DBUS_IFACE_WPS, "DeviceType", dbus.ByteArray(val2),
|
if_obj.Set(WPAS_DBUS_IFACE_WPS, "DeviceType", dbus.ByteArray(val2),
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
val = if_obj.Get(WPAS_DBUS_IFACE_WPS, "DeviceType",
|
val = if_obj.Get(WPAS_DBUS_IFACE_WPS, "DeviceType",
|
||||||
|
@ -527,11 +527,11 @@ def test_dbus_wps_invalid(dev, apdev):
|
||||||
'Bssid': '02:33:44:55:66:77'},
|
'Bssid': '02:33:44:55:66:77'},
|
||||||
{'Role': 'enrollee', 'Type': 'pin', 'Pin': 123},
|
{'Role': 'enrollee', 'Type': 'pin', 'Pin': 123},
|
||||||
{'Role': 'enrollee', 'Type': 'pbc',
|
{'Role': 'enrollee', 'Type': 'pbc',
|
||||||
'Bssid': dbus.ByteArray('12345')},
|
'Bssid': dbus.ByteArray(b'12345')},
|
||||||
{'Role': 'enrollee', 'Type': 'pbc',
|
{'Role': 'enrollee', 'Type': 'pbc',
|
||||||
'P2PDeviceAddress': 12345},
|
'P2PDeviceAddress': 12345},
|
||||||
{'Role': 'enrollee', 'Type': 'pbc',
|
{'Role': 'enrollee', 'Type': 'pbc',
|
||||||
'P2PDeviceAddress': dbus.ByteArray('12345')},
|
'P2PDeviceAddress': dbus.ByteArray(b'12345')},
|
||||||
{'Role': 'enrollee', 'Type': 'pbc', 'Foo': 'bar'} ]
|
{'Role': 'enrollee', 'Type': 'pbc', 'Foo': 'bar'} ]
|
||||||
for args in failures:
|
for args in failures:
|
||||||
try:
|
try:
|
||||||
|
@ -999,18 +999,18 @@ def test_dbus_scan_invalid(dev, apdev):
|
||||||
({'Type': 'active', 'SSIDs': 'foo'}, "InvalidArgs"),
|
({'Type': 'active', 'SSIDs': 'foo'}, "InvalidArgs"),
|
||||||
({'Type': 'active', 'SSIDs': ['foo']}, "InvalidArgs"),
|
({'Type': 'active', 'SSIDs': ['foo']}, "InvalidArgs"),
|
||||||
({'Type': 'active',
|
({'Type': 'active',
|
||||||
'SSIDs': [ dbus.ByteArray("1"), dbus.ByteArray("2"),
|
'SSIDs': [ dbus.ByteArray(b"1"), dbus.ByteArray(b"2"),
|
||||||
dbus.ByteArray("3"), dbus.ByteArray("4"),
|
dbus.ByteArray(b"3"), dbus.ByteArray(b"4"),
|
||||||
dbus.ByteArray("5"), dbus.ByteArray("6"),
|
dbus.ByteArray(b"5"), dbus.ByteArray(b"6"),
|
||||||
dbus.ByteArray("7"), dbus.ByteArray("8"),
|
dbus.ByteArray(b"7"), dbus.ByteArray(b"8"),
|
||||||
dbus.ByteArray("9"), dbus.ByteArray("10"),
|
dbus.ByteArray(b"9"), dbus.ByteArray(b"10"),
|
||||||
dbus.ByteArray("11"), dbus.ByteArray("12"),
|
dbus.ByteArray(b"11"), dbus.ByteArray(b"12"),
|
||||||
dbus.ByteArray("13"), dbus.ByteArray("14"),
|
dbus.ByteArray(b"13"), dbus.ByteArray(b"14"),
|
||||||
dbus.ByteArray("15"), dbus.ByteArray("16"),
|
dbus.ByteArray(b"15"), dbus.ByteArray(b"16"),
|
||||||
dbus.ByteArray("17") ]},
|
dbus.ByteArray(b"17") ]},
|
||||||
"InvalidArgs"),
|
"InvalidArgs"),
|
||||||
({'Type': 'active',
|
({'Type': 'active',
|
||||||
'SSIDs': [ dbus.ByteArray("1234567890abcdef1234567890abcdef1") ]},
|
'SSIDs': [ dbus.ByteArray(b"1234567890abcdef1234567890abcdef1") ]},
|
||||||
"InvalidArgs"),
|
"InvalidArgs"),
|
||||||
({'Type': 'active', 'IEs': 'foo'}, "InvalidArgs"),
|
({'Type': 'active', 'IEs': 'foo'}, "InvalidArgs"),
|
||||||
({'Type': 'active', 'IEs': ['foo']}, "InvalidArgs"),
|
({'Type': 'active', 'IEs': ['foo']}, "InvalidArgs"),
|
||||||
|
@ -1023,9 +1023,9 @@ def test_dbus_scan_invalid(dev, apdev):
|
||||||
'Channels': [ (dbus.UInt32(2412), dbus.Int32(20)) ] },
|
'Channels': [ (dbus.UInt32(2412), dbus.Int32(20)) ] },
|
||||||
"InvalidArgs"),
|
"InvalidArgs"),
|
||||||
({'Type': 'active', 'AllowRoam': "yes" }, "InvalidArgs"),
|
({'Type': 'active', 'AllowRoam': "yes" }, "InvalidArgs"),
|
||||||
({'Type': 'passive', 'IEs': [ dbus.ByteArray("\xdd\x00") ]},
|
({'Type': 'passive', 'IEs': [ dbus.ByteArray(b"\xdd\x00") ]},
|
||||||
"InvalidArgs"),
|
"InvalidArgs"),
|
||||||
({'Type': 'passive', 'SSIDs': [ dbus.ByteArray("foo") ]},
|
({'Type': 'passive', 'SSIDs': [ dbus.ByteArray(b"foo") ]},
|
||||||
"InvalidArgs")]
|
"InvalidArgs")]
|
||||||
for (t,err) in tests:
|
for (t,err) in tests:
|
||||||
try:
|
try:
|
||||||
|
@ -1056,14 +1056,14 @@ def test_dbus_scan_oom(dev, apdev):
|
||||||
"=wpas_dbus_get_scan_ies;wpas_dbus_handler_scan",
|
"=wpas_dbus_get_scan_ies;wpas_dbus_handler_scan",
|
||||||
"Scan"):
|
"Scan"):
|
||||||
iface.Scan({ 'Type': 'active',
|
iface.Scan({ 'Type': 'active',
|
||||||
'IEs': [ dbus.ByteArray("\xdd\x00") ],
|
'IEs': [ dbus.ByteArray(b"\xdd\x00") ],
|
||||||
'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] })
|
'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] })
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 1,
|
with alloc_fail_dbus(dev[0], 1,
|
||||||
"=wpas_dbus_get_scan_ssids;wpas_dbus_handler_scan",
|
"=wpas_dbus_get_scan_ssids;wpas_dbus_handler_scan",
|
||||||
"Scan"):
|
"Scan"):
|
||||||
iface.Scan({ 'Type': 'active',
|
iface.Scan({ 'Type': 'active',
|
||||||
'SSIDs': [ dbus.ByteArray("open"),
|
'SSIDs': [ dbus.ByteArray(b"open"),
|
||||||
dbus.ByteArray() ],
|
dbus.ByteArray() ],
|
||||||
'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] })
|
'Channels': [ (dbus.UInt32(2412), dbus.UInt32(20)) ] })
|
||||||
|
|
||||||
|
@ -1120,9 +1120,9 @@ def test_dbus_scan(dev, apdev):
|
||||||
def run_scan(self, *args):
|
def run_scan(self, *args):
|
||||||
logger.debug("run_scan")
|
logger.debug("run_scan")
|
||||||
iface.Scan({'Type': 'active',
|
iface.Scan({'Type': 'active',
|
||||||
'SSIDs': [ dbus.ByteArray("open"),
|
'SSIDs': [ dbus.ByteArray(b"open"),
|
||||||
dbus.ByteArray() ],
|
dbus.ByteArray() ],
|
||||||
'IEs': [ dbus.ByteArray("\xdd\x00"),
|
'IEs': [ dbus.ByteArray(b"\xdd\x00"),
|
||||||
dbus.ByteArray() ],
|
dbus.ByteArray() ],
|
||||||
'AllowRoam': False,
|
'AllowRoam': False,
|
||||||
'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]})
|
'Channels': [(dbus.UInt32(2412), dbus.UInt32(20))]})
|
||||||
|
@ -1793,7 +1793,7 @@ def test_dbus_network_oom(dev, apdev):
|
||||||
|
|
||||||
tests = [ (1,
|
tests = [ (1,
|
||||||
'wpa_dbus_dict_get_entry;set_network_properties;wpas_dbus_handler_add_network',
|
'wpa_dbus_dict_get_entry;set_network_properties;wpas_dbus_handler_add_network',
|
||||||
dbus.Dictionary({ 'ssid': dbus.ByteArray(' ') },
|
dbus.Dictionary({ 'ssid': dbus.ByteArray(b' ') },
|
||||||
signature='sv')),
|
signature='sv')),
|
||||||
(1, '=set_network_properties;wpas_dbus_handler_add_network',
|
(1, '=set_network_properties;wpas_dbus_handler_add_network',
|
||||||
dbus.Dictionary({ 'ssid': 'foo' }, signature='sv')),
|
dbus.Dictionary({ 'ssid': 'foo' }, signature='sv')),
|
||||||
|
@ -1806,7 +1806,7 @@ def test_dbus_network_oom(dev, apdev):
|
||||||
dbus.Dictionary({ 'priority': dbus.Int32(1) },
|
dbus.Dictionary({ 'priority': dbus.Int32(1) },
|
||||||
signature='sv')),
|
signature='sv')),
|
||||||
(1, '=set_network_properties;wpas_dbus_handler_add_network',
|
(1, '=set_network_properties;wpas_dbus_handler_add_network',
|
||||||
dbus.Dictionary({ 'ssid': dbus.ByteArray(' ') },
|
dbus.Dictionary({ 'ssid': dbus.ByteArray(b' ') },
|
||||||
signature='sv')) ]
|
signature='sv')) ]
|
||||||
for (count,funcs,args) in tests:
|
for (count,funcs,args) in tests:
|
||||||
with alloc_fail_dbus(dev[0], count, funcs, "AddNetwork", "InvalidArgs"):
|
with alloc_fail_dbus(dev[0], count, funcs, "AddNetwork", "InvalidArgs"):
|
||||||
|
@ -1934,10 +1934,10 @@ def test_dbus_blob(dev, apdev):
|
||||||
(bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
|
(bus,wpas_obj,path,if_obj) = prepare_dbus(dev[0])
|
||||||
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
|
iface = dbus.Interface(if_obj, WPAS_DBUS_IFACE)
|
||||||
|
|
||||||
blob = dbus.ByteArray("\x01\x02\x03")
|
blob = dbus.ByteArray(b"\x01\x02\x03")
|
||||||
iface.AddBlob('blob1', blob)
|
iface.AddBlob('blob1', blob)
|
||||||
try:
|
try:
|
||||||
iface.AddBlob('blob1', dbus.ByteArray("\x01\x02\x04"))
|
iface.AddBlob('blob1', dbus.ByteArray(b"\x01\x02\x04"))
|
||||||
raise Exception("Invalid AddBlob() accepted")
|
raise Exception("Invalid AddBlob() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
if "BlobExists" not in str(e):
|
if "BlobExists" not in str(e):
|
||||||
|
@ -1993,7 +1993,7 @@ def test_dbus_blob(dev, apdev):
|
||||||
|
|
||||||
def run_blob(self, *args):
|
def run_blob(self, *args):
|
||||||
logger.debug("run_blob")
|
logger.debug("run_blob")
|
||||||
iface.AddBlob('blob2', dbus.ByteArray("\x01\x02\x04"))
|
iface.AddBlob('blob2', dbus.ByteArray(b"\x01\x02\x04"))
|
||||||
iface.RemoveBlob('blob2')
|
iface.RemoveBlob('blob2')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -2012,7 +2012,7 @@ def test_dbus_blob_oom(dev, apdev):
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
with alloc_fail_dbus(dev[0], i, "wpas_dbus_handler_add_blob",
|
with alloc_fail_dbus(dev[0], i, "wpas_dbus_handler_add_blob",
|
||||||
"AddBlob"):
|
"AddBlob"):
|
||||||
iface.AddBlob('blob_no_mem', dbus.ByteArray("\x01\x02\x03\x04"))
|
iface.AddBlob('blob_no_mem', dbus.ByteArray(b"\x01\x02\x03\x04"))
|
||||||
|
|
||||||
def test_dbus_autoscan(dev, apdev):
|
def test_dbus_autoscan(dev, apdev):
|
||||||
"""D-Bus Autoscan()"""
|
"""D-Bus Autoscan()"""
|
||||||
|
@ -2704,8 +2704,8 @@ def test_dbus_p2p_invalid(dev, apdev):
|
||||||
{'RequestedDeviceTypes': dbus.Array([], signature="s")},
|
{'RequestedDeviceTypes': dbus.Array([], signature="s")},
|
||||||
{'RequestedDeviceTypes': dbus.Array([['foo']], signature="as")},
|
{'RequestedDeviceTypes': dbus.Array([['foo']], signature="as")},
|
||||||
{'RequestedDeviceTypes': dbus.Array([], signature="i")},
|
{'RequestedDeviceTypes': dbus.Array([], signature="i")},
|
||||||
{'RequestedDeviceTypes': [dbus.ByteArray('12345678'),
|
{'RequestedDeviceTypes': [dbus.ByteArray(b'12345678'),
|
||||||
dbus.ByteArray('1234567')]},
|
dbus.ByteArray(b'1234567')]},
|
||||||
{'Foo': dbus.Int16(1)},
|
{'Foo': dbus.Int16(1)},
|
||||||
{'Foo': dbus.UInt16(1)},
|
{'Foo': dbus.UInt16(1)},
|
||||||
{'Foo': dbus.Int64(1)},
|
{'Foo': dbus.Int64(1)},
|
||||||
|
@ -2904,29 +2904,29 @@ def test_dbus_p2p_oom(dev, apdev):
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 1, ":=_wpa_dbus_dict_entry_get_binarray",
|
with alloc_fail_dbus(dev[0], 1, ":=_wpa_dbus_dict_entry_get_binarray",
|
||||||
"Find", "InvalidArgs"):
|
"Find", "InvalidArgs"):
|
||||||
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray('123') ] }))
|
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] }))
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array;_wpa_dbus_dict_entry_get_binarray",
|
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array;_wpa_dbus_dict_entry_get_binarray",
|
||||||
"Find", "InvalidArgs"):
|
"Find", "InvalidArgs"):
|
||||||
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray('123') ] }))
|
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] }))
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 2, "=_wpa_dbus_dict_entry_get_binarray",
|
with alloc_fail_dbus(dev[0], 2, "=_wpa_dbus_dict_entry_get_binarray",
|
||||||
"Find", "InvalidArgs"):
|
"Find", "InvalidArgs"):
|
||||||
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray('123'),
|
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123'),
|
dbus.ByteArray(b'123'),
|
||||||
dbus.ByteArray('123') ] }))
|
dbus.ByteArray(b'123') ] }))
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 1, "wpabuf_alloc_ext_data;_wpa_dbus_dict_entry_get_binarray",
|
with alloc_fail_dbus(dev[0], 1, "wpabuf_alloc_ext_data;_wpa_dbus_dict_entry_get_binarray",
|
||||||
"Find", "InvalidArgs"):
|
"Find", "InvalidArgs"):
|
||||||
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray('123') ] }))
|
p2p.Find(dbus.Dictionary({ 'Foo': [ dbus.ByteArray(b'123') ] }))
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_fill_value_from_variant;wpas_dbus_handler_p2p_find",
|
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_fill_value_from_variant;wpas_dbus_handler_p2p_find",
|
||||||
"Find", "InvalidArgs"):
|
"Find", "InvalidArgs"):
|
||||||
|
@ -2935,7 +2935,7 @@ def test_dbus_p2p_oom(dev, apdev):
|
||||||
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array",
|
with alloc_fail_dbus(dev[0], 1, "_wpa_dbus_dict_entry_get_byte_array",
|
||||||
"AddService", "InvalidArgs"):
|
"AddService", "InvalidArgs"):
|
||||||
args = { 'service_type': 'bonjour',
|
args = { 'service_type': 'bonjour',
|
||||||
'response': dbus.ByteArray(500*'b') }
|
'response': dbus.ByteArray(500*b'b') }
|
||||||
p2p.AddService(args)
|
p2p.AddService(args)
|
||||||
|
|
||||||
with alloc_fail_dbus(dev[0], 2, "_wpa_dbus_dict_entry_get_byte_array",
|
with alloc_fail_dbus(dev[0], 2, "_wpa_dbus_dict_entry_get_byte_array",
|
||||||
|
@ -2978,7 +2978,7 @@ def run_dbus_p2p_discovery(dev, apdev):
|
||||||
raise Exception("Unexpected peer(s) in the list")
|
raise Exception("Unexpected peer(s) in the list")
|
||||||
|
|
||||||
args = {'DiscoveryType': 'social',
|
args = {'DiscoveryType': 'social',
|
||||||
'RequestedDeviceTypes': [dbus.ByteArray('12345678')],
|
'RequestedDeviceTypes': [dbus.ByteArray(b'12345678')],
|
||||||
'Timeout': dbus.Int32(1) }
|
'Timeout': dbus.Int32(1) }
|
||||||
p2p.Find(dbus.Dictionary(args))
|
p2p.Find(dbus.Dictionary(args))
|
||||||
p2p.StopFind()
|
p2p.StopFind()
|
||||||
|
@ -3029,7 +3029,7 @@ def run_dbus_p2p_discovery(dev, apdev):
|
||||||
sec = res['SecondaryDeviceTypes']
|
sec = res['SecondaryDeviceTypes']
|
||||||
if len(sec) < 1:
|
if len(sec) < 1:
|
||||||
raise Exception("Secondary device type missing")
|
raise Exception("Secondary device type missing")
|
||||||
if "\x00\x01\x00\x50\xF2\x04\x00\x02" not in sec:
|
if b"\x00\x01\x00\x50\xF2\x04\x00\x02" not in sec:
|
||||||
raise Exception("Secondary device type mismatch")
|
raise Exception("Secondary device type mismatch")
|
||||||
|
|
||||||
if 'VendorExtension' not in res:
|
if 'VendorExtension' not in res:
|
||||||
|
@ -3037,7 +3037,7 @@ def run_dbus_p2p_discovery(dev, apdev):
|
||||||
vendor = res['VendorExtension']
|
vendor = res['VendorExtension']
|
||||||
if len(vendor) < 1:
|
if len(vendor) < 1:
|
||||||
raise Exception("Vendor extension missing")
|
raise Exception("Vendor extension missing")
|
||||||
if "\x11\x22\x33\x44" not in vendor:
|
if b"\x11\x22\x33\x44" not in vendor:
|
||||||
raise Exception("Secondary device type mismatch")
|
raise Exception("Secondary device type mismatch")
|
||||||
|
|
||||||
if 'VSIE' not in res:
|
if 'VSIE' not in res:
|
||||||
|
@ -3045,7 +3045,7 @@ def run_dbus_p2p_discovery(dev, apdev):
|
||||||
vendor = res['VSIE']
|
vendor = res['VSIE']
|
||||||
if len(vendor) < 1:
|
if len(vendor) < 1:
|
||||||
raise Exception("VSIE missing")
|
raise Exception("VSIE missing")
|
||||||
if vendor != "\xdd\x06\x00\x11\x22\x33\x55\x66":
|
if vendor != b"\xdd\x06\x00\x11\x22\x33\x55\x66":
|
||||||
raise Exception("VSIE mismatch")
|
raise Exception("VSIE mismatch")
|
||||||
|
|
||||||
self.found = True
|
self.found = True
|
||||||
|
@ -3250,7 +3250,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
|
||||||
{ 'service_type': 'bonjour', 'response': 'foo' },
|
{ 'service_type': 'bonjour', 'response': 'foo' },
|
||||||
{ 'service_type': 'bonjour', 'query': bonjour_query },
|
{ 'service_type': 'bonjour', 'query': bonjour_query },
|
||||||
{ 'service_type': 'bonjour', 'response': bonjour_response },
|
{ 'service_type': 'bonjour', 'response': bonjour_response },
|
||||||
{ 'service_type': 'bonjour', 'query': dbus.ByteArray(500*'a') },
|
{ 'service_type': 'bonjour', 'query': dbus.ByteArray(500*b'a') },
|
||||||
{ 'service_type': 'bonjour', 'foo': 'bar' } ]
|
{ 'service_type': 'bonjour', 'foo': 'bar' } ]
|
||||||
for args in tests:
|
for args in tests:
|
||||||
try:
|
try:
|
||||||
|
@ -3260,7 +3260,7 @@ def test_dbus_p2p_service_discovery(dev, apdev):
|
||||||
if "InvalidArgs" not in str(e):
|
if "InvalidArgs" not in str(e):
|
||||||
raise Exception("Unexpected error message for invalid AddService(): " + str(e))
|
raise Exception("Unexpected error message for invalid AddService(): " + str(e))
|
||||||
|
|
||||||
args = { 'tlv': dbus.ByteArray("\x02\x00\x00\x01") }
|
args = { 'tlv': dbus.ByteArray(b"\x02\x00\x00\x01") }
|
||||||
ref = p2p.ServiceDiscoveryRequest(args)
|
ref = p2p.ServiceDiscoveryRequest(args)
|
||||||
p2p.ServiceDiscoveryCancelRequest(ref)
|
p2p.ServiceDiscoveryCancelRequest(ref)
|
||||||
try:
|
try:
|
||||||
|
@ -3348,7 +3348,7 @@ def test_dbus_p2p_service_discovery_query(dev, apdev):
|
||||||
def deviceFound(self, path):
|
def deviceFound(self, path):
|
||||||
logger.debug("deviceFound: path=%s" % path)
|
logger.debug("deviceFound: path=%s" % path)
|
||||||
args = { 'peer_object': path,
|
args = { 'peer_object': path,
|
||||||
'tlv': dbus.ByteArray("\x02\x00\x00\x01") }
|
'tlv': dbus.ByteArray(b"\x02\x00\x00\x01") }
|
||||||
p2p.ServiceDiscoveryRequest(args)
|
p2p.ServiceDiscoveryRequest(args)
|
||||||
|
|
||||||
def serviceDiscoveryResponse(self, sd_request):
|
def serviceDiscoveryResponse(self, sd_request):
|
||||||
|
@ -3598,7 +3598,7 @@ def test_dbus_p2p_autogo(dev, apdev):
|
||||||
self.exceptions = True
|
self.exceptions = True
|
||||||
raise Exception("Unexpected number of group members")
|
raise Exception("Unexpected number of group members")
|
||||||
|
|
||||||
ext = dbus.ByteArray("\x11\x22\x33\x44")
|
ext = dbus.ByteArray(b"\x11\x22\x33\x44")
|
||||||
# Earlier implementation of this interface was a bit strange. The
|
# Earlier implementation of this interface was a bit strange. The
|
||||||
# property is defined to have aay signature and that is what the
|
# property is defined to have aay signature and that is what the
|
||||||
# getter returned. However, the setter expected there to be a
|
# getter returned. However, the setter expected there to be a
|
||||||
|
@ -3621,7 +3621,7 @@ def test_dbus_p2p_autogo(dev, apdev):
|
||||||
|
|
||||||
# And now verify that the more appropriate encoding is accepted as
|
# And now verify that the more appropriate encoding is accepted as
|
||||||
# well.
|
# well.
|
||||||
res.append(dbus.ByteArray('\xaa\xbb\xcc\xdd\xee\xff'))
|
res.append(dbus.ByteArray(b'\xaa\xbb\xcc\xdd\xee\xff'))
|
||||||
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
res2 = g_obj.Get(WPAS_DBUS_GROUP, 'WPSVendorExtensions',
|
res2 = g_obj.Get(WPAS_DBUS_GROUP, 'WPSVendorExtensions',
|
||||||
|
@ -3635,7 +3635,7 @@ def test_dbus_p2p_autogo(dev, apdev):
|
||||||
raise Exception("Vendor extension value changed")
|
raise Exception("Vendor extension value changed")
|
||||||
|
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
res.append(dbus.ByteArray('\xaa\xbb'))
|
res.append(dbus.ByteArray(b'\xaa\xbb'))
|
||||||
try:
|
try:
|
||||||
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
|
@ -3947,7 +3947,7 @@ def test_dbus_p2p_join(dev, apdev):
|
||||||
byte_arrays=True)
|
byte_arrays=True)
|
||||||
logger.debug("Group properties: " + str(res))
|
logger.debug("Group properties: " + str(res))
|
||||||
|
|
||||||
ext = dbus.ByteArray("\x11\x22\x33\x44")
|
ext = dbus.ByteArray(b"\x11\x22\x33\x44")
|
||||||
try:
|
try:
|
||||||
# Set(WPSVendorExtensions) not allowed for P2P Client
|
# Set(WPSVendorExtensions) not allowed for P2P Client
|
||||||
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
g_obj.Set(WPAS_DBUS_GROUP, 'WPSVendorExtensions', res,
|
||||||
|
@ -4068,8 +4068,8 @@ def _test_dbus_p2p_config(dev, apdev):
|
||||||
raise Exception("Parameter %s value changes" % k)
|
raise Exception("Parameter %s value changes" % k)
|
||||||
|
|
||||||
changes = { 'SsidPostfix': 'foo',
|
changes = { 'SsidPostfix': 'foo',
|
||||||
'VendorExtension': [ dbus.ByteArray('\x11\x22\x33\x44') ],
|
'VendorExtension': [ dbus.ByteArray(b'\x11\x22\x33\x44') ],
|
||||||
'SecondaryDeviceTypes': [ dbus.ByteArray('\x11\x22\x33\x44\x55\x66\x77\x88') ]}
|
'SecondaryDeviceTypes': [ dbus.ByteArray(b'\x11\x22\x33\x44\x55\x66\x77\x88') ]}
|
||||||
if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig",
|
if_obj.Set(WPAS_DBUS_IFACE_P2PDEVICE, "P2PDeviceConfig",
|
||||||
dbus.Dictionary(changes, signature='sv'),
|
dbus.Dictionary(changes, signature='sv'),
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE)
|
dbus_interface=dbus.PROPERTIES_IFACE)
|
||||||
|
@ -5554,7 +5554,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
dev[0].request("VENDOR_ELEM_REMOVE 1 *")
|
dev[0].request("VENDOR_ELEM_REMOVE 1 *")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie = dbus.ByteArray("\x00\x00")
|
ie = dbus.ByteArray(b"\x00\x00")
|
||||||
iface.VendorElemAdd(-1, ie)
|
iface.VendorElemAdd(-1, ie)
|
||||||
raise Exception("Invalid VendorElemAdd() accepted")
|
raise Exception("Invalid VendorElemAdd() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -5562,7 +5562,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
raise Exception("Unexpected error message for invalid VendorElemAdd[1]: " + str(e))
|
raise Exception("Unexpected error message for invalid VendorElemAdd[1]: " + str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie = dbus.ByteArray("")
|
ie = dbus.ByteArray(b'')
|
||||||
iface.VendorElemAdd(1, ie)
|
iface.VendorElemAdd(1, ie)
|
||||||
raise Exception("Invalid VendorElemAdd() accepted")
|
raise Exception("Invalid VendorElemAdd() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -5570,7 +5570,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
raise Exception("Unexpected error message for invalid VendorElemAdd[2]: " + str(e))
|
raise Exception("Unexpected error message for invalid VendorElemAdd[2]: " + str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie = dbus.ByteArray("\x00\x01")
|
ie = dbus.ByteArray(b"\x00\x01")
|
||||||
iface.VendorElemAdd(1, ie)
|
iface.VendorElemAdd(1, ie)
|
||||||
raise Exception("Invalid VendorElemAdd() accepted")
|
raise Exception("Invalid VendorElemAdd() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -5592,7 +5592,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
raise Exception("Unexpected error message for invalid VendorElemGet[2]: " + str(e))
|
raise Exception("Unexpected error message for invalid VendorElemGet[2]: " + str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie = dbus.ByteArray("\x00\x00")
|
ie = dbus.ByteArray(b"\x00\x00")
|
||||||
iface.VendorElemRem(-1, ie)
|
iface.VendorElemRem(-1, ie)
|
||||||
raise Exception("Invalid VendorElemRemove() accepted")
|
raise Exception("Invalid VendorElemRemove() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -5600,16 +5600,16 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
|
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
ie = dbus.ByteArray("")
|
ie = dbus.ByteArray(b'')
|
||||||
iface.VendorElemRem(1, ie)
|
iface.VendorElemRem(1, ie)
|
||||||
raise Exception("Invalid VendorElemRemove() accepted")
|
raise Exception("Invalid VendorElemRemove() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
if "InvalidArgs" not in str(e) or "Invalid value" not in str(e):
|
if "InvalidArgs" not in str(e) or "Invalid value" not in str(e):
|
||||||
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
|
raise Exception("Unexpected error message for invalid VendorElemRemove[1]: " + str(e))
|
||||||
|
|
||||||
iface.VendorElemRem(1, "*")
|
iface.VendorElemRem(1, b"*")
|
||||||
|
|
||||||
ie = dbus.ByteArray("\x00\x01\x00")
|
ie = dbus.ByteArray(b"\x00\x01\x00")
|
||||||
iface.VendorElemAdd(1, ie)
|
iface.VendorElemAdd(1, ie)
|
||||||
|
|
||||||
val = iface.VendorElemGet(1)
|
val = iface.VendorElemGet(1)
|
||||||
|
@ -5619,7 +5619,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
if val[i] != dbus.Byte(ie[i]):
|
if val[i] != dbus.Byte(ie[i]):
|
||||||
raise Exception("Unexpected VendorElemGet data")
|
raise Exception("Unexpected VendorElemGet data")
|
||||||
|
|
||||||
ie2 = dbus.ByteArray("\xe0\x00")
|
ie2 = dbus.ByteArray(b"\xe0\x00")
|
||||||
iface.VendorElemAdd(1, ie2)
|
iface.VendorElemAdd(1, ie2)
|
||||||
|
|
||||||
ies = ie + ie2
|
ies = ie + ie2
|
||||||
|
@ -5631,7 +5631,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
raise Exception("Unexpected VendorElemGet data[2]")
|
raise Exception("Unexpected VendorElemGet data[2]")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
test_ie = dbus.ByteArray("\x01\x01")
|
test_ie = dbus.ByteArray(b"\x01\x01")
|
||||||
iface.VendorElemRem(1, test_ie)
|
iface.VendorElemRem(1, test_ie)
|
||||||
raise Exception("Invalid VendorElemRemove() accepted")
|
raise Exception("Invalid VendorElemRemove() accepted")
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
|
@ -5643,7 +5643,7 @@ def _test_dbus_vendor_elem(dev, apdev):
|
||||||
if len(val) != len(ie2):
|
if len(val) != len(ie2):
|
||||||
raise Exception("Unexpected VendorElemGet length[3]")
|
raise Exception("Unexpected VendorElemGet length[3]")
|
||||||
|
|
||||||
iface.VendorElemRem(1, "*")
|
iface.VendorElemRem(1, b"*")
|
||||||
try:
|
try:
|
||||||
iface.VendorElemGet(1)
|
iface.VendorElemGet(1)
|
||||||
raise Exception("Invalid VendorElemGet() accepted after removal")
|
raise Exception("Invalid VendorElemGet() accepted after removal")
|
||||||
|
@ -5754,7 +5754,7 @@ def test_dbus_mesh(dev, apdev):
|
||||||
dbus_interface=dbus.PROPERTIES_IFACE,
|
dbus_interface=dbus.PROPERTIES_IFACE,
|
||||||
byte_arrays=True)
|
byte_arrays=True)
|
||||||
logger.debug("MeshGroup: " + str(res))
|
logger.debug("MeshGroup: " + str(res))
|
||||||
if res != "wpas-mesh-open":
|
if res != b"wpas-mesh-open":
|
||||||
raise Exception("Unexpected MeshGroup")
|
raise Exception("Unexpected MeshGroup")
|
||||||
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
|
dev1 = WpaSupplicant('wlan1', '/tmp/wpas-wlan1')
|
||||||
dev1.mesh_group_remove()
|
dev1.mesh_group_remove()
|
||||||
|
|
|
@ -57,7 +57,7 @@ def test_dpp_qr_code_parsing(dev, apdev):
|
||||||
"DPP:;;",
|
"DPP:;;",
|
||||||
"DPP:C:1/2;M:;K;;",
|
"DPP:C:1/2;M:;K;;",
|
||||||
"DPP:I:;M:01020304050;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;",
|
"DPP:I:;M:01020304050;K:MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgADURzxmttZoIRIPWGoQMV00XHWCAQIhXruVWOz0NjlkIA=;;",
|
||||||
"DPP:K:" + base64.b64encode("hello") + ";;",
|
"DPP:K:" + base64.b64encode(b"hello") + ";;",
|
||||||
"DPP:K:MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;",
|
"DPP:K:MEkwEwYHKoZIzj0CAQYIKoZIzj0DAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;",
|
||||||
"DPP:K:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANNZaZA4T/kRDjnmpI1ACOJhAuTIIEk2KFOpS6XPpGF+EVr/ao3XemkE0/nzXmGaLzLqTUCJknSdxTnVPeWfCVsCAwEAAQ==;;",
|
"DPP:K:MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANNZaZA4T/kRDjnmpI1ACOJhAuTIIEk2KFOpS6XPpGF+EVr/ao3XemkE0/nzXmGaLzLqTUCJknSdxTnVPeWfCVsCAwEAAQ==;;",
|
||||||
"DPP:K:MIIBCjCB0wYHKoZIzj0CATCBxwIBATAkBgcqhkjOPQEBAhkA/////////////////////v//////////MEsEGP////////////////////7//////////AQYZCEFGeWcgOcPp+mrciQwSf643uzBRrmxAxUAMEWub8hCL2TtV5Uo04Eg6uEhltUEMQQYjagOsDCQ9ny/IOtDoYgA9P8K/YL/EBIHGSuV/8jaeGMQEe1rJM3Vc/l3oR55SBECGQD///////////////+Z3vg2FGvJsbTSKDECAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;",
|
"DPP:K:MIIBCjCB0wYHKoZIzj0CATCBxwIBATAkBgcqhkjOPQEBAhkA/////////////////////v//////////MEsEGP////////////////////7//////////AQYZCEFGeWcgOcPp+mrciQwSf643uzBRrmxAxUAMEWub8hCL2TtV5Uo04Eg6uEhltUEMQQYjagOsDCQ9ny/IOtDoYgA9P8K/YL/EBIHGSuV/8jaeGMQEe1rJM3Vc/l3oR55SBECGQD///////////////+Z3vg2FGvJsbTSKDECAQEDMgAEXiJuIWt1Q/CPCkuULechh37UsXPmbUANOeN5U9sOQROE4o/NEFeFEejROHYwwehF;;",
|
||||||
|
|
|
@ -8306,8 +8306,8 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
struct.pack(">HHB", EAP_TLV_INTERMEDIATE_RESULT_TLV, 1, 0xff),
|
struct.pack(">HHB", EAP_TLV_INTERMEDIATE_RESULT_TLV, 1, 0xff),
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: More than one Crypto-Binding TLV in the message",
|
("EAP-FAST: More than one Crypto-Binding TLV in the message",
|
||||||
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*'A' +
|
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A' +
|
||||||
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*'A',
|
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: Too short Crypto-Binding TLV",
|
("EAP-FAST: Too short Crypto-Binding TLV",
|
||||||
struct.pack(">HHB", EAP_TLV_CRYPTO_BINDING_TLV, 1, 0xff),
|
struct.pack(">HHB", EAP_TLV_CRYPTO_BINDING_TLV, 1, 0xff),
|
||||||
|
@ -8364,7 +8364,7 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
struct.pack(">HHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 4 + 32,
|
struct.pack(">HHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 4 + 32,
|
||||||
PAC_TYPE_PAC_OPAQUE, 0,
|
PAC_TYPE_PAC_OPAQUE, 0,
|
||||||
PAC_TYPE_PAC_INFO, 0,
|
PAC_TYPE_PAC_INFO, 0,
|
||||||
PAC_TYPE_PAC_KEY, 32) + 32*'A',
|
PAC_TYPE_PAC_KEY, 32) + 32*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: Invalid CRED_LIFETIME length, Ignored unknown PAC-Info type 0, and Invalid PAC-Type length 1",
|
("EAP-FAST: Invalid CRED_LIFETIME length, Ignored unknown PAC-Info type 0, and Invalid PAC-Type length 1",
|
||||||
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
||||||
|
@ -8373,7 +8373,7 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
PAC_TYPE_PAC_OPAQUE, 0,
|
PAC_TYPE_PAC_OPAQUE, 0,
|
||||||
PAC_TYPE_PAC_INFO, 13, PAC_TYPE_CRED_LIFETIME, 0,
|
PAC_TYPE_PAC_INFO, 13, PAC_TYPE_CRED_LIFETIME, 0,
|
||||||
0, 0, PAC_TYPE_PAC_TYPE, 1, 0,
|
0, 0, PAC_TYPE_PAC_TYPE, 1, 0,
|
||||||
PAC_TYPE_PAC_KEY, 32) + 32*'A',
|
PAC_TYPE_PAC_KEY, 32) + 32*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: Unsupported PAC-Type 0",
|
("EAP-FAST: Unsupported PAC-Type 0",
|
||||||
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
||||||
|
@ -8381,7 +8381,7 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
struct.pack(">HHHHHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 6 + 4 + 32,
|
struct.pack(">HHHHHHHHHHH", EAP_TLV_PAC_TLV, 4 + 4 + 6 + 4 + 32,
|
||||||
PAC_TYPE_PAC_OPAQUE, 0,
|
PAC_TYPE_PAC_OPAQUE, 0,
|
||||||
PAC_TYPE_PAC_INFO, 6, PAC_TYPE_PAC_TYPE, 2, 0,
|
PAC_TYPE_PAC_INFO, 6, PAC_TYPE_PAC_TYPE, 2, 0,
|
||||||
PAC_TYPE_PAC_KEY, 32) + 32*'A',
|
PAC_TYPE_PAC_KEY, 32) + 32*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: PAC-Info overrun (type=0 len=2 left=1)",
|
("EAP-FAST: PAC-Info overrun (type=0 len=2 left=1)",
|
||||||
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
||||||
|
@ -8389,7 +8389,7 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
struct.pack(">HHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 5 + 4 + 32,
|
struct.pack(">HHHHHHHHBHH", EAP_TLV_PAC_TLV, 4 + 4 + 5 + 4 + 32,
|
||||||
PAC_TYPE_PAC_OPAQUE, 0,
|
PAC_TYPE_PAC_OPAQUE, 0,
|
||||||
PAC_TYPE_PAC_INFO, 5, 0, 2, 1,
|
PAC_TYPE_PAC_INFO, 5, 0, 2, 1,
|
||||||
PAC_TYPE_PAC_KEY, 32) + 32*'A',
|
PAC_TYPE_PAC_KEY, 32) + 32*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: Valid PAC",
|
("EAP-FAST: Valid PAC",
|
||||||
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
struct.pack(">HHH", EAP_TLV_RESULT_TLV, 2,
|
||||||
|
@ -8399,10 +8399,10 @@ def test_eap_fast_proto_phase2(dev, apdev):
|
||||||
PAC_TYPE_PAC_OPAQUE, 0,
|
PAC_TYPE_PAC_OPAQUE, 0,
|
||||||
PAC_TYPE_PAC_INFO, 10, PAC_TYPE_A_ID, 1, 0x41,
|
PAC_TYPE_PAC_INFO, 10, PAC_TYPE_A_ID, 1, 0x41,
|
||||||
PAC_TYPE_A_ID_INFO, 1, 0x42,
|
PAC_TYPE_A_ID_INFO, 1, 0x42,
|
||||||
PAC_TYPE_PAC_KEY, 32) + 32*'A',
|
PAC_TYPE_PAC_KEY, 32) + 32*b'A',
|
||||||
True),
|
True),
|
||||||
("EAP-FAST: Invalid version/subtype in Crypto-Binding TLV",
|
("EAP-FAST: Invalid version/subtype in Crypto-Binding TLV",
|
||||||
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*'A',
|
struct.pack(">HH", EAP_TLV_CRYPTO_BINDING_TLV, 60) + 60*b'A',
|
||||||
True) ]
|
True) ]
|
||||||
for title, payload, failure in tests:
|
for title, payload, failure in tests:
|
||||||
logger.info("Phase 2 test: " + title)
|
logger.info("Phase 2 test: " + title)
|
||||||
|
|
|
@ -665,15 +665,15 @@ def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0",
|
||||||
ip_src="0.0.0.0", ip_dst="255.255.255.255",
|
ip_src="0.0.0.0", ip_dst="255.255.255.255",
|
||||||
rapid_commit=True, override_op=None, magic_override=None,
|
rapid_commit=True, override_op=None, magic_override=None,
|
||||||
opt_end=True, extra_op=None):
|
opt_end=True, extra_op=None):
|
||||||
proto = '\x08\x00' # IPv4
|
proto = b'\x08\x00' # IPv4
|
||||||
_ip_src = socket.inet_pton(socket.AF_INET, ip_src)
|
_ip_src = socket.inet_pton(socket.AF_INET, ip_src)
|
||||||
_ip_dst = socket.inet_pton(socket.AF_INET, ip_dst)
|
_ip_dst = socket.inet_pton(socket.AF_INET, ip_dst)
|
||||||
|
|
||||||
_ciaddr = '\x00\x00\x00\x00'
|
_ciaddr = b'\x00\x00\x00\x00'
|
||||||
_yiaddr = '\x00\x00\x00\x00'
|
_yiaddr = b'\x00\x00\x00\x00'
|
||||||
_siaddr = '\x00\x00\x00\x00'
|
_siaddr = b'\x00\x00\x00\x00'
|
||||||
_giaddr = socket.inet_pton(socket.AF_INET, giaddr)
|
_giaddr = socket.inet_pton(socket.AF_INET, giaddr)
|
||||||
_chaddr = binascii.unhexlify(chaddr.replace(':','')) + 10*'\x00'
|
_chaddr = binascii.unhexlify(chaddr.replace(':','')) + 10 * b'\x00'
|
||||||
htype = 1 # Hardware address type; 1 = Ethernet
|
htype = 1 # Hardware address type; 1 = Ethernet
|
||||||
hlen = 6 # Hardware address length
|
hlen = 6 # Hardware address length
|
||||||
hops = 0
|
hops = 0
|
||||||
|
@ -691,14 +691,14 @@ def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0",
|
||||||
if override_op is not None:
|
if override_op is not None:
|
||||||
op = override_op
|
op = override_op
|
||||||
payload = struct.pack('>BBBBLHH', op, htype, hlen, hops, xid, secs, flags)
|
payload = struct.pack('>BBBBLHH', op, htype, hlen, hops, xid, secs, flags)
|
||||||
sname = 64*'\x00'
|
sname = 64*b'\x00'
|
||||||
file = 128*'\x00'
|
file = 128*b'\x00'
|
||||||
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + sname + file
|
payload += _ciaddr + _yiaddr + _siaddr + _giaddr + _chaddr + sname + file
|
||||||
# magic - DHCP
|
# magic - DHCP
|
||||||
if magic_override is not None:
|
if magic_override is not None:
|
||||||
payload += magic_override
|
payload += magic_override
|
||||||
else:
|
else:
|
||||||
payload += '\x63\x82\x53\x63'
|
payload += b'\x63\x82\x53\x63'
|
||||||
# Option: DHCP Message Type
|
# Option: DHCP Message Type
|
||||||
if dhcp_msg is not None:
|
if dhcp_msg is not None:
|
||||||
payload += struct.pack('BBB', OPT_DHCP_MESSAGE_TYPE, 1, dhcp_msg)
|
payload += struct.pack('BBB', OPT_DHCP_MESSAGE_TYPE, 1, dhcp_msg)
|
||||||
|
@ -716,7 +716,7 @@ def build_dhcp(req, dhcp_msg, chaddr, giaddr="0.0.0.0",
|
||||||
|
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
ipv4 = start + csum + _ip_src + _ip_dst
|
ipv4 = start + csum + _ip_src + _ip_dst
|
||||||
|
|
||||||
|
@ -817,7 +817,7 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params):
|
||||||
raise Exception("Unexpected ethertype in HLP response: %d" % proto)
|
raise Exception("Unexpected ethertype in HLP response: %d" % proto)
|
||||||
frame = frame[2:]
|
frame = frame[2:]
|
||||||
ip = frame[0:20]
|
ip = frame[0:20]
|
||||||
if ip_checksum(ip) != '\x00\x00':
|
if ip_checksum(ip) != b'\x00\x00':
|
||||||
raise Exception("IP header checksum mismatch in HLP response")
|
raise Exception("IP header checksum mismatch in HLP response")
|
||||||
frame = frame[20:]
|
frame = frame[20:]
|
||||||
udp = frame[0:8]
|
udp = frame[0:8]
|
||||||
|
@ -835,7 +835,7 @@ def run_fils_sk_hlp(dev, apdev, rapid_commit_server, params):
|
||||||
file = frame[0:128]
|
file = frame[0:128]
|
||||||
frame = frame[128:]
|
frame = frame[128:]
|
||||||
options = frame
|
options = frame
|
||||||
if options[0:4] != '\x63\x82\x53\x63':
|
if options[0:4] != b'\x63\x82\x53\x63':
|
||||||
raise Exception("No DHCP magic seen in HLP response")
|
raise Exception("No DHCP magic seen in HLP response")
|
||||||
options = options[4:]
|
options = options[4:]
|
||||||
# TODO: fully parse and validate DHCPACK options
|
# TODO: fully parse and validate DHCPACK options
|
||||||
|
@ -999,21 +999,21 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params):
|
||||||
|
|
||||||
tot_len = 20 + 1
|
tot_len = 20 + 1
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
_ip_src = '\x00\x00\x00\x00'
|
_ip_src = b'\x00\x00\x00\x00'
|
||||||
_ip_dst = '\x00\x00\x00\x00'
|
_ip_dst = b'\x00\x00\x00\x00'
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
ipv4_overflow = start + csum + _ip_src + _ip_dst
|
ipv4_overflow = start + csum + _ip_src + _ip_dst
|
||||||
|
|
||||||
tot_len = 20
|
tot_len = 20
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 123)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 123)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
ipv4_unknown_proto = start + csum + _ip_src + _ip_dst
|
ipv4_unknown_proto = start + csum + _ip_src + _ip_dst
|
||||||
|
|
||||||
tot_len = 20
|
tot_len = 20
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
ipv4_missing_udp_hdr = start + csum + _ip_src + _ip_dst
|
ipv4_missing_udp_hdr = start + csum + _ip_src + _ip_dst
|
||||||
|
|
||||||
|
@ -1022,14 +1022,14 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params):
|
||||||
udp = struct.pack('>HHHH', src_port, dst_port, 8 + 1, 0)
|
udp = struct.pack('>HHHH', src_port, dst_port, 8 + 1, 0)
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
udp_overflow = start + csum + _ip_src + _ip_dst + udp
|
udp_overflow = start + csum + _ip_src + _ip_dst + udp
|
||||||
|
|
||||||
udp = struct.pack('>HHHH', src_port, dst_port, 7, 0)
|
udp = struct.pack('>HHHH', src_port, dst_port, 7, 0)
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
udp_underflow = start + csum + _ip_src + _ip_dst + udp
|
udp_underflow = start + csum + _ip_src + _ip_dst + udp
|
||||||
|
|
||||||
|
@ -1038,7 +1038,7 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params):
|
||||||
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
udp_unknown_port = start + csum + _ip_src + _ip_dst + udp
|
udp_unknown_port = start + csum + _ip_src + _ip_dst + udp
|
||||||
|
|
||||||
|
@ -1047,24 +1047,24 @@ def test_fils_sk_hlp_req_parsing(dev, apdev, params):
|
||||||
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
udp = struct.pack('>HHHH', src_port, dst_port, 8, 0)
|
||||||
tot_len = 20 + len(udp)
|
tot_len = 20 + len(udp)
|
||||||
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
start = struct.pack('>BBHHBBBB', 0x45, 0, tot_len, 0, 0, 0, 128, 17)
|
||||||
ipv4 = start + '\x00\x00' + _ip_src + _ip_dst
|
ipv4 = start + b'\x00\x00' + _ip_src + _ip_dst
|
||||||
csum = ip_checksum(ipv4)
|
csum = ip_checksum(ipv4)
|
||||||
dhcp_missing_data = start + csum + _ip_src + _ip_dst + udp
|
dhcp_missing_data = start + csum + _ip_src + _ip_dst + udp
|
||||||
|
|
||||||
dhcp_not_req = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
dhcp_not_req = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
||||||
chaddr=dev[0].own_addr(), override_op=BOOTREPLY)
|
chaddr=dev[0].own_addr(), override_op=BOOTREPLY)
|
||||||
dhcp_no_magic = build_dhcp(req=True, dhcp_msg=None,
|
dhcp_no_magic = build_dhcp(req=True, dhcp_msg=None,
|
||||||
chaddr=dev[0].own_addr(), magic_override='',
|
chaddr=dev[0].own_addr(), magic_override=b'',
|
||||||
rapid_commit=False, opt_end=False)
|
rapid_commit=False, opt_end=False)
|
||||||
dhcp_unknown_magic = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
dhcp_unknown_magic = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
||||||
chaddr=dev[0].own_addr(),
|
chaddr=dev[0].own_addr(),
|
||||||
magic_override='\x00\x00\x00\x00')
|
magic_override=b'\x00\x00\x00\x00')
|
||||||
dhcp_opts = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
dhcp_opts = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
||||||
chaddr=dev[0].own_addr(),
|
chaddr=dev[0].own_addr(),
|
||||||
extra_op='\x00\x11', opt_end=False)
|
extra_op=b'\x00\x11', opt_end=False)
|
||||||
dhcp_opts2 = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
dhcp_opts2 = build_dhcp(req=True, dhcp_msg=DHCPNAK,
|
||||||
chaddr=dev[0].own_addr(),
|
chaddr=dev[0].own_addr(),
|
||||||
extra_op='\x11\x01', opt_end=False)
|
extra_op=b'\x11\x01', opt_end=False)
|
||||||
dhcp_valid = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
dhcp_valid = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
||||||
chaddr=dev[0].own_addr())
|
chaddr=dev[0].own_addr())
|
||||||
|
|
||||||
|
@ -1197,16 +1197,16 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
dhcpdisc = build_dhcp(req=False, dhcp_msg=DHCPACK,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3")
|
||||||
#sock.sendto(dhcpdisc[2+20+8:], addr)
|
#sock.sendto(dhcpdisc[2+20+8:], addr)
|
||||||
chaddr = binascii.unhexlify(dev[0].own_addr().replace(':','')) + 10*'\x00'
|
chaddr = binascii.unhexlify(dev[0].own_addr().replace(':','')) + 10*b'\x00'
|
||||||
tests = [ "\x00",
|
tests = [ b"\x00",
|
||||||
"\x02" + 500 * "\x00",
|
b"\x02" + 500 * b"\x00",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + 500 * "\x00",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 500*b"\x00",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + 16*"\x00" + 64*"\x00" + 128*"\x00" + "\x63\x82\x53\x63",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + 16*"\x00" + 64*"\x00" + 128*"\x00" + "\x63\x82\x53\x63" + "\x00\x11",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x00\x11",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + 16*"\x00" + 64*"\x00" + 128*"\x00" + "\x63\x82\x53\x63" + "\x11\x01",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + 16*b"\x00" + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x11\x01",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + chaddr + 64*"\x00" + 128*"\x00" + "\x63\x82\x53\x63" + "\x35\x00\xff",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x00\xff",
|
||||||
"\x02\x00\x00\x00" + 20*"\x00" + "\x7f\x00\x00\x03" + chaddr + 64*"\x00" + 128*"\x00" + "\x63\x82\x53\x63" + "\x35\x01\x00\xff",
|
b"\x02\x00\x00\x00" + 20*b"\x00" + b"\x7f\x00\x00\x03" + chaddr + 64*b"\x00" + 128*b"\x00" + b"\x63\x82\x53\x63" + b"\x35\x01\x00\xff",
|
||||||
1501 * "\x00" ]
|
1501 * b"\x00" ]
|
||||||
for t in tests:
|
for t in tests:
|
||||||
sock.sendto(t, addr)
|
sock.sendto(t, addr)
|
||||||
dev[0].wait_connected()
|
dev[0].wait_connected()
|
||||||
|
@ -1234,7 +1234,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
||||||
extra_op="\x00\x11", opt_end=False)
|
extra_op=b"\x00\x11", opt_end=False)
|
||||||
sock.sendto(dhcpoffer[2+20+8:], addr)
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
||||||
(msg,addr) = sock.recvfrom(1000)
|
(msg,addr) = sock.recvfrom(1000)
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
|
@ -1249,7 +1249,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
||||||
extra_op="\x11\x01", opt_end=False)
|
extra_op=b"\x11\x01", opt_end=False)
|
||||||
sock.sendto(dhcpoffer[2+20+8:], addr)
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
||||||
(msg,addr) = sock.recvfrom(1000)
|
(msg,addr) = sock.recvfrom(1000)
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
|
@ -1264,7 +1264,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
||||||
extra_op="\x36\x01\x30")
|
extra_op=b"\x36\x01\x30")
|
||||||
sock.sendto(dhcpoffer[2+20+8:], addr)
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
||||||
(msg,addr) = sock.recvfrom(1000)
|
(msg,addr) = sock.recvfrom(1000)
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
|
@ -1276,7 +1276,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
dev[0].request("FILS_HLP_REQ_FLUSH")
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
||||||
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
||||||
chaddr=dev[0].own_addr(),
|
chaddr=dev[0].own_addr(),
|
||||||
extra_op="\x00\x11", opt_end=False)
|
extra_op=b"\x00\x11", opt_end=False)
|
||||||
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
||||||
raise Exception("FILS_HLP_REQ_ADD failed")
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
|
@ -1285,7 +1285,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
||||||
extra_op="\x36\x01\x30")
|
extra_op=b"\x36\x01\x30")
|
||||||
sock.sendto(dhcpoffer[2+20+8:], addr)
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
||||||
dev[0].wait_connected()
|
dev[0].wait_connected()
|
||||||
dev[0].request("DISCONNECT")
|
dev[0].request("DISCONNECT")
|
||||||
|
@ -1295,7 +1295,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
dev[0].request("FILS_HLP_REQ_FLUSH")
|
dev[0].request("FILS_HLP_REQ_FLUSH")
|
||||||
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
dhcpdisc = build_dhcp(req=True, dhcp_msg=DHCPDISCOVER,
|
||||||
chaddr=dev[0].own_addr(),
|
chaddr=dev[0].own_addr(),
|
||||||
extra_op="\x11\x01", opt_end=False)
|
extra_op=b"\x11\x01", opt_end=False)
|
||||||
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
if "OK" not in dev[0].request("FILS_HLP_REQ_ADD " + "ff:ff:ff:ff:ff:ff " + binascii.hexlify(dhcpdisc).decode()):
|
||||||
raise Exception("FILS_HLP_REQ_ADD failed")
|
raise Exception("FILS_HLP_REQ_ADD failed")
|
||||||
dev[0].dump_monitor()
|
dev[0].dump_monitor()
|
||||||
|
@ -1304,7 +1304,7 @@ def test_fils_sk_hlp_dhcp_parsing(dev, apdev, params):
|
||||||
logger.debug("Received DHCP message from %s" % str(addr))
|
logger.debug("Received DHCP message from %s" % str(addr))
|
||||||
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
dhcpoffer = build_dhcp(req=False, dhcp_msg=DHCPOFFER, rapid_commit=False,
|
||||||
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
chaddr=dev[0].own_addr(), giaddr="127.0.0.3",
|
||||||
extra_op="\x36\x01\x30")
|
extra_op=b"\x36\x01\x30")
|
||||||
sock.sendto(dhcpoffer[2+20+8:], addr)
|
sock.sendto(dhcpoffer[2+20+8:], addr)
|
||||||
dev[0].wait_connected()
|
dev[0].wait_connected()
|
||||||
dev[0].request("DISCONNECT")
|
dev[0].request("DISCONNECT")
|
||||||
|
|
|
@ -1606,8 +1606,8 @@ def test_gas_anqp_venue_url(dev, apdev):
|
||||||
venue2 = struct.pack('B', len(lang2 + name2)) + lang2.encode() + name2.encode()
|
venue2 = struct.pack('B', len(lang2 + name2)) + lang2.encode() + name2.encode()
|
||||||
venue_name = binascii.hexlify(venue_info + venue1 + venue2).decode()
|
venue_name = binascii.hexlify(venue_info + venue1 + venue2).decode()
|
||||||
|
|
||||||
url1 = "http://example.com/venue"
|
url1 = b"http://example.com/venue"
|
||||||
url2 = "https://example.org/venue-info/"
|
url2 = b"https://example.org/venue-info/"
|
||||||
duple1 = struct.pack('BB', 1 + len(url1), 1) + url1
|
duple1 = struct.pack('BB', 1 + len(url1), 1) + url1
|
||||||
duple2 = struct.pack('BB', 1 + len(url2), 2) + url2
|
duple2 = struct.pack('BB', 1 + len(url2), 2) + url2
|
||||||
venue_url = binascii.hexlify(duple1 + duple2).decode()
|
venue_url = binascii.hexlify(duple1 + duple2).decode()
|
||||||
|
|
|
@ -34,7 +34,7 @@ def _test_kernel_bss_leak(dev, apdev, deauth):
|
||||||
'sa': pkt['da'],
|
'sa': pkt['da'],
|
||||||
'da': pkt['sa'],
|
'da': pkt['sa'],
|
||||||
'bssid': pkt['bssid'],
|
'bssid': pkt['bssid'],
|
||||||
'payload': '\x01\x00',
|
'payload': b'\x01\x00',
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -411,7 +411,7 @@ def test_p2p_msg_invitation_req(dev, apdev):
|
||||||
# Invalid Device Name header length in Device Info attribute
|
# Invalid Device Name header length in Device Info attribute
|
||||||
dialog_token += 1
|
dialog_token += 1
|
||||||
msg = p2p_hdr(dst, src, type=P2P_INVITATION_REQ, dialog_token=dialog_token)
|
msg = p2p_hdr(dst, src, type=P2P_INVITATION_REQ, dialog_token=dialog_token)
|
||||||
devname = 'A'
|
devname = b'A'
|
||||||
attrs = struct.pack("<BH6BH8BB8B4B", P2P_ATTR_DEVICE_INFO, 6 + 2 + 8 + 1 + 8 + 4 + len(devname),
|
attrs = struct.pack("<BH6BH8BB8B4B", P2P_ATTR_DEVICE_INFO, 6 + 2 + 8 + 1 + 8 + 4 + len(devname),
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
0,
|
0,
|
||||||
|
@ -433,7 +433,7 @@ def test_p2p_msg_invitation_req(dev, apdev):
|
||||||
1, 2, 3, 4, 5, 6, 7, 8,
|
1, 2, 3, 4, 5, 6, 7, 8,
|
||||||
0x10, 0x11, 0, 4,
|
0x10, 0x11, 0, 4,
|
||||||
64, 9, 0, 64)
|
64, 9, 0, 64)
|
||||||
devname = '123456789012345678901234567890123'
|
devname = b'123456789012345678901234567890123'
|
||||||
attrs += struct.pack("<BH6BH8BB8B4B", P2P_ATTR_DEVICE_INFO, 6 + 2 + 8 + 1 + 8 + 4 + len(devname),
|
attrs += struct.pack("<BH6BH8BB8B4B", P2P_ATTR_DEVICE_INFO, 6 + 2 + 8 + 1 + 8 + 4 + len(devname),
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
0,
|
0,
|
||||||
|
@ -475,7 +475,7 @@ def test_p2p_msg_invitation_req(dev, apdev):
|
||||||
# Too long P2P Group ID attribute
|
# Too long P2P Group ID attribute
|
||||||
dialog_token += 1
|
dialog_token += 1
|
||||||
msg = p2p_hdr(dst, src, type=P2P_INVITATION_REQ, dialog_token=dialog_token)
|
msg = p2p_hdr(dst, src, type=P2P_INVITATION_REQ, dialog_token=dialog_token)
|
||||||
attrs = struct.pack("<BH6B", P2P_ATTR_GROUP_ID, 6 + 33, 0, 0, 0, 0, 0, 0) + "123456789012345678901234567890123"
|
attrs = struct.pack("<BH6B", P2P_ATTR_GROUP_ID, 6 + 33, 0, 0, 0, 0, 0, 0) + b"123456789012345678901234567890123"
|
||||||
msg['payload'] += ie_p2p(attrs)
|
msg['payload'] += ie_p2p(attrs)
|
||||||
hapd.mgmt_tx(msg)
|
hapd.mgmt_tx(msg)
|
||||||
|
|
||||||
|
@ -1155,7 +1155,7 @@ def test_p2p_msg_pd_req(dev, apdev):
|
||||||
# No attributes
|
# No attributes
|
||||||
dialog_token += 1
|
dialog_token += 1
|
||||||
msg = p2p_hdr(dst, src, type=P2P_PROV_DISC_REQ, dialog_token=dialog_token)
|
msg = p2p_hdr(dst, src, type=P2P_PROV_DISC_REQ, dialog_token=dialog_token)
|
||||||
attrs = ""
|
attrs = b''
|
||||||
msg['payload'] += ie_p2p(attrs)
|
msg['payload'] += ie_p2p(attrs)
|
||||||
hapd.mgmt_tx(msg)
|
hapd.mgmt_tx(msg)
|
||||||
if hapd.mgmt_rx(timeout=1) is None:
|
if hapd.mgmt_rx(timeout=1) is None:
|
||||||
|
|
|
@ -706,7 +706,7 @@ def test_wnm_bss_tm_req(dev, apdev):
|
||||||
# Preferred Candidate List followed by vendor element
|
# Preferred Candidate List followed by vendor element
|
||||||
req = bss_tm_req(addr, apdev[0]['bssid'],
|
req = bss_tm_req(addr, apdev[0]['bssid'],
|
||||||
req_mode=0x01, dialog_token=8)
|
req_mode=0x01, dialog_token=8)
|
||||||
subelems = ""
|
subelems = b''
|
||||||
req['payload'] += struct.pack("<BB6BLBBB", 52, 13 + len(subelems),
|
req['payload'] += struct.pack("<BB6BLBBB", 52, 13 + len(subelems),
|
||||||
1, 2, 3, 4, 5, 6,
|
1, 2, 3, 4, 5, 6,
|
||||||
0, 81, 1, 7) + subelems
|
0, 81, 1, 7) + subelems
|
||||||
|
|
|
@ -1981,7 +1981,7 @@ def test_mesh_missing_mic(dev, apdev):
|
||||||
(categ, action) = struct.unpack('BB', payload[0:2])
|
(categ, action) = struct.unpack('BB', payload[0:2])
|
||||||
if categ == 15 and action == 1 and remove_mic:
|
if categ == 15 and action == 1 and remove_mic:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x8c\x10')
|
pos = frame.find(b'\x8c\x10')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find MIC element")
|
raise Exception("Could not find MIC element")
|
||||||
logger.info("Found MIC at %d" % pos)
|
logger.info("Found MIC at %d" % pos)
|
||||||
|
@ -2049,13 +2049,13 @@ def test_mesh_pmkid_mismatch(dev, apdev):
|
||||||
(categ, action) = struct.unpack('BB', payload[0:2])
|
(categ, action) = struct.unpack('BB', payload[0:2])
|
||||||
if categ == 15 and action == 1 and break_pmkid:
|
if categ == 15 and action == 1 and break_pmkid:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x75\x14')
|
pos = frame.find(b'\x75\x14')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find Mesh Peering Management element")
|
raise Exception("Could not find Mesh Peering Management element")
|
||||||
logger.info("Found Mesh Peering Management element at %d" % pos)
|
logger.info("Found Mesh Peering Management element at %d" % pos)
|
||||||
# Break PMKID to hit "Mesh RSN: Invalid PMKID (Chosen PMK did
|
# Break PMKID to hit "Mesh RSN: Invalid PMKID (Chosen PMK did
|
||||||
# not match calculated PMKID)"
|
# not match calculated PMKID)"
|
||||||
rx_msg['frame'] = frame[0:pos + 6] + '\x00\x00\x00\x00' + frame[pos + 10:]
|
rx_msg['frame'] = frame[0:pos + 6] + b'\x00\x00\x00\x00' + frame[pos + 10:]
|
||||||
break_pmkid = False
|
break_pmkid = False
|
||||||
if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
|
if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
|
||||||
raise Exception("MGMT_RX_PROCESS failed")
|
raise Exception("MGMT_RX_PROCESS failed")
|
||||||
|
@ -2089,7 +2089,7 @@ def test_mesh_peering_proto(dev, apdev):
|
||||||
(categ, action) = struct.unpack('BB', payload[0:2])
|
(categ, action) = struct.unpack('BB', payload[0:2])
|
||||||
if categ == 15 and action == 1 and test == 1:
|
if categ == 15 and action == 1 and test == 1:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x75\x04')
|
pos = frame.find(b'\x75\x04')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find Mesh Peering Management element")
|
raise Exception("Could not find Mesh Peering Management element")
|
||||||
logger.info("Found Mesh Peering Management element at %d" % pos)
|
logger.info("Found Mesh Peering Management element at %d" % pos)
|
||||||
|
@ -2099,7 +2099,7 @@ def test_mesh_peering_proto(dev, apdev):
|
||||||
test += 1
|
test += 1
|
||||||
elif categ == 15 and action == 1 and test == 2:
|
elif categ == 15 and action == 1 and test == 2:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x72\x0e')
|
pos = frame.find(b'\x72\x0e')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find Mesh ID element")
|
raise Exception("Could not find Mesh ID element")
|
||||||
logger.info("Found Mesh ID element at %d" % pos)
|
logger.info("Found Mesh ID element at %d" % pos)
|
||||||
|
@ -2109,13 +2109,13 @@ def test_mesh_peering_proto(dev, apdev):
|
||||||
test += 1
|
test += 1
|
||||||
elif categ == 15 and action == 1 and test == 3:
|
elif categ == 15 and action == 1 and test == 3:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x72\x0e')
|
pos = frame.find(b'\x72\x0e')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find Mesh ID element")
|
raise Exception("Could not find Mesh ID element")
|
||||||
logger.info("Found Mesh ID element at %d" % pos)
|
logger.info("Found Mesh ID element at %d" % pos)
|
||||||
# Replace Mesh ID to hit "MPM: Mesh ID or Mesh Configuration
|
# Replace Mesh ID to hit "MPM: Mesh ID or Mesh Configuration
|
||||||
# element do not match local MBSS"
|
# element do not match local MBSS"
|
||||||
rx_msg['frame'] = frame[0:pos] + '\x72\x0etest-test-test' + frame[pos + 16:]
|
rx_msg['frame'] = frame[0:pos] + b'\x72\x0etest-test-test' + frame[pos + 16:]
|
||||||
test += 1
|
test += 1
|
||||||
elif categ == 15 and action == 1 and test == 4:
|
elif categ == 15 and action == 1 and test == 4:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
|
@ -2131,14 +2131,14 @@ def test_mesh_peering_proto(dev, apdev):
|
||||||
test += 1
|
test += 1
|
||||||
elif categ == 15 and action == 1 and test == 6:
|
elif categ == 15 and action == 1 and test == 6:
|
||||||
# Mesh Peering Open
|
# Mesh Peering Open
|
||||||
pos = frame.find('\x75\x04')
|
pos = frame.find(b'\x75\x04')
|
||||||
if not pos:
|
if not pos:
|
||||||
raise Exception("Could not find Mesh Peering Management element")
|
raise Exception("Could not find Mesh Peering Management element")
|
||||||
logger.info("Found Mesh Peering Management element at %d" % pos)
|
logger.info("Found Mesh Peering Management element at %d" % pos)
|
||||||
# Truncate the element to hit
|
# Truncate the element to hit
|
||||||
# "MPM: Invalid peer mgmt ie" and
|
# "MPM: Invalid peer mgmt ie" and
|
||||||
# "MPM: Mesh parsing rejected frame"
|
# "MPM: Mesh parsing rejected frame"
|
||||||
rx_msg['frame'] = frame[0:pos] + '\x75\x00\x00\x00' + frame[pos + 6:]
|
rx_msg['frame'] = frame[0:pos] + b'\x75\x00\x00\x00' + frame[pos + 6:]
|
||||||
test += 1
|
test += 1
|
||||||
if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
|
if "OK" not in dev[0].request("MGMT_RX_PROCESS freq={} datarate={} ssi_signal={} frame={}".format(rx_msg['freq'], rx_msg['datarate'], rx_msg['ssi_signal'], rx_msg['frame'].encode('hex'))):
|
||||||
raise Exception("MGMT_RX_PROCESS failed")
|
raise Exception("MGMT_RX_PROCESS failed")
|
||||||
|
|
|
@ -171,7 +171,7 @@ def test_tspec_protocol(dev, apdev):
|
||||||
hapd.mgmt_tx(msg)
|
hapd.mgmt_tx(msg)
|
||||||
|
|
||||||
# too short WMM element
|
# too short WMM element
|
||||||
msg['payload'] = struct.pack('BBBB', 17, 1, dialog, 0) + payload[4:] + '\xdd\x06\x00\x50\xf2\x02\x02\x01'
|
msg['payload'] = struct.pack('BBBB', 17, 1, dialog, 0) + payload[4:] + b'\xdd\x06\x00\x50\xf2\x02\x02\x01'
|
||||||
hapd.mgmt_tx(msg)
|
hapd.mgmt_tx(msg)
|
||||||
|
|
||||||
# DELTS
|
# DELTS
|
||||||
|
|
Loading…
Reference in a new issue