NaCl (software). NaCl (Networking and Cryptography Library, pronounced "salt") is  a public domain, high-speed software library for cryptography.

NaCl was created by the mathematician and programmer Daniel J. Bernstein, who is best known for the creation of qmail and Curve25519. The core team also includes Tanja Lange and Peter Schwabe. The main goal while creating NaCl, according to the team's 2011 paper, was to "avoid various types of cryptographic disasters suffered by previous cryptographic libraries". The team does so by safer designs that avoid issues such as side-channel leakage and loss of randomness, by being performant enough that safety features do not get disabled by the user, and by picking better cryptographic primitives. The high-level "box" API is designed to encourage the use of authenticated encryption.

Functions

Public-key cryptography 
 , public-key authenticated encryption. Key agreement happens via X25519; encryption is done by Salsa20-Poly1305.
 , scalar multiplication on X25519. This function can be used for elliptic-curve Diffie–Hellman.
 , signatures using Ed25519 and SHA-512.

Secret-key cryptography 
 , private-key authenticated encryption using Salsa20-Poly1305.
 , encryption using Salsa20, XSalsa20, or AES.
 , authentication using HMAC-SHA-512-256.
 , single-message  authentication using Poly1305.

Low-level functions
 , hashing using SHA-512 or SHA-256
 , string comparison in constant time.

Implementations 
The reference implementation is written in C, often incorporating inline assembly routines. C++ support is implemented as a wrapper. A Python wrapper was planned, but is not part of the latest (20110221) release. The home page, last updated in 2016, mentions prototype wrappers.

The reference NaCl implementation has a variety of programming language bindings, such as PHP and Tcl.

Libsodium 
Libsodium is an API-compatible fork of reference NaCl created in 2013. It is "installable and packageable", or in other words can be compiled into a dynamic library and installed as a software package thanks to the addition of build files (NaCl had none). It is also "portable and cross-compilable".

As libsodium can be dynamically linked, it serves as the basis for a number of bindings in languages such as Pharo, Perl 5, and Python.

libsodium also extends the NaCl API with new algorithms (e.g. BLAKE2, ChaCha20-Poly1305, AEGIS) and new classes of functions (e.g. secure memory, random number generation, short-input hashing, password hashing and key derivation).

TweetNaCl 
In 2013, the NaCl team and three others released TweetNaCl, a condensed implementation of NaCl's 25 functions that fits in the size of 100 tweets (140 symbols each).

TweetNaCl has been used as the basis of ports including TweetNaCl.js and TweetNaCl-Java. It has also been rewritten in the SPARK Ada subset as SPARKNaCl, which the authors describe as "(unlike TweetNaCl) readable owing to the large number of explanatory comments and contracts in the code."

Other implementations 
 dryoc — a pure-Rust cryptography library implementing the libsodium/NaCl API with support for protected memory.
 Monocypher — a rewrite of NaCl in C. Aims to have the speed of reference NaCl and the size of TweetNaCl.

See also 

 The use of the term salt in cryptography
 Comparison of cryptography libraries
 List of free and open-source software packages

References

External links 
 

Public-domain software
Cryptographic software
2008 software