def cr.vm.pdf

bend-osdev-crypto@0.1.0.0 · vmac.bend:422

import bend-osdev-crypto@0.1.0.0/vmac.bend as Vmac
import Base
import bend-osdev-bytes@0.1.0.0/bytes.bend as B
import bend-osdev-word64@0.1.0.0/word64.bend as W

422# the PDF's words for a nonce of 1 to 15 bytes
423def cr.vm.pdf(~K: Data, ~Blk: Data, ~bsize: Nat, ~enc: K -> Blk -> Blk, ~blk_of: B.Octets -> Maybe<&2, Blk>, ~blk_to: Blk -> B.Octets, +k: K, +words: Nat, +nonce: List<&2, U32>) -> List<&2, W.W64>:
424  +n = B.len(nonce)
425  +last = cr.vm.at(nonce, Nat.sub(n, 1n))
426  +bit = U32.and(1, last)
427  +cleared = B.append(B.take(Nat.sub(n, 1n), nonce), [cr.vm.pdf.last(Nat.is_eq(words, 1n), last)])
428  +t = cr.vm.e(~K, ~Blk, ~enc, ~blk_of, ~blk_to, k, B.Octets.of_list(B.append(B.zeros(Nat.sub(bsize, n)), cleared)))
429  cr.vm.pdf.pick(Nat.is_eq(words, 1n), U32.is_eq(bit, 1), t, words)

Uses (19)

Used by (1)