def HsMd.md_pad

bend-osdev-hashes@0.1.0.0 · hashes.bend:180

import bend-osdev-hashes@0.1.0.0/hashes.bend as Hashes
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B

180# The Merkle-Damgard padding after cnt bytes of an unfinished block: the
181# byte 0x80, zeros, then the length field, so that the whole is a number of
182# blocks (the block size last + 1 a power of two)
183def HsMd.md_pad(~last: U32, +cnt: U32, +field: List<&2, U32>) -> List<&2, U32>:
184  +k = U32.and(U32.sub(U32.sub(last, U32.from_nat(B.len(field))), cnt), last)
185  Con{128, B.append(B.zeros(U32.to_nat(k)), field)}

Uses (9)

Used by (6)