|
| 1 | +CryptoLine |
| 2 | +========== |
| 3 | + |
| 4 | +CryptoLine is a tool and a language for the verification of low-level |
| 5 | +implementations of mathematical constructs. It has been used to verify |
| 6 | +implementations in |
| 7 | +[OpenSSL](https://www.openssl.org), |
| 8 | +[BoringSSL](https://opensource.google.com/projects/boringssl), |
| 9 | +[mbed TLS](https://tls.mbed.org), |
| 10 | +[pqm4](https://github.com/mupq/pqm4), |
| 11 | +[ntt-polymul](https://github.com/ntt-polymul/ntt-polymul), etc. |
| 12 | + |
| 13 | + |
| 14 | +Prerequisite |
| 15 | +============ |
| 16 | + |
| 17 | +To compile and run CryptoLine, the following packages need to be installed. |
| 18 | + |
| 19 | +- [OCaml compiler](https://ocaml.org) (version 4.08.1 up) |
| 20 | +- [GNU Make](https://www.gnu.org/software/make/) |
| 21 | +- OCaml packages: dune, ocamlfind, lwt, lwt_ppx, zarith |
| 22 | +- One of the following computer algebra systems: |
| 23 | + + [Singular](https://www.singular.uni-kl.de) (recommended, the default to be used) |
| 24 | + + [SageMath](http://www.sagemath.org) |
| 25 | + + [Magma](http://magma.maths.usyd.edu.au/magma/) |
| 26 | + + [Mathematica](https://www.wolfram.com/mathematica/) |
| 27 | + + [Macaulay2](https://faculty.math.illinois.edu/Macaulay2/) |
| 28 | + + [Maple](https://www.maplesoft.com) |
| 29 | +- One of the following SMT solvers: |
| 30 | + + [Boolector](https://boolector.github.io) (recommended, the default to be used) |
| 31 | + + [Z3](https://github.com/Z3Prover/z3) |
| 32 | + + [Mathsat](http://mathsat.fbk.eu) |
| 33 | + |
| 34 | +CryptoLine are successfully compiled with OCaml 4.08.1, 4.11.2, |
| 35 | + 4.12.1, 4.13.1, and 4.14.0 together with dune 3.2.0, lwt 5.5.0, |
| 36 | + lwt_ppx 2.0.3, and zarith 1.12. |
| 37 | + |
| 38 | +To run the installation script `build.sh`, `sudo` is required. |
| 39 | +On a Ubuntu machine, install `sudo` by running the following |
| 40 | +command as root: |
| 41 | + |
| 42 | +``` |
| 43 | +# apt -y install sudo |
| 44 | +``` |
| 45 | + |
| 46 | + |
| 47 | +Installation |
| 48 | +============ |
| 49 | + |
| 50 | +Follow the following instructions (or simply run the script `build.sh` |
| 51 | +in the project root) to build and install CryptoLine as well as |
| 52 | +the compute algebra system Singular and the SMT QF_BV solver Boolector |
| 53 | +on Ubuntu 20.04 LTS. |
| 54 | + |
| 55 | +``` |
| 56 | +$ sudo apt -y install \ |
| 57 | + build-essential bc ocaml ocaml-dune libzarith-ocaml-dev \ |
| 58 | + liblwt-ocaml-dev |
| 59 | +$ scripts/install-singular.sh |
| 60 | +$ scripts/install-boolector.sh |
| 61 | +$ dune build |
| 62 | +$ sudo dune install |
| 63 | +``` |
| 64 | + |
| 65 | +Run the following command to see the available command-line arguments. |
| 66 | + |
| 67 | +``` |
| 68 | +$ cv -help |
| 69 | +``` |
| 70 | + |
| 71 | +To uninstall CryptoLine, run the following command. |
| 72 | + |
| 73 | +``` |
| 74 | +$ dune uninstall |
| 75 | +``` |
| 76 | + |
| 77 | +To test the installation of CryptoLine, run the script |
| 78 | +`run_experiments` in the project root. |
| 79 | + |
| 80 | +``` |
| 81 | +$ ./run_experiments -simple |
| 82 | +``` |
| 83 | + |
| 84 | +Below is the expected output (time may vary). |
| 85 | + |
| 86 | +``` |
| 87 | +Verifying examples/qhasm/fe25519_add.cl: 0 seconds [OK] |
| 88 | +Verifying examples/qhasm/fe25519_sub.cl: 1 seconds [OK] |
| 89 | +Verifying examples/qhasm/fe25519r64_add.cl: 0 seconds [OK] |
| 90 | +Verifying examples/qhasm/fe25519r64_addsub.cl: 0 seconds [OK] |
| 91 | +Verifying examples/qhasm/fe25519r64_sub.cl: 0 seconds [OK] |
| 92 | +``` |
| 93 | + |
| 94 | + |
| 95 | +Basic Usage |
| 96 | +=========== |
| 97 | + |
| 98 | +Parse a CryptoLine specification `spec.cl`. |
| 99 | + |
| 100 | +``` |
| 101 | +$ cv -p spec.cl |
| 102 | +``` |
| 103 | + |
| 104 | +Output the SSA (Static Single Assignment) form of a CryptoLine specification |
| 105 | +`spec.cl`. |
| 106 | + |
| 107 | +``` |
| 108 | +$ cv -pssa spec.cl |
| 109 | +``` |
| 110 | + |
| 111 | +Verify a CryptoLine specification `spec.cl` with verbose outputs (`-v`), |
| 112 | +incremental checking of algebraic soundness (`-isafety`), at most 24 |
| 113 | +parallel jobs (`-jobs 24`), program slicing (`-slicing`), and without |
| 114 | +carry constraints for computer algebra systems |
| 115 | +(`-no_carry_constraint`). |
| 116 | + |
| 117 | +``` |
| 118 | +$ cv -v -isafety -jobs 24 -slicing -no_carry_constraint spec.cl |
| 119 | +``` |
| 120 | + |
| 121 | +Many examples of CryptoLine specifications can be found in `examples`. |
| 122 | + |
| 123 | + |
| 124 | +CryptoLine Language |
| 125 | +=================== |
| 126 | + |
| 127 | +Read doc/cryptoline.pdf for the details of the CryptoLine language. |
| 128 | +Examples of CryptoLine specifications are available in `examples` with |
| 129 | +`.cl` filename suffix. |
| 130 | +More examples can be found on |
| 131 | +[GitHub](https://github.com/fmlab-iis/cryptoline). |
| 132 | + |
| 133 | + |
| 134 | +Tutorial |
| 135 | +======== |
| 136 | + |
| 137 | +A tutorial of CryptoLine is available in doc/tutorial.pdf. |
| 138 | + |
| 139 | + |
| 140 | +Syntax Highlight |
| 141 | +================ |
| 142 | + |
| 143 | +Syntax highlighting in Emacs is provided by misc/cryptoLine-mode.el. |
| 144 | + |
| 145 | +```elisp |
| 146 | +; Change [PATH_TO_CRYPTOLINE] to the right location |
| 147 | +(add-to-list 'load-path "[PATH_TO_CRYPTOLINE]/misc") |
| 148 | +(autoload 'cryptoline-mode "cryptoline-mode" "Major mode for CryptoLine files." t) |
| 149 | +(add-to-list 'auto-mode-alist '("\\.cl\\'" . cryptoline-mode)) |
| 150 | +``` |
| 151 | + |
| 152 | +Syntax highlighting in Visual Studio Code is provided by the extension |
| 153 | +misc/cryptoline-vscode-extension/cryptoline-x.y.z.vsix where x.y.z is |
| 154 | +the version of the extension. |
| 155 | + |
| 156 | + |
| 157 | +Reference |
| 158 | +========= |
| 159 | + |
| 160 | +- Yu-Fu Fu, Jiaxiang Liu, Xiaomu Shi, Ming-Hsien Tsai, Bow-Yaw Wang, and Bo-Yin Yang. |
| 161 | + Signed Cryptographic Program Verification with Typed CryptoLine. |
| 162 | + In Proceedings of the 2019 ACM SIGSAC Conference on Computer and Communications Security (CCS '19). |
| 163 | + ACM, New York, NY, USA, 1591-1606. DOI: https://doi.org/10.1145/3319535.3354199 |
| 164 | +- Andy Polyakov, Ming-Hsien Tsai, Bow-Yaw Wang, Bo-Yin Yang: |
| 165 | + Verifying Arithmetic Assembly Programs in Cryptographic Primitives (Invited Talk). |
| 166 | + International Conference on Concurrency Theory (CONCUR), |
| 167 | + 4:1-4:16, LIPIcs, 2018 |
| 168 | +- Ming-Hsien Tsai, Bow-Yaw Wang, Bo-Yin Yang: |
| 169 | + Certified Verification of Algebraic Properties on Low-Level Mathematical Constructs in Cryptographic Programs. |
| 170 | + ACM SIGSAC Conference on Computer and Communications Security (CCS), |
| 171 | + pp. 1973-1987, ACM, 2017 |
| 172 | +- Yu-Fang Chen, Chang-Hong Hsu, Hsin-Hung Lin, Peter Schwabe, Ming-Hsien Tsai, Bow-Yaw Wang, Bo-Yin Yang, Shang-Yi Yang: |
| 173 | + Verifying Curve25519 Software. |
| 174 | + ACM SIGSAC Conference on Computer and Communications Security (CCS), |
| 175 | + pp. 299-309, ACM, 2014 |
0 commit comments