md4.bend checks
raw source on the hub · import bend-osdev-hashes@0.1.0.0/md4.bend as Md4
MD4 (RFC 1320, R. Rivest, "The MD4 Message-Digest Algorithm", 1992): a 128-bit digest of 64-byte blocks, three rounds of sixteen steps each (the step order, shifts and constants of section 3.4, unrolled by gen/rounds.py). Little-endian words; the length in bits is padded in little-endian. MD4 is broken (collisions are found by hand): it is here to read what already uses it (NTLM, rsync's older protocols).
The hash, as the crypto package's hash interface takes it: ~Hs.HsMdState<Hs.HsW4>, ~64n, ~16n, ~HsMd4.init(), ~HsMd4.update, ~HsMd4.final, ~HsMd4.digest
3 imports
import Base import bend-osdev-bytes@0.1.0.0/bytes.bend as B import ./hashes.bend as Hs
Definitions
def hs.md4.f source · line 16 · raw
@+x:U32 -> @y:U32 -> @z:U32 -> U32
the round functions F (round 1), G (round 2) and H (round 3)
def hs.md4.g source · line 19 · raw
@+x:U32 -> @+y:U32 -> @+z:U32 -> U32
def hs.md4.h source · line 22 · raw
@x:U32 -> @y:U32 -> @z:U32 -> U32
def hs.md4.step source · line 26 · raw
@a:U32 -> @f:U32 -> @x:U32 -> @k:U32 -> @+s:Nat -> U32
one step: (a + f + X[k] + K) <<< s
def hs.md4.rounds source · line 30 · raw
@x:0xd04c3185dce130521497bf85ab03f249/hashes.HsW16 -> @cv:0xd04c3185dce130521497bf85ab03f249/hashes.HsW4 -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW4
BEGIN GENERATED by gen/rounds.py: md4
def HsMd4.iv source · line 88 · raw
0xd04c3185dce130521497bf85ab03f249/hashes.HsW4
The chaining value before any block (section 3.3)
def HsMd4.compress source · line 93 · raw
@cv:0xd04c3185dce130521497bf85ab03f249/hashes.HsW4 -> @blk:List<&2, U32> -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsW4
One 64-byte block (a list of another length is read as zero words: the engine passes only whole blocks)
def HsMd4.init source · line 96 · raw
0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW4>
def HsMd4.update source · line 99 · raw
@s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW4> -> @o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW4>
def HsMd4.final source · line 104 · raw
@s:0xd04c3185dce130521497bf85ab03f249/hashes.HsMdState<0xd04c3185dce130521497bf85ab03f249/hashes.HsW4> -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets
the digest of the bytes so far: the padding and the length, then the four words little-endian
def HsMd4.digest source · line 108 · raw
@o:0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets -> 0x9df7f91779a4a1c215bfa96cd0864601/bytes.Octets
The digest in one call