Class AesSiv
- Namespace
- Dorssel.Security.Cryptography
- Assembly
- Dorssel.Security.Cryptography.AesExtra.dll
Represents an Advanced Encryption Standard (AES) key to be used with the Synthetic Initialization Vector (SIV) mode of operation.
public sealed class AesSiv : IDisposable
- Inheritance
-
AesSiv
- Implements
- Inherited Members
Constructors
AesSiv(byte[])
Initializes a new instance of the AesSiv class with a provided key.
public AesSiv(byte[] key)
Parameters
key
byte[]The secret key to use for this instance.
Exceptions
- ArgumentNullException
key
is null.- CryptographicException
The
key
length is other than 32, 48, or 64 bytes (256, 384, or 512 bits).
AesSiv(ReadOnlySpan<byte>)
Initializes a new instance of the AesSiv class with a provided key.
public AesSiv(ReadOnlySpan<byte> key)
Parameters
key
ReadOnlySpan<byte>The secret key to use for this instance.
Exceptions
- CryptographicException
The
key
length is other than 32, 48, or 64 bytes (256, 384, or 512 bits).
Methods
Decrypt(byte[], byte[], params byte[][])
Decrypts the ciphertext into the provided destination buffer if the data can be validated.
public void Decrypt(byte[] ciphertext, byte[] plaintext, params byte[][] associatedData)
Parameters
ciphertext
byte[]The encrypted content to decrypt, including the prepended IV.
plaintext
byte[]The byte array to receive the decrypted contents.
associatedData
byte[][]Extra data associated with this message, which must match the value provided during encryption.
Exceptions
- ArgumentNullException
ciphertext
is null.- ArgumentException
ciphertext
is too short.- ArgumentNullException
plaintext
is null.- ArgumentException
plaintext
is not exactly one block smaller thanciphertext
.- ArgumentNullException
associatedData
is null.- ArgumentException
associatedData
has too many items.- ArgumentException
associatedData
contains an item that is null.- ObjectDisposedException
The AesSiv instance has been disposed.
- CryptographicException
The tag value could not be verified.
Decrypt(ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)
Decrypts the ciphertext into the provided destination buffer if the data can be validated.
public void Decrypt(ReadOnlySpan<byte> ciphertext, Span<byte> plaintext, ReadOnlySpan<byte> associatedData)
Parameters
ciphertext
ReadOnlySpan<byte>The encrypted content to decrypt, including the prepended IV.
plaintext
Span<byte>The byte array to receive the decrypted contents.
associatedData
ReadOnlySpan<byte>Extra data associated with this message, which must match the value provided during encryption.
Remarks
This method expects exactly one associated data item, possibly of zero length, which differs from expecting no associated data items at all.
Exceptions
- ArgumentException
ciphertext
is too short.- ArgumentException
plaintext
is not exactly one block smaller thanciphertext
.- ObjectDisposedException
The AesSiv instance has been disposed.
- CryptographicException
The tag value could not be verified.
Decrypt(ReadOnlySpan<byte>, Span<byte>, params ReadOnlySpan<ReadOnlyMemory<byte>>)
Decrypts the ciphertext into the provided destination buffer if the data can be validated.
public void Decrypt(ReadOnlySpan<byte> ciphertext, Span<byte> plaintext, params ReadOnlySpan<ReadOnlyMemory<byte>> associatedData)
Parameters
ciphertext
ReadOnlySpan<byte>The encrypted content to decrypt, including the prepended IV.
plaintext
Span<byte>The byte array to receive the decrypted contents.
associatedData
ReadOnlySpan<ReadOnlyMemory<byte>>Extra data associated with this message, which must match the value provided during encryption.
Exceptions
- ArgumentException
ciphertext
is too short.- ArgumentException
plaintext
is not exactly one block smaller thanciphertext
.- ArgumentException
associatedData
has too many items.- ObjectDisposedException
The AesSiv instance has been disposed.
- CryptographicException
The tag value could not be verified.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Encrypt(byte[], byte[], params byte[][])
Encrypts the plaintext into the ciphertext destination buffer, prepending the synthetic IV.
public void Encrypt(byte[] plaintext, byte[] ciphertext, params byte[][] associatedData)
Parameters
plaintext
byte[]The content to encrypt.
ciphertext
byte[]The byte array to receive the encrypted contents, prepended with the synthetic IV.
associatedData
byte[][]Extra data associated with this message, which must also be provided during decryption.
Exceptions
- ArgumentNullException
plaintext
is null.- ArgumentNullException
ciphertext
is null.- ArgumentException
ciphertext
is too short.- ArgumentException
ciphertext
is not exactly one block larger thanplaintext
.- ArgumentNullException
associatedData
is null.- ArgumentException
associatedData
has too many items.- ArgumentException
associatedData
contains an item that is null.- ObjectDisposedException
The AesSiv instance has been disposed.
Encrypt(ReadOnlySpan<byte>, Span<byte>, ReadOnlySpan<byte>)
Encrypts the plaintext into the ciphertext destination buffer, prepending the synthetic IV.
public void Encrypt(ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, ReadOnlySpan<byte> associatedData)
Parameters
plaintext
ReadOnlySpan<byte>The content to encrypt.
ciphertext
Span<byte>The byte array to receive the encrypted contents, prepended with the synthetic IV.
associatedData
ReadOnlySpan<byte>Extra data associated with this message, which must also be provided during decryption.
Remarks
This method adds exactly one associated data item, possibly of zero length, which differs from adding no associated data items at all.
Exceptions
- ArgumentException
ciphertext
is not exactly one block larger thanplaintext
.- ObjectDisposedException
The AesSiv instance has been disposed.
Encrypt(ReadOnlySpan<byte>, Span<byte>, params ReadOnlySpan<ReadOnlyMemory<byte>>)
Encrypts the plaintext into the ciphertext destination buffer, prepending the synthetic IV.
public void Encrypt(ReadOnlySpan<byte> plaintext, Span<byte> ciphertext, params ReadOnlySpan<ReadOnlyMemory<byte>> associatedData)
Parameters
plaintext
ReadOnlySpan<byte>The content to encrypt.
ciphertext
Span<byte>The byte array to receive the encrypted contents, prepended with the synthetic IV.
associatedData
ReadOnlySpan<ReadOnlyMemory<byte>>Extra data associated with this message, which must also be provided during decryption.
Exceptions
- ArgumentException
ciphertext
is not exactly one block larger thanplaintext
.- ArgumentException
associatedData
has too many items.- ObjectDisposedException
The AesSiv instance has been disposed.