LibsignalHmac.lean
SHA-256 Compression Hook and Chaining-State Layout
Trusted: definitions used by the statement. Memory layout of sha2's 8-word little-endian SHA-256 chaining state (shaStateBytes, readShaState) and the extern hook compress256Hook modeling sha2::sha256::compress256(state: &mut [u32; 8], blocks: &[[u8; 64]]) over an abstract compression function F : ShaState → List (BitVec 8) → ShaState. See Computational/.
@[expose] public sectionnamespace CryptoVerificationnamespace LibsignalHmacopen Arm64 ProofLib CryptoGames CryptoGames.HMACopen CryptoVerification.LibsignalAesCbc (returnToLinkRegister toLEBytes)def shaStateBytes
The 32 bytes of a chaining state as stored by sha2 ([u32; 8], native LE words).
def readShaState
The chaining state stored at a: 8 LE 32-bit words.
def compress256Hook
sha2::sha256::compress256(state = x0, blocks.: with st the 8 LE words at x0 and bs the x2 · 64 bytes at x1, mem[x0 .. x0+32] := shaStateBytes ((chunks64 bs).foldl F st) (all inputs read before writing); pc := lr.
def compress256Hook (F : ShaState → List (BitVec 8) → ShaState) (s : State) : State :=
let st := readShaState s.mem (s.readReg64 .x0)
let bs := s.mem.readBytes (s.readReg64 .x1) (64 * (s.readReg64 .x2).toNat)
returnToLinkRegister (s.setMem (s.mem.writeBytes (s.readReg64 .x0) (shaStateBytes ((chunks64 bs).foldl F st))))end LibsignalHmacend CryptoVerification