![]() |
m2mb API docs
30.00.007
m2mb API sets documentation
|
SSL TLS support. More...
Go to the source code of this file.
Data Structures | |
| struct | M2MB_SSL_PSK_TABLE_T |
| struct | M2MB_SSL_CERT_T |
| struct | M2MB_SSL_CA_INFO_T |
| struct | M2MB_SSL_CA_LIST_T |
| union | M2MB_SSL_SEC_INFO_U |
| struct | M2MB_SSL_CONFIG_T |
Typedefs | |
| typedef HANDLE | M2MB_SSL_CTXT_HANDLE |
| typedef HANDLE | M2MB_SSL_CONFIG_HANDLE |
| typedef uiHANDLE | M2MB_SSL_CONNECTION_HANDLE |
| typedef enum M2MB_SSL_PROTOCOL_VERSION_E | M2MB_SSL_PROTOCOL_VERSION_E |
| typedef enum M2MB_SSL_CIPHER_SUITE_E | M2MB_SSL_CIPHER_SUITE_E |
| typedef enum M2MB_SSL_CERT_TYPE_E | M2MB_SSL_CERT_TYPE_E |
| typedef struct M2MB_SSL_PSK_TABLE_T | M2MB_SSL_PSK_TABLE_T |
| typedef struct M2MB_SSL_CERT_T | M2MB_SSL_CERT_T |
| typedef struct M2MB_SSL_CA_INFO_T | M2MB_SSL_CA_INFO_T |
| typedef struct M2MB_SSL_CA_LIST_T | M2MB_SSL_CA_LIST_T |
| typedef enum M2MB_SSL_AUTH_TYPE_E | M2MB_SSL_AUTH_TYPE_E |
| typedef struct M2MB_SSL_CONFIG_T | M2MB_SSL_CONFIG_T |
Functions | |
| M2MB_SSL_CTXT_HANDLE | m2mb_ssl_create_ctxt (void) |
| creates SSL TLS context More... | |
| M2MB_SSL_CONFIG_HANDLE | m2mb_ssl_create_config (M2MB_SSL_CONFIG_T sslConfig, INT32 *result) |
| creates an SSL TLS configuration More... | |
| INT32 | m2mb_ssl_delete_config (M2MB_SSL_CONFIG_HANDLE sslConfigHndl) |
| deletes an SSL TLS configuration More... | |
| M2MB_SSL_CONNECTION_HANDLE | m2mb_ssl_secure_socket (M2MB_SSL_CONFIG_HANDLE sslConfigHndl, M2MB_SSL_CTXT_HANDLE sslCtxtHndl, M2MB_SOCKET_BSD_SOCKET socket_fd, INT32 *result) |
| creates secure socket connection More... | |
| INT32 | m2mb_ssl_connect (M2MB_SSL_CONNECTION_HANDLE sslConnectionHandle) |
| performs SSL TLS connection More... | |
| INT32 | m2mb_ssl_write (M2MB_SSL_CONNECTION_HANDLE sslConnectionHandle, void *buf, UINT32 len) |
| writes len bytes from buf into sslConnectionHandle SSL TLS connection More... | |
| INT32 | m2mb_ssl_read (M2MB_SSL_CONNECTION_HANDLE sslConnectionHandle, void *buf, UINT32 len) |
| read len bytes from sslConnectionHandle SSL TLS connection into buf More... | |
| INT32 | m2mb_ssl_shutdown (M2MB_SSL_CONNECTION_HANDLE sslConnectionHandle) |
| shutdown SSL TLS connection More... | |
| INT32 | m2mb_ssl_cert_store (M2MB_SSL_CERT_TYPE_E sslCertType, M2MB_SSL_SEC_INFO_U sslSecInfo, CHAR *name) |
| store certificates from buffer More... | |
| INT32 | m2mb_ssl_cert_load (M2MB_SSL_CTXT_HANDLE sslCtxtHndl, M2MB_SSL_CERT_TYPE_E sslCertType, CHAR *name) |
| load certificates in the SSL context More... | |
| INT32 | m2mb_ssl_cert_delete (M2MB_SSL_CERT_TYPE_E sslCertType, CHAR *name) |
| delete certificates More... | |
| void | m2mb_ssl_delete_ctxt (M2MB_SSL_CTXT_HANDLE sslCtxtHndl) |
| delete context More... | |
| INT32 | m2mb_ssl_config (M2MB_SSL_CONFIG_HANDLE sslConfigHndl, INT32 cmd, void *argp) |
| to configure the paramaters More... | |
SSL TLS support.
m2m/m2m_common/m2mb_inc/m2mb_ssl.h
SSL TLS secure socket APIs
@notes Dependencies: #include <m2mb_types.h> #include <m2mb_socket.h> #include <m2mb_trace.h>
| INT32 m2mb_ssl_cert_delete | ( | M2MB_SSL_CERT_TYPE_E | sslCertType, |
| CHAR * | name | ||
| ) |
delete certificates
delete CA list or client certificate and key or PSK table depending on first parameter(SSL cert type)
| [in] | CHAR | *name specifies name of the SSL certificate to be deleted |
Example
| INT32 m2mb_ssl_cert_load | ( | M2MB_SSL_CTXT_HANDLE | sslCtxtHndl, |
| M2MB_SSL_CERT_TYPE_E | sslCertType, | ||
| CHAR * | name | ||
| ) |
load certificates in the SSL context
load in the SSL context CA list or client cert and key or PSK table previously stored with m2mb_ssl_cert_store
| [in] | M2MB_SSL_CTXT_HANDLE | sslCtxtHndl specifies the SSL context handle of the context to be loaded |
| [in] | M2MB_SSL_CERT_TYPE_E | sslCertType specifies the SSL certificate type |
| [in] | CHAR | *name specifies name of the SSL certificate |
Example
| INT32 m2mb_ssl_cert_store | ( | M2MB_SSL_CERT_TYPE_E | sslCertType, |
| M2MB_SSL_SEC_INFO_U | sslSecInfo, | ||
| CHAR * | name | ||
| ) |
store certificates from buffer
store CA list or client certificate and key or PSK table depending on first parameter(SSL cert type)
| [in] | M2MB_SSL_CERT_TYPE_E | sslCertType specifies the SSL certificate type |
| [in] | M2MB_SSL_SEC_INFO_U | sslSecInfo specifies the SSL certificate(CA list or client certificate and key or PSK table depending on first parameter) |
| [in] | CHAR | *name specifies name of the SSL certificate |
Example
| INT32 m2mb_ssl_config | ( | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl, |
| INT32 | cmd, | ||
| void * | argp | ||
| ) |
to configure the paramaters
this API can be used to set configurations for DTLS and SNI. for DTLS, use this API to set sock address. for SNI, use this API to pass server name.
| [in] | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl specifies the SSL configuration handler previously created through m2mb_ssl_create_config |
| [in] | INT32 | cmd Integer value 0, 1, or 2 specifies the action. |
| [in] | void | *argp pointer to the value to set for that action in cmd |
Example
| INT32 m2mb_ssl_connect | ( | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle | ) |
performs SSL TLS connection
performs SSL TLS handshake over sslConnectionHandle
| [in] | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle specifies the sslConnectionHandle previously returned by m2mb_ssl_secure_socket |
Example
| M2MB_SSL_CONFIG_HANDLE m2mb_ssl_create_config | ( | M2MB_SSL_CONFIG_T | sslConfig, |
| INT32 * | result | ||
| ) |
creates an SSL TLS configuration
creates an SSL TLS configuration with specified configuration parameters and returns an handler to be used when creating secure socket connection(m2mb_ssl_secure_socket)
| [in] | M2MB_SSL_CONFIG_T | sslConfig specifies SSL configuration parameters(TLS version, auth type and ciphersuites) |
| [out] | INT32 | *result returns result < 0 in case of error |
Example
| M2MB_SSL_CTXT_HANDLE m2mb_ssl_create_ctxt | ( | void | ) |
creates SSL TLS context
creates SSL TLS context that permits to load certificates(m2mb_ssl_cert_load) if needed and to create a secure socket connection(m2mb_ssl_secure_socket)
Example
| INT32 m2mb_ssl_delete_config | ( | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl | ) |
deletes an SSL TLS configuration
| [in] | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl specifies the config handler to be deleted |
Example
| void m2mb_ssl_delete_ctxt | ( | M2MB_SSL_CTXT_HANDLE | sslCtxtHndl | ) |
delete context
| [in] | M2MB_SSL_CTXT_HANDLE | sslCtxtHndl specifies handle of the context to be deleted |
Example
| INT32 m2mb_ssl_read | ( | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle, |
| void * | buf, | ||
| UINT32 | len | ||
| ) |
read len bytes from sslConnectionHandle SSL TLS connection into buf
| [in] | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle specifies the sslConnectionHandle |
| [in] | UINT8 | *buf specifies the input buffer |
| [in] | UINT32 | len specifies the input len |
Example
| M2MB_SSL_CONNECTION_HANDLE m2mb_ssl_secure_socket | ( | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl, |
| M2MB_SSL_CTXT_HANDLE | sslCtxtHndl, | ||
| M2MB_SOCKET_BSD_SOCKET | socket_fd, | ||
| INT32 * | result | ||
| ) |
creates secure socket connection
creates secure socket connection retrieving context and configuration parameters and linking a secure socket connection id to socket fd
| [in] | M2MB_SSL_CONFIG_HANDLE | sslConfigHndl specifies the SSL configuration handler previously created through m2mb_ssl_create_config |
| [in] | M2MB_SSL_CONTEXT_HANDLE | sslCtxtHndl specifies the SSL context previously created through m2mb_ssl_create_ctxt |
| [in] | M2MB_SOCKET_BSD_SOCKET | socket_fd specifies the socket fd |
| [out] | INT32 | *result returns result < 0 in case of error |
Example
| INT32 m2mb_ssl_shutdown | ( | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle | ) |
shutdown SSL TLS connection
| [in] | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle specifies the sslConnectionHandle |
Example
| INT32 m2mb_ssl_write | ( | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle, |
| void * | buf, | ||
| UINT32 | len | ||
| ) |
writes len bytes from buf into sslConnectionHandle SSL TLS connection
| [in] | M2MB_SSL_CONNECTION_HANDLE | sslConnectionHandle specifies the sslConnectionHandle |
| [in] | UINT8 | *buf specifies the input buffer |
| [in] | UINT32 | len specifies the input len |
Example