From 473c0e3b39355427640d85e21dfa53fa2d8d9b12 Mon Sep 17 00:00:00 2001
From: Bepis <36346617+bbepis@users.noreply.github.com>
Date: Fri, 5 Apr 2019 22:42:09 +1100
Subject: [PATCH] Add crypto entrypoint
---
BepInEx.Bootstrap/BepInEx.Bootstrap.csproj | 1 +
BepInEx.Bootstrap/RngEntrypoint.cs | 34 ++++++++++++++++++++++
2 files changed, 35 insertions(+)
create mode 100644 BepInEx.Bootstrap/RngEntrypoint.cs
diff --git a/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj b/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj
index 856be7b..f6b4bfc 100644
--- a/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj
+++ b/BepInEx.Bootstrap/BepInEx.Bootstrap.csproj
@@ -28,6 +28,7 @@
+
diff --git a/BepInEx.Bootstrap/RngEntrypoint.cs b/BepInEx.Bootstrap/RngEntrypoint.cs
new file mode 100644
index 0000000..e45aade
--- /dev/null
+++ b/BepInEx.Bootstrap/RngEntrypoint.cs
@@ -0,0 +1,34 @@
+using System.Runtime.InteropServices;
+using System.Security.Cryptography;
+
+namespace BepInEx.Bootstrap
+{
+ [ComVisible(true)]
+ public class RngEntrypoint : RandomNumberGenerator
+ {
+ private RNGCryptoServiceProvider InternalProvider { get; }
+
+ static RngEntrypoint()
+ {
+ Entrypoint.Init();
+ }
+
+ public RngEntrypoint()
+ => InternalProvider = new RNGCryptoServiceProvider();
+
+ public RngEntrypoint(string str)
+ => InternalProvider = new RNGCryptoServiceProvider(str);
+
+ public RngEntrypoint(byte[] rgb)
+ => InternalProvider = new RNGCryptoServiceProvider(rgb);
+
+ public RngEntrypoint(CspParameters cspParams)
+ => InternalProvider = new RNGCryptoServiceProvider(cspParams);
+
+ public override void GetBytes(byte[] data)
+ => InternalProvider.GetBytes(data);
+
+ public override void GetNonZeroBytes(byte[] data)
+ => InternalProvider.GetNonZeroBytes(data);
+ }
+}
\ No newline at end of file