def ccm.xcrypt

bend-osdev-cipher-modes@0.1.0.0 · ccm.bend:74

import bend-osdev-cipher-modes@0.1.0.0/ccm.bend as Ccm
import Base
import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M

74# CTR from counter 1: the whole blocks, then the tail xor the next S_i
75def ccm.xcrypt(~K: Data, ~enc: K -> M.CmBlock -> M.CmBlock, +k: K, +a0: M.CmBlock, s: M.CmSplit) -> List<&2, U32>:
76  match s:
77    case M.CmSplit{+bs, tail}:
78      M.cm.join_onto(ccm.ctrb(~K, ~enc, k, bs, a0, 1), M.cm.xor_bytes(tail, M.cm.bytes_of(enc(k, ccm.ai(a0, U32.add(1, U32.from_nat(List.length(&2, M.CmBlock, bs))))))))

Uses (12)

Used by (13)