~/bend-docscommunity

LAWS.bend source

LAWS.bend on the hub · documented module

# Laws about CAST-256 (cast6.bend): for every key (every key size) and# block, decryption undoes encryption and encryption undoes decryption; and a# refused key, proved by computation.import Baseimport bend-osdev-bytes@0.1.1.0/bytes.bend as Bimport bend-osdev-mode-core@0.1.0.0/mode_core.bend as Mimport bend-osdev-cipher-core@0.1.0.0/cipher_core.bend as Limport ./cast6.bend as C6# CAST-256 (RFC 2612), every key sizelaw cast6_round_trip:  for k: C6.LcCast6Key  for +b: M.CmBlock  {C6.LcCast6.decrypt(k, C6.LcCast6.encrypt(k, b)) == b : M.CmBlock}law cast6_round_trip_dual:  for k: C6.LcCast6Key  for +b: M.CmBlock  {C6.LcCast6.encrypt(k, C6.LcCast6.decrypt(k, b)) == b : M.CmBlock}# A refusal, proved by computation (gen/vectors.py); RFC 2612's vectors run# in check.bend (README.md, Laws)# BEGIN GENERATED by gen/vectors.py: vectors# a CAST-256 key of 18 bytes is refusedlaw cast6_bad_key_length:  {Result.map(&2, &2, L.LcError, C6.LcCast6Key, Unit, k => Unit{}, C6.LcCast6.key(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))) == Fail{L.LcBadKeyLength{18n}} : Result<&2, &2, L.LcError, Unit>}# END GENERATED: vectors