<PackageReference Include="BouncyCastle.Cryptography" Version="2.8.0-beta.349" />

Org.BouncyCastle.Crypto.Modes.ChaCha20Poly1305

public class ChaCha20Poly1305 : IAeadCipher
Implementation of the ChaCha20-Poly1305 AEAD construction as defined in RFC 7539 / RFC 8439.
public virtual string AlgorithmName { get; }

The name of the algorithm ("ChaCha20Poly1305").

Default constructor using the standard Poly1305 MAC.

public ChaCha20Poly1305(IMac poly1305)

Constructor allowing a custom Poly1305 implementation.

protected ChaCha20Poly1305(ChaCha7539Engine chacha20, IMac poly1305, int nonceSize)

Constructor for subclasses to inject an alternative ChaCha20 engine (e.g. XChaCha20) and the matching nonce size.

public virtual int DoFinal(byte[] outBytes, int outOff)

Finish the operation, generating or verifying the MAC.

public virtual byte[] GetMac()

Return the Message Authentication Code (MAC) generated or verified by the cipher.

public virtual int GetOutputSize(int len)

Return the size of the output buffer required for an input of len bytes.

public virtual int GetUpdateOutputSize(int len)

Return the size of the output buffer required for a ProcessBytes call with len bytes.

public virtual void Init(bool forEncryption, ICipherParameters parameters)

Initialise the ChaCha20Poly1305 cipher.

public virtual void ProcessAadByte(byte input)

Process a single byte of Additional Authenticated Data (AAD).

public virtual void ProcessAadBytes(byte[] inBytes, int inOff, int len)

Process a sequence of bytes of Additional Authenticated Data (AAD).

public virtual int ProcessByte(byte input, byte[] outBytes, int outOff)

Process a single byte of data.

public virtual int ProcessBytes(byte[] inBytes, int inOff, int len, byte[] outBytes, int outOff)

Process a sequence of bytes from the input buffer.

public virtual void Reset()

Reset the cipher to its initial state (ready for a new message with the same key but DIFFERENT nonce).