NaCl.Core is a managed-only cryptography library for .NET which provides modern cryptographic primitives.
Crypto | Description |
---|---|
ChaCha20 | A high-speed stream cipher based on Salsa20 |
XChaCha20 | Based on ChaCha20 IETF with extended nonce (192-bit instead of 96-bit) |
Poly1305 | A state-of-the-art secret-key message-authentication code (MAC) based on RFC8439 |
ChaCha20Poly1305 | An Authenticated Encryption with Associated Data (AEAD) algorithm; IETF variant as defined in RFC8439 and in its predecessor RFC7539 |
XChaCha20Poly1305 | A variant of ChaCha20-Poly1305 that utilizes the XChaCha20 construction in place of ChaCha20; as defined in the RFC Draft |
Install the NaCl.Core NuGet package from the .NET Core CLI using:
dotnet add package NaCl.Core
or from the NuGet package manager:
Install-Package NaCl.Core
Or alternatively, you can add the NaCl.Core package from within Visual Studio's NuGet package manager.
Daily NuGet builds of the project are also available in the MyGet feed:
// Create the primitive
var aead = new ChaCha20Poly1305(key);
// Use the primitive to encrypt a plaintext
var ciphertext = aead.Encrypt(plaintext, aad, nonce);
// ... or to decrypt a ciphertext
var output = aead.Decrypt(ciphertext, aad, nonce);
// Use the primitive to compute a tag
var tag = Poly1305.ComputeMac(key, data);
// ... or to verify a tag
Poly1305.VerifyMac(key, data, tag);
- Includes the mandatory RFC test vectors.
- Project Wycheproof by members of Google Security Team, for testing against known attacks (when applicable).
- ChaCha, a variant of Salsa20 by Daniel J. Bernstein.
- The Poly1305-AES message-authentication code by Daniel J. Bernstein.
- ChaCha20 and Poly1305 for IETF Protocols RFC.
- XSalsa20, an extended-nonce Salsa20 variant used in NaCl.
- XChaCha20-Poly1305, an extended-nonce ChaCha20-Poly1305 IETF variant.