~/bend-docscommunity

LAWS_padded.bend open laws/TODOs

raw source on the hub · import bend-osdev-cbc@0.1.0.0/LAWS_padded.bend as LAWS_padded

CBC with PKCS #7 padding (cbc.bend's encrypt_padded and decrypt_padded): decryption undoes encryption for every message, of any length. The law rests on LAWS.bend's cbc_round_trip and bend-osdev-pkcs7's laws, so it is in a pair of its own (CONVENTIONS.md, Laws): a proof that uses only the block and byte round trips takes in none of pkcs7's proofs.

4 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 ./cbc.bend as C

Laws

law cbc_padded_round_trip provedin PROOF_padded.bendsource · line 14 · raw

@-K:Data -> @-enc:(@_:K -> @_:0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock -> 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock) -> @-dec:(@_:K -> @_:0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock -> 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock) -> @+k:K -> @inv:(@xs:List<&2, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock> -> {0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock.dec_enc(K, enc, dec, k, xs) == xs : List<&2, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmBlock>}) -> @+iv:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> @+m:0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets -> @hi:{0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets.len(iv) == 16n : Nat} -> {Result.bind(&2, &2, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmError, 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets, 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets, 0x4ff94cd9a03eee1d38142effbcc617fb/cbc.Cbc.encrypt_padded(K, enc, k, iv, m), c => 0x4ff94cd9a03eee1d38142effbcc617fb/cbc.Cbc.decrypt_padded(K, dec, k, iv, c)) == Done{m} : Result<&2, &2, 0x999adc34209a88c2495b3a5407a5ad25/mode_core.CmError, 0xe0217e1ab38629fddf738452c1f2a82e/bytes.Octets>}

for every cipher and key with inv (as LAWS.bend's laws take it), every 16-byte IV and every message: encryption succeeds and decryption gives the message back