Data Structures | Public Member Functions | Static Public Member Functions | Static Public Attributes
wolfSSL.CSharp.wolfssl Class Reference

Data Structures

class  DTLS_con
 Contains information regarding a DTLS connection having UdpClient udp and IPEndPoint ep. Used to keep memory alive. More...
 

Public Member Functions

delegate int CallbackIORecv_delegate (IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
 
delegate int CallbackIOSend_delegate (IntPtr ssl, IntPtr buf, int sz, IntPtr ctx)
 
delegate uint psk_delegate (IntPtr ssl, string identity, IntPtr key, uint max_sz)
 
delegate uint psk_client_delegate (IntPtr ssl, string hint, IntPtr identity, uint id_max_len, IntPtr key, uint max_sz)
 
delegate void loggingCb (int lvl, StringBuilder msg)
 
delegate int CallbackVerify_delegate (int ret, IntPtr x509_ctx)
 

Static Public Member Functions

static IntPtr new_ssl (IntPtr ctx)
 Create a new ssl structure More...
 
static int accept (IntPtr ssl)
 Used for a server to accept a connection More...
 
static int connect (IntPtr ssl)
 Used for a client to connect More...
 
static int read (IntPtr ssl, StringBuilder buf, int sz)
 Read message from secure connection More...
 
static int read (IntPtr ssl, byte[] buf, int sz)
 Read message from secure connection using a byte array More...
 
static int write (IntPtr ssl, StringBuilder buf, int sz)
 Write message to secure connection More...
 
static int write (IntPtr ssl, byte[] buf, int sz)
 Write message to secure connection More...
 
static void free (IntPtr ssl)
 Free information stored in ssl struct More...
 
static int shutdown (IntPtr ssl)
 Shutdown a connection More...
 
static void SetIORecv (IntPtr ctx, CallbackIORecv_delegate func)
 Optional, can be used to set a custom receive function More...
 
static void SetIOSend (IntPtr ctx, CallbackIOSend_delegate func)
 Optional, can be used to set a custom send function More...
 
static IntPtr CTX_new (IntPtr method)
 Create a new CTX structure More...
 
static IntPtr CTX_dtls_new (IntPtr method)
 Create a new CTX structure for a DTLS connection More...
 
static void CTX_free (IntPtr ctx)
 Free information used in CTX structure More...
 
static int CTX_use_psk_identity_hint (IntPtr ctx, StringBuilder hint)
 Set identity hint to use More...
 
static void CTX_set_psk_server_callback (IntPtr ctx, psk_delegate psk_cb)
 Set the function to use for PSK connections More...
 
static void CTX_set_psk_client_callback (IntPtr ctx, psk_client_delegate psk_cb)
 Set the function to use for PSK connections More...
 
static void set_psk_server_callback (IntPtr ssl, psk_delegate psk_cb)
 Set the function to use for PSK connections on a single TLS/DTLS connection More...
 
static int set_fd (IntPtr ssl, Socket fd)
 Set Socket for TLS connection More...
 
static Socket get_fd (IntPtr ssl)
 Get socket of a TLS connection More...
 
static int set_dtls_fd (IntPtr ssl, UdpClient udp, IPEndPoint ep)
 Set information needed to send and receive a DTLS connection More...
 
static DTLS_con get_dtls_fd (IntPtr ssl)
 Get the pointer to DTLS_con class used for connection More...
 
static int get_ciphers (StringBuilder list, int sz)
 Get available cipher suites More...
 
static int Init ()
 Initialize wolfSSL library More...
 
static int Cleanup ()
 Clean up wolfSSL library memory More...
 
static IntPtr useTLSv1_2_server ()
 Set up TLS version 1.2 method More...
 
static IntPtr useTLSv1_3_server ()
 Set up TLS version 1.3 method More...
 
static IntPtr usev23_server ()
 Use any TLS version More...
 
static IntPtr useTLSv1_2_client ()
 Set up TLS version 1.2 method More...
 
static IntPtr useTLSv1_3_client ()
 Set up TLS version 1.3 method More...
 
static IntPtr usev23_client ()
 Use any TLS version More...
 
static IntPtr useDTLSv1_2_server ()
 Set up DTLS version 1.2 More...
 
static IntPtr useDTLSv1_2_client ()
 Set up DTLS version 1.2 More...
 
static string get_current_cipher (IntPtr ssl)
 Gets the current cipher suite being used in connection More...
 
static int CTX_set_cipher_list (IntPtr ctx, StringBuilder list)
 Set available cipher suites for all ssl structs created from ctx More...
 
static int set_cipher_list (IntPtr ssl, StringBuilder list)
 Set available cipher suite in local connection More...
 
static string get_version (IntPtr ssl)
 Gets the version of the connection made ie TLSv1.2 More...
 
static string get_error (IntPtr ssl)
 Get a string containing error value and reason More...
 
static int CTX_use_certificate_file (IntPtr ctx, string fileCert, int type)
 Used to load in the certificate file More...
 
static int CTX_load_verify_locations (IntPtr ctx, string fileCert, string path)
 Used to load in the peer trusted root file More...
 
static int CTX_use_PrivateKey_file (IntPtr ctx, string fileKey, int type)
 Used to load in the private key from a file More...
 
static int SetTmpDH_file (IntPtr ssl, StringBuilder dhparam, int file_type)
 Set temporary DH parameters More...
 
static int CTX_SetTmpDH_file (IntPtr ctx, StringBuilder dhparam, int file_type)
 Set temporary DH parameters More...
 
static int CTX_SetMinDhKey_Sz (IntPtr ctx, short minDhKey)
 Used to set the minimum size of DH key More...
 
static int CTX_set_verify (IntPtr ctx, int mode, CallbackVerify_delegate vc)
 Set the certificate verification mode and optional callback function More...
 
static int set_verify (IntPtr ssl, int mode, CallbackVerify_delegate vc)
 Set the certificate verification mode and optional callback function More...
 
static int SetLogging (loggingCb input)
 Set the function to use for logging More...
 
static void log (int lvl, string msg)
 Log a message to set logging function More...
 

Static Public Attributes

static readonly int SSL_FILETYPE_PEM = 1
 
static readonly int SSL_FILETYPE_ASN1 = 2
 
static readonly int SSL_FILETYPE_RAW = 3
 
static readonly int SSL_VERIFY_NONE = 0
 
static readonly int SSL_VERIFY_PEER = 1
 
static readonly int SSL_VERIFY_FAIL_IF_NO_PEER_CERT = 2
 
static readonly int SSL_VERIFY_CLIENT_ONCE = 4
 
static readonly int SSL_VERIFY_FAIL_EXCEPT_PSK = 8
 
static readonly int CBIO_ERR_GENERAL = -1
 
static readonly int CBIO_ERR_WANT_READ = -2
 
static readonly int CBIO_ERR_WANT_WRITE = -2
 
static readonly int CBIO_ERR_CONN_RST = -3
 
static readonly int CBIO_ERR_ISR = -4
 
static readonly int CBIO_ERR_CONN_CLOSE = -5
 
static readonly int CBIO_ERR_TIMEOUT = -6
 
static readonly int ERROR_LOG = 0
 
static readonly int INFO_LOG = 1
 
static readonly int ENTER_LOG = 2
 
static readonly int LEAVE_LOG = 3
 
static readonly int OTHER_LOG = 4
 
static readonly int SUCCESS = 1
 
static readonly int FAILURE = 0
 

Member Function Documentation

◆ accept()

static int wolfSSL.CSharp.wolfssl.accept ( IntPtr  ssl)
inlinestatic

Used for a server to accept a connection

Parameters
sslstructure containing info for connection
Returns
1 on success

◆ Cleanup()

static int wolfSSL.CSharp.wolfssl.Cleanup ( )
inlinestatic

Clean up wolfSSL library memory

Returns
1 on success

◆ connect()

static int wolfSSL.CSharp.wolfssl.connect ( IntPtr  ssl)
inlinestatic

Used for a client to connect

Parameters
sslstructure containing connection info
Returns
1 on success

◆ CTX_dtls_new()

static IntPtr wolfSSL.CSharp.wolfssl.CTX_dtls_new ( IntPtr  method)
inlinestatic

Create a new CTX structure for a DTLS connection

Parameters
methodMethod to use in connection ie DTLSv1.2
Returns

◆ CTX_free()

static void wolfSSL.CSharp.wolfssl.CTX_free ( IntPtr  ctx)
inlinestatic

Free information used in CTX structure

Parameters
ctxstructure to free

◆ CTX_load_verify_locations()

static int wolfSSL.CSharp.wolfssl.CTX_load_verify_locations ( IntPtr  ctx,
string  fileCert,
string  path 
)
inlinestatic

Used to load in the peer trusted root file

Parameters
ctxCTX structure for TLS/SSL connections
fileCertName of the file to load including absolute path
typepath to multiple certificates (try to load all in path)
Returns
1 on success

◆ CTX_new()

static IntPtr wolfSSL.CSharp.wolfssl.CTX_new ( IntPtr  method)
inlinestatic

Create a new CTX structure

Parameters
methodmethod to use such as TLSv1.2
Returns
pointer to CTX structure

◆ CTX_set_cipher_list()

static int wolfSSL.CSharp.wolfssl.CTX_set_cipher_list ( IntPtr  ctx,
StringBuilder  list 
)
inlinestatic

Set available cipher suites for all ssl structs created from ctx

Parameters
ctxCTX structure to set
listList full of ciphers suites
Returns
1 on success

◆ CTX_set_psk_client_callback()

static void wolfSSL.CSharp.wolfssl.CTX_set_psk_client_callback ( IntPtr  ctx,
psk_client_delegate  psk_cb 
)
inlinestatic

Set the function to use for PSK connections

Parameters
ctxpointer to CTX that the function is set in
psk_cbPSK function to use

◆ CTX_set_psk_server_callback()

static void wolfSSL.CSharp.wolfssl.CTX_set_psk_server_callback ( IntPtr  ctx,
psk_delegate  psk_cb 
)
inlinestatic

Set the function to use for PSK connections

Parameters
ctxpointer to CTX that the function is set in
psk_cbPSK function to use

◆ CTX_set_verify()

static int wolfSSL.CSharp.wolfssl.CTX_set_verify ( IntPtr  ctx,
int  mode,
CallbackVerify_delegate  vc 
)
inlinestatic

Set the certificate verification mode and optional callback function

Parameters
ctxpointer to CTX that the function is set in
modeSee SSL_VERIFY options
vcOptional verify callback function to use

◆ CTX_SetMinDhKey_Sz()

static int wolfSSL.CSharp.wolfssl.CTX_SetMinDhKey_Sz ( IntPtr  ctx,
short  minDhKey 
)
inlinestatic

Used to set the minimum size of DH key

Parameters
ctxStructure to store key size
minDhKeyMin key size
Returns
1 on success

◆ CTX_SetTmpDH_file()

static int wolfSSL.CSharp.wolfssl.CTX_SetTmpDH_file ( IntPtr  ctx,
StringBuilder  dhparam,
int  file_type 
)
inlinestatic

Set temporary DH parameters

Parameters
ctxStructure to set in
dhparamfile name
file_typetype of file ie PEM
Returns
1 on success

◆ CTX_use_certificate_file()

static int wolfSSL.CSharp.wolfssl.CTX_use_certificate_file ( IntPtr  ctx,
string  fileCert,
int  type 
)
inlinestatic

Used to load in the certificate file

Parameters
ctxCTX structure for TLS/SSL connections
fileCertName of the file to load including absolute path
typeType of file ie PEM or DER
Returns
1 on success

◆ CTX_use_PrivateKey_file()

static int wolfSSL.CSharp.wolfssl.CTX_use_PrivateKey_file ( IntPtr  ctx,
string  fileKey,
int  type 
)
inlinestatic

Used to load in the private key from a file

Parameters
ctxCTX structure for TLS/SSL connections
fileKeyName of the file, includeing absolute directory
typeType of file ie PEM or DER
Returns
1 on success

◆ CTX_use_psk_identity_hint()

static int wolfSSL.CSharp.wolfssl.CTX_use_psk_identity_hint ( IntPtr  ctx,
StringBuilder  hint 
)
inlinestatic

Set identity hint to use

Parameters
ctxpointer to structure of ctx to set hint in
hinthint to use
Returns
1 on success

◆ free()

static void wolfSSL.CSharp.wolfssl.free ( IntPtr  ssl)
inlinestatic

Free information stored in ssl struct

Parameters
sslpointer to ssl struct to free

◆ get_ciphers()

static int wolfSSL.CSharp.wolfssl.get_ciphers ( StringBuilder  list,
int  sz 
)
inlinestatic

Get available cipher suites

Parameters
listlist to fill with cipher suite names
szsize of list available to fill
Returns
1 on success

◆ get_current_cipher()

static string wolfSSL.CSharp.wolfssl.get_current_cipher ( IntPtr  ssl)
inlinestatic

Gets the current cipher suite being used in connection

Parameters
sslSSL struct to get cipher suite from
Returns
string containing current cipher suite

◆ get_dtls_fd()

static DTLS_con wolfSSL.CSharp.wolfssl.get_dtls_fd ( IntPtr  ssl)
inlinestatic

Get the pointer to DTLS_con class used for connection

Parameters
sslstructure to get connection from
Returns
DTLS_con object

◆ get_error()

static string wolfSSL.CSharp.wolfssl.get_error ( IntPtr  ssl)
inlinestatic

Get a string containing error value and reason

Parameters
sslSSL struct that had error
Returns
String containing error value and reason

◆ get_fd()

static Socket wolfSSL.CSharp.wolfssl.get_fd ( IntPtr  ssl)
inlinestatic

Get socket of a TLS connection

Parameters
sslstructure to get socket from
Returns
Socket object used for connection

◆ get_version()

static string wolfSSL.CSharp.wolfssl.get_version ( IntPtr  ssl)
inlinestatic

Gets the version of the connection made ie TLSv1.2

Parameters
sslSSL struct to get version of
Returns
string containing version

◆ Init()

static int wolfSSL.CSharp.wolfssl.Init ( )
inlinestatic

Initialize wolfSSL library

Returns
1 on success

◆ log()

static void wolfSSL.CSharp.wolfssl.log ( int  lvl,
string  msg 
)
inlinestatic

Log a message to set logging function

Parameters
lvlLevel of log message
msgMessage to log

◆ new_ssl()

static IntPtr wolfSSL.CSharp.wolfssl.new_ssl ( IntPtr  ctx)
inlinestatic

Create a new ssl structure

Parameters
ctxstructure to create ssl structure from
Returns
pointer to ssl structure

◆ read() [1/2]

static int wolfSSL.CSharp.wolfssl.read ( IntPtr  ssl,
StringBuilder  buf,
int  sz 
)
inlinestatic

Read message from secure connection

Parameters
sslstructure containing info about connection
bufobject to hold incoming message (Unicode format)
szsize of available memory in buf
Returns
amount of data read on success

◆ read() [2/2]

static int wolfSSL.CSharp.wolfssl.read ( IntPtr  ssl,
byte []  buf,
int  sz 
)
inlinestatic

Read message from secure connection using a byte array

Parameters
sslstructure containing info about connection
bufobject to hold incoming message (raw bytes)
szsize of available memory in buf
Returns
amount of data read on success

◆ set_cipher_list()

static int wolfSSL.CSharp.wolfssl.set_cipher_list ( IntPtr  ssl,
StringBuilder  list 
)
inlinestatic

Set available cipher suite in local connection

Parameters
sslStructure to set cipher suite in
listList of cipher suites
Returns
1 on success

◆ set_dtls_fd()

static int wolfSSL.CSharp.wolfssl.set_dtls_fd ( IntPtr  ssl,
UdpClient  udp,
IPEndPoint  ep 
)
inlinestatic

Set information needed to send and receive a DTLS connection

Parameters
sslstructure to set information in
udpUDP object to send and receive
epEnd point of connection
Returns
1 on success

◆ set_fd()

static int wolfSSL.CSharp.wolfssl.set_fd ( IntPtr  ssl,
Socket  fd 
)
inlinestatic

Set Socket for TLS connection

Parameters
sslstructure to set Socket in
fdSocket to use
Returns
1 on success

◆ set_psk_server_callback()

static void wolfSSL.CSharp.wolfssl.set_psk_server_callback ( IntPtr  ssl,
psk_delegate  psk_cb 
)
inlinestatic

Set the function to use for PSK connections on a single TLS/DTLS connection

Parameters
ctxpointer to SSL that the function is set in
psk_cbPSK function to use

◆ set_verify()

static int wolfSSL.CSharp.wolfssl.set_verify ( IntPtr  ssl,
int  mode,
CallbackVerify_delegate  vc 
)
inlinestatic

Set the certificate verification mode and optional callback function

Parameters
ctxpointer to SSL object that the function is set in
modeSee SSL_VERIFY options
vcOptional verify callback function to use

◆ SetIORecv()

static void wolfSSL.CSharp.wolfssl.SetIORecv ( IntPtr  ctx,
CallbackIORecv_delegate  func 
)
inlinestatic

Optional, can be used to set a custom receive function

Parameters
ctxstructure to set receive function in
funcfunction to use when reading socket

◆ SetIOSend()

static void wolfSSL.CSharp.wolfssl.SetIOSend ( IntPtr  ctx,
CallbackIOSend_delegate  func 
)
inlinestatic

Optional, can be used to set a custom send function

Parameters
ctxstructure to set function in
funcfunction to use when sending data

◆ SetLogging()

static int wolfSSL.CSharp.wolfssl.SetLogging ( loggingCb  input)
inlinestatic

Set the function to use for logging

Parameters
inputFunction that conforms as to loggingCb
Returns
1 on success

◆ SetTmpDH_file()

static int wolfSSL.CSharp.wolfssl.SetTmpDH_file ( IntPtr  ssl,
StringBuilder  dhparam,
int  file_type 
)
inlinestatic

Set temporary DH parameters

Parameters
sslStructure to set in
dhparamfile name
file_typetype of file ie PEM
Returns
1 on success

◆ shutdown()

static int wolfSSL.CSharp.wolfssl.shutdown ( IntPtr  ssl)
inlinestatic

Shutdown a connection

Parameters
sslpointer to ssl struct to close connection of
Returns
1 on success

◆ useDTLSv1_2_client()

static IntPtr wolfSSL.CSharp.wolfssl.useDTLSv1_2_client ( )
inlinestatic

Set up DTLS version 1.2

Returns
pointer to DTLSv1.2 method

◆ useDTLSv1_2_server()

static IntPtr wolfSSL.CSharp.wolfssl.useDTLSv1_2_server ( )
inlinestatic

Set up DTLS version 1.2

Returns
pointer to DTLSv1.2 method

◆ useTLSv1_2_client()

static IntPtr wolfSSL.CSharp.wolfssl.useTLSv1_2_client ( )
inlinestatic

Set up TLS version 1.2 method

Returns
pointer to TLSv1.2 method

◆ useTLSv1_2_server()

static IntPtr wolfSSL.CSharp.wolfssl.useTLSv1_2_server ( )
inlinestatic

Set up TLS version 1.2 method

Returns
pointer to TLSv1.2 method

◆ useTLSv1_3_client()

static IntPtr wolfSSL.CSharp.wolfssl.useTLSv1_3_client ( )
inlinestatic

Set up TLS version 1.3 method

Returns
pointer to TLSv1.3 method

◆ useTLSv1_3_server()

static IntPtr wolfSSL.CSharp.wolfssl.useTLSv1_3_server ( )
inlinestatic

Set up TLS version 1.3 method

Returns
pointer to TLSv1.3 method

◆ usev23_client()

static IntPtr wolfSSL.CSharp.wolfssl.usev23_client ( )
inlinestatic

Use any TLS version

Returns
pointer to method

◆ usev23_server()

static IntPtr wolfSSL.CSharp.wolfssl.usev23_server ( )
inlinestatic

Use any TLS version

Returns
pointer to method

◆ write() [1/2]

static int wolfSSL.CSharp.wolfssl.write ( IntPtr  ssl,
StringBuilder  buf,
int  sz 
)
inlinestatic

Write message to secure connection

Parameters
sslstructure containing connection info
bufmessage to send
szsize of the message
Returns
amount sent on success

◆ write() [2/2]

static int wolfSSL.CSharp.wolfssl.write ( IntPtr  ssl,
byte []  buf,
int  sz 
)
inlinestatic

Write message to secure connection

Parameters
sslstructure containing connection info
bufmessage to send
szsize of the message
Returns
amount sent on success