<h2>NaCl - Networking and Cryptography library (pronounced "salt")</h2>

<hr>

<h3>Sysnopsis</h3>

<pre>
    nacl::info
    nacl::rcsid
    nacl::randombytes names
    nacl::randombytes source ?random|urandom|secrandomcopybytes|cryptgenrandom|default?
    nacl::randombytes lengthValue
    nacl::randombytes box ?-nonce?
    nacl::randombytes scalarmult ?-scalar|-group?
    nacl::randombytes secretbox ?-nonce|-key?
    nacl::randombytes stream ?-nonce|-key?
    nacl::randombytes auth ?-key?
    nacl::randombytes onetimeauth ?-key?
</pre>

<p>Public-key cryptography</p>

<pre>
    nacl::box info
    nacl::box keypair publicKeyVariable secretKeyVariable
    nacl::box cipherVariable messageValue nonceValue publicKeyValue secretKeyValue
    nacl::box open messageVariable cipherValue nonceValue publicKeyValue secretKeyValue
    nacl::scalarmult info
    nacl::scalarmult resultVariable scalarValue groupValue
    nacl::scalarmult base resultVariable scalarValue
    nacl::sign info
    nacl::sign keypair publicKeyVariable secretKeyVariable
    nacl::sign signedVariable messageValue secretKeyValue
    nacl::sign verify messageVariable signedValue publicKeyValue
</pre>

<p>Secret-key cryptography</p>

<pre>
    nacl::secretbox info
    nacl::secretbox cipherVariable messageValue nonceValue keyValue
    nacl::secretbox open messageVariable cipherValue nonceValue keyValue
    nacl::stream info
    nacl::stream generate cipherVariable nonceValue keyValue
    nacl::stream cipherVariable messageValue nonceValue keyValue
    nacl::auth info
    nacl::auth ?-hmac256|-hmac512256? authVariable messageValue keyValue
    nacl::auth verify -hmac256|-hmac512256 authValue messageValue keyValue
    nacl::onetimeauth info
    nacl::onetimeauth authVariable messageValue keyValue
    nacl::onetimeauth verify authValue messageValue keyValue
</pre>

<p>Low-level functions</p>

<pre>
    nacl::hash info
    nacl::hash ?-sha256|-sha512? hashVariable messageValue
</pre>

<hr>

<h3>Description</h3>

<p>NaCl (pronounced "salt") is a new easy-to-use high-speed software library for network communication, encryption, decryption, signatures, etc. NaCl's goal is to provide all of the core operations needed to build higher-level cryptographic tools. Of course, other libraries already exist for these core operations. NaCl advances the state of the art by improving security, by improving usability, and by improving speed.</p>

<hr>

<h3>Key features</h3>

<p>No data flow from secrets to load addresses. No data flow from secrets to branch conditions. No padding oracles. Centralizing randomness. Avoiding unnecessary randomness. Extremely high speed.</p>

<h3>Functions supported</h3>

<p>Simple NaCl applications need only six high-level NaCl functions: crypto_box for public-key authenticated encryption; crypto_box_open for verification and decryption; crypto_box_keypair to create a public key in the first place; and similarly for signatures crypto_sign, crypto_sign_open, and crypto_sign_keypair.</p>

<p>A minimalist implementation of the NaCl API would provide just these six functions. TweetNaCl is more ambitious, supporting all 25 of the NaCl functions listed below, which as mentioned earlier are all of the C NaCl functions used by applications. This list includes all of NaCl's "default" primitives except for crypto_auth_hmacsha512256, which was included in NaCl only for compatibility with standards and is superseded by crypto_onetimeauth.</p>

<p>The Ed25519 signature system has not yet been integrated into NaCl, since the Ed25519 software has not yet been fully audited; NaCl currently provides an older signature system. However, NaCl has announced that it will transition to Ed25519, so TweetNaCl provides Ed25519.</p>

<b>Public-key cryptography</b>

<ul>
  <li>Authenticated encryption using Curve25519, Salsa20, and Poly1305</li>
  <ul>
    <li>crypto_box = crypto_box_curve25519xsalsa20poly1305</li>
    <li>Not implemented: crypto_box_beforenm + crypto_box_afternm</li>
    <li>crypto_scalarmult = crypto_scalarmult_curve25519</li>
  </uL>
</ul>

<ul>
  <li>Signatures using Ed25519</li>
  <ul>
    <li>crypto_sign = crypto_sign_ed25519</li>
  </ul>
</ul>

<b>Secret-key cryptography</b>

<ul>
  <li>Authenticated encryption using Salsa20 and Poly1305</li>
  <ul>
    <li>crypto_secretbox = crypto_secretbox_xsalsa20poly1305</li>
  </ul>
</ul>

<ul>
  <li>Encryption using Salsa20</li>
  <ul>
    <li>crypto_stream = crypto_stream_xsalsa20</li>
  </ul>
</ul>

<ul>
  <li>Authentication using HMAC-SHA-512-256</li>
  <ul>
    <li>crypto_auth_hmacsha256_ref, crypto_auth_hmacsha512256_ref</li>
  </ul>
</ul>

<ul>
  <li>One-time authentication using Poly1305</li>
  <ul>
    <li>crypto_onetimeauth = crypto_onetimeauth_poly1305</li>
  </ul>
</ul>

<b>Low-level functions</b>

<ul>
  <li>Hashing using SHA-512 or SHA-256</li>
  <ul>
    <li>crypto_hash_sha256_ref, crypto_hash = crypto_hash_sha512</li>
  </ul>
</ul>

<hr>

<h3>Wiki Pages</h3>

<ul>
  <li>[hints]</li>
  <li>[examples]</li>
</ul>

<hr>

<h3>See Also</h3>

nacl.cr.yp.to 20110221]<br>
The security impact of a new cryptographic library]</p>

tweetnacl.cr.yp.to 20140427]<br>
TweetNaCl: A crypto library in 100 tweets]</p>


<hr>

<h3>Legal Notice</h3>

<p>Copyright (C) 2016 Alexander Schoepe, Bochum, DE</p>

<p>NaCl and TweetNaCl crypto library are public domain and the Tcl package BSD-3 license</p>

<p>Contributors (alphabetical order)<p>

<p>Daniel J. Bernstein, University of Illinois at Chicago and Technische Universiteit Eindhoven<br>
Bernard van Gastel, Radboud Universiteit Nijmegen<br>
Wesley Janssen, Radboud Universiteit Nijmegen<br>
Tanja Lange, Technische Universiteit Eindhoven<br>
Peter Schwabe, Radboud Universiteit Nijmegen<br>
Sjaak Smetsers, Radboud Universiteit Nijmegen</p>

<hr>

• privacy