Class Aead
Represents the abstract class from which all implementations of Authenticated Encryption with Associated Data (AEAD) must derive.
Inherited Members
Namespace: AtlasRhythm.Cryptography.Aeads
Assembly: AtlasRhythm.Cryptography.dll
Syntax
public abstract class Aead
Properties
| Improve this Doc View SourceKey
Declaration
protected abstract byte[] Key { get; }
Property Value
| Type | Description |
|---|---|
| Byte[] |
KeyByteSizes
Gets the key sizes, in bytes, supported by this instance.
Declaration
public abstract KeySizes KeyByteSizes { get; }
Property Value
| Type | Description |
|---|---|
| KeySizes |
NonceByteSizes
Gets the nonce sizes, in bytes, supported by this instance.
Declaration
public abstract KeySizes NonceByteSizes { get; }
Property Value
| Type | Description |
|---|---|
| KeySizes |
TagByteSizes
Gets the tag sizes, in bytes, supported by this instance.
Declaration
public abstract KeySizes TagByteSizes { get; }
Property Value
| Type | Description |
|---|---|
| KeySizes |
Methods
| Improve this Doc View SourceDecrypt(Byte[], Byte[], Byte[])
Decrypts the ciphertext and returns the plaintext in a new buffer if the authentication tag can be validated.
Declaration
public byte[] Decrypt(byte[] nonce, byte[] ciphertextAndTag, byte[] associatedData = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | nonce | The nonce associated with this message, which must match the value provided during encryption. |
| Byte[] | ciphertextAndTag | The byte array containing the concatenated ciphertext and authentication tag. |
| Byte[] | associatedData | Extra data associated with this message, which must match the value provided during encryption. |
Returns
| Type | Description |
|---|---|
| Byte[] | The byte array containing the plaintext. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The |
| ArgumentException | The |
| ArgumentException | The |
| CryptographicException | The tag value could not be verified. |
Decrypt(Byte[], Byte[], Byte[], Byte[], Byte[])
Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.
Declaration
public void Decrypt(byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | nonce | The nonce associated with this message, which must match the value provided during encryption. |
| Byte[] | ciphertext | The encrypted content to decrypt. |
| Byte[] | tag | The authentication tag produced for this message during encryption. |
| Byte[] | plaintext | The byte array to receive the decrypted contents. |
| Byte[] | associatedData | Extra data associated with this message, which must match the value provided during encryption. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The |
| ArgumentException | The |
| ArgumentException | The |
| ArgumentException | The |
| CryptographicException | The tag value could not be verified. |
Decrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, ReadOnlySpan<Byte>)
Decrypts the ciphertext and returns the plaintext in a new buffer if the authentication tag can be validated.
Declaration
public byte[] Decrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> ciphertextAndTag, ReadOnlySpan<byte> associatedData = default(ReadOnlySpan<byte>))
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | nonce | The nonce associated with this message, which must match the value provided during encryption. |
| ReadOnlySpan<Byte> | ciphertextAndTag | The byte span containing the concatenated ciphertext and authentication tag. |
| ReadOnlySpan<Byte> | associatedData | Extra data associated with this message, which must match the value provided during encryption. |
Returns
| Type | Description |
|---|---|
| Byte[] | The byte array containing the plaintext. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The |
| ArgumentException | The |
| CryptographicException | The tag value could not be verified. |
Decrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, ReadOnlySpan<Byte>)
Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.
Declaration
public void Decrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> tag, Span<byte> plaintext, ReadOnlySpan<byte> associatedData = default(ReadOnlySpan<byte>))
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | nonce | The nonce associated with this message, which must match the value provided during encryption. |
| ReadOnlySpan<Byte> | ciphertext | The encrypted content to decrypt. |
| ReadOnlySpan<Byte> | tag | The authentication tag produced for this message during encryption. |
| Span<Byte> | plaintext | The byte span to receive the decrypted contents. |
| ReadOnlySpan<Byte> | associatedData | Extra data associated with this message, which must match the value provided during encryption. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The |
| ArgumentException | The |
| ArgumentException | The |
| CryptographicException | The tag value could not be verified. |
DecryptCore(Byte*, Byte*, Byte*, Int32, Byte*, Byte*, Int32, Byte*)
Declaration
protected abstract bool DecryptCore(byte *key, byte *nonce, byte *ciphertext, int size, byte *tag, byte *associatedData, int associatedDataSize, byte *plaintext)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte* | key | |
| Byte* | nonce | |
| Byte* | ciphertext | |
| Int32 | size | |
| Byte* | tag | |
| Byte* | associatedData | |
| Int32 | associatedDataSize | |
| Byte* | plaintext |
Returns
| Type | Description |
|---|---|
| Boolean |
Encrypt(Byte[], Byte[], Byte[])
Encrypts the plaintext and returns the concatenated ciphertext and authentication tag in a new buffer.
Declaration
public byte[] Encrypt(byte[] nonce, byte[] plaintext, byte[] associatedData = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | nonce | The nonce associated with this message, which should be a unique value for every operation with the same key. |
| Byte[] | plaintext | The content to encrypt. |
| Byte[] | associatedData | Extra data associated with this message, which must also be provided during decryption. |
Returns
| Type | Description |
|---|---|
| Byte[] | The byte array containing the concatenated ciphertext and authentication tag. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The |
| ArgumentException | The |
Encrypt(Byte[], Byte[], Byte[], Byte[], Byte[])
Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.
Declaration
public void Encrypt(byte[] nonce, byte[] plaintext, byte[] ciphertext, byte[] tag, byte[] associatedData = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte[] | nonce | The nonce associated with this message, which should be a unique value for every operation with the same key. |
| Byte[] | plaintext | The content to encrypt. |
| Byte[] | ciphertext | The byte array to receive the encrypted contents. |
| Byte[] | tag | The byte array to receive the generated authentication tag. |
| Byte[] | associatedData | Extra data associated with this message, which must also be provided during decryption. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | The |
| ArgumentException | The |
| ArgumentException | The |
| ArgumentException | The |
Encrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, ReadOnlySpan<Byte>)
Encrypts the plaintext and returns the concatenated ciphertext and authentication tag in a new buffer.
Declaration
public byte[] Encrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plaintext, ReadOnlySpan<byte> associatedData = default(ReadOnlySpan<byte>))
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | nonce | The nonce associated with this message, which should be a unique value for every operation with the same key. |
| ReadOnlySpan<Byte> | plaintext | The content to encrypt. |
| ReadOnlySpan<Byte> | associatedData | Extra data associated with this message, which must also be provided during decryption. |
Returns
| Type | Description |
|---|---|
| Byte[] | The byte array containing the concatenated ciphertext and authentication tag. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The |
Encrypt(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Span<Byte>, Span<Byte>, ReadOnlySpan<Byte>)
Encrypts the plaintext into the ciphertext destination buffer and generates the authentication tag into a separate buffer.
Declaration
public void Encrypt(ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, Span<byte> tag, ReadOnlySpan<byte> associatedData = default(ReadOnlySpan<byte>))
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<Byte> | nonce | The nonce associated with this message, which should be a unique value for every operation with the same key. |
| ReadOnlySpan<Byte> | plaintext | The content to encrypt. |
| Span<Byte> | ciphertext | The byte span to receive the encrypted contents. |
| Span<Byte> | tag | The byte span to receive the generated authentication tag. |
| ReadOnlySpan<Byte> | associatedData | Extra data associated with this message, which must also be provided during decryption. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | The |
| ArgumentException | The |
| ArgumentException | The |
EncryptCore(Byte*, Byte*, Byte*, Int32, Byte*, Int32, Byte*, Byte*)
Declaration
protected abstract void EncryptCore(byte *key, byte *nonce, byte *plaintext, int size, byte *associatedData, int associatedDataSize, byte *ciphertext, byte *tag)
Parameters
| Type | Name | Description |
|---|---|---|
| Byte* | key | |
| Byte* | nonce | |
| Byte* | plaintext | |
| Int32 | size | |
| Byte* | associatedData | |
| Int32 | associatedDataSize | |
| Byte* | ciphertext | |
| Byte* | tag |