~/bend-docscommunity

LAWS.bend open laws/TODOs

raw source on the hub · import bend-osdev-camellia@0.1.0.0/LAWS.bend as LAWS

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.

5 imports
import Base
import bend-osdev-bytes@0.1.1.0/bytes.bend as B
import bend-osdev-mode-core@0.1.0.0/mode_core.bend as M
import bend-osdev-cipher-core@0.1.0.0/cipher_core.bend as L
import ./camellia.bend as C

Laws

law camellia_round_trip provedin PROOF.bendsource · line 12 · raw

@k:0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamelliaKey -> @+b:0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock -> {0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.decrypt(k, 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.encrypt(k, b)) == b : 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock}

law camellia_round_trip_dual provedin PROOF.bendsource · line 17 · raw

@k:0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamelliaKey -> @+b:0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock -> {0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.encrypt(k, 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.decrypt(k, b)) == b : 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock}

law camellia_rfc3713 provedin PROOF.bendsource · line 28 · raw

{Result.map(&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamelliaKey, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock, k => 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.encrypt(k, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock{19088743, 2309737967, 4275878552, 1985229328}), 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.key(0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets.of_list([1, 35, 69, 103, 137, 171, 205, 239, 254, 220, 186, 152, 118, 84, 50, 16]))) == Done{0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock{1734816056, 1419143539, 139920982, 1223343683}} : Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock>}

BEGIN GENERATED by gen/vectors.py: vectors RFC 3713, Appendix A: Camellia-128, key = plaintext = 0123456789ABCDEFFEDCBA9876543210, ciphertext 67673138549669730857065648EABE43

law camellia_bad_key_length provedin PROOF.bendsource · line 32 · raw

{Result.map(&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamelliaKey, Unit, k => Unit{}, 0xda3b2fd4e59297519c52e7bd64cb55c5/camellia.LcCamellia.key(0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets.of_list([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]))) == Fail{0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcBadKeyLength{20n}} : Result<&2, &2, 0x5c26418ab13c9e565c5b1309d2f085a0/cipher_core.LcError, Unit>}

a Camellia key of 20 bytes is refused