diff --git a/wrapper/CSharp/include.am b/wrapper/CSharp/include.am
index 549d7efb86..585ac9ae9c 100644
--- a/wrapper/CSharp/include.am
+++ b/wrapper/CSharp/include.am
@@ -32,6 +32,7 @@ EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.Designer.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.resx
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/X509.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Client/App.config
@@ -40,3 +41,7 @@ EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Client/Properties/Settings.Designer.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Client/Properties/Settings.settings
EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.cs
EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Client/wolfSSL-TLS-Client.csproj
+EXTRA_DIST+= wrapper/CSharp/wolfCrypt-Test/App.config
+EXTRA_DIST+= wrapper/CSharp/wolfCrypt-Test/Properties/AssemblyInfo.cs
+EXTRA_DIST+= wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs
+EXTRA_DIST+= wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.csproj
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfCrypt-Test/App.config b/wrapper/CSharp/wolfCrypt-Test/App.config
new file mode 100755
index 0000000000..b540b1fdf3
--- /dev/null
+++ b/wrapper/CSharp/wolfCrypt-Test/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfCrypt-Test/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfCrypt-Test/Properties/AssemblyInfo.cs
new file mode 100755
index 0000000000..ed34d06a03
--- /dev/null
+++ b/wrapper/CSharp/wolfCrypt-Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("wolfCrypt-Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("wolfSSL")]
+[assembly: AssemblyProduct("wolfCrypt-Test")]
+[assembly: AssemblyCopyright("Copyright wolfSSL 2020")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("a4f4a244-1306-47f4-a168-31f78d7362fa")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs b/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs
new file mode 100755
index 0000000000..8c749486d1
--- /dev/null
+++ b/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.cs
@@ -0,0 +1,72 @@
+/* wolfCrypt-Test.cs
+ *
+ * Copyright (C) 2006-2020 wolfSSL Inc.
+ *
+ * This file is part of wolfSSL.
+ *
+ * wolfSSL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wolfSSL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
+ */
+
+/* Tests for the wolfCrypt C# wrapper */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using wolfSSL.CSharp;
+
+public class wolfCrypt_Test_CSharp
+{
+ private static void random_test()
+ {
+ int ret, i, zeroCount = 0;
+ Byte[] data = new Byte[128];
+
+ /* Random Test */
+ ret = wolfcrypt.Random(data, data.Length);
+ if (ret == 0) {
+ /* Check for 0's */
+ for (i=0; i<(int)data.Length; i++) {
+ if (data[i] == 0) {
+ zeroCount++;
+ }
+ }
+ if (zeroCount == data.Length) {
+ Console.WriteLine("RNG zero check error");
+ }
+ else {
+ Console.WriteLine("RNG Test Passed\n");
+ }
+ }
+ else {
+ Console.WriteLine("RNG Error" + wolfcrypt.GetError(ret));
+ }
+ }
+
+ private static void ecc_test()
+ {
+
+ }
+
+ public static void Main(string[] args)
+ {
+ wolfcrypt.Init();
+
+ random_test();
+ ecc_test();
+
+ wolfcrypt.Cleanup();
+ }
+}
diff --git a/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.csproj b/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.csproj
new file mode 100755
index 0000000000..dde3208894
--- /dev/null
+++ b/wrapper/CSharp/wolfCrypt-Test/wolfCrypt-Test.csproj
@@ -0,0 +1,123 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}
+ Exe
+ Properties
+ wolfCrypt_Test
+ wolfCrypt-Test
+ v4.5
+ 512
+ publish\
+ true
+ Disk
+ false
+ Foreground
+ 7
+ Days
+ false
+ false
+ true
+ 0
+ 1.0.0.%2a
+ false
+ false
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\DLL Debug\
+ DEBUG;TRACE
+ prompt
+ 3
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\DLL Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+ true
+ ..\x64\DLL Debug\
+ DEBUG;TRACE
+ 4
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ ..\x64\DLL Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52609808-0418-46d3-8e17-141927a1a39a}
+ wolfSSL_CSharp
+
+
+
+
+ False
+ Microsoft .NET Framework 4.5 %28x86 and x64%29
+ true
+
+
+ False
+ .NET Framework 3.5 SP1 Client Profile
+ false
+
+
+ False
+ .NET Framework 3.5 SP1
+ false
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL_CSharp.sln b/wrapper/CSharp/wolfSSL_CSharp.sln
index f3b4dc7074..fe6e314b86 100755
--- a/wrapper/CSharp/wolfSSL_CSharp.sln
+++ b/wrapper/CSharp/wolfSSL_CSharp.sln
@@ -29,16 +29,30 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-TLS-Client", "wolfS
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-TLS-ServerThreaded", "wolfSSL-TLS-ServerThreaded\wolfSSL-TLS-ServerThreaded.csproj", "{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfCrypt-Test", "wolfCrypt-Test\wolfCrypt-Test.csproj", "{A4F4A244-1306-47F4-A168-31F78D7362FA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
DLL Debug|Any CPU = DLL Debug|Any CPU
DLL Debug|Win32 = DLL Debug|Win32
DLL Debug|x64 = DLL Debug|x64
DLL Release|Any CPU = DLL Release|Any CPU
DLL Release|Win32 = DLL Release|Win32
DLL Release|x64 = DLL Release|x64
+ Release|Any CPU = Release|Any CPU
+ Release|Win32 = Release|Win32
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Win32.Build.0 = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|x64.ActiveCfg = Debug|x64
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|x64.Build.0 = Debug|x64
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -51,6 +65,18 @@ Global
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Win32.Build.0 = Release|Any CPU
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|x64.ActiveCfg = Release|x64
{52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|x64.Build.0 = Release|x64
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Win32.ActiveCfg = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Win32.Build.0 = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|x64.ActiveCfg = Release|x64
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|x64.Build.0 = Release|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Win32.Build.0 = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|x64.ActiveCfg = Debug|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|x64.Build.0 = Debug|x64
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -63,6 +89,18 @@ Global
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Win32.Build.0 = Release|Any CPU
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|x64.ActiveCfg = Release|x64
{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|x64.Build.0 = Release|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Win32.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Win32.Build.0 = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|x64.ActiveCfg = Release|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|x64.Build.0 = Release|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Win32.Build.0 = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|x64.ActiveCfg = Debug|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|x64.Build.0 = Debug|x64
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -75,6 +113,18 @@ Global
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Win32.Build.0 = Release|Any CPU
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|x64.ActiveCfg = Release|x64
{030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|x64.Build.0 = Release|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Win32.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Win32.Build.0 = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|x64.ActiveCfg = Release|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|x64.Build.0 = Release|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Win32.Build.0 = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|x64.ActiveCfg = Debug|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|x64.Build.0 = Debug|x64
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -87,6 +137,18 @@ Global
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Win32.Build.0 = Release|Any CPU
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|x64.ActiveCfg = Release|x64
{730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|x64.Build.0 = Release|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Any CPU.Build.0 = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Win32.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Win32.Build.0 = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|x64.ActiveCfg = Release|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|x64.Build.0 = Release|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Win32.Build.0 = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|x64.ActiveCfg = Debug|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|x64.Build.0 = Debug|x64
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -99,6 +161,17 @@ Global
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Win32.Build.0 = Release|Any CPU
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|x64.ActiveCfg = Release|x64
{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|x64.Build.0 = Release|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Win32.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Win32.Build.0 = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|x64.ActiveCfg = Release|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|x64.Build.0 = Release|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Win32.ActiveCfg = Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Win32.Build.0 = Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|x64.ActiveCfg = Debug|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|x64.Build.0 = Debug|x64
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Any CPU.ActiveCfg = DLL Debug|Win32
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Any CPU.Build.0 = DLL Debug|Win32
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32
@@ -111,6 +184,16 @@ Global
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|Win32.Build.0 = DLL Release|Win32
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|x64.ActiveCfg = DLL Release|x64
{73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|x64.Build.0 = DLL Release|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Any CPU.ActiveCfg = Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Win32.ActiveCfg = Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Win32.Build.0 = Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|x64.ActiveCfg = Release|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|x64.Build.0 = Release|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Debug|Win32.ActiveCfg = Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Debug|Win32.Build.0 = Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Debug|x64.ActiveCfg = Debug|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Debug|x64.Build.0 = Debug|x64
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Any CPU.ActiveCfg = DLL Debug|Win32
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Any CPU.Build.0 = DLL Debug|Win32
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32
@@ -123,6 +206,17 @@ Global
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|Win32.Build.0 = DLL Release|Win32
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|x64.ActiveCfg = DLL Release|x64
{611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|x64.Build.0 = DLL Release|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|Any CPU.ActiveCfg = Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|Win32.ActiveCfg = Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|Win32.Build.0 = Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|x64.ActiveCfg = Release|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|x64.Build.0 = Release|x64
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|Win32.Build.0 = Debug|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|x64.ActiveCfg = Debug|x64
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Debug|x64.Build.0 = Debug|x64
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -135,6 +229,18 @@ Global
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Release|Win32.Build.0 = Release|Any CPU
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Release|x64.ActiveCfg = Release|x64
{E2415718-0A15-48DB-A774-01FB0093B626}.DLL Release|x64.Build.0 = Release|x64
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|Win32.ActiveCfg = Release|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|Win32.Build.0 = Release|Any CPU
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|x64.ActiveCfg = Release|x64
+ {E2415718-0A15-48DB-A774-01FB0093B626}.Release|x64.Build.0 = Release|x64
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|Win32.Build.0 = Debug|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|x64.ActiveCfg = Debug|x64
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Debug|x64.Build.0 = Debug|x64
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -147,6 +253,18 @@ Global
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Release|Win32.Build.0 = Release|Any CPU
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Release|x64.ActiveCfg = Release|x64
{B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.DLL Release|x64.Build.0 = Release|x64
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|Win32.ActiveCfg = Release|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|Win32.Build.0 = Release|Any CPU
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|x64.ActiveCfg = Release|x64
+ {B9DF2972-38F6-4B42-B228-E3C1A47DF8E8}.Release|x64.Build.0 = Release|x64
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|Win32.Build.0 = Debug|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|x64.ActiveCfg = Debug|x64
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Debug|x64.Build.0 = Debug|x64
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
@@ -159,6 +277,36 @@ Global
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Release|Win32.Build.0 = Release|Any CPU
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Release|x64.ActiveCfg = Release|x64
{8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.DLL Release|x64.Build.0 = Release|x64
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|Win32.ActiveCfg = Release|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|Win32.Build.0 = Release|Any CPU
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|x64.ActiveCfg = Release|x64
+ {8ABD2E8F-AEE7-40ED-A966-900ACFAE555F}.Release|x64.Build.0 = Release|x64
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|Win32.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Debug|x64.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|x64.ActiveCfg = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Debug|x64.Build.0 = Debug|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|Win32.Build.0 = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|x64.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.DLL Release|x64.Build.0 = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|Win32.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|Win32.Build.0 = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|x64.ActiveCfg = Release|Any CPU
+ {A4F4A244-1306-47F4-A168-31F78D7362FA}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs b/wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs
new file mode 100755
index 0000000000..d38f7da0db
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/wolfCrypt.cs
@@ -0,0 +1,371 @@
+/* wolfCrypt.cs
+ *
+ * Copyright (C) 2006-2020 wolfSSL Inc.
+ *
+ * This file is part of wolfSSL.
+ *
+ * wolfSSL is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * wolfSSL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
+ */
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+
+namespace wolfSSL.CSharp {
+ public class wolfcrypt
+ {
+ private const string wolfssl_dll = "wolfssl.dll";
+
+ /********************************
+ * Init wolfSSL library
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wolfCrypt_Init();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wolfCrypt_Cleanup();
+
+
+ /********************************
+ * Random
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static IntPtr wc_rng_new(IntPtr nonce, UInt32 nonceSz, IntPtr heap);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static void wc_rng_free(IntPtr rng);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wc_RNG_GenerateBlock(IntPtr rng, IntPtr output, UInt32 sz);
+
+ /********************************
+ * ECC
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static IntPtr wc_ecc_key_new(IntPtr heap);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static void wc_ecc_key_free(IntPtr key);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wc_ecc_make_key_ex(IntPtr rng, int keysize, IntPtr key, int curve_id);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wc_ecc_sign_hash(IntPtr hashPtr, uint hashlen, IntPtr sigPtr, IntPtr siglen, IntPtr rng, IntPtr key);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wc_ecc_verify_hash(IntPtr sigPtr, uint siglen, IntPtr hashPtr, uint hashlen, IntPtr res, IntPtr key);
+
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static int wc_EccPrivateKeyDecode(IntPtr keyBuf, IntPtr idx, IntPtr key, uint keyBufSz);
+
+ /********************************
+ * Logging
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ private extern static IntPtr wc_GetErrorString(int error);
+
+ public delegate void loggingCb(int lvl, StringBuilder msg);
+ private static loggingCb internal_log;
+
+ ///
+ /// Log a message to set logging function
+ ///
+ /// Level of log message
+ /// Message to log
+ private static void log(int lvl, string msg)
+ {
+ /* if log is not set then print nothing */
+ if (internal_log == null)
+ return;
+ StringBuilder ptr = new StringBuilder(msg);
+ internal_log(lvl, ptr);
+ }
+
+ [DllImport("kernel32.dll", EntryPoint = "RtlFillMemory", SetLastError = false)]
+ private extern static void RtlFillMemory(IntPtr destination, uint length, byte fill);
+
+ /********************************
+ * Enum types from wolfSSL library
+ */
+
+ /* Logging levels */
+ public static readonly int ERROR_LOG = 0;
+ public static readonly int INFO_LOG = 1;
+ public static readonly int ENTER_LOG = 2;
+ public static readonly int LEAVE_LOG = 3;
+ public static readonly int OTHER_LOG = 4;
+
+ /* Error codes */
+ public static readonly int SUCCESS = 0;
+ public static readonly int MEMORY_E = -125; /* out of memory error */
+ public static readonly int EXCEPTION_E = -1;
+
+
+ /***********************************************************************
+ * Class Public Functions
+ **********************************************************************/
+ ///
+ /// Initialize wolfCrypt library
+ ///
+ /// 0 on success
+ public static int Init()
+ {
+ int ret;
+ try {
+ ret = wolfCrypt_Init();
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "wolfCrypt init error " + e.ToString());
+ ret = EXCEPTION_E;
+ }
+ return ret;
+ }
+
+ ///
+ /// Clean up wolfCrypt library memory
+ ///
+ /// 0 on success
+ public static int Cleanup()
+ {
+ int ret;
+ try {
+ ret = wolfCrypt_Cleanup();
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "wolfCrypt cleanup error " + e.ToString());
+ ret = EXCEPTION_E;
+ }
+ return ret;
+ }
+
+
+ /***********************************************************************
+ * Random
+ **********************************************************************/
+
+ ///
+ /// Create new WC_RNG context
+ ///
+ /// Pointer to allocated WC_RNG or null
+ public static IntPtr RandomNew()
+ {
+ IntPtr rng;
+ try {
+ /* Allocate and init new WC_RNG structure */
+ rng = wc_rng_new(
+ IntPtr.Zero, 0, /* Nonce (optional / used by FIPS only) */
+ IntPtr.Zero); /* Heap hint for static memory only */
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "random new exception " + e.ToString());
+ rng = IntPtr.Zero;
+ }
+ return rng;
+ }
+
+ ///
+ /// Free WC_RNG context
+ ///
+ /// Pointer to allocated WC_RNG
+ public static void RandomFree(IntPtr rng)
+ {
+ if (rng != IntPtr.Zero) {
+ /* Free WC_RNG structure */
+ wc_rng_free(rng);
+ }
+ }
+
+ ///
+ /// Generate random data (use existing WC_RNG context)
+ ///
+ /// WC_RNG created from RandomNew()
+ /// buffer to populate random data
+ /// size of buffer
+ /// 0=success or negative for error
+ public static int Random(IntPtr rng, byte[] buf, int sz)
+ {
+ int ret;
+ IntPtr data;
+
+ try {
+ /* Allocate global buffer for wolfAPI random */
+ data = Marshal.AllocHGlobal(sz);
+ if (data != IntPtr.Zero) {
+ /* Generate random block */
+ ret = wc_RNG_GenerateBlock(rng, data, Convert.ToUInt32(sz));
+ if (ret == 0) {
+ /* copy returned data */
+ Marshal.Copy(data, buf, 0, sz);
+ }
+ else {
+ log(ERROR_LOG, "random generate block error " + ret + ": " + GetError(ret));
+ }
+ Marshal.FreeHGlobal(data);
+ }
+ else {
+ ret = MEMORY_E;
+ }
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "random generate block exception " + e.ToString());
+ ret = EXCEPTION_E;
+ }
+
+ return ret;
+ }
+
+ ///
+ /// Generate random data (single shot)
+ ///
+ /// buffer to populate random data
+ /// size of buffer
+ /// 0=success or negative for error
+ public static int Random(byte[] buf, int sz)
+ {
+ int ret;
+ IntPtr rng = RandomNew();
+ if (rng == IntPtr.Zero) {
+ return MEMORY_E;
+ }
+ ret = Random(rng, buf, sz);
+ RandomFree(rng);
+ return ret;
+ }
+
+
+ /***********************************************************************
+ * ECC
+ **********************************************************************/
+
+ ///
+ /// Generate a new ECC private / public key pair
+ ///
+ /// Key size in bytes (example: SECP256R1 = 32)
+ /// Allocated ECC key structure or null
+ public static IntPtr EccMakeKey(int keysize)
+ {
+ int ret;
+ IntPtr key = IntPtr.Zero;
+ IntPtr rng = IntPtr.Zero;
+ try {
+ /* Allocate and init new WC_RNG structure */
+ key = wc_ecc_key_new(IntPtr.Zero);
+ if (key != IntPtr.Zero) {
+ rng = RandomNew();
+ ret = wc_ecc_make_key_ex(rng, keysize, key, 0); /* 0=use default curve */
+ if (ret != 0) {
+ EccFreeKey(key);
+ key = IntPtr.Zero;
+ }
+ RandomFree(rng);
+ rng = IntPtr.Zero;
+ }
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "ECC make key exception " + e.ToString());
+ RandomFree(rng);
+ EccFreeKey(key);
+ key = IntPtr.Zero;
+ }
+ return key;
+ }
+
+ ///
+ /// Generate a new ECC private / public key pair
+ ///
+ /// ASN.1 private key buffer (see ecc_clikey_der_256)
+ /// Allocated ECC key structure or null
+ public static IntPtr EccImportKey(byte[] keyASN1)
+ {
+ int ret;
+ IntPtr key = IntPtr.Zero;
+ try {
+ key = wc_ecc_key_new(IntPtr.Zero);
+ if (key != IntPtr.Zero) {
+ IntPtr idx = Marshal.AllocHGlobal(sizeof(uint));
+ IntPtr keydata = Marshal.AllocHGlobal(keyASN1.Length);
+ RtlFillMemory(idx, sizeof(uint), 0); /* zero init */
+ Marshal.Copy(keyASN1, 0, keydata, keyASN1.Length);
+ ret = wc_EccPrivateKeyDecode(keydata, idx, key, Convert.ToUInt32(keyASN1.Length));
+ if (ret != 0) {
+ EccFreeKey(key);
+ key = IntPtr.Zero;
+ }
+ Marshal.FreeHGlobal(idx); /* not used */
+ Marshal.FreeHGlobal(keydata);
+ }
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "ECC make key exception " + e.ToString());
+ EccFreeKey(key); /* make sure its free'd */
+ key = IntPtr.Zero;
+ }
+ return key;
+ }
+
+ public static int EccSign(IntPtr key, byte[] hash, byte[] signature)
+ {
+ //private extern static int wc_ecc_sign_hash(IntPtr inPtr, UInt32 inlen, IntPtr outPtr, IntPtr outlen, IntPtr rng, IntPtr key);
+ return SUCCESS;
+ }
+
+ public static int EccVerify(IntPtr key, byte[] signature, byte[] hash)
+ {
+ //private extern static int wc_ecc_verify_hash(IntPtr sigPtr, UInt32 siglen, IntPtr hashPtr, UInt32 hashlen, IntPtr res, IntPtr key);
+ return SUCCESS;
+ }
+
+ ///
+ /// Free an ECC key structure
+ ///
+ /// ECC key structure allocated using EccMakeKey() or EccImportKey()
+ public static void EccFreeKey(IntPtr key)
+ {
+ if (key != IntPtr.Zero) {
+ wc_ecc_key_free(key);
+ }
+ }
+
+
+
+ /***********************************************************************
+ * Logging / Other
+ **********************************************************************/
+
+ ///
+ /// Set the function to use for logging
+ ///
+ /// Function that conforms as to loggingCb
+ /// 0 on success
+ public static int SetLogging(loggingCb input)
+ {
+ internal_log = input;
+ return SUCCESS;
+ }
+
+ ///
+ /// Get error string for wolfCrypt error codes
+ ///
+ /// Negative error number from wolfCrypt API
+ /// Error string
+ public static string GetError(int error)
+ {
+ try {
+ IntPtr errStr = wc_GetErrorString(error);
+ return Marshal.PtrToStringAnsi(errStr);
+ }
+ catch (Exception e) {
+ log(ERROR_LOG, "Get error exception " + e.ToString());
+ return string.Empty;
+ }
+ }
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
index a2019cadb4..7774d63229 100644
--- a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
+++ b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
@@ -187,8 +187,8 @@ public IntPtr get_ssl()
}
public void free()
{
- log(INFO_LOG, "freeing ssl handle");
-
+ log(INFO_LOG, "freeing ssl handle");
+
if (!Object.Equals(this.fd_pin, default(GCHandle)))
{
this.fd_pin.Free();
@@ -340,9 +340,9 @@ public void free()
private extern static int wolfSSL_get_error(IntPtr ssl, int err);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void loggingCb(int lvl, StringBuilder msg);
- private static loggingCb internal_log;
+ private static loggingCb internal_log;
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static void wolfSSL_Debugging_ON();
+ private extern static void wolfSSL_Debugging_ON();
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static void wolfSSL_Debugging_OFF();
@@ -355,33 +355,33 @@ public void free()
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static int wolfSSL_SetTmpDH_file(IntPtr ssl, StringBuilder dhParam, int type);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static int wolfSSL_CTX_SetTmpDH_file(IntPtr ctx, StringBuilder dhParam, int type);
-
-
+ private extern static int wolfSSL_CTX_SetTmpDH_file(IntPtr ctx, StringBuilder dhParam, int type);
+
+
/********************************
* Verify Callback
- */
+ */
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate int CallbackVerify_delegate(int ret, IntPtr x509_ctx);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static void wolfSSL_CTX_set_verify(IntPtr ctx, int mode, CallbackVerify_delegate vc);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static void wolfSSL_set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc);
-
-
+ private extern static void wolfSSL_set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc);
+
+
/********************************
* X509 Store
- */
+ */
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr wolfSSL_X509_STORE_CTX_get_current_cert(IntPtr x509Ctx);
+ private extern static IntPtr wolfSSL_X509_STORE_CTX_get_current_cert(IntPtr x509Ctx);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static int wolfSSL_X509_STORE_CTX_get_error(IntPtr sk);
+ private extern static int wolfSSL_X509_STORE_CTX_get_error(IntPtr sk);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static IntPtr wolfSSL_X509_STORE_GetCerts(IntPtr x509Ctx);
+ private extern static IntPtr wolfSSL_X509_STORE_GetCerts(IntPtr x509Ctx);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static int wolfSSL_sk_X509_num(IntPtr sk);
+ private extern static int wolfSSL_sk_X509_num(IntPtr sk);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
- private extern static void wolfSSL_sk_X509_free(IntPtr sk);
+ private extern static void wolfSSL_sk_X509_free(IntPtr sk);
[DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
private extern static IntPtr wolfSSL_sk_X509_pop(IntPtr sk);
@@ -391,8 +391,8 @@ public void free()
*/
public static readonly int SSL_FILETYPE_PEM = 1;
public static readonly int SSL_FILETYPE_ASN1 = 2;
- public static readonly int SSL_FILETYPE_RAW = 3;
-
+ public static readonly int SSL_FILETYPE_RAW = 3;
+
public static readonly int SSL_VERIFY_NONE = 0;
public static readonly int SSL_VERIFY_PEER = 1;
public static readonly int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2;
@@ -544,7 +544,7 @@ private static int wolfSSL_dtlsCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr c
{
if (sz <= 0)
{
- log(ERROR_LOG, "wolfssl dtls send error, size less than 0");
+ log(ERROR_LOG, "wolfssl DTLS send error, size less than 0");
return wolfssl.CBIO_ERR_GENERAL;
}
@@ -580,7 +580,7 @@ private static int wolfSSL_dtlsCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr c
{
if (sz <= 0)
{
- log(ERROR_LOG, "wolfssl dtls receive error, size less than 0");
+ log(ERROR_LOG, "wolfssl DTLS receive error, size less than 0");
return wolfssl.CBIO_ERR_GENERAL;
}
@@ -723,7 +723,7 @@ public static int read(IntPtr ssl, StringBuilder buf, int sz)
int ret;
byte[] msg;
- buf.Clear(); /* Clear incomming buffer */
+ buf.Clear(); /* Clear incoming buffer */
if (sslCtx == IntPtr.Zero)
{
@@ -924,7 +924,7 @@ public static int shutdown(IntPtr ssl)
}
catch (Exception e)
{
- log(ERROR_LOG, "wolfssl shutdwon error " + e.ToString());
+ log(ERROR_LOG, "wolfssl shutdown error " + e.ToString());
return FAILURE;
}
}
@@ -1188,8 +1188,8 @@ public static int set_fd(IntPtr ssl, Socket fd)
if (ssl == IntPtr.Zero)
{
return FAILURE;
- }
-
+ }
+
try
{
if (!fd.Equals(null))
@@ -1571,7 +1571,7 @@ public static string get_current_cipher(IntPtr ssl)
///
- /// Set available cipher suites for all ssl structs created from ctx
+ /// Set available cipher suites for all ssl struct's created from ctx
///
/// CTX structure to set
/// List full of ciphers suites
@@ -1933,9 +1933,9 @@ public static int set_verify(IntPtr ssl, int mode, CallbackVerify_delegate vc)
log(ERROR_LOG, "wolfssl set verify error " + e.ToString());
return FAILURE;
}
- }
-
-
+ }
+
+
///
/// Set the certificate verification mode and optional callback function
///
@@ -1954,7 +1954,7 @@ public static X509 X509_STORE_CTX_get_current_cert(IntPtr x509Ctx)
}
IntPtr x509 = wolfSSL_X509_STORE_CTX_get_current_cert(x509Ctx);
if (x509 != IntPtr.Zero) {
- return new X509(x509, false);
+ return new X509(x509, false);
}
return ret;
}
@@ -1963,9 +1963,9 @@ public static X509 X509_STORE_CTX_get_current_cert(IntPtr x509Ctx)
log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
return ret;
}
- }
-
-
+ }
+
+
///
/// Gets all of the certificates from store
///
@@ -1983,17 +1983,17 @@ public static X509[] X509_STORE_CTX_get_certs(IntPtr x509Ctx)
IntPtr sk = wolfSSL_X509_STORE_GetCerts(x509Ctx);
if (sk != IntPtr.Zero) {
int i;
- int numCerts = wolfSSL_sk_X509_num(sk);
- ret = new X509[numCerts];
-
- for (i = 0; i < numCerts; i++) {
- IntPtr current = wolfSSL_sk_X509_pop(sk);
- if (current != IntPtr.Zero)
- {
- ret[i] = new X509(current, true);
- }
- }
- wolfSSL_sk_X509_free(sk);
+ int numCerts = wolfSSL_sk_X509_num(sk);
+ ret = new X509[numCerts];
+
+ for (i = 0; i < numCerts; i++) {
+ IntPtr current = wolfSSL_sk_X509_pop(sk);
+ if (current != IntPtr.Zero)
+ {
+ ret[i] = new X509(current, true);
+ }
+ }
+ wolfSSL_sk_X509_free(sk);
}
return ret;
@@ -2003,9 +2003,9 @@ public static X509[] X509_STORE_CTX_get_certs(IntPtr x509Ctx)
log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
return ret;
}
- }
-
-
+ }
+
+
///
/// Get the current WOLFSSL_X509_STORE_CTX error value
///
@@ -2019,29 +2019,29 @@ public static int X509_STORE_CTX_get_error(IntPtr x509Ctx)
log(ERROR_LOG, "pointer passed in was not set");
return -1;
}
- return wolfSSL_X509_STORE_CTX_get_error(x509Ctx);
+ return wolfSSL_X509_STORE_CTX_get_error(x509Ctx);
}
catch (Exception e)
{
log(ERROR_LOG, "wolfssl WOLFSSL_X509_STORE_CTX error " + e.ToString());
return -1;
}
- }
-
- ///
- /// Print low level C library debug messages to stdout when compiled with macro DEBUG_WOLFSSL
- ///
- public static void Debugging_ON()
- {
- wolfSSL_Debugging_ON();
- }
-
- ///
- /// Turn off low level C debug messages
- ///
- public static void Debugging_OFF()
- {
- wolfSSL_Debugging_OFF();
+ }
+
+ ///
+ /// Print low level C library debug messages to stdout when compiled with macro DEBUG_WOLFSSL
+ ///
+ public static void Debugging_ON()
+ {
+ wolfSSL_Debugging_ON();
+ }
+
+ ///
+ /// Turn off low level C debug messages
+ ///
+ public static void Debugging_OFF()
+ {
+ wolfSSL_Debugging_OFF();
}
///
diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
index 6d5c854dc1..3cd6a5bcdd 100755
--- a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
+++ b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
@@ -59,6 +59,7 @@
+