AeadChaCha20Poly1305.NetCore 1.0.1

dotnet add package AeadChaCha20Poly1305.NetCore --version 1.0.1                
NuGet\Install-Package AeadChaCha20Poly1305.NetCore -Version 1.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AeadChaCha20Poly1305.NetCore" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AeadChaCha20Poly1305.NetCore --version 1.0.1                
#r "nuget: AeadChaCha20Poly1305.NetCore, 1.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AeadChaCha20Poly1305.NetCore as a Cake Addin
#addin nuget:?package=AeadChaCha20Poly1305.NetCore&version=1.0.1

// Install AeadChaCha20Poly1305.NetCore as a Cake Tool
#tool nuget:?package=AeadChaCha20Poly1305.NetCore&version=1.0.1                

AeadChaCha20Poly1305.NetCore

License: MIT nuget

Implementation of AEAD_CHACHA20_POLY1305 an authenticated encryption with additional data algorithm using ChaCha20, and Poly1305 designed by D. J. Bernstein. Optimized for PinnedMemory, and .NET core.

You can read more about AEAD, ChaCha20, and Poly1305 using the resources below:

Install

From a command prompt

dotnet add package AeadChaCha20Poly1305.NetCore
Install-Package AeadChaCha20Poly1305.NetCore

You can also search for package via your nuget ui / website:

https://www.nuget.org/packages/AeadChaCha20Poly1305.NetCore/

Examples

You can find more examples in the github examples project.

var nonce = new byte[16];
var key = new byte[32];
var data = new byte[1024];

using var provider = new RNGCryptoServiceProvider();
provider.GetBytes(nonce);
provider.GetBytes(key);
provider.GetBytes(data);

using var keyPin = new PinnedMemory<byte>(key, false);
var aeadChaCha20Poly1305 = new AeadChaCha20Poly1305(keyPin, nonce, new byte[] { 32 });

// Encryption / Authentication
using var dataPin = new PinnedMemory<byte>(data, false);
eadChaCha20Poly1305.UpdateBlock(dataPin,0, dataPin.Length);

using var output = new PinnedMemory<byte>(new byte[aeadChaCha20Poly1305.GetLength()]);
aeadChaCha20Poly1305.DoFinal(output, 0);
var tag = aeadChaCha20Poly1305.GetTag(); // Poly1305 tag used to authenticate cipher

// Decryption / Authentication
aeadChaCha20Poly1305.Reset();
aeadChaCha20Poly1305.SetTag(tag);
aeadChaCha20Poly1305.UpdateBlock(output,0, output.Length);

using var plain = new PinnedMemory<byte>(new byte[aeadChaCha20Poly1305.GetLength()]);
aeadChaCha20Poly1305.DoFinal(plain, 0);

Constructor

AeadChaCha20Poly1305(PinnedMemory<byte> key, byte[] nonce, byte[] ad = null, int rounds = 20)

Methods

Get the cipher output length.

int GetLength()

Get the cipher authentication tag length.

int GetTagLength()

Get the contents of the internal buffer, this can be used to compare data before encryption, or decryption.

byte[] GetBuffer()

Update the cipher with a single byte.

void Update(byte input)

Update the cipher with a pinned memory byte array.

void UpdateBlock(PinnedMemory<byte> input, int inOff, int len)

Update the cipher with a byte array.

void UpdateBlock(byte[] input, int inOff, int len)

Produce the final cipher outputting to pinned memory. Key & nonce remain.

void DoFinal(PinnedMemory<byte> output, int outOff)

Get the final cipher tag, this should be called after DoFinal.

PinnedMemory<byte> GetTag()

Set the final cipher tag, this should be called before DoFinal, and is required for decryption.

void SetTag(PinnedMemory<byte> value)

Reset the cipher back to it's initial state for further processing. Key remains until dispose is called.

void Reset()

Clear key & nonce, reset cipher back to it's initial state.

void Dispose()
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 540 8/11/2020
1.0.0 441 8/11/2020