Signed-off-by: Masashi Honma <masashi.honma@xxxxxxxxx> --- tests/hwsim/test_ap_psk.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/hwsim/test_ap_psk.py b/tests/hwsim/test_ap_psk.py index 780f18bc7..92919b7f8 100644 --- a/tests/hwsim/test_ap_psk.py +++ b/tests/hwsim/test_ap_psk.py @@ -1239,16 +1239,19 @@ def build_eapol(msg): data += msg['rsn_key_id'] data += msg['rsn_key_mic'] data += struct.pack('>H', msg['rsn_key_data_len']) - data += msg['rsn_key_data'] + if type(msg['rsn_key_data']) == bytes: + data += msg['rsn_key_data'] + else: + data += msg['rsn_key_data'].encode() else: data += msg['payload'] return data def sha1_prf(key, label, data, outlen): - res = '' + res = bytes() counter = 0 while outlen > 0: - m = hmac.new(key, label, hashlib.sha1) + m = hmac.new(key, label.encode(), hashlib.sha1) m.update(struct.pack('B', 0)) m.update(data) m.update(struct.pack('B', counter)) @@ -1307,7 +1310,7 @@ def recv_eapol(hapd): return parse_eapol(eapol) def send_eapol(hapd, addr, data): - res = hapd.request("EAPOL_RX " + addr + " " + binascii.hexlify(data)) + res = hapd.request("EAPOL_RX " + addr + " " + binascii.hexlify(data).decode()) if "OK" not in res: raise Exception("EAPOL_RX to hostapd failed") @@ -1617,24 +1620,31 @@ def build_eapol_key_3_4(anonce, kck, key_data, replay_counter=2, return msg def aes_wrap(kek, plain): - n = len(plain) / 8 + n = len(plain) // 8 a = 0xa6a6a6a6a6a6a6a6 enc = AES.new(kek).encrypt r = [plain[i * 8:(i + 1) * 8] for i in range(0, n)] for j in range(6): for i in range(1, n + 1): - b = enc(struct.pack('>Q', a) + r[i - 1]) + if type(r[i - 1]) == bytes: + value = r[i - 1] + else: + value = r[i - 1].encode() + b = enc(struct.pack('>Q', a) + value) a = struct.unpack('>Q', b[:8])[0] ^ (n * j + i) r[i - 1] =b[8:] - return struct.pack('>Q', a) + ''.join(r) + ret = bytes() + for elem in r: + ret = ret + elem + return struct.pack('>Q', a) + ret def pad_key_data(plain): pad_len = len(plain) % 8 if pad_len: pad_len = 8 - pad_len - plain += '\xdd' + plain += b'\xdd' pad_len -= 1 - plain += pad_len * '\0' + plain += pad_len * b'\x00' return plain def test_ap_wpa2_psk_supp_proto(dev, apdev): -- 2.17.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap