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:
authorMarek Safar <marek.safar@gmail.com>2018-09-19 15:19:22 +0300
committerGitHub <noreply@github.com>2018-09-19 15:19:22 +0300
commitefd29b5cf854679349066e22ef9038b8cfe76d94 (patch)
tree2de750c1ac8a487d7f6d149592a6362ade6a5a77 /src/System.Private.CoreLib/shared/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
parentf9124d69e41d42196510dd7234b2d53fed48ad4c (diff)
parent49f9ed0e66fc2d4cd682821396c6af5e80182048 (diff)
Merge pull request #25 from ntherning/bump-corert
Bump to latest upstream
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);
}
}