Skip to content

Commit

Permalink
Move cbmc -> proofs/cbmc
Browse files Browse the repository at this point in the history
This paves the way for the integration of the hol-light/s2n-bignum
proofs in proofs/hol-light.

Signed-off-by: Hanno Becker <[email protected]>
  • Loading branch information
hanno-becker committed Jan 15, 2025
1 parent 8383b16 commit 78f99af
Show file tree
Hide file tree
Showing 291 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ through suitable barriers and constant-time patterns.
We use the [C Bounded Model Checker (CBMC)](https://github.com/diffblue/cbmc) to prove absence of various classes of
undefined behaviour in C, including out of bounds memory accesses and integer overflows. The proofs cover
all C code in [mlkem/*](mlkem) and [mlkem/fips202/*](mlkem/fips202) involved in running mlkem-native with its C backend.
See [cbmc](cbmc) for details.
See [proofs/cbmc](proofs/cbmc) for details.

Experiments are underway to verify assembly using the [HOL-Light](https://hol-light.github.io/) theorem prover
and the [s2n-bignum](https://github.com/awslabs/s2n-bignum) infrastructure (e.g. see
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cbmc/Makefile.common → proofs/cbmc/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ PROOF_STUB = $(CBMC_ROOT)/stubs
# selectively enable access to such symbols via each proof's Makefile.
EXPORT_FILE_LOCAL_SYMBOLS =

SRCDIR ?= $(abspath $(PROOF_ROOT)/..)
SRCDIR ?= $(abspath $(PROOF_ROOT)/../../)
LITANI ?= litani
PROJECT_NAME = "mlkem-native"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions cbmc/proof_guide.md → proofs/cbmc/proof_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ context described by the annotations; if the annotations add further constraints
function contract annotation provides contextual assumptions about a function as _preconditions_ to CBMC, and adds
further _constraints_ for the program state at function return.

In mlkem-native, we use abbreviated forms of the CBMC annotations defined by macros in the [cbmc.h](../mlkem/cbmc.h). We
In mlkem-native, we use abbreviated forms of the CBMC annotations defined by macros in the [cbmc.h](../../mlkem/cbmc.h). We
now list the most prominent.

### Function contracts
Expand Down Expand Up @@ -383,7 +383,7 @@ Proof of a single function can be run from the proof directory for that function
This produces `logs/result.txt` in plaintext format.
Before pushing a new proof for a new function, make sure that _all_ proofs run OK from the [cbmc](./) directory with
Before pushing a new proof for a new function, make sure that _all_ proofs run OK from the [proofs/cbmc](./) directory with
```
MLKEM_K=3 ./run-cbmc-proofs.py --summarize -j$(nproc)
Expand All @@ -407,7 +407,7 @@ This section follows the recipe above, and adds actual settings, contracts and c
### Populate a proof directory
The proof directory is [cbmc/poly_tobytes](poly_tobytes).
The proof directory is [proofs/cbmc/poly_tobytes](poly_tobytes).
### Update Makefile
Expand Down Expand Up @@ -452,7 +452,7 @@ So we need to write a requires contract to constrain the ranges of the coefficie
is no constraint on the output byte array, other than it must be the right length, which is given by the function
prototype.
We can use the macros in [mlkem/cbmc.h](../mlkem/cbmc.h) to help, thus:
We can use the macros in [mlkem/cbmc.h](../../mlkem/cbmc.h) to help, thus:
```
void poly_tobytes(uint8_t r[MLKEM_POLYBYTES], const poly *a)
Expand All @@ -464,7 +464,7 @@ __contract__(
`array_bound` is a macro that expands to a quantified expression that expresses that the elemtns of `a->coeffs` between
index values `0` (inclusive) and `MLKEM_N` (exclusive) are in the range `0` through `(MLKEM_Q - 1)` (both
inclusive). See the macro definition in [mlkem/cbmc.h](../mlkem/cbmc.h) for details.
inclusive). See the macro definition in [mlkem/cbmc.h](../../mlkem/cbmc.h) for details.
### Interior contracts and loop invariants
Expand Down Expand Up @@ -515,7 +515,7 @@ and so on for the other two statements in the loop body.
With those changes, CBMC completes the proof in about 10 seconds:
```
cd cbmc/poly_tobytes
cd proofs/cbmc/poly_tobytes
make result
cat logs/result.txt
```
Expand All @@ -528,7 +528,7 @@ VERIFICATION SUCCESSFUL
We can also use the higher-level Python script to prove just that one function:
```
cd cbmc
cd proofs/cbmc
MLKEM_K=3 ./run-cbmc-proofs.py --summarize -j$(nproc) -p poly_tobytes
```
yields
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ check-spdx()
success=false
fi
done
for file in $(git ls-files -- "*.[chsS]" "*.py" ":/!cbmc/*.py" ":/!examples/bring_your_own_fips202/fips202/tiny_sha3/*" ":/!examples/custom_backend/mlkem_native/mlkem/fips202/native/custom/src/*"); do
for file in $(git ls-files -- "*.[chsS]" "*.py" ":/!proofs/cbmc/*.py" ":/!examples/bring_your_own_fips202/fips202/tiny_sha3/*" ":/!examples/custom_backend/mlkem_native/mlkem/fips202/native/custom/src/*"); do
# Ignore symlinks
if [[ ! -L $file && $(grep "Copyright (c) 2024 The mlkem-native project authors" $file | wc -l) == 0 ]]; then
echo "::error file=$file,line=${line:-1},title=Missing copyright header error::$file is missing copyright header"
Expand Down
2 changes: 1 addition & 1 deletion scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ class Tests:
"--no-coverage",
]
+ self.make_j(),
cwd="cbmc",
cwd="proofs/cbmc",
env=os.environ.copy() | envvars,
)
p.communicate()
Expand Down

0 comments on commit 78f99af

Please sign in to comment.