AesGcm.Decrypt Method

Definition

Overloads

Decrypt(Byte[], Byte[], Byte[], Byte[], Byte[])

Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.

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.

Decrypt(Byte[], Byte[], Byte[], Byte[], Byte[])

Decrypts the ciphertext into the provided destination buffer if the authentication tag can be validated.

public void Decrypt (byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[]? associatedData = default);
public void Decrypt (byte[] nonce, byte[] ciphertext, byte[] tag, byte[] plaintext, byte[] associatedData = default);
member this.Decrypt : byte[] * byte[] * byte[] * byte[] * byte[] -> unit
Public Sub Decrypt (nonce As Byte(), ciphertext As Byte(), tag As Byte(), plaintext As Byte(), Optional associatedData As Byte() = Nothing)

Parameters

nonce
Byte[]

The nonce associated with this message, which must match the value provided during encryption.

ciphertext
Byte[]

The encrypted content to decrypt.

tag
Byte[]

The authentication tag produced for this message during encryption.

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

The plaintext parameter and the ciphertext do not have the same length.

-or-

The nonce parameter length is not permitted by NonceByteSizes.

-or-

The tag parameter length is not permitted by TagByteSizes.

The nonce, ciphertext, tag, or plaintext parameter is null.

The tag value could not be verified, or the decryption operation otherwise failed.

Remarks

If tag cannot be validated (using the key, nonce, ciphertext, and associatedData values), then plaintext is cleared.

Applies to

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.

public void Decrypt (ReadOnlySpan<byte> nonce, ReadOnlySpan<byte> ciphertext, ReadOnlySpan<byte> tag, Span<byte> plaintext, ReadOnlySpan<byte> associatedData = default);
member this.Decrypt : ReadOnlySpan<byte> * ReadOnlySpan<byte> * ReadOnlySpan<byte> * Span<byte> * ReadOnlySpan<byte> -> unit
Public Sub Decrypt (nonce As ReadOnlySpan(Of Byte), ciphertext As ReadOnlySpan(Of Byte), tag As ReadOnlySpan(Of Byte), plaintext As Span(Of Byte), Optional associatedData As ReadOnlySpan(Of Byte) = Nothing)

Parameters

nonce
ReadOnlySpan<Byte>

The nonce associated with this message, which must match the value provided during encryption.

ciphertext
ReadOnlySpan<Byte>

The encrypted content to decrypt.

tag
ReadOnlySpan<Byte>

The authentication tag produced for this message during encryption.

plaintext
Span<Byte>

The byte span to receive the decrypted contents.

associatedData
ReadOnlySpan<Byte>

Extra data associated with this message, which must match the value provided during encryption.

Exceptions

The plaintext parameter and the ciphertext do not have the same length.

-or-

The nonce parameter length is not permitted by NonceByteSizes.

-or-

The tag parameter length is not permitted by TagByteSizes.

The tag value could not be verified, or the decryption operation otherwise failed.

Remarks

If tag cannot be validated (using the key, nonce, ciphertext, and associatedData values), then plaintext is cleared.

Applies to