AesGcm.Decrypt 方法

定义

重载

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)

参数

nonce
Byte[]

与此消息关联的 nonce。它必须与加密过程中提供的值相匹配。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.

例外

plaintext 参数和 ciphertext 的长度不同。The plaintext parameter and the ciphertext do not have the same length.

- 或 --or-

nonce 参数长度不被 NonceByteSizes 所允许。The nonce parameter length is not permitted by NonceByteSizes.

- 或 --or-

tag 参数长度不被 TagByteSizes 所允许。The tag parameter length is not permitted by TagByteSizes.

nonceciphertexttagplaintext 参数为 nullThe nonce, ciphertext, tag, or plaintext parameter is null.

无法验证标记值,或者解密操作失败。The tag value could not be verified, or the decryption operation otherwise failed.

注解

如果 tag 无法验证 (使用键、 nonceciphertextassociatedData 值) ,则 plaintext 会将其清除。If tag cannot be validated (using the key, nonce, ciphertext, and associatedData values), then plaintext is cleared.

适用于

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)

参数

nonce
ReadOnlySpan<Byte>

与此消息关联的 nonce。它必须与加密过程中提供的值相匹配。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.

例外

plaintext 参数和 ciphertext 的长度不同。The plaintext parameter and the ciphertext do not have the same length.

- 或 --or-

nonce 参数长度不被 NonceByteSizes 所允许。The nonce parameter length is not permitted by NonceByteSizes.

- 或 --or-

tag 参数长度不被 TagByteSizes 所允许。The tag parameter length is not permitted by TagByteSizes.

无法验证标记值,或者解密操作失败。The tag value could not be verified, or the decryption operation otherwise failed.

注解

如果 tag 无法验证 (使用键、 nonceciphertextassociatedData 值) ,则 plaintext 会将其清除。If tag cannot be validated (using the key, nonce, ciphertext, and associatedData values), then plaintext is cleared.

适用于