Defined in 802.11i p.48
(key, to_hash)
| 246 | |
| 247 | |
| 248 | def michael(key, to_hash): |
| 249 | """Defined in 802.11i p.48""" |
| 250 | |
| 251 | # Block size: 4 |
| 252 | nb_block, nb_extra_bytes = divmod(len(to_hash), 4) |
| 253 | # Add padding |
| 254 | data = to_hash + chb(0x5a) + b"\x00" * (7 - nb_extra_bytes) |
| 255 | |
| 256 | # Hash |
| 257 | m_l, m_r = unpack('<II', key) |
| 258 | for i in range(nb_block + 2): |
| 259 | # Convert i-th block to int |
| 260 | block_i = unpack('<I', data[i * 4:i * 4 + 4])[0] |
| 261 | m_l ^= block_i |
| 262 | m_l, m_r = _michael_b(m_l, m_r) |
| 263 | return pack('<II', m_l, m_r) |
| 264 | |
| 265 | # TKIP packet utils |
| 266 |
no test coverage detected