def lrw_b.serpent

bend-osdev-crypto@0.1.0.0 · PROOF.bend:1076

import bend-osdev-crypto@0.1.0.0/PROOF.bend as PROOF
import Base
import bend-osdev-cipher-modes@0.1.0.0/cipher_modes.bend as M
import bend-osdev-legacy-ciphers@0.1.0.0/serpent.bend as Sp
import bend-osdev-legacy-ciphers@0.1.0.0/LAWS.bend as LL
import bend-osdev-crypto@0.1.0.0/lrw.bend as Lw
import bend-osdev-crypto@0.1.0.0/inst_cm.bend as CM

1076def lrw_b.serpent(+k: Sp.LcSerpentKey, t: Maybe<&2, M.CmBlock>, +p: M.CmBlock) -> {p == Lw.cr.lrw.bdec(~Sp.LcSerpentKey, ~M.CmBlock, ~Sp.LcSerpent.decrypt, ~CM.CrBlk128.xor, k, t, Lw.cr.lrw.benc(~Sp.LcSerpentKey, ~M.CmBlock, ~Sp.LcSerpent.encrypt, ~CM.CrBlk128.xor, k, t, p)) : M.CmBlock}:
1077  match t:
1078    case None{}:
1079      Equal.sym(M.CmBlock, Sp.LcSerpent.decrypt(k, Sp.LcSerpent.encrypt(k, p)), p, LL.serpent_round_trip(k, p))
1080    case Some{+x}:
1081      %cmblock_xx(Sp.LcSerpent.encrypt(k, CM.CrBlk128.xor(p, x)), x) : {p == CM.CrBlk128.xor(Sp.LcSerpent.decrypt(k, _), x) : M.CmBlock}
1082      %Equal.sym(M.CmBlock, Sp.LcSerpent.decrypt(k, Sp.LcSerpent.encrypt(k, CM.CrBlk128.xor(p, x))), CM.CrBlk128.xor(p, x), LL.serpent_round_trip(k, CM.CrBlk128.xor(p, x))) : {p == CM.CrBlk128.xor(_, x) : M.CmBlock}
1083      cmblock_xx(p, x)

Uses (11)

Used by (1)