diff --git a/.gitignore b/.gitignore
index 8761d1658..f8ff8a508 100644
--- a/.gitignore
+++ b/.gitignore
@@ -169,3 +169,6 @@ wolfcrypt/user-crypto/missing
wolfcrypt/user-crypto/Makefile.in
wolfcrypt/user-crypto/lib/libusercrypto.*
*.hzs
+
+# wolfSSL CSharp wrapper
+wrapper/CSharp/x64/
diff --git a/Makefile.am b/Makefile.am
index 687895e34..e8941e6b5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,6 +70,7 @@ EXTRA_DIST+= wolfcrypt/user-crypto/lib/.gitkeep
EXTRA_DIST+= wolfcrypt/user-crypto/README.txt
EXTRA_DIST+= wolfcrypt/user-crypto/Makefile.am
+include wrapper/include.am
include cyassl/include.am
include wolfssl/include.am
include certs/include.am
diff --git a/wolfssl/wolfcrypt/settings.h b/wolfssl/wolfcrypt/settings.h
index c671df00a..c3a37c610 100644
--- a/wolfssl/wolfcrypt/settings.h
+++ b/wolfssl/wolfcrypt/settings.h
@@ -1000,6 +1000,16 @@ static char *fgets(char *buff, int sz, FILE *fp)
#endif
#endif
+/* C Sharp wrapper defines */
+#ifdef HAVE_CSHARP
+ #ifndef WOLFSSL_DTLS
+ #define WOLFSSL_DTLS
+ #endif
+ #undef NO_PSK
+ #undef NO_SHA256
+ #undef NO_DH
+#endif
+
/* Place any other flags or defines here */
diff --git a/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config
new file mode 100755
index 000000000..fad249e40
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/Properties/AssemblyInfo.cs
new file mode 100755
index 000000000..dc597de7c
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/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("wolfSSL-DTLS-PSK-Server")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("wolfSSL-DTLS-PSK-Server")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[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("77149dab-52f6-4b83-a9bd-da5beb402621")]
+
+// 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/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs
new file mode 100755
index 000000000..ecac02924
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs
@@ -0,0 +1,163 @@
+
+using System;
+
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using wolfSSL.CSharp;
+
+
+
+public class wolfSSL_DTLS_PSK_Server
+{
+
+
+ ///
+ /// Example of a PSK function call back
+ ///
+ /// pointer to ssl structure
+ /// identity of client connecting
+ /// buffer to hold key
+ /// max key size
+ /// size of key set
+ public static uint my_psk_server_cb(IntPtr ssl, string identity, IntPtr key, uint max_key)
+ {
+ /* perform a check on the identity sent across
+ * log function must be set for print out of logging information
+ */
+ wolfssl.log(1, "PSK Client Identity = " + identity);
+
+ /* Use desired key, note must be a key smaller than max key size parameter
+ Replace this with desired key. Is trivial one for testing */
+ if (max_key < 4)
+ return 0;
+ byte[] tmp = { 26, 43, 60, 77 };
+ Marshal.Copy(tmp, 0, key, 4);
+
+ return (uint)4;
+ }
+
+
+ public static void Main(string[] args)
+ {
+ IntPtr ctx;
+ IntPtr ssl;
+
+ /* These paths should be changed according to use */
+ string fileCert = @"server-cert.pem";
+ string fileKey = @"server-key.pem";
+ StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+ wolfssl.psk_delegate psk_cb = new wolfssl.psk_delegate(my_psk_server_cb);
+
+ StringBuilder buff = new StringBuilder(1024);
+ StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
+
+ wolfssl.Init();
+
+ Console.WriteLine("Calling ctx Init from wolfSSL");
+ ctx = wolfssl.CTX_dtls_new(wolfssl.useDTLSv1_2_server());
+ Console.WriteLine("Finished init of ctx .... now load in cert and key");
+
+ if (!File.Exists(fileCert) || !File.Exists(fileKey))
+ {
+ Console.WriteLine("Could not find cert or key file");
+ return;
+ }
+
+
+ if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error setting cert file");
+ return;
+ }
+
+
+ if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, 1) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error setting key file");
+ return;
+ }
+
+
+ /* Test psk use with DHE */
+ StringBuilder hint = new StringBuilder("cyassl server");
+ wolfssl.CTX_use_psk_identity_hint(ctx, hint);
+ wolfssl.CTX_set_psk_server_callback(ctx, psk_cb);
+
+ short minDhKey = 128;
+ wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+ Console.Write("Setting cipher suite to ");
+ StringBuilder set_cipher = new StringBuilder("DHE-PSK-AES128-CBC-SHA256");
+ Console.WriteLine(set_cipher);
+ if (wolfssl.CTX_set_cipher_list(ctx, set_cipher) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Failed to set cipher suite");
+ return;
+ }
+
+ IPAddress ip = IPAddress.Parse("0.0.0.0");
+ UdpClient udp = new UdpClient(11111);
+ IPEndPoint ep = new IPEndPoint(ip, 11111);
+ Console.WriteLine("Started UDP and waiting for a connection");
+
+ ssl = wolfssl.new_ssl(ctx);
+
+ if (wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting dhparam");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ if (wolfssl.set_dtls_fd(ssl, udp, ep) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ if (wolfssl.accept(ssl) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ /* print out results of TLS/SSL accept */
+ Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+ Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+ /* get connection information and print ip - port */
+ wolfssl.DTLS_con con = wolfssl.get_dtls_fd(ssl);
+ Console.Write("Connected to ip ");
+ Console.Write(con.ep.Address.ToString());
+ Console.Write(" on port ");
+ Console.WriteLine(con.ep.Port.ToString());
+
+ /* read information sent and send a reply */
+ if (wolfssl.read(ssl, buff, 1023) < 0)
+ {
+ Console.WriteLine("Error reading message");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+ Console.WriteLine(buff);
+
+ if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+ {
+ Console.WriteLine("Error writing message");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ Console.WriteLine("At the end freeing stuff");
+ wolfssl.shutdown(ssl);
+ wolfssl.free(ssl);
+ udp.Close();
+
+ wolfssl.CTX_free(ctx);
+ wolfssl.Cleanup();
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj
new file mode 100755
index 000000000..aae0b1f05
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj
@@ -0,0 +1,88 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}
+ Exe
+ Properties
+ wolfSSL_DTLS_PSK_Server
+ wolfSSL-DTLS-PSK-Server
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\DLL Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\DLL Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ ..\x64\DLL Debug\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ ..\x64\DLL Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52609808-0418-46d3-8e17-141927a1a39a}
+ wolfSSL_CSharp
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-DTLS-Server/App.config b/wrapper/CSharp/wolfSSL-DTLS-Server/App.config
new file mode 100755
index 000000000..fad249e40
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-Server/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-DTLS-Server/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfSSL-DTLS-Server/Properties/AssemblyInfo.cs
new file mode 100755
index 000000000..76d3c655d
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-Server/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("wolfSSL-DTLS-Server")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("wolfSSL-DTLS-Server")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[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("9da922fb-8459-479f-ab06-42b5c0378d2f")]
+
+// 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/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs
new file mode 100755
index 000000000..1fb9d3bf8
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs
@@ -0,0 +1,129 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using wolfSSL.CSharp;
+
+public class wolfSSL_DTLS_Server
+{
+ ///
+ /// Example of a logging function
+ ///
+ /// level of log
+ /// message to log
+ public static void standard_log(int lvl, StringBuilder msg)
+ {
+ Console.WriteLine(msg);
+ }
+
+
+ public static void Main(string[] args)
+ {
+ IntPtr ctx;
+ IntPtr ssl;
+
+ /* These paths should be changed for use */
+ string fileCert = @"server-cert.pem";
+ string fileKey = @"server-key.pem";
+ StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+ StringBuilder buff = new StringBuilder(1024);
+ StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
+
+ //example of function used for setting logging
+ wolfssl.SetLogging(standard_log);
+
+ wolfssl.Init();
+
+ Console.WriteLine("Calling ctx Init from wolfSSL");
+ ctx = wolfssl.CTX_dtls_new(wolfssl.useDTLSv1_2_server());
+ Console.WriteLine("Finished init of ctx .... now load in cert and key");
+
+ if (!File.Exists(fileCert) || !File.Exists(fileKey))
+ {
+ Console.WriteLine("Could not find cert or key file");
+ return;
+ }
+
+
+ if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error setting cert file");
+ return;
+ }
+
+
+ if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, 1) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error setting key file");
+ return;
+ }
+
+ short minDhKey = 128;
+ wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+
+ IPAddress ip = IPAddress.Parse("0.0.0.0");
+ UdpClient udp = new UdpClient(11111);
+ IPEndPoint ep = new IPEndPoint(ip, 11111);
+ Console.WriteLine("Started UDP and waiting for a connection");
+
+ ssl = wolfssl.new_ssl(ctx);
+
+ if (wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting dhparam");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ if (wolfssl.set_dtls_fd(ssl, udp, ep) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ if (wolfssl.accept(ssl) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ /* print out results of TLS/SSL accept */
+ Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+ Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+ /* get connection information and print ip - port */
+ wolfssl.DTLS_con con = wolfssl.get_dtls_fd(ssl);
+ Console.Write("Connected to ip ");
+ Console.Write(con.ep.Address.ToString());
+ Console.Write(" on port ");
+ Console.WriteLine(con.ep.Port.ToString());
+
+ /* read information sent and send a reply */
+ if (wolfssl.read(ssl, buff, 1023) < 0)
+ {
+ Console.WriteLine("Error reading message");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+ Console.WriteLine(buff);
+
+ if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+ {
+ Console.WriteLine("Error writing message");
+ Console.WriteLine(wolfssl.get_error(ssl));
+ return;
+ }
+
+ Console.WriteLine("At the end freeing stuff");
+ wolfssl.shutdown(ssl);
+ wolfssl.free(ssl);
+ udp.Close();
+
+ wolfssl.CTX_free(ctx);
+ wolfssl.Cleanup();
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj
new file mode 100755
index 000000000..2e8e63d8f
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj
@@ -0,0 +1,89 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}
+ Exe
+ Properties
+ wolfSSL_DTLS_Server
+ wolfSSL-DTLS-Server
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\DLL Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\DLL Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ ..\x64\DLL Debug\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+ 0
+
+
+ ..\x64\DLL Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52609808-0418-46d3-8e17-141927a1a39a}
+ wolfSSL_CSharp
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config
new file mode 100755
index 000000000..fad249e40
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-TLS-PSK-Server/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/Properties/AssemblyInfo.cs
new file mode 100755
index 000000000..6c0c13c43
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/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("wolfSSL-TLS-PSK-Server")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("wolfSSL-TLS-PSK-Server")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[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("1de70ade-16d5-4c90-9657-c19c2762bca6")]
+
+// 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/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs
new file mode 100755
index 000000000..64cc335f0
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs
@@ -0,0 +1,159 @@
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using wolfSSL.CSharp;
+
+
+
+public class wolfSSL_TLS_PSK_Server
+{
+
+
+ ///
+ /// Example of a PSK function call back
+ ///
+ /// pointer to ssl structure
+ /// identity of client connecting
+ /// buffer to hold key
+ /// max key size
+ /// size of key set
+ public static uint my_psk_server_cb(IntPtr ssl, string identity, IntPtr key, uint max_key)
+ {
+ /* perform a check on the identity sent across
+ * log function must be set for print out of logging information
+ */
+ wolfssl.log(1, "PSK Client Identity = " + identity);
+
+ /* Use desired key, note must be a key smaller than max key size parameter
+ Replace this with desired key. Is trivial one for testing */
+ if (max_key < 4)
+ return 0;
+ byte[] tmp = { 26, 43, 60, 77 };
+ Marshal.Copy(tmp, 0, key, 4);
+
+ return (uint)4;
+ }
+
+
+ public static void Main(string[] args)
+ {
+ IntPtr ctx;
+ IntPtr ssl;
+ Socket fd;
+
+ wolfssl.psk_delegate psk_cb = new wolfssl.psk_delegate(my_psk_server_cb);
+
+ /* These paths should be changed according to use */
+ string fileCert = @"server-cert.pem";
+ string fileKey = @"server-key.pem";
+ StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+ StringBuilder buff = new StringBuilder(1024);
+ StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
+
+ wolfssl.Init();
+
+ Console.WriteLine("Calling ctx Init from wolfSSL");
+ ctx = wolfssl.CTX_new(wolfssl.useTLSv1_2_server());
+ Console.WriteLine("Finished init of ctx .... now load in cert and key");
+
+ if (!File.Exists(fileCert) || !File.Exists(fileKey))
+ {
+ Console.WriteLine("Could not find cert or key file");
+ return;
+ }
+
+ if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting cert file");
+ return;
+ }
+
+ if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting key file");
+ return;
+ }
+
+
+ StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
+ wolfssl.get_ciphers(ciphers, 4096);
+ Console.WriteLine("Ciphers : " + ciphers.ToString());
+
+ short minDhKey = 128;
+ wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+ Console.Write("Setting cipher suite to ");
+ StringBuilder set_cipher = new StringBuilder("DHE-PSK-AES128-CBC-SHA256");
+ Console.WriteLine(set_cipher);
+ if (wolfssl.CTX_set_cipher_list(ctx, set_cipher) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Failed to set cipher suite");
+ return;
+ }
+
+ /* Test psk use with DHE */
+ StringBuilder hint = new StringBuilder("cyassl server");
+ if (wolfssl.CTX_use_psk_identity_hint(ctx, hint) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error setting hint");
+ return;
+ }
+ wolfssl.CTX_set_psk_server_callback(ctx, psk_cb);
+
+ /* set up TCP socket */
+ IPAddress ip = IPAddress.Parse("0.0.0.0"); //bind to any
+ TcpListener tcp = new TcpListener(ip, 11111);
+ tcp.Start();
+
+ Console.WriteLine("Started TCP and waiting for a connection");
+ fd = tcp.AcceptSocket();
+ ssl = wolfssl.new_ssl(ctx);
+
+ Console.WriteLine("Connection made wolfSSL_accept ");
+ if (wolfssl.set_fd(ssl, fd) != wolfssl.SUCCESS)
+ {
+ /* get and print out the error */
+ Console.Write(wolfssl.get_error(ssl));
+ return;
+ }
+
+ wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM);
+
+ if (wolfssl.accept(ssl) != wolfssl.SUCCESS)
+ {
+ /* get and print out the error */
+ Console.Write(wolfssl.get_error(ssl));
+ return;
+ }
+
+ /* print out results of TLS/SSL accept */
+ Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+ Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+ /* read and print out the message then reply */
+ if (wolfssl.read(ssl, buff, 1023) < 0)
+ {
+ Console.WriteLine("Error in read");
+ return;
+ }
+ Console.WriteLine(buff);
+
+ if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+ {
+ Console.WriteLine("Error in write");
+ return;
+ }
+
+ wolfssl.shutdown(ssl);
+ wolfssl.free(ssl);
+ fd.Close();
+
+ wolfssl.CTX_free(ctx);
+ wolfssl.Cleanup();
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj
new file mode 100755
index 000000000..3308ae37b
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj
@@ -0,0 +1,88 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}
+ Exe
+ Properties
+ wolfSSL_TLS_PSK_Server
+ wolfSSL-TLS-PSK-Server
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ ..\DLL Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ ..\DLL Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ ..\x64\DLL Debug\
+ DEBUG;TRACE
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+ ..\x64\DLL Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {52609808-0418-46d3-8e17-141927a1a39a}
+ wolfSSL_CSharp
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/App.config b/wrapper/CSharp/wolfSSL-TLS-Server/App.config
new file mode 100755
index 000000000..fad249e40
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfSSL-TLS-Server/Properties/AssemblyInfo.cs
new file mode 100755
index 000000000..762bc4d31
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/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("wolfSSL-TLS-Server")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("wolfSSL-TLS-Server")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[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("716e8f30-1318-4e3b-b788-d0380b397a4c")]
+
+// 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/wolfSSL-TLS-Server/Properties/Settings.Designer.cs b/wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.Designer.cs
new file mode 100755
index 000000000..6409d3ec6
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.17929
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace wolfSSL_TLS_CSharp.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.settings b/wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.settings
new file mode 100755
index 000000000..15034e76c
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.settings
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
new file mode 100755
index 000000000..190efe8c6
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
@@ -0,0 +1,121 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+using wolfSSL.CSharp;
+
+public class wolfSSL_TLS_CSHarp
+{
+ ///
+ /// Example of a logging function
+ ///
+ /// level of log
+ /// message to log
+ public static void standard_log(int lvl, StringBuilder msg)
+ {
+ Console.WriteLine(msg);
+ }
+
+ public static void Main(string[] args)
+ {
+ IntPtr ctx;
+ IntPtr ssl;
+ Socket fd;
+
+ /* These paths should be changed for use */
+ string fileCert = @"server-cert.pem";
+ string fileKey = @"server-key.pem";
+ StringBuilder dhparam = new StringBuilder("dh2048.pem");
+
+ StringBuilder buff = new StringBuilder(1024);
+ StringBuilder reply = new StringBuilder("Hello, this is the wolfSSL C# wrapper");
+
+ //example of function used for setting logging
+ wolfssl.SetLogging(standard_log);
+
+ wolfssl.Init();
+
+ Console.WriteLine("Calling ctx Init from wolfSSL");
+ ctx = wolfssl.CTX_new(wolfssl.usev23_server());
+ Console.WriteLine("Finished init of ctx .... now load in cert and key");
+
+ if (!File.Exists(fileCert) || !File.Exists(fileKey))
+ {
+ Console.WriteLine("Could not find cert or key file");
+ return;
+ }
+
+ if (wolfssl.CTX_use_certificate_file(ctx, fileCert, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting cert file");
+ return;
+ }
+
+ if (wolfssl.CTX_use_PrivateKey_file(ctx, fileKey, wolfssl.SSL_FILETYPE_PEM) != wolfssl.SUCCESS)
+ {
+ Console.WriteLine("Error in setting key file");
+ return;
+ }
+
+
+ StringBuilder ciphers = new StringBuilder(new String(' ', 4096));
+ wolfssl.get_ciphers(ciphers, 4096);
+ Console.WriteLine("Ciphers : " + ciphers.ToString());
+
+ short minDhKey = 128;
+ wolfssl.CTX_SetMinDhKey_Sz(ctx, minDhKey);
+
+ /* set up TCP socket */
+ IPAddress ip = IPAddress.Parse("0.0.0.0"); //bind to any
+ TcpListener tcp = new TcpListener(ip, 11111);
+ tcp.Start();
+
+ Console.WriteLine("Started TCP and waiting for a connection");
+ fd = tcp.AcceptSocket();
+ ssl = wolfssl.new_ssl(ctx);
+
+ Console.WriteLine("Connection made wolfSSL_accept ");
+ if (wolfssl.set_fd(ssl, fd) != wolfssl.SUCCESS)
+ {
+ /* get and print out the error */
+ Console.Write(wolfssl.get_error(ssl));
+ return;
+ }
+
+ wolfssl.SetTmpDH_file(ssl, dhparam, wolfssl.SSL_FILETYPE_PEM);
+
+ if (wolfssl.accept(ssl) != 1)
+ {
+ /* get and print out the error */
+ Console.Write(wolfssl.get_error(ssl));
+ return;
+ }
+
+ /* print out results of TLS/SSL accept */
+ Console.WriteLine("SSL version is " + wolfssl.get_version(ssl));
+ Console.WriteLine("SSL cipher suite is " + wolfssl.get_current_cipher(ssl));
+
+ /* read and print out the message then reply */
+ if (wolfssl.read(ssl, buff, 1023) < 0)
+ {
+ Console.WriteLine("Error in read");
+ return;
+ }
+ Console.WriteLine(buff);
+
+ if (wolfssl.write(ssl, reply, reply.Length) != reply.Length)
+ {
+ Console.WriteLine("Error in write");
+ return;
+ }
+
+ wolfssl.shutdown(ssl);
+ wolfssl.free(ssl);
+ fd.Close();
+
+ wolfssl.CTX_free(ctx);
+ wolfssl.Cleanup();
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj
new file mode 100755
index 000000000..f1ee88264
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj
@@ -0,0 +1,133 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}
+ Exe
+ Properties
+ wolfSSL_TLS_CSharp
+ wolfSSL-TLS-Server
+ 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
+
+
+
+
+
+
+
+
+
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+ {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
new file mode 100755
index 000000000..53c74f173
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp.sln
@@ -0,0 +1,252 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL_CSharp", "wolfSSL_CSharp\wolfSSL_CSharp.csproj", "{52609808-0418-46D3-8E17-141927A1A39A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {73973223-5EE8-41CA-8E88-1D60E89A237B} = {73973223-5EE8-41CA-8E88-1D60E89A237B}
+ EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-TLS-Server", "wolfSSL-TLS-Server\wolfSSL-TLS-Server.csproj", "{8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-TLS-PSK-Server", "wolfSSL-TLS-PSK-Server\wolfSSL-TLS-PSK-Server.csproj", "{030431C7-26AB-4447-815B-F27E88BE5D5B}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-DTLS-Server", "wolfSSL-DTLS-Server\wolfSSL-DTLS-Server.csproj", "{730F047E-37A6-498F-A543-B6C98AA7B338}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wolfSSL-DTLS-PSK-Server", "wolfSSL-DTLS-PSK-Server\wolfSSL-DTLS-PSK-Server.csproj", "{77AEF1BE-4BE3-4837-8188-2A06E4D963F5}"
+ ProjectSection(ProjectDependencies) = postProject
+ {52609808-0418-46D3-8E17-141927A1A39A} = {52609808-0418-46D3-8E17-141927A1A39A}
+ EndProjectSection
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "wolfSSL", "wolfSSL", "{252D09D0-D007-4AEB-9F7A-A74408039A8A}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wolfssl", "..\..\wolfssl.vcxproj", "{73973223-5EE8-41CA-8E88-1D60E89A237B}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "..\..\testsuite\testsuite.vcxproj", "{611E8971-46E0-4D0A-B5A1-632C3B00CB80}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|Mixed Platforms = Debug|Mixed Platforms
+ Debug|Win32 = Debug|Win32
+ Debug|x64 = Debug|x64
+ DLL Debug|Any CPU = DLL Debug|Any CPU
+ DLL Debug|Mixed Platforms = DLL Debug|Mixed Platforms
+ DLL Debug|Win32 = DLL Debug|Win32
+ DLL Debug|x64 = DLL Debug|x64
+ DLL Release|Any CPU = DLL Release|Any CPU
+ DLL Release|Mixed Platforms = DLL Release|Mixed Platforms
+ DLL Release|Win32 = DLL Release|Win32
+ DLL Release|x64 = DLL Release|x64
+ Release|Any CPU = Release|Any CPU
+ Release|Mixed Platforms = Release|Mixed Platforms
+ 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Debug|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|x64.ActiveCfg = Debug|x64
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Debug|x64.Build.0 = Debug|x64
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {52609808-0418-46D3-8E17-141927A1A39A}.Release|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Debug|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|x64.ActiveCfg = Debug|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Debug|x64.Build.0 = Debug|x64
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|Win32.ActiveCfg = Release|Any CPU
+ {8921AD35-4E62-4DAC-8FEE-8C9F8E57DDD2}.Release|x64.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Debug|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|x64.ActiveCfg = Debug|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Debug|x64.Build.0 = Debug|x64
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|Win32.ActiveCfg = Release|Any CPU
+ {030431C7-26AB-4447-815B-F27E88BE5D5B}.Release|x64.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Debug|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|x64.ActiveCfg = Debug|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Debug|x64.Build.0 = Debug|x64
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|Win32.ActiveCfg = Release|Any CPU
+ {730F047E-37A6-498F-A543-B6C98AA7B338}.Release|x64.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Debug|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Win32.ActiveCfg = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|Win32.Build.0 = Debug|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|x64.ActiveCfg = Debug|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Debug|x64.Build.0 = Debug|x64
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Any CPU.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Any CPU.Build.0 = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.DLL Release|Win32.ActiveCfg = Release|Any CPU
+ {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|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|Win32.ActiveCfg = Release|Any CPU
+ {77AEF1BE-4BE3-4837-8188-2A06E4D963F5}.Release|x64.ActiveCfg = Release|Any CPU
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Any CPU.ActiveCfg = Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|Mixed Platforms.Build.0 = 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 = DLL Debug|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Debug|x64.Build.0 = DLL Debug|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Any CPU.ActiveCfg = DLL Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Mixed Platforms.ActiveCfg = DLL Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Mixed Platforms.Build.0 = DLL Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|Win32.Build.0 = DLL Debug|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|x64.ActiveCfg = DLL Debug|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Debug|x64.Build.0 = DLL Debug|x64
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|Any CPU.ActiveCfg = DLL Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|Mixed Platforms.ActiveCfg = DLL Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|Mixed Platforms.Build.0 = DLL Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.DLL Release|Win32.ActiveCfg = DLL Release|Win32
+ {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|Mixed Platforms.ActiveCfg = Release|Win32
+ {73973223-5EE8-41CA-8E88-1D60E89A237B}.Release|Mixed Platforms.Build.0 = 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|Mixed Platforms.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}.DLL Debug|Any CPU.ActiveCfg = DLL Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Mixed Platforms.ActiveCfg = DLL Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Mixed Platforms.Build.0 = DLL Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|x64.ActiveCfg = DLL Debug|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Debug|x64.Build.0 = DLL Debug|x64
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|Any CPU.ActiveCfg = DLL Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|Mixed Platforms.ActiveCfg = DLL Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|Mixed Platforms.Build.0 = DLL Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.DLL Release|Win32.ActiveCfg = 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|Mixed Platforms.ActiveCfg = Release|Win32
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80}.Release|Mixed Platforms.Build.0 = 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
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(NestedProjects) = preSolution
+ {73973223-5EE8-41CA-8E88-1D60E89A237B} = {252D09D0-D007-4AEB-9F7A-A74408039A8A}
+ {611E8971-46E0-4D0A-B5A1-632C3B00CB80} = {252D09D0-D007-4AEB-9F7A-A74408039A8A}
+ EndGlobalSection
+EndGlobal
diff --git a/wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs b/wrapper/CSharp/wolfSSL_CSharp/Properties/AssemblyInfo.cs
new file mode 100755
index 000000000..2931bee7b
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/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("wolfSSL.CSharp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Microsoft")]
+[assembly: AssemblyProduct("wolfSSL.CSharp")]
+[assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
+[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("b50b8d16-ff19-4ea4-8881-13cf972765db")]
+
+// 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/wolfSSL_CSharp/Properties/Resources.Designer.cs b/wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.Designer.cs
new file mode 100755
index 000000000..dd0327fd4
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.Designer.cs
@@ -0,0 +1,63 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.17929
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace wolfssl_wrapper.Properties {
+ using System;
+
+
+ ///
+ /// A strongly-typed resource class, for looking up localized strings, etc.
+ ///
+ // This class was auto-generated by the StronglyTypedResourceBuilder
+ // class via a tool like ResGen or Visual Studio.
+ // To add or remove a member, edit your .ResX file then rerun ResGen
+ // with the /str option, or rebuild your VS project.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Returns the cached ResourceManager instance used by this class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("wolfSSL.CSharp.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Overrides the current thread's CurrentUICulture property for all
+ /// resource lookups using this strongly typed resource class.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.resx b/wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.resx
new file mode 100755
index 000000000..85c909092
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/Properties/Resources.resx
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 1.3
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
new file mode 100755
index 000000000..c384be2d1
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL.cs
@@ -0,0 +1,1181 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+using System.IO;
+using System.Net;
+using System.Net.Sockets;
+
+namespace wolfSSL.CSharp {
+ public class wolfssl
+ {
+ private const string wolfssl_dll = "wolfssl.dll";
+
+ /********************************
+ * Class for DTLS connections
+ */
+ public class DTLS_con
+ {
+ public UdpClient udp;
+ public IPEndPoint ep;
+ }
+
+
+ /********************************
+ * Init wolfSSL library
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_Init();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_Cleanup();
+
+
+ /********************************
+ * Methods of connection
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfTLSv1_2_server_method();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSLv23_server_method();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfTLSv1_2_client_method();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSLv23_client_method();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfDTLSv1_2_server_method();
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfDTLSv1_2_client_method();
+
+
+ /********************************
+ * Call backs
+ */
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate int CallbackIORecv_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_SetIORecv(IntPtr ctx, CallbackIORecv_delegate recv);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_SetIOReadCtx(IntPtr ssl, IntPtr rctx);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_GetIOReadCtx(IntPtr ssl);
+
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate int CallbackIOSend_delegate(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_SetIOSend(IntPtr ctx, CallbackIOSend_delegate send);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_SetIOWriteCtx(IntPtr ssl, IntPtr wctx);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_GetIOWriteCtx(IntPtr ssl);
+
+
+ /********************************
+ * CTX structure
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_CTX_new(IntPtr method);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_CTX_use_certificate_file(IntPtr ctx, string file, int type);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_CTX_use_PrivateKey_file(IntPtr ctx, string file, int type);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static void wolfSSL_CTX_free(IntPtr ctx);
+
+
+ /********************************
+ * PSK
+ */
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate uint psk_delegate(IntPtr ssl, string identity, IntPtr key, uint max_sz);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static void wolfSSL_set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static void wolfSSL_CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder identity);
+
+
+ /********************************
+ * SSL Structure
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_new(IntPtr ctx);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_accept(IntPtr ssl);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_connect(IntPtr ssl);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_read(IntPtr ssl, StringBuilder buf, int sz);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_write(IntPtr ssl, StringBuilder buf, int sz);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_shutdown(IntPtr ssl);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static void wolfSSL_free(IntPtr ssl);
+
+
+ /********************************
+ * Cipher lists
+ */
+ /* only supports full name from cipher_name[] delimited by : */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_CTX_set_cipher_list(IntPtr ctx, StringBuilder ciphers);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_set_cipher_list(IntPtr ssl, StringBuilder ciphers);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_get_ciphers(StringBuilder ciphers, int sz);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_get_cipher(IntPtr ssl);
+ [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_CIPHER_get_name(IntPtr cipher);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_get_current_cipher(IntPtr ssl);
+ [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_get_version(IntPtr ssl);
+ [DllImport(wolfssl_dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_get_cipher_list(IntPtr ssl);
+
+
+ /********************************
+ * Error logging
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static IntPtr wolfSSL_ERR_error_string(int err, StringBuilder errOut);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public 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;
+
+
+ /********************************
+ * DH
+ */
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_CTX_SetMinDhKey_Sz(IntPtr ctx, short size);
+ [DllImport(wolfssl_dll, CallingConvention = CallingConvention.Cdecl)]
+ public extern static int wolfSSL_SetTmpDH_file(IntPtr ssl, StringBuilder dhParam, int type);
+
+
+ /********************************
+ * Enum types from wolfSSL library
+ */
+ 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 CBIO_ERR_GENERAL = -1;
+ public static readonly int CBIO_ERR_WANT_READ = -2;
+ public static readonly int CBIO_ERR_WANT_WRITE = -2;
+ public static readonly int CBIO_ERR_CONN_RST = -3;
+ public static readonly int CBIO_ERR_ISR = -4;
+ public static readonly int CBIO_ERR_CONN_CLOSE = -5;
+ public static readonly int CBIO_ERR_TIMEOUT = -6;
+
+ public static readonly int SUCCESS = 1;
+ public static readonly int FAILURE = 0;
+
+
+ ///
+ /// Call back to allow recieving TLS information
+ ///
+ /// structure of ssl passed in
+ /// buffer to contain recieved msg
+ /// size of buffer
+ /// optional information passed in
+ /// size of message recieved
+ private static int wolfSSLCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+ {
+ if (sz <= 0)
+ {
+ log(1, "wolfssl recieve error, size less than 0");
+ return wolfssl.CBIO_ERR_GENERAL;
+ }
+
+ int amtRecv = 0;
+
+ System.Runtime.InteropServices.GCHandle gch;
+ gch = GCHandle.FromIntPtr(ctx);
+ Socket con = (System.Net.Sockets.Socket)gch.Target;
+
+ try
+ {
+ Byte[] msg = new Byte[sz];
+ amtRecv = con.Receive(msg, msg.Length, 0);
+ Marshal.Copy(msg, 0, buf, sz);
+ }
+ catch (Exception e)
+ {
+ log(1, "Error in recive " + e.ToString());
+ return wolfssl.CBIO_ERR_CONN_CLOSE;
+ }
+
+ return amtRecv;
+ }
+
+
+ ///
+ /// Call back used for sending TLS information
+ ///
+ /// pointer to ssl struct
+ /// buffer containing information to send
+ /// size of buffer to send
+ /// optional information
+ /// amount of information sent
+ private static int wolfSSLCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+ {
+ if (sz <= 0)
+ {
+ log(1, "wolfssl send error, size less than 0");
+ return wolfssl.CBIO_ERR_GENERAL;
+ }
+
+ System.Runtime.InteropServices.GCHandle gch;
+ gch = GCHandle.FromIntPtr(ctx);
+
+ Socket con = (System.Net.Sockets.Socket)gch.Target;
+
+ Byte[] msg = new Byte[sz];
+
+ Marshal.Copy(buf, msg, 0, sz);
+ try
+ {
+ con.Send(msg, 0, msg.Length, SocketFlags.None);
+ return sz;
+ }
+ catch (Exception e)
+ {
+ log(1, "socket connection issue "+ e.ToString());
+ return wolfssl.CBIO_ERR_CONN_CLOSE;
+ }
+ }
+
+
+ ///
+ /// Call back used for sending DTLS information
+ ///
+ /// pointer to ssl struct
+ /// buffer containing information to send
+ /// size of buffer to send
+ /// optional information
+ /// amount of information sent
+ private static int wolfSSL_dtlsCbIOSend(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+ {
+ if (sz <= 0)
+ {
+ log(1, "wolfssl dtls send error, size less than 0");
+ return wolfssl.CBIO_ERR_GENERAL;
+ }
+
+ System.Runtime.InteropServices.GCHandle gch;
+ gch = GCHandle.FromIntPtr(ctx);
+
+ DTLS_con con = (DTLS_con)gch.Target;
+
+ Byte[] msg = new Byte[sz];
+
+ Marshal.Copy(buf, msg, 0, sz);
+ try
+ {
+ con.udp.Send(msg, msg.Length, con.ep);
+ return msg.Length;
+ }
+ catch (Exception e)
+ {
+ log(1, "socket connection issue " + e.ToString());
+ return wolfssl.CBIO_ERR_CONN_CLOSE;
+ }
+ }
+
+
+ ///
+ /// Call back to allow recieving DTLS information
+ ///
+ /// structure of ssl passed in
+ /// buffer to contain recieved msg
+ /// size of buffer
+ /// optional information passed in
+ /// size of message recieved
+ private static int wolfSSL_dtlsCbIORecv(IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
+ {
+
+ if (sz <= 0)
+ {
+ log(1, "wolfssl dtls recieve error, size less than 0");
+ return wolfssl.CBIO_ERR_GENERAL;
+ }
+
+ System.Runtime.InteropServices.GCHandle gch;
+ gch = GCHandle.FromIntPtr(ctx);
+ DTLS_con con = (DTLS_con)gch.Target;
+
+ Byte[] msg = new Byte[sz];
+ try
+ {
+ msg = con.udp.Receive(ref con.ep);
+ }
+ catch (Exception e)
+ {
+ /* issue with receive or size of buffer */
+ log(1, "socket read issue "+ e.ToString());
+ return wolfssl.CBIO_ERR_CONN_CLOSE;
+ }
+
+ Marshal.Copy(msg, 0, buf, msg.Length);
+
+ return msg.Length;
+ }
+
+
+ ///
+ /// Create a new ssl structure
+ ///
+ /// structure to create ssl structure from
+ /// pointer to ssl structure
+ public static IntPtr new_ssl(IntPtr ctx)
+ {
+ try
+ {
+ return wolfSSL_new(ctx);
+ }
+ catch (Exception e)
+ {
+ log(1, e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Used for a server to accept a connection
+ ///
+ /// structure containing info for connection
+ /// 1 on success
+ public static int accept(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return FAILURE;
+ try
+ {
+ return wolfSSL_accept(ssl);
+ }
+ catch (Exception e)
+ {
+ log(1, "accept error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Used for a client to connect
+ ///
+ /// structure containing connection info
+ /// 1 on success
+ public static int connect(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return FAILURE;
+ try
+ {
+ return wolfSSL_connect(ssl);
+ }
+ catch (Exception e)
+ {
+ log(1, "connect error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Read message from secure connection
+ ///
+ /// structure containing info about connection
+ /// object to hold incoming message
+ /// size of available memory in buf
+ /// amount of data read on success
+ public static int read(IntPtr ssl, StringBuilder buf, int sz)
+ {
+ if (ssl == IntPtr.Zero)
+ return FAILURE;
+ try
+ {
+ return wolfSSL_read(ssl, buf, sz);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl read error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Write message to secure connection
+ ///
+ /// structure containing connection info
+ /// message to send
+ /// size of the message
+ /// amount sent on success
+ public static int write(IntPtr ssl, StringBuilder buf, int sz)
+ {
+ if (ssl == IntPtr.Zero)
+ return FAILURE;
+ try
+ {
+ return wolfSSL_write(ssl, buf, sz);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl write error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Free information stored in ssl struct
+ ///
+ /// pointer to ssl struct to free
+ public static void free(IntPtr ssl)
+ {
+ try
+ {
+ /* free the handle for the socket */
+ IntPtr ptr = wolfSSL_GetIOReadCtx(ssl);
+ if (ptr != IntPtr.Zero)
+ {
+ GCHandle gch = GCHandle.FromIntPtr(ptr);
+ gch.Free();
+ }
+ ptr = wolfSSL_GetIOWriteCtx(ssl);
+ if (ptr != IntPtr.Zero)
+ {
+ GCHandle gch = GCHandle.FromIntPtr(ptr);
+ gch.Free();
+ }
+ wolfSSL_free(ssl);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl free error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Shutdown a connection
+ ///
+ /// pointer to ssl struct to close connection of
+ /// 1 on success
+ public static int shutdown(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return FAILURE;
+ try
+ {
+ return wolfSSL_shutdown(ssl);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl shutdwon error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Optional, can be used to set a custom recieve function
+ ///
+ /// structure to set recieve function in
+ /// function to use when reading socket
+ public static void SetIORecv(IntPtr ctx, CallbackIORecv_delegate func)
+ {
+ try
+ {
+ wolfSSL_SetIORecv(ctx, func);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl setIORecv error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Optional, can be used to set a custom send function
+ ///
+ /// structure to set function in
+ /// function to use when sending data
+ public static void SetIOSend(IntPtr ctx, CallbackIOSend_delegate func)
+ {
+ try
+ {
+ wolfSSL_SetIOSend(ctx, func);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl setIOSend error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Create a new CTX structure
+ ///
+ /// method to use such as TLSv1.2
+ /// pointer to CTX structure
+ public static IntPtr CTX_new(IntPtr method)
+ {
+ try
+ {
+ IntPtr ctx = wolfSSL_CTX_new(method);
+ if (ctx == IntPtr.Zero)
+ return ctx;
+
+ CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSLCbIORecv);
+ wolfSSL_SetIORecv(ctx, recv);
+
+ CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSLCbIOSend);
+ wolfSSL_SetIOSend(ctx, send);
+
+ return ctx;
+ }
+ catch (Exception e)
+ {
+ log(1, "ctx_new error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Create a new CTX structure for a DTLS connection
+ ///
+ /// Method to use in connection ie DTLSv1.2
+ ///
+ public static IntPtr CTX_dtls_new(IntPtr method)
+ {
+ try
+ {
+ IntPtr ctx = wolfSSL_CTX_new(method);
+ if (ctx == IntPtr.Zero)
+ return ctx;
+
+ CallbackIORecv_delegate recv = new CallbackIORecv_delegate(wolfssl.wolfSSL_dtlsCbIORecv);
+ wolfSSL_SetIORecv(ctx, recv);
+
+ CallbackIOSend_delegate send = new CallbackIOSend_delegate(wolfssl.wolfSSL_dtlsCbIOSend);
+ wolfSSL_SetIOSend(ctx, send);
+
+ return ctx;
+ }
+ catch (Exception e)
+ {
+ log(1, "ctx_dtls_new error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Free information used in CTX structure
+ ///
+ /// structure to free
+ public static void CTX_free(IntPtr ctx)
+ {
+ try
+ {
+ wolfSSL_CTX_free(ctx);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl ctx free error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Set identity hint to use
+ ///
+ /// pointer to structure of ctx to set hint in
+ /// hint to use
+ /// 1 on success
+ public static int CTX_use_psk_identity_hint(IntPtr ctx, StringBuilder hint)
+ {
+ try
+ {
+ return wolfSSL_CTX_use_psk_identity_hint(ctx, hint);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl psk identity hint error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Set the function to use for PSK connections
+ ///
+ /// pointer to CTX that the function is set in
+ /// PSK function to use
+ public static void CTX_set_psk_server_callback(IntPtr ctx, psk_delegate psk_cb)
+ {
+ try
+ {
+ wolfSSL_CTX_set_psk_server_callback(ctx, psk_cb);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl psk server callback error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Set the function to use for PSK connections on a single TLS/DTLS connection
+ ///
+ /// pointer to SSL that the function is set in
+ /// PSK function to use
+ public static void set_psk_server_callback(IntPtr ssl, psk_delegate psk_cb)
+ {
+ try
+ {
+ wolfSSL_set_psk_server_callback(ssl, psk_cb);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl psk server callback error " + e.ToString());
+ }
+ }
+
+
+ ///
+ /// Set Socket for TLS connection
+ ///
+ /// structure to set Socket in
+ /// Socket to use
+ /// 1 on success
+ public static int set_fd(IntPtr ssl, Socket fd)
+ {
+ /* sanity check on inputs */
+ if (ssl == IntPtr.Zero)
+ {
+ return FAILURE;
+ }
+
+ try
+ {
+ if (!fd.Equals(null))
+ {
+ IntPtr ptr = GCHandle.ToIntPtr(GCHandle.Alloc(fd));
+ wolfSSL_SetIOWriteCtx(ssl, ptr); //pass along the socket for writing to
+ wolfSSL_SetIOReadCtx(ssl, ptr); //pass along the socket for reading from
+ }
+ }
+ catch (Exception e)
+ {
+ log(1, "Error setting up fd!! " + e.ToString());
+ return FAILURE;
+ }
+
+ return 1;
+ }
+
+
+ ///
+ /// Get socket of a TLS connection
+ ///
+ /// structure to get socket from
+ /// Socket object used for connection
+ public static Socket get_fd(IntPtr ssl)
+ {
+ try
+ {
+ IntPtr ptr = wolfSSL_GetIOReadCtx(ssl);
+ if (ptr != IntPtr.Zero)
+ {
+ GCHandle gch = GCHandle.FromIntPtr(ptr);
+ return (System.Net.Sockets.Socket)gch.Target;
+ }
+ return null;
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get_fd error " + e.ToString());
+ return null;
+ }
+ }
+
+
+
+ ///
+ /// Set information needed to send and receive a DTLS connection
+ ///
+ /// structure to set information in
+ /// UDP object to send and receive
+ /// End point of connection
+ /// 1 on success
+ public static int set_dtls_fd(IntPtr ssl, UdpClient udp, IPEndPoint ep)
+ {
+ IntPtr ptr;
+ DTLS_con con;
+
+ /* sanity check on inputs */
+ if (ssl == IntPtr.Zero)
+ {
+ return FAILURE;
+ }
+
+ try
+ {
+ if (!udp.Equals(null) && !ep.Equals(null))
+ {
+ con = new DTLS_con();
+ con.udp = udp;
+ con.ep = ep;
+ ptr = GCHandle.ToIntPtr(GCHandle.Alloc(con));
+ wolfSSL_SetIOWriteCtx(ssl, ptr); //pass along the socket for writing to
+ wolfSSL_SetIOReadCtx(ssl, ptr); //pass along the socket for reading from
+ }
+ }
+ catch (Exception e)
+ {
+ log(1, "Error setting up fd!! " + e.ToString());
+ return FAILURE;
+ }
+
+ return 1;
+ }
+
+
+ ///
+ /// Get the pointer to DTLS_con class used for connection
+ ///
+ /// structure to get connection from
+ /// DTLS_con object
+ public static DTLS_con get_dtls_fd(IntPtr ssl)
+ {
+ try
+ {
+ IntPtr ptr = wolfSSL_GetIOReadCtx(ssl);
+ if (ptr != IntPtr.Zero)
+ {
+ GCHandle gch = GCHandle.FromIntPtr(ptr);
+ return (DTLS_con)gch.Target;
+ }
+ return null;
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get_dtls_fd error " + e.ToString());
+ return null;
+ }
+ }
+
+
+ ///
+ /// Get available cipher suites
+ ///
+ /// list to fill with cipher suite names
+ /// size of list available to fill
+ /// 1 on success
+ public static int get_ciphers(StringBuilder list, int sz)
+ {
+ try
+ {
+ return wolfSSL_get_ciphers(list, sz);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get_ciphers error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Initialize wolfSSL library
+ ///
+ /// 1 on success
+ public static int Init()
+ {
+ try
+ {
+ return wolfSSL_Init();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl init error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Clean up wolfSSL library memory
+ ///
+ /// 1 on success
+ public static int Cleanup()
+ {
+ try
+ {
+ return wolfSSL_Cleanup();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl cleanup error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Set up TLS version 1.2 method
+ ///
+ /// pointer to TLSv1.2 method
+ public static IntPtr useTLSv1_2_server()
+ {
+ try
+ {
+ return wolfTLSv1_2_server_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Use any TLS version
+ ///
+ /// pointer to method
+ public static IntPtr usev23_server()
+ {
+ try
+ {
+ return wolfSSLv23_server_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Set up TLS version 1.2 method
+ ///
+ /// pointer to TLSv1.2 method
+ public static IntPtr useTLSv1_2_client()
+ {
+ try
+ {
+ return wolfTLSv1_2_client_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Use any TLS version
+ ///
+ /// pointer to method
+ public static IntPtr usev23_client()
+ {
+ try
+ {
+ return wolfSSLv23_client_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Set up DTLS version 1.2
+ ///
+ /// pointer to DTLSv1.2 method
+ public static IntPtr useDTLSv1_2_server()
+ {
+ try
+ {
+ return wolfDTLSv1_2_server_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Set up DTLS version 1.2
+ ///
+ /// pointer to DTLSv1.2 method
+ public static IntPtr useDTLSv1_2_client()
+ {
+ try
+ {
+ return wolfDTLSv1_2_client_method();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl error " + e.ToString());
+ return IntPtr.Zero;
+ }
+ }
+
+
+ ///
+ /// Gets the current cipher suite being used in connection
+ ///
+ /// SSL struct to get cipher suite from
+ /// string containing current cipher suite
+ public static string get_current_cipher(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return null;
+ try
+ {
+ IntPtr ssl_cipher;
+ IntPtr ssl_cipher_ptr;
+ string ssl_cipher_str;
+
+ ssl_cipher = wolfSSL_get_current_cipher(ssl);
+ ssl_cipher_ptr = wolfSSL_CIPHER_get_name(ssl_cipher);
+ ssl_cipher_str = Marshal.PtrToStringAnsi(ssl_cipher_ptr);
+
+ return ssl_cipher_str;
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get current cipher error " + e.ToString());
+ return null;
+ }
+ }
+
+
+ ///
+ /// Set avialable cipher suites for all ssl structs created from ctx
+ ///
+ /// CTX structure to set
+ /// List full of ciphers suites
+ /// 1 on success
+ public static int CTX_set_cipher_list(IntPtr ctx, StringBuilder list)
+ {
+ try
+ {
+ return wolfSSL_CTX_set_cipher_list(ctx, list);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl ctx set cipher list error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Set available cipher suite in local connection
+ ///
+ /// Structure to set cipher suite in
+ /// List of cipher suites
+ /// 1 on success
+ public static int set_cipher_list(IntPtr ssl, StringBuilder list)
+ {
+ try
+ {
+ return wolfSSL_set_cipher_list(ssl, list);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl set cipher error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Gets the version of the connection made ie TLSv1.2
+ ///
+ /// SSL struct to get version of
+ /// string containing version
+ public static string get_version(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return null;
+
+ try
+ {
+ IntPtr version_ptr;
+ string version;
+
+ version_ptr = wolfSSL_get_version(ssl);
+ version = Marshal.PtrToStringAnsi(version_ptr);
+
+ return version;
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get version error " + e.ToString());
+ return null;
+ }
+ }
+
+
+ ///
+ /// Get a string containing error value and reason
+ ///
+ /// SSL struct that had error
+ /// String containing error value and reason
+ public static string get_error(IntPtr ssl)
+ {
+ if (ssl == IntPtr.Zero)
+ return null;
+
+ try
+ {
+ int err;
+ StringBuilder err_name;
+ StringBuilder ret;
+
+ /* wolfSSL max error length is 80 */
+ ret = new StringBuilder(' ', 100);
+ err = wolfSSL_get_error(ssl, 0);
+ err_name = new StringBuilder(' ', 80);
+ wolfSSL_ERR_error_string(err, err_name);
+ ret.Append("Error " + err + " " + err_name);
+
+ return ret.ToString();
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl get error, error " + e.ToString());
+ return null;
+ }
+ }
+
+
+ ///
+ /// Used to load in the certificate file
+ ///
+ /// CTX structure for TLS/SSL connections
+ /// Name of the file to load including absolute path
+ /// Type of file ie PEM or DER
+ /// 1 on success
+ public static int CTX_use_certificate_file(IntPtr ctx, string fileCert, int type)
+ {
+ try
+ {
+ return wolfSSL_CTX_use_certificate_file(ctx, fileCert, type);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl ctx use cert file error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Used to load in the private key from a file
+ ///
+ /// CTX structure for TLS/SSL connections
+ /// Name of the file, includeing absolute directory
+ /// Type of file ie PEM or DER
+ /// 1 on succes
+ public static int CTX_use_PrivateKey_file(IntPtr ctx, string fileKey, int type)
+ {
+ try
+ {
+ return wolfSSL_CTX_use_PrivateKey_file(ctx, fileKey, type);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl ctx use key file error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Set temporary DH parameters
+ ///
+ /// Structure to set in
+ /// file name
+ /// type of file ie PEM
+ /// 1 on success
+ public static int SetTmpDH_file(IntPtr ssl, StringBuilder dhparam, int file_type)
+ {
+ try
+ {
+ return wolfSSL_SetTmpDH_file(ssl, dhparam, file_type);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl set tmp dh file error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Used to set the minimum size of DH key
+ ///
+ /// Structure to store key size
+ /// Min key size
+ /// 1 on success
+ public static int CTX_SetMinDhKey_Sz(IntPtr ctx, short minDhKey)
+ {
+ try
+ {
+ return wolfSSL_CTX_SetMinDhKey_Sz(ctx, minDhKey);
+ }
+ catch (Exception e)
+ {
+ log(1, "wolfssl ctx set min dh key error " + e.ToString());
+ return FAILURE;
+ }
+ }
+
+
+ ///
+ /// Set the function to use for logging
+ ///
+ /// Function that conforms as to loggingCb
+ /// 1 on success
+ public static int SetLogging(loggingCb input)
+ {
+ internal_log = input;
+ return SUCCESS;
+ }
+
+
+ ///
+ /// Log a message to set logging function
+ ///
+ /// Level of log message
+ /// Message to log
+ public static void log(int lvl, string msg)
+ {
+ /* if log is not set then pring nothing */
+ if (internal_log == null)
+ return;
+ StringBuilder ptr = new StringBuilder(msg);
+ internal_log(lvl, ptr);
+ }
+ }
+}
diff --git a/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
new file mode 100755
index 000000000..7cc8fc8b3
--- /dev/null
+++ b/wrapper/CSharp/wolfSSL_CSharp/wolfSSL_CSharp.csproj
@@ -0,0 +1,80 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {52609808-0418-46D3-8E17-141927A1A39A}
+ Library
+ Properties
+ wolfSSL.CSharp
+ wolfSSL_CSharp
+ v4.5
+ 512
+
+
+ true
+ full
+ false
+ ..\DLL Debug\
+ DEBUG;TRACE
+ prompt
+ 3
+
+
+ pdbonly
+ true
+ ..\DLL Release\
+ TRACE
+ prompt
+ 4
+
+
+ true
+ ..\x64\DLL Debug\
+ DEBUG;TRACE
+ 3
+ full
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+ ..\x64\DLL Release\
+ TRACE
+ true
+ pdbonly
+ x64
+ prompt
+ MinimumRecommendedRules.ruleset
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xcopy "$(ProjectDir)..\..\..\certs\server-key.pem" "$(TargetDir)" /Y /R
+xcopy "$(ProjectDir)..\..\..\certs\server-cert.pem" "$(TargetDir)" /Y /R
+xcopy "$(ProjectDir)..\..\..\certs\dh2048.pem" "$(TargetDir)" /Y /R
+
+
+
\ No newline at end of file
diff --git a/wrapper/include.am b/wrapper/include.am
new file mode 100644
index 000000000..2b3f26e2a
--- /dev/null
+++ b/wrapper/include.am
@@ -0,0 +1,26 @@
+
+# wolfSSL CSharp wrapper files
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-PSK-Server/App.config
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-PSK-Server/Properties/AssemblyInfo.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-PSK-Server/wolfSSL-DTLS-PSK-Server.csproj
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-Server/App.config
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-Server/Properties/AssemblyInfo.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-DTLS-Server/wolfSSL-DTLS-Server.csproj
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-PSK-Server/App.config
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-PSK-Server/Properties/AssemblyInfo.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-PSK-Server/wolfSSL-TLS-PSK-Server.csproj
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/App.config
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/Properties/AssemblyInfo.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.Designer.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/Properties/Settings.settings
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.cs
+EXTRA_DIST+= wrapper/CSharp/wolfSSL-TLS-Server/wolfSSL-TLS-Server.csproj
+EXTRA_DIST+= wrapper/CSharp/wolfSSL_CSharp.sln
+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/wolfSSL_CSharp.csproj