LAWS.bend source
LAWS.bend on the hub · documented module
# Laws about ARIA (aria.bend): for every key (every key size) and block,# decryption undoes encryption and encryption undoes decryption; and RFC# 5794 A.1 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 ./aria.bend as A# ARIA (RFC 5794), every key sizelaw aria_round_trip: for k: A.LcAriaKey for +b: M.CmBlock {A.LcAria.decrypt(k, A.LcAria.encrypt(k, b)) == b : M.CmBlock}law aria_round_trip_dual: for k: A.LcAriaKey for +b: M.CmBlock {A.LcAria.encrypt(k, A.LcAria.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 5794, Appendix A.1: ARIA-128, key 000102030405060708090A0B0C0D0E0F,# plaintext 00112233445566778899AABBCCDDEEFF, ciphertext# D718FBD6AB644C739DA95F3BE6451778law aria_rfc5794: {Result.map(&2, &2, L.LcError, A.LcAriaKey, M.CmBlock, k => A.LcAria.encrypt(k, M.CmBlock{1122867, 1146447479, 2291772091, 3437096703}), A.LcAria.key(B.Octets.of_list([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]))) == Done{M.CmBlock{3608738774, 2875477107, 2645122875, 3863287672}} : Result<&2, &2, L.LcError, M.CmBlock>}# an ARIA key of 20 bytes is refusedlaw aria_bad_key_length: {Result.map(&2, &2, L.LcError, A.LcAriaKey, Unit, k => Unit{}, A.LcAria.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