Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs')
-rw-r--r--src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs30
1 files changed, 2 insertions, 28 deletions
diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs b/src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
index bc357125b..9d072a3b0 100644
--- a/src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
+++ b/src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
@@ -10,35 +10,9 @@ internal partial class Interop
{
internal partial class BCrypt
{
- internal static unsafe int BCryptGenRandom(byte* pbBuffer, int count)
- {
- Debug.Assert(pbBuffer != null);
- Debug.Assert(count >= 0);
-
- return BCryptGenRandom(IntPtr.Zero, pbBuffer, count, BCRYPT_USE_SYSTEM_PREFERRED_RNG);
- }
-
- private const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
- internal const int STATUS_SUCCESS = 0x0;
- internal const int STATUS_NO_MEMORY = unchecked((int)0xC0000017);
+ internal const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
[DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
- private static unsafe extern int BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
- }
-
- internal static unsafe void GetRandomBytes(byte* buffer, int length)
- {
- int status = BCrypt.BCryptGenRandom(buffer, length);
- if (status != BCrypt.STATUS_SUCCESS)
- {
- if (status == BCrypt.STATUS_NO_MEMORY)
- {
- throw new OutOfMemoryException();
- }
- else
- {
- throw new InvalidOperationException();
- }
- }
+ internal static extern unsafe NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
}
}