import Base import bend-osdev-bytes@0.1.1.0/bytes.bend as B import bend-osdev-cipher-core@0.1.0.0/cipher_core.bend as L import bend-osdev-cipher-core@0.1.0.0/LAWS.bend as CoreL import bend-osdev-cipher-core@0.1.0.0/PROOF.bend as CoreP import ./cast5.bend as C5 import ./LAWS.bend as Laws def swap2(b: L.LcBlock64) -> {b == L.lc.swap(L.lc.swap(b)) : L.LcBlock64}: match b: case L.LcBlock64{h, l}: {==} # CAST-128: its rounds, then the exchange of the halves, undone def Laws.cast5_round_trip(k, b): match k: case C5.LcCast5Key{+rks}: %swap2(L.lc.fe.run(~C5.LcCast5Rk, ~C5.cast5.f, rks, b)) : {L.lc.fe.unrun(~C5.LcCast5Rk, ~C5.cast5.f, rks, _) == b : L.LcBlock64} Equal.sym(L.LcBlock64, b, L.lc.fe.unrun(~C5.LcCast5Rk, ~C5.cast5.f, rks, L.lc.fe.run(~C5.LcCast5Rk, ~C5.cast5.f, rks, b)), CoreL.feistel_unrun_run(~C5.LcCast5Rk, ~C5.cast5.f, rks, b)) def Laws.cast5_round_trip_dual(k, b): match k: case C5.LcCast5Key{+rks}: %CoreL.feistel_run_unrun(~C5.LcCast5Rk, ~C5.cast5.f, rks, L.lc.swap(b)) : {L.lc.swap(_) == b : L.LcBlock64} Equal.sym(L.LcBlock64, b, L.lc.swap(L.lc.swap(b)), swap2(b)) # BEGIN GENERATED by gen/vectors.py: vectors def Laws.cast5_rfc2144(): {==} def Laws.cast5_bad_key_length(): {==} # END GENERATED: vectors