Home

Awesome

The Cryspen HACL Packages

This repository contains ready-to-use crypto packages developed by Cryspen on top of HACL*. In particular, it contains a portable C crypto library that selects optimized implementations for each platform, as well as Rust, OCaml, and JavaScript bindings for this library.

Currently, we are in the process of adding more usable APIs, providing extensive documentation, and further optimizing the algorithms.

What is HACL* and why should you use HACL Packages?

HACL* is a collection of high-assurance cryptographic algorithms developed as part of Project Everest. It includes source code written in F*, generated C code, verified assembly code from the Vale project, and an agile multiplexed cryptographic provider called EverCrypt. As such, the full HACL* repository contains many software artifacts and a complicated build system that can be intimidating to a crypto developer who simply wishes to use verified crypto.

Quickstart

Install build dependencies

We need the following dependencies ...

Depending on your system you can install them as follows (click to expand) ...

<details> <summary><b>Arch Linux</b></summary>
$ sudo pacman -S cmake ninja python

# Either of ...
$ sudo pacman -S clang
$ sudo pacman -S gcc
</details> <details> <summary><b>Fedora</b></summary>
$ sudo dnf install cmake ninja-build python3

# Either of ...
$ sudo dnf install clang
$ sudo dnf install gcc
</details> <details> <summary><b>Ubuntu</b></summary>
$ sudo apt install cmake ninja-build python3

# Either of ...
$ sudo apt install clang
$ sudo apt install gcc
</details> <details> <summary><b>macOS</b></summary>
$ brew install cmake ninja python

# Either of ...
$ brew install llvm
$ brew install gcc
</details>

Build (and test) HACL Packages

You can run ...

$ ./mach build --test

... to build HACL Packages and run the tests. All actions are driven by mach. See ./mach --help for details.

Platform support

The HACL Packages are supported based on the following tiers.

Tier 1

Tier 1 targets are guaranteed to work. These targets have automated testing to ensure that changes do not break them.

Tier 2

Tier 2 targets are guaranteed to build. These targets have automated builds to ensure that changes do not break the builds. However, not all of them are always tested.

Tier 3

Tier 3 targets are supported by the code but there are no automated checks and there is no guarantee that they work.

Compiler support

<!-- When using the `c89` edition of HACL GCC 4.8 and up are supported. In any other case a modern C compiler is expected. -->

A modern C compiler is expected.

Algorithms

The following tables gives an overview over the algorithms supported by the HACL packages.

FamilyAlgorithmSupport
AEADAES-GCM 128AES-NI & CLMUL (x86 only)
AEADAES-GCM 256AES-NI & CLMUL (x86 only)
AEADChacha20-Poly1305Portable | vec128 | vec256
ECDHCurve25519Portable | BMI2 & ADX
ECDHP-256Portable
SignatureEd25519Portable
SignatureECDSA P-256r1Portable
SignatureECDSA P-256k1Portable
SignatureRSA-PSSPortable
HashSHA2-224Portable | SHAEXT
HashSHA2-256Portable | SHAEXT
HashSHA2-384Portable
HashSHA2-512Portable
HashSHA3Portable
HashBlake2Portable | vec128 | vec256
Key DerivationHKDFPortable (depends on hash)
Symmetric EncryptionChacha20Portable | vec128 | vec256
Symmetric EncryptionAES 128AES-NI & CLMUL (x86 only)
Symmetric EncryptionAES 256AES-NI & CLMUL (x86 only)
MACHMACPortable (depends on hash)
MACPoly1305Portable | vec128 | vec256 | x64 ASM

Testing

Testing is done with gtest and requires a C++11 compiler (or C++20 MSVC).

Measure Test Coverage

Test coverage in HACL Packages can be measured with ...

./mach build --tests --coverage
./mach test --coverage
./tools/coverage.sh

Note that only clang is supported as a compiler and you may get an error ...

cc: error: unrecognized command-line option ‘-fprofile-instr-generate’; did you mean ‘-fprofile-generate’?

... when your default compiler is not clang. In this case, try to set the CC and CXX environment variables accordingly ...

export CC=clang
export CXX=clang++

Furthermore, additional tools are required to measure (and view) test coverage.

Make sure you have lcov and genhtml.

For Ubuntu these can be installed via ...

$ sudo apt install lcov

When everything went well you should be able to view the coverage reports with, e.g., ...

firefox build/Debug/coverage/full/html/index.html

Dependencies

Tests require the nlohmann_json package to read json test files. CMake takes care of pulling and building the package.

License

HACL packages are licensed under either of

at your option.