NaCl (software)
Template:Short description Script error: No such module "Distinguish". Script error: No such module "about".
Page Module:Infobox/styles.css has no content.
| NaCl | |
|---|---|
| [[Programmer|Original authorTemplate:Pluralize from text]] | Daniel J. Bernstein, Tanja Lange, Peter Schwabe |
| Initial release | 2008 |
| Operating system | UNIX-like |
| License | public domain[1] |
| Website | nacl |
Script error: No such module "Check for conflicting parameters".
NaCl (Networking and Cryptography Library, pronounced "salt") is a public domain, high-speed software library for cryptography.[2]
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.[3][4] 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.[1]
Functions
Public-key cryptography
crypto_box, public-key authenticated encryption. Key agreement happens via X25519; encryption is done by Salsa20-Poly1305.[5]crypto_scalarmult, scalar multiplication on X25519. This function can be used for elliptic-curve Diffie–Hellman.crypto_sign, signatures using Ed25519 and SHA-512.
Secret-key cryptography
crypto_secretbox, private-key authenticated encryption using Salsa20-Poly1305.crypto_stream, encryption using Salsa20, XSalsa20, or AES.crypto_auth, authentication using HMAC-SHA-512-256.crypto_onetimeauth, single-message authentication using Poly1305.
Low-level functions
crypto_hash, hashing using SHA-512 or SHA-256[6]crypto_verify, string comparison in constant time.[7]
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,[8] but is not part of the latest (20110221) release. The home page, last updated in 2016, mentions prototype wrappers.[2]
The reference NaCl implementation has a variety of programming language bindings, such as PHP[9] and Tcl.[10]Template:Third-party inline
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".[11]
As libsodium can be dynamically linked, it serves as the basis for a number of bindings in languages such as Squeak,[12] Pharo,[13] Perl 5,[14] and Python.[15][16]
libsodium also extends the NaCl API with new algorithms (e.g. BLAKE2,[17] ChaCha20-Poly1305, AEGIS)[18] and new classes of functions (e.g. secure memory, random number generation, short-input hashing,[19] 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).[20]
TweetNaCl has been used as the basis of ports including TweetNaCl.js[21] and TweetNaCl-Java.[22] 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."[23]
Other implementations
- RustCrypto - a popular set of pure-Rust crypto libraries that includes an NaCl compatibility layer.
- dryoc — a pure-Rust cryptography library implementing the libsodium/NaCl API with support for protected memory.[24]
- Monocypher — a rewrite of NaCl in C. Aims to have the speed of reference NaCl and the size of TweetNaCl.[25]
See also
- The use of the term salt in cryptography
- Comparison of cryptography libraries
- List of free and open-source software packages
References
Page Template:Reflist/styles.css has no content.
- ^ a b Page Module:Citation/CS1/styles.css has no content.Daniel J. Bernstein; Tanja Lange; Peter Schwabe. "The security impact of a new cryptographic library" (PDF). Archived (PDF) from the original on 2017-08-09.
- ^ a b Page Module:Citation/CS1/styles.css has no content."NaCl: Networking and Cryptography library".
- ^ Page Module:Citation/CS1/styles.css has no content."Tanja Lange's Homepage".
- ^ Page Module:Citation/CS1/styles.css has no content."Peter Schwabe's Homepage".
- ^ Page Module:Citation/CS1/styles.css has no content.Bernstein, Daniel J. (10 March 2009). Cryptography in NaCl (PDF). Archived (PDF) from the original on 25 March 2017. Retrieved 8 February 2016.
- ^ Page Module:Citation/CS1/styles.css has no content."Hashing: crypto_hash". 2010-08-30. Retrieved 2015-11-14.
- ^ Page Module:Citation/CS1/styles.css has no content."String comparison: crypto_verify". nacl.cr.yp.to. Retrieved 19 January 2024.
- ^ Page Module:Citation/CS1/styles.css has no content."NaCl Internals".
- ^ Page Module:Citation/CS1/styles.css has no content."NaCl PHP Extension". Github. 2019-06-14.
- ^ Page Module:Citation/CS1/styles.css has no content."Tclers Wiki - NaCl for Tcl".
- ^ Page Module:Citation/CS1/styles.css has no content.Denis, Frank (18 January 2024). "libsodium: A modern, portable, easy to use crypto library". GitHub.
- ^ Page Module:Citation/CS1/styles.css has no content."SqueakSource 'Sodium' repository". 6 August 2025.
- ^ Page Module:Citation/CS1/styles.css has no content."SmalltalkHub repository". 22 January 2018.
- ^ Page Module:Citation/CS1/styles.css has no content."Crypt::NaCl::Sodium".
- ^ Page Module:Citation/CS1/styles.css has no content.Python Cryptographic Authority (18 January 2024). "pyca/pynacl". GitHub.
PyNaCl is a Python binding to libsodium, which is a fork of the Networking and Cryptography library.
- ^ Page Module:Citation/CS1/styles.css has no content."Bindings for other languages". libsodium.
- ^ Page Module:Citation/CS1/styles.css has no content."Generic hashing". 2017-12-13. Retrieved 2018-05-19.
- ^ Page Module:Citation/CS1/styles.css has no content."AEAD constructions". libsodium.
- ^ Page Module:Citation/CS1/styles.css has no content."Short-input hashing". libsodium.
- ^ Page Module:Citation/CS1/styles.css has no content.Daniel J. Bernstein; Bernard van Gastel; Wesley Janssen; Tanja Lange; Peter Schwabe; Sjaak Smetsers (2013). "TweetNaCl".
- ^ Page Module:Citation/CS1/styles.css has no content."TweetNaCl.js".
- ^ Page Module:Citation/CS1/styles.css has no content."TweetNaCl-Java". GitHub.
- ^ Page Module:Citation/CS1/styles.css has no content."SPARKNaCl". GitHub.
- ^ Page Module:Citation/CS1/styles.css has no content."Don't Roll Your Own Crypto (dryoc): pure-Rust, hard to misuse cryptography library". GitHub.
- ^ Page Module:Citation/CS1/styles.css has no content.Vaillant, Loup (17 January 2024). "LoupVaillant/Monocypher". GitHub.