~/bend-docscommunity

michael.bend checks

raw source on the hub · import bend-osdev-hashes@0.1.0.0/michael.bend as Michael

Michael, the message integrity code of TKIP (IEEE Std 802.11i-2004; the algorithm as A. Wool, IEEE Trans. Wireless Commun. 3(5), 2004, Fig. 1, and Huang, Seberry, Susilo and Bunder, LNCS 3823, 2005, Algorithms 2.1 and 2.2, describe it; README.md): a 64-bit tag under a 64-bit key, over 32-bit words, little-endian (the byte order those sources do not state; IEEE 802.11-2012 M.6.3's TKIP vector confirms it, while the six recalled test vectors are unverified: README.md). With the key (K0, K1) as two little-endian words, (L, R) = (K0, K1); the message is padded with the byte 0x5a and four to seven zero bytes to a multiple of four bytes; each word M_i is taken in by L = L xor M_i, (L, R) = b(L, R), where b is R ^= L <<< 17; L += R; R ^= XSWAP(L); L += R; R ^= L <<< 3; L += R; R ^= L >>> 2; L += R (XSWAP swaps the two bytes of each 16-bit half); the tag is L and R, little-endian. Michael was designed for the old hardware TKIP runs on, for a security level of only about 20 bits: it is here for TKIP.

It streams through the engine with four-byte blocks (~last = 3). As a MAC the crypto package adapts it (crypto/inst_michael.bend).

3 imports
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import ./hashes.bend as Hs

Definitions

def hs.michael.b source · line 24 · raw

@lr:0xd04c3185dce130521497bf85ab03f249/hashes.HsW2 -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW2

the block function b

def hs.michael.word source · line 36 · raw

@lr:0xd04c3185dce130521497bf85ab03f249/hashes.HsW2 -> @w:U32 -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW2

def HsMichael.compress source · line 42 · raw

@lr:0xd04c3185dce130521497bf85ab03f249/hashes.HsW2 -> @blk:List<&2, U32> -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW2

One four-byte word (any other length leaves the value unchanged)

def hs.michael.key source · line 50 · raw

@xs:List<&2, U32> -> Result<&2, &2, 0xd04c3185dce130521497bf85ab03f249/hashes.HsError, 0xd04c3185dce130521497bf85ab03f249/hashes.HsW2>

The key: eight bytes, as (K0, K1) (HsBadKeyLength otherwise)

def HsMichael.key source · line 57 · raw

@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> Result<&2, &2, 0xd04c3185dce130521497bf85ab03f249/hashes.HsError, 0xd04c3185dce130521497bf85ab03f249/hashes.HsW2>

def HsMichael.init source · line 61 · raw

@k:0xd04c3185dce130521497bf85ab03f249/hashes.HsW2 -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW2>

the state before any byte, under a key

def HsMichael.update source · line 64 · raw

@s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW2> -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW2>

def hs.michael.pad source · line 69 · raw

@cnt:U32 -> List<&2, U32>

the padding after cnt bytes of an unfinished word: 0x5a, then four to seven zeros, to a whole number of words

def HsMichael.final source · line 73 · raw

@+s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW2> -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

the tag of the bytes so far

def HsMichael.mic source · line 77 · raw

@k:0xd04c3185dce130521497bf85ab03f249/hashes.HsW2 -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets

The tag in one call