Table of Contents

AeadTransformExtensions Class

Definition

Namespace
Bodu.Security.Cryptography.Extensions
Assembly
Bodu.Security.Cryptography.dll
Package
Bodu.Security.Cryptography 1.2.0
Source
AeadTransformExtensions.cs

Provides convenience helpers over IAeadTransform that size the output buffer and return a freshly allocated array, for callers who prefer arrays to caller-supplied spans.

public static class AeadTransformExtensions
Inheritance
AeadTransformExtensions
Inherited Members

Methods

Decrypt(IAeadTransform, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Verifies and decrypts ciphertextWithTag and returns a new array containing the recovered plaintext.

public static byte[] Decrypt(this IAeadTransform transform, ReadOnlySpan<byte> ciphertextWithTag, ReadOnlySpan<byte> associatedData = default)

Parameters

transform IAeadTransform

The AEAD transform. Must not be null.

ciphertextWithTag ReadOnlySpan<byte>

The ciphertext followed by its authentication tag.

associatedData ReadOnlySpan<byte>

The data that must match what was supplied at encryption time. Defaults to empty.

Returns

byte[]

A new array of length ciphertextWithTag.Length - (transform.TagSize / 8).

Exceptions

ArgumentNullException

transform is null.

CryptographicException

The authentication tag did not match.

Encrypt(IAeadTransform, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Encrypts plaintext and returns a new array containing the ciphertext followed by the authentication tag.

public static byte[] Encrypt(this IAeadTransform transform, ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> associatedData = default)

Parameters

transform IAeadTransform

The AEAD transform. Must not be null.

plaintext ReadOnlySpan<byte>

The data to encrypt.

associatedData ReadOnlySpan<byte>

The data authenticated but not encrypted. Defaults to empty.

Returns

byte[]

A new array of length plaintext.Length + (transform.TagSize / 8).

Exceptions

ArgumentNullException

transform is null.

Applies to

ProductVersions
.NET8, 10