62 {
64 {
66 {
68 {
70 {
72 {
73 global::Interop.BCrypt.BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO = global::Interop.BCrypt.BCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.Create();
74 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.pbNonce = pbNonce;
75 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.cbNonce = nonce.
Length;
76 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.pbTag = pbTag;
77 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.cbTag = tag.
Length;
78 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.pbAuthData = pbAuthData;
79 bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO.cbAuthData = associatedData.
Length;
80 int cbResult;
81 global::Interop.BCrypt.NTSTATUS nTSTATUS = global::Interop.BCrypt.BCryptDecrypt(keyHandle, pbInput, ciphertext.
Length,
new IntPtr(&bCRYPT_AUTHENTICATED_CIPHER_MODE_INFO),
null, 0, pbOutput, plaintext.
Length, out cbResult, 0);
82 switch (nTSTATUS)
83 {
84 case global::Interop.BCrypt.NTSTATUS.STATUS_SUCCESS:
85 break;
86 case global::Interop.BCrypt.NTSTATUS.STATUS_AUTH_TAG_MISMATCH:
87 if (clearPlaintextOnFailure)
88 {
89 CryptographicOperations.ZeroMemory(plaintext);
90 }
92 default:
93 throw global::Interop.BCrypt.CreateCryptographicException(nTSTATUS);
94 }
95 }
96 }
97 }
98 }
99 }
100 }
static string Cryptography_AuthTagMismatch
static unsafe ref readonly byte GetNonNullPinnableReference(ReadOnlySpan< byte > buffer)