LAWS.bend open laws/TODOs
raw source on the hub · import bend-osdev-cast5@0.1.0.0/LAWS.bend as LAWS
Laws about CAST-128 (cast5.bend): for every key (every key size) and block, decryption undoes encryption and encryption undoes decryption; and RFC 2144 B.1's 128-bit vector and a refused key, proved by computation.
4 imports
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 ./cast5.bend as C5
Laws
law cast5_round_trip provedin PROOF.bendsource · line 11 · raw
@k:0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5Key -> @+b:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64 -> {0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.decrypt(k, 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.encrypt(k, b)) == b : 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64}
law cast5_round_trip_dual provedin PROOF.bendsource · line 16 · raw
@k:0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5Key -> @+b:0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64 -> {0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.encrypt(k, 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.decrypt(k, b)) == b : 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64}
law cast5_rfc2144 provedin PROOF.bendsource · line 28 · raw
{Result.map(&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5Key, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64, k => 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.encrypt(k, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64{19088743, 2309737967}), 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.key(0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets.of_list([1, 35, 69, 103, 18, 52, 86, 120, 35, 69, 103, 137, 52, 86, 120, 154]))) == Done{0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64{596332517, 2222867634}} : Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBlock64>}BEGIN GENERATED by gen/vectors.py: vectors RFC 2144, Appendix B.1: CAST-128 with the 128-bit key 0123456712345678234567893456789A, plaintext 0123456789ABCDEF, ciphertext 238B4FE5847E44B2
law cast5_bad_key_length provedin PROOF.bendsource · line 32 · raw
{Result.map(&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5Key, Unit, k => Unit{}, 0x09727f2e3edd91028d60228469c8929b/cast5.LcCast5.key(0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets.of_list([0, 0, 0, 0]))) == Fail{0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBadKeyLength{4n}} : Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, Unit>}a CAST-128 key of 4 bytes is refused (40 bits at least)