Skip to content

Latest commit

 

History

History
60 lines (41 loc) · 1.98 KB

README.md

File metadata and controls

60 lines (41 loc) · 1.98 KB

ocaml-sodium

Ctypes bindings to libsodium 1.0.9+ which wraps NaCl. GNU/Linux, FreeBSD, and OS X operating systems are supported. OCaml 4.01.0 or later is required to build.

All original NaCl primitives are wrapped. crypto_shorthash is missing.

open Sodium
let nonce = Box.random_nonce () in
let (sk, pk ) = Box.random_keypair () in
let (sk',pk') = Box.random_keypair () in
let c = Box.Bytes.box sk pk' "Hello, Spooky World!" nonce in
let m = Box.Bytes.box_open sk' pk c nonce in
print_endline (String.escaped c);
print_endline m

Considerations

Originally described in The Security Impact of a New Cryptographic Library, NaCl is a high-level, performant cryptography library exposing a straightforward interface.

This binding has not been thoroughly and independently audited so your use case must be able to tolerate this uncertainty.

Despite ocaml-sodium's thin interface on top of libsodium, it is still important to be mindful of security invariants. In particular, you should ensure that nonces used for cryptographic operations are never repeated with the same key set.

Building

Bazel

Prerequisite: Bazel 3.7.0

Build the OCaml library: $ bazel build lib:sodium

Build just libsodium: $ bazel build lib:libsodium

The current version uses libsodium version 1.0.18-RELEASE from https://github.com/jedisct1/libsodium.

See bzl/tools/user.bazelrc for a sample private rc file.

Tests

Internal consistency tests may be found in lib_test.

Salt

Salt is very important for the camel. It needs eight times as much salt as do cattle and sheep. A camel needs 1 kg of salt a week and it is advisable to leave salt with camels every week.

-- UN FAO Manual for Primary Animal Health Care Workers