LibsignalAesCbc.lean
Little-endian byte encodings and the return helper (toLEBytes, returnToLinkRegister)
Trusted: definitions used by the statement. The theorems of the default library (Computational/ outside CliElfLib) use toLEBytes, blockToBytes, bytesToKey from this file; the theorems of Computational/ (CliElfLib) also use returnToLinkRegister. Read them. The theorems here are checked by Lean. See Computational/.
This file defines the little-endian conversions between BitVecs (AES blocks and keys from LibsignalBinary/) and byte lists, as AArch64 loads and stores them, together with returnToLinkRegister, the return to the caller that the binary specifications' extern hooks end with. keyToBytes and the memcpy / memset hooks, used only by proofs, are in LibsignalBinary/.
Glossary: AAPCS64 = the Arm 64-bit calling convention (arguments in x0–x7, result in x0, return address in lr); LE = little-endian.
returnToLinkRegister returns to lr and leaves every other register unchanged (the caller keeps nothing live in caller-saved registers across hook calls).
Despite the file and namespace name, nothing here specifies AES-CBC itself: the cryptographic primitives' machine code is hooked, not verified (DEV-E8).
Main definitions
-
toLEBytes: the lownbytes of aBitVec, least significant first. -
blockToBytes: the 16 LE bytes of an AESBlock. -
bytesToKey: the 256-bitAesKeywhose LE bytes are the given list. -
returnToLinkRegister: return to the caller (pc := lr).
@[expose] public sectionnamespace CryptoVerificationnamespace LibsignalAesCbcopen Arm64 ProofLib CryptoGames CryptoGames.CBCByte encodings (little-endian, as AArch64 loads and stores)
def toLEBytes
The n LE bytes of x: byte j is bits 8j .. 8j+7.
def toLEBytes (n : ℕ) {w : ℕ} (x : BitVec w) : List (BitVec 8) :=
List.ofFn fun j : Fin n => x.extractLsb' (8 * j.val) 82 declarations not shown (lines 61–66): theorems, which Lean checks, or definitions that no headline statement uses
CryptoVerification., CryptoVerification.
Extern hooks
def returnToLinkRegister
Return to the caller: pc := lr.
end LibsignalAesCbcend CryptoVerification