77from cryptography .hazmat .primitives .ciphers import Cipher , algorithms , modes
88from cryptography .hazmat .backends import default_backend
99
10+ import scapy .modules .six as six
11+ from scapy .modules .six .moves import range
1012from scapy .compat import hex_bytes , orb
1113from scapy .packet import Raw
1214
@@ -144,7 +146,7 @@ def gen_TKIP_RC4_key(TSC, TA, TK):
144146 assert len (TSC ) == 6
145147 assert len (TA ) == 6
146148 assert len (TK ) == 16
147- assert all (isinstance (x , ( int , long ) ) for x in TSC + TA + TK )
149+ assert all (isinstance (x , six . integer_types ) for x in TSC + TA + TK )
148150
149151 # Phase 1
150152 # 802.11i p.54
@@ -158,7 +160,7 @@ def gen_TKIP_RC4_key(TSC, TA, TK):
158160 TTAK .append (_MK16 (TA [5 ], TA [4 ]))
159161
160162 # Phase 1 - Step 2
161- for i in xrange (PHASE1_LOOP_CNT ):
163+ for i in range (PHASE1_LOOP_CNT ):
162164 j = 2 * (i & 1 )
163165 TTAK [0 ] = _CAST16 (TTAK [0 ] + _SBOX16 (TTAK [4 ] ^ _MK16 (TK [1 + j ], TK [0 + j ])))
164166 TTAK [1 ] = _CAST16 (TTAK [1 ] + _SBOX16 (TTAK [0 ] ^ _MK16 (TK [5 + j ], TK [4 + j ])))
@@ -194,7 +196,7 @@ def gen_TKIP_RC4_key(TSC, TA, TK):
194196 WEPSeed .append ((TSC [1 ] | 0x20 ) & 0x7f )
195197 WEPSeed .append (TSC [0 ])
196198 WEPSeed .append (((PPK [5 ] ^ _MK16 (TK [1 ], TK [0 ])) >> 1 ) & 0xFF )
197- for i in xrange (6 ):
199+ for i in range (6 ):
198200 WEPSeed .append (PPK [i ] & 0xFF )
199201 WEPSeed .append (PPK [i ] >> 8 )
200202
@@ -237,7 +239,7 @@ def michael(key, to_hash):
237239
238240 # Hash
239241 l , r = unpack ('<II' , key )
240- for i in xrange (nb_block + 2 ):
242+ for i in range (nb_block + 2 ):
241243 # Convert i-th block to int
242244 block_i = unpack ('<I' , data [i * 4 :i * 4 + 4 ])[0 ]
243245 l ^= block_i
0 commit comments