Handle "too small" success from CNG and clear out decryption residuals
authorJeremy Barton <jbarton@microsoft.com>
Tue, 8 Oct 2019 20:37:58 +0000 (13:37 -0700)
committerGitHub <noreply@github.com>
Tue, 8 Oct 2019 20:37:58 +0000 (13:37 -0700)
commitc518055310888674f820f4198e4ef9d41e046f03
treea1a6a18595f9a3ec85930680c6e4fdb8a1386f91
parentd69397eb532b36675528f4a80f818eda51202872
Handle "too small" success from CNG and clear out decryption residuals

* When NCryptEncrypt or NCryptDecrypt reports success with a cbResult value that doesn't make sense, normalize the error to NTE_BUFFER_TOO_SMALL.
* When resizing arrays for the array-returning implementation, clear out the temporary arrays to reduce the amount of time they're sitting in memory before the GC clears the memory for reissuance.

Commit migrated from https://github.com/dotnet/corefx/commit/7c586d32edce94c910fc8b402f4adedaa3cf05fd
src/libraries/Common/src/System/Security/Cryptography/RSACng.EncryptDecrypt.cs