Debian Codegraph @

crt/s2n/tests/cbmc/README.md

raw symbols SCIP
1 CBMC Proof Infrastructure
2 =========================
3
4 This directory contains automated proofs of the memory safety of various parts
5 of the s2n codebase. A continuous integration system validates every
6 pull request posted to the repository against these proofs, and developers can
7 also run the proofs on their local machines.
8
9 The proofs are checked using the
10 [C Bounded Model Checker](http://www.cprover.org/cbmc/), an open-source static
11 analysis tool
12 ([GitHub repository](https://github.com/diffblue/cbmc)). This README describes
13 how to run the proofs on your local clone of s2n.
14
15
16 Prerequisites
17 -------------
18
19 You will need Python 3.
20 On macOS and Linux, you will need Make, plus the CBMC build tools.
21
22
23 Installing CBMC
24 ---------------
25
26 - Clone the [CBMC repository](https://github.com/diffblue/cbmc).
27
28 - The canonical compilation and installation instructions are in the
29 [COMPILING.md](https://github.com/diffblue/cbmc/blob/develop/COMPILING.md)
30 file in the CBMC repository
31
32 - Ensure that you can run the programs `cbmc`, `goto-cc`, and `goto-instrument` from the command line.
33 If you build CBMC with CMake, the programs will have been installed under the
34 `build/bin/Debug` or `build/bin/Release` directories under the top-level `cbmc` directory; you
35 should add that directory to your `$PATH`.
36 If you built CBMC using Make, then those programs will have been installed in the `src/cbmc`, `src/goto-cc`, and `src/goto-instrument` directories respectively.
37
38 - Install [Litani](https://github.com/awslabs/aws-build-accumulator).
39
40 - Install [cbmc-viewer](https://github.com/model-checking/cbmc-viewer/releases).
41
42 Running the proofs
43 ------------------
44
45 Each of the leaf directories under `proofs` is a proof of the memory safety of a single entry point.
46 To run a proof, change into the directory for that proof and run `make` on Linux or macOS.
47 The proofs may take some time to run; they eventually write their output to `cbmc.txt`, which should have the text `VERIFICATION SUCCESSFUL` at the end.
48
49
50 Proof directory structure
51 -------------------------
52
53 This directory contains the following subdirectories:
54
55 - `proofs` contains the proofs run against each pull request
56 - `include` contains the `.h` files needed by proofs
57 - `source` contains functions useful in multiple CBMC proofs
58 - `stubs` contains stubs for functions which are modelled by CBMC
59
60 OpenSSL Stubs
61 -------------
62
63 To reduce verification complexity, CBMC uses an abstract representation of the OpenSSL, which covers its essential behavior with additional checks.
64 Our stubs remove all the verification-irrelevant code from OpenSSL while adding function contracts (i.e., pre- and post-conditions) to all OpenSSL function calls.
65 The purpose of the verification is to check whether a given program uses correctly OpenSSL without hitting a bogus state.
66 We had to do a similar thing when verifying the [AWS Encryption SDK for C](https://github.com/aws/aws-encryption-sdk-c/tree/master/.cbmc-batch/include/openssl).
67 All OpenSSL stubs are under `include\openssl` and `source\openssl`.