mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-29 02:38:22 -05:00
tests: Use floor division (//) to avoid issues with python3
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
4d364d9ee0
commit
236bbda8e4
@ -1617,7 +1617,7 @@ def build_eapol_key_3_4(anonce, kck, key_data, replay_counter=2,
|
|||||||
return msg
|
return msg
|
||||||
|
|
||||||
def aes_wrap(kek, plain):
|
def aes_wrap(kek, plain):
|
||||||
n = len(plain) / 8
|
n = len(plain) // 8
|
||||||
a = 0xa6a6a6a6a6a6a6a6
|
a = 0xa6a6a6a6a6a6a6a6
|
||||||
enc = AES.new(kek).encrypt
|
enc = AES.new(kek).encrypt
|
||||||
r = [plain[i * 8:(i + 1) * 8] for i in range(0, n)]
|
r = [plain[i * 8:(i + 1) * 8] for i in range(0, n)]
|
||||||
|
@ -6280,7 +6280,7 @@ def wsc_kdf(key, label, bits):
|
|||||||
m = hmac.new(key, data, hashlib.sha256)
|
m = hmac.new(key, data, hashlib.sha256)
|
||||||
result += m.digest()
|
result += m.digest()
|
||||||
i += 1
|
i += 1
|
||||||
return result[0:bits / 8]
|
return result[0:bits // 8]
|
||||||
|
|
||||||
def wsc_keys(kdk):
|
def wsc_keys(kdk):
|
||||||
keys = wsc_kdf(kdk, "Wi-Fi Easy and Secure Key Derivation", 640)
|
keys = wsc_kdf(kdk, "Wi-Fi Easy and Secure Key Derivation", 640)
|
||||||
@ -6294,8 +6294,8 @@ def wsc_dev_pw_half_psk(authkey, dev_pw):
|
|||||||
return m.digest()[0:16]
|
return m.digest()[0:16]
|
||||||
|
|
||||||
def wsc_dev_pw_psk(authkey, dev_pw):
|
def wsc_dev_pw_psk(authkey, dev_pw):
|
||||||
dev_pw_1 = dev_pw[0:len(dev_pw) / 2]
|
dev_pw_1 = dev_pw[0:len(dev_pw) // 2]
|
||||||
dev_pw_2 = dev_pw[len(dev_pw) / 2:]
|
dev_pw_2 = dev_pw[len(dev_pw) // 2:]
|
||||||
psk1 = wsc_dev_pw_half_psk(authkey, dev_pw_1)
|
psk1 = wsc_dev_pw_half_psk(authkey, dev_pw_1)
|
||||||
psk2 = wsc_dev_pw_half_psk(authkey, dev_pw_2)
|
psk2 = wsc_dev_pw_half_psk(authkey, dev_pw_2)
|
||||||
return psk1,psk2
|
return psk1,psk2
|
||||||
@ -6365,7 +6365,7 @@ def wsc_dh_kdf(peer_pk, own_private, mac_addr, e_nonce, r_nonce):
|
|||||||
peer_public = int(binascii.hexlify(peer_pk), 16)
|
peer_public = int(binascii.hexlify(peer_pk), 16)
|
||||||
if peer_public < 2 or peer_public >= group_5_prime:
|
if peer_public < 2 or peer_public >= group_5_prime:
|
||||||
raise Exception("Invalid peer public key")
|
raise Exception("Invalid peer public key")
|
||||||
if pow(peer_public, (group_5_prime - 1) / 2, group_5_prime) != 1:
|
if pow(peer_public, (group_5_prime - 1) // 2, group_5_prime) != 1:
|
||||||
raise Exception("Unexpected Legendre symbol for peer public key")
|
raise Exception("Unexpected Legendre symbol for peer public key")
|
||||||
|
|
||||||
shared_secret = pow(peer_public, own_private, group_5_prime)
|
shared_secret = pow(peer_public, own_private, group_5_prime)
|
||||||
|
@ -1097,7 +1097,7 @@ def test_grpform_go_neg_dup_on_restart(dev):
|
|||||||
attrs = p2p_attr_capability(dev_capab=0x25, group_capab=0x08)
|
attrs = p2p_attr_capability(dev_capab=0x25, group_capab=0x08)
|
||||||
attrs += p2p_attr_go_intent(go_intent=7, tie_breaker=1)
|
attrs += p2p_attr_go_intent(go_intent=7, tie_breaker=1)
|
||||||
attrs += p2p_attr_config_timeout()
|
attrs += p2p_attr_config_timeout()
|
||||||
attrs += p2p_attr_listen_channel(chan=(int(peer['listen_freq']) - 2407) / 5)
|
attrs += p2p_attr_listen_channel(chan=(int(peer['listen_freq']) - 2407) // 5)
|
||||||
attrs += p2p_attr_intended_interface_addr(lower.p2p_dev_addr())
|
attrs += p2p_attr_intended_interface_addr(lower.p2p_dev_addr())
|
||||||
attrs += p2p_attr_channel_list()
|
attrs += p2p_attr_channel_list()
|
||||||
attrs += p2p_attr_device_info(addr_low, config_methods=0x80, name="Device A")
|
attrs += p2p_attr_device_info(addr_low, config_methods=0x80, name="Device A")
|
||||||
|
Loading…
Reference in New Issue
Block a user