package mirage-crypto

  1. Overview
  2. Docs
Simple symmetric cryptography for the modern age

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mirage-crypto-2.2.0.tbz
sha256=4b87091b6a77843bf97a74aae2e7da21310307ff7d2105712c4369680122d80a
sha512=3361649703d0e391e5adc40770dcb4dcbee2ecd27a64962e28c7f8240a67131efe9226a5240ac7a019c1464f217abec9c71dbb8412ef2b4eafeb4ad8e3931805

Description

Mirage-crypto provides symmetric ciphers (DES, AES, RC4, ChaCha20/Poly1305).

Published: 27 Jul 2026

README

OCaml cryptographic primitives library

This repository contains a small cryptographic library that puts emphasis on the applicative style and ease of use. It includes basic ciphers (AES, 3DES, RC4, ChaCha20/Poly1305), AEAD primitives (AES-GCM, AES-CCM, ChaCha20/Poly1305), public-key primitives (RSA, DSA, DH), elliptic curves (NIST P-256, P-384, P-521, and curve 25519), and a strong RNG (Fortuna).

RSA timing attacks are countered by blinding. AES timing attacks are avoided by delegating to AES-NI.

Initially, this package was developed for MirageOS, but it is very well suitable in any OCaml application. It is a fork of the ocaml-nocrypto package developed by David Kaloper. It was forked with the permission of the original author in order to facilitate changes (e.g. build system) required by MirageOS that the upstream didn't have time to keep up with.

The following packages are provided in this repository, each installable via opam install package-name:

  • mirage-crypto - the base for symmetric ciphers (AES, 3DES, RC4, ChaCha20/Poly1305) - uses allocation-free and loop-free C code,
  • mirage-crypto-ec - elliptic curves (NIST P-256, P-384, P-521, curve 25519) - uses primitives exported from fiat-crypto,
  • mirage-crypto-pk - asymmetric cryptography (RSA, DSA, DH) - uses zarith with gmp,
  • mirage-crypto-rng - random number generators (Fortuna, HMAC-DRBG),
  • mirage-crypto-rng-mirage - seed and feed entropy for the RNG with MirageOS unikernels,
  • mirage-crypto-rng-mkernel - seed and feed entropy for the RNG with mkernel (using the miou scheduler).

On Unix, getrandom() (and getentropy()) or /dev/urandom are used for random number generation. On MirageOS, entropy harvesting and feeding uses non-deterministic execution time (whirlwind RNG), and hooks into the main event loop to get some bits of the timestamp of each event, rdrand and rdseed CPU instructions if available.

RNG seeding

If RNG fails with Fatal error: exception Unseeded_generator, you need to seed it.

let () = Mirage_crypto_rng_unix.use_default ()

LICENSE

Mostly ISC, the mirage-crypto-rng-mirage is 2 clause BSD licensed, mirage-crypto-ec is MIT licensed.

Dependencies (4)

  1. eqaf >= "0.8"
  2. dune-configurator >= "2.0.0"
  3. dune >= "2.7"
  4. ocaml >= "4.13.0"

Dev Dependencies (2)

  1. ohex with-test & >= "0.2.0"
  2. ounit2 with-test

Used by (26)

  1. albatross = "2.1.0"
  2. awa >= "0.4.0"
  3. ca-certs >= "1.0.1"
  4. ca-certs-nss >= "3.101" & < "3.104"
  5. capnp-rpc-net >= "1.2.4"
  6. dkim >= "0.8.0"
  7. dns-cli >= "9.1.0"
  8. dnssec >= "9.1.0"
  9. dream >= "1.0.0~alpha7"
  10. git-mirage >= "3.17.0"
  11. granary
  12. jose >= "0.10.0"
  13. kdf
  14. letsencrypt >= "1.0.0" & < "2.0.0"
  15. mirage-crypto-pk >= "2.2.0"
  16. mirage-crypto-rng >= "2.2.0"
  17. noise
  18. ocluster >= "0.4.0"
  19. oidc
  20. otr >= "1.0.0"
  21. passe
  22. proton
  23. spoke >= "0.0.4"
  24. tls >= "1.0.4"
  25. tls-mirage >= "1.0.4"
  26. x509 >= "1.0.6"

Conflicts (2)

  1. result < "1.5"
  2. ocaml-freestanding