MCPcopy Index your code
hub / github.com/secdev/scapy / michael

Function michael

scapy/modules/krack/crypto.py:248–263  ·  view source on GitHub ↗

Defined in 802.11i p.48

(key, to_hash)

Source from the content-addressed store, hash-verified

246
247
248def 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

Callers 2

check_MIC_ICVFunction · 0.85
build_MIC_ICVFunction · 0.85

Calls 2

chbFunction · 0.90
_michael_bFunction · 0.85

Tested by

no test coverage detected