SymEnc.lean
Declarations on this page (11)
Symmetric Encryption Equational Theory
DyLean term algebra and attacker deduction rules for AES-256-CBC with PKCS#7 padding (symEnc and symDec).
namespace DY.SymEncclass CanSymEnc
public
class CanSymEnc (Bytes: Type u) where
symEnc: (key: Bytes) → (iv: Bytes) → (msg: Bytes) → Bytes
symDec: (key: Bytes) → (iv: Bytes) → (ct: Bytes) → Err Bytesstructure SubF
public
structure SubF (Bytes: Type) where
key: Bytes
iv: Bytes
msg: Bytes
def SubF.
PKCS#7 padded ciphertext length 16 * (|msg| / 16 + 1).
end Enc#combine
#combine into BytesFunctor, BytesLength from
Enc,variable [BytesFunctor] [BytesFunctor.Has SubF]
abbrev Enc.
public
abbrev Enc.SubF.pack (x: Enc.SubF Bytes) := BytesView.pack xinstance
def symEnc.
@[expose] public
def symEnc.attackerKnowledge: SubAttackerKnowledge SubF where
pred p out := ∃ key iv msg, out = symEnc key iv msg ∧ p key ∧ p iv ∧ p msg
def symDec.
@[expose] public
def symDec.attackerKnowledge: SubAttackerKnowledge SubF where
pred p out := ∃ key iv ct, some out = symDec key iv ct ∧ p key ∧ p iv ∧ p ct#combine
#combine [BytesFunctor.Has SubF] into attackerKnowledge' from
symEnc,
symDec,end DY.SymEnc