LAWS.bend source
LAWS.bend on the hub · documented module
# Laws about Camellia (camellia.bend): for every key (every key size) and# block, decryption undoes encryption and encryption undoes decryption; and# RFC 3713's Camellia-128 vector 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 ./camellia.bend as C# Camellia (RFC 3713), every key sizelaw camellia_round_trip: for k: C.LcCamelliaKey for +b: M.CmBlock {C.LcCamellia.decrypt(k, C.LcCamellia.encrypt(k, b)) == b : M.CmBlock}law camellia_round_trip_dual: for k: C.LcCamelliaKey for +b: M.CmBlock {C.LcCamellia.encrypt(k, C.LcCamellia.decrypt(k, b)) == b : M.CmBlock}# Vectors: the specification's test values and refusals, proved by# computation (gen/vectors.py)# BEGIN GENERATED by gen/vectors.py: vectors# RFC 3713, Appendix A: Camellia-128, key = plaintext =# 0123456789ABCDEFFEDCBA9876543210, ciphertext 67673138549669730857065648EABE43law camellia_rfc3713: {Result.map(&2, &2, L.LcError, C.LcCamelliaKey, M.CmBlock, k => C.LcCamellia.encrypt(k, M.CmBlock{19088743, 2309737967, 4275878552, 1985229328}), C.LcCamellia.key(B.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]))) == Done{M.CmBlock{1734816056, 1419143539, 139920982, 1223343683}} : Result<&2, &2, L.LcError, M.CmBlock>}# a Camellia key of 20 bytes is refusedlaw camellia_bad_key_length: {Result.map(&2, &2, L.LcError, C.LcCamelliaKey, Unit, k => Unit{}, C.LcCamellia.key(B.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))) == Fail{L.LcBadKeyLength{20n}} : Result<&2, &2, L.LcError, Unit>}# END GENERATED: vectors