summaryrefslogtreecommitdiff
path: root/src/mscorlib/corefx/Interop/Windows/BCrypt
diff options
context:
space:
mode:
Diffstat (limited to 'src/mscorlib/corefx/Interop/Windows/BCrypt')
-rw-r--r--src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs26
-rw-r--r--src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.NTSTATUS.cs19
2 files changed, 45 insertions, 0 deletions
diff --git a/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs b/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
new file mode 100644
index 0000000000..d2ce4131b0
--- /dev/null
+++ b/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
@@ -0,0 +1,26 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+
+internal partial class Interop
+{
+ internal partial class BCrypt
+ {
+ internal static unsafe NTSTATUS 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;
+
+ [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+ private static unsafe extern NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
+ }
+}
diff --git a/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.NTSTATUS.cs b/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.NTSTATUS.cs
new file mode 100644
index 0000000000..49d674f399
--- /dev/null
+++ b/src/mscorlib/corefx/Interop/Windows/BCrypt/Interop.NTSTATUS.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+using System;
+
+internal partial class Interop
+{
+ internal partial class BCrypt
+ {
+ internal enum NTSTATUS : uint
+ {
+ STATUS_SUCCESS = 0x0,
+ STATUS_NOT_FOUND = 0xc0000225,
+ STATUS_INVALID_PARAMETER = 0xc000000d,
+ STATUS_NO_MEMORY = 0xc0000017,
+ }
+ }
+}