AeadTransformExtensions Class
Definition
- Namespace
- Bodu.Security.Cryptography.Extensions
- Assembly
- Bodu.Security.Cryptography.dll
- Package
- Bodu.Security.Cryptography 1.2.0
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
transformIAeadTransformThe AEAD transform. Must not be null.
ciphertextWithTagReadOnlySpan<byte>The ciphertext followed by its authentication tag.
associatedDataReadOnlySpan<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
transformis 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
transformIAeadTransformThe AEAD transform. Must not be null.
plaintextReadOnlySpan<byte>The data to encrypt.
associatedDataReadOnlySpan<byte>The data authenticated but not encrypted. Defaults to empty.
Returns
- byte[]
A new array of length
plaintext.Length + (transform.TagSize / 8).
Exceptions
- ArgumentNullException
transformis null.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |