Skip to content

Cryptographic primitives for OCaml, in OCaml (also used in MirageOS)

License

Notifications You must be signed in to change notification settings

mirage/mirage-crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Jan 31, 2025
fe7bad7 · Jan 31, 2025
Sep 18, 2023
Jan 8, 2025
Jan 8, 2025
Feb 24, 2024
Sep 18, 2023
Feb 22, 2024
Aug 20, 2024
Jun 9, 2024
Jun 11, 2024
Jan 30, 2025
Jan 30, 2025
Jan 31, 2025
Jan 8, 2025
Feb 22, 2024
Sep 18, 2023
Oct 1, 2024
Jan 30, 2025
Oct 27, 2016
Aug 3, 2021
Aug 3, 2021
Mar 11, 2024
Sep 18, 2023
Sep 18, 2023
Nov 7, 2022
Dec 17, 2024
Dec 17, 2024
Dec 17, 2024
Dec 17, 2024
Dec 17, 2024
Dec 17, 2024
Dec 17, 2024
Jan 8, 2025
Dec 17, 2024

Repository files navigation

mirage-crypto - Cryptographic primitives for MirageOS

%%VERSION%%

mirage-crypto is 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.

Mirage-crypto is a fork of the ocaml-nocrypto written by David Kaloper. It was forked with the permission of the original author in order to facilitate changes (e.g. build system) required by Mirage that the upstream didn't have time to keep up with.

Mirage-crypto-rng embeds the former mirage-entropy opam package, which implements various entropy sources:

  • non-deterministic execution time (used at initial seeding, see the whirlwind RNG paper)
  • a hook into the Lwt event loop that collects a timestamp of each event
  • rdseed and rdrand (x86/x86-64 only)

API documentation online

Build

dune build
dune runtest

FAQ

RNG seeding

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

Lwt:

let () = Mirage_crypto_rng_lwt.initialize (module Mirage_crypto_rng.Fortuna)

Unix:

let () = Mirage_crypto_rng_unix.initialize (module Mirage_crypto_rng.Fortuna)