Commit c2188c1
committed
proofs: added AutoCorrode/C proofs of a subset of poly.c functionality
AutoCorrode is a separation logic framework developed by AWS for use in the
verification of the Nitro Isolation Engine. Originally targetting Rust, a new
frontend for C11 has recently been added using an established Isabelle library,
Isabelle/C, for parsing. C code can be embedded both in Isabelle theory files
for reasoning about, or code can be loaded from .c files, parsed, and processed
into Isabelle definitions automatically (post preprocessing with cpp).
The C frontend is still a work-in-progress, but has sufficiently advanced enough
that material from the poly.c file from mlkem-native can now be verified using
an abstract specification and weakest-precondition style reasoning.
In this initial commit:
We define a pipeline which takes MLKEM .c and .h files and autogenerates
AutoCorrode/C definitions. Setting this up correctly requires some care: C11
files must first be preprocessed using the C preprocessor, the relevant
definitions and supporting types that we are interested in verifying must be
filtered out from the resulting generated code, and any feature that we cannot
support (e.g. __darwin_builtin types, when running on an Apple machine) must be
filtered out. To do this we use a series of "manifest" files which identify the
functions we are interested in working with, which is processed by dedicated
Python script files and the `micro_c_translate` command in Isabelle.
Using the pipeline above, we extract all of the functions and supporting types
from `poly.{c, h}` and the supporting `verify.{c, h}` file, specify them, and
verify them with respect to a series of pre/postcondition specifications
using Weakest Precondition-style reasoning. To do this, we define a machine
"locale" or "interface" setting up the memory model of the AutoCorrode/C
library. This presents a bit of a chicken-and-egg situation, as the
AutoCorrode/C memory model requires knowledge of any types that will be mutated,
however translated C functions must be defined within the scope of the machine
model in order to constrain the types of memory addresses and memory values.
As a result of this, extraction of C code proceeds in two stages, with the
first stage extracting types alone, prior to the definition of the machine and
used to define it, which is then used further when extracting C functions.
The machine model is instantiated with a concrete model, demonstrating that the
axioms describing the machine are consistent, and opening the door to execute
the translated C code via Isabelle's code-generation mechanism for conformance
testing.
Note that the more complex functions in this changeset are still a
work-in-progress, including the NTT.
Signed-off-by: Dominic Mulligan <dominic.p.mulligan@gmail.com>1 parent 152b23e commit c2188c1
26 files changed
Lines changed: 4374 additions & 1 deletion
File tree
- .github/workflows
- proofs
- isabelle
- generated
- pipeline
- config
- templates
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
54 | 62 | | |
55 | 63 | | |
56 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Submodule AutoCorrode added at b80b3ac
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
0 commit comments