![]() |
WL865E4-P
36.07.001
|
This section describes the M2MB APIs for Layer Security (TLS) and the Secure Socket Layer (SSL). More...
This section describes the M2MB APIs for Layer Security (TLS) and the Secure Socket Layer (SSL).
TLS/SSL is used to provide security and data integrity between two pers communicating over TCP. After a TCP/UDP connection is established, the two pers use a handshake mechanism to establish the keys used for encryption/decryption and data verification. Once the handshake is successful, data can be transmitted/received over the SSL connection.
#define M2MB__SSL_TRUE 1 |
Denotes TRUE
Definition at line 80 of file m2mb_ssl.h.
#define M2MB_SSL_ALERT -54 |
Macro for a decoded alert
Definition at line 76 of file m2mb_ssl.h.
#define M2MB_SSL_ARG_FAIL -6 |
Macro for Failure due to bad function param
Definition at line 62 of file m2mb_ssl.h.
#define M2MB_SSL_CERT_AUTH_FAIL -35 |
Macro for authentication failure
Definition at line 74 of file m2mb_ssl.h.
#define M2MB_SSL_CLOSE_NOTIFY -18 |
Macro for a SSL connection closure by remote host
Definition at line 73 of file m2mb_ssl.h.
#define M2MB_SSL_END_OF_FILE -17 |
Macro for no data to read in SSL
Definition at line 72 of file m2mb_ssl.h.
#define M2MB_SSL_FAILURE -1 |
Macro for Generic failure
Definition at line 61 of file m2mb_ssl.h.
#define M2MB_SSL_FALSE 0 |
Denotes FALSE
Definition at line 79 of file m2mb_ssl.h.
#define M2MB_SSL_FILE_NOT_FOUND -55 |
Macro for File not found
Definition at line 77 of file m2mb_ssl.h.
#define M2MB_SSL_FULL -50 |
Not used
Definition at line 75 of file m2mb_ssl.h.
#define M2MB_SSL_INTERRUPT_FAIL -14 |
Macro for an interrupt and MAY be an error
Definition at line 69 of file m2mb_ssl.h.
#define M2MB_SSL_INVALID_HANDLE (0) |
Macro for invalid SSL handle
Definition at line 83 of file m2mb_ssl.h.
#define M2MB_SSL_LIMIT_FAIL -9 |
Not used
Definition at line 65 of file m2mb_ssl.h.
#define M2MB_SSL_MAX_CA_LIST 10 |
Macro for mavimum number of CA certs
Definition at line 81 of file m2mb_ssl.h.
#define M2MB_SSL_MAX_CERT_NAME_LEN 64 |
Macro for Maximum length of name of a certificate
Definition at line 286 of file m2mb_ssl.h.
#define M2MB_SSL_MAX_CIPHER_COUNT 64 |
Macro for Maximum ciphers
Definition at line 285 of file m2mb_ssl.h.
#define M2MB_SSL_MAX_SNI_NAME_LEN (64) |
Macro for Maximum length of SNI name
Definition at line 287 of file m2mb_ssl.h.
#define M2MB_SSL_MEM_FAIL -8 |
Not used
Definition at line 64 of file m2mb_ssl.h.
#define M2MB_SSL_PLATFORM_FAIL -7 |
Not used
Definition at line 63 of file m2mb_ssl.h.
#define M2MB_SSL_PROTOCOL_FAIL -12 |
Macro for protocol error
Definition at line 67 of file m2mb_ssl.h.
#define M2MB_SSL_READ_ERROR -16 |
Macro for an error while decoding from socket
Definition at line 71 of file m2mb_ssl.h.
#define M2MB_SSL_TIMEOUT_FAIL -13 |
Macro for timeout and MAY be an error
Definition at line 68 of file m2mb_ssl.h.
#define M2MB_SSL_UNSUPPORTED_FAIL -10 |
Not used
Definition at line 66 of file m2mb_ssl.h.
#define M2MB_SSL_WRITE_ERROR -15 |
Macro for an error while encoding on socket
Definition at line 70 of file m2mb_ssl.h.
typedef enum M2MB_SSL_AUTH_TYPE_E M2MB_SSL_AUTH_TYPE_E |
SSL authentication types enum.
typedef struct M2MB_SSL_CA_INFO_T M2MB_SSL_CA_INFO_T |
SSL certificate authority list information.
typedef struct M2MB_SSL_CA_LIST_T M2MB_SSL_CA_LIST_T |
SSL certificate authority information for conversion and storage.
typedef enum M2MB_SSL_CERT_FMT_E M2MB_SSL_CERT_FMT_E |
SSL certificate format enum.
typedef struct M2MB_SSL_CERT_LIST_T M2MB_SSL_CERT_LIST_T |
SSL Cert list structure.
typedef struct M2MB_SSL_CERT_T M2MB_SSL_CERT_T |
SSL certificate information for conversion and storage.
typedef enum M2MB_SSL_CERT_TYPE_E M2MB_SSL_CERT_TYPE_E |
SSL certificate type enum.
typedef enum M2MB_SSL_CIPHER_SUITE_E M2MB_SSL_CIPHER_SUITE_E |
TLS ciphersuites enum.
typedef struct M2MB_SSL_CONFIG_T M2MB_SSL_CONFIG_T |
Structure to configure an SSL connection.
typedef HANDLE M2MB_SSL_CTXT_HANDLE |
SSL context handle.
This is obtained from m2mb_ssl_create_ctxt API and then used in subsequent SSL APIs.
Definition at line 107 of file m2mb_ssl.h.
typedef enum M2MB_SSL_PEMCERT_TYPE_E M2MB_SSL_PEMCERT_TYPE_E |
SSL certificate type enum.
typedef enum M2MB_SSL_PROTOCOL_VERSION_E M2MB_SSL_PROTOCOL_VERSION_E |
TLS protocol version enum.
typedef struct M2MB_SSL_PSK_TABLE_T M2MB_SSL_PSK_TABLE_T |
PSK table structure. Structure to hold a preshared key (PSK) used to populate the PSK table. The PSK table is used by TLS PSK cipher suites.
typedef enum M2MB_SSL_SSL_ROLE_E M2MB_SSL_SSL_ROLE_E |
SSL object role.
typedef enum M2MB_SSL_UPPROTO_TYPE M2MB_SSL_UPPROTO_TYPE_E |
typedef enum SSL_CFG_PARAM SSL_CFG_PARAM_E |
enum M2MB_SSL_AUTH_TYPE_E |
SSL authentication types enum.
Enumerator | |
---|---|
M2MB_SSL_NO_AUTH | |
M2MB_SSL_SERVER_AUTH | |
M2MB_SSL_SERVER_CLIENT_AUTH |
Definition at line 269 of file m2mb_ssl.h.
enum M2MB_SSL_CERT_FMT_E |
SSL certificate format enum.
Enumerator | |
---|---|
M2MB_SSL_DER | |
M2MB_SSL_PEM | DER format certificate or key |
Definition at line 202 of file m2mb_ssl.h.
enum M2MB_SSL_CERT_TYPE_E |
SSL certificate type enum.
Definition at line 180 of file m2mb_ssl.h.
TLS ciphersuites enum.
Definition at line 120 of file m2mb_ssl.h.
SSL certificate type enum.
Definition at line 191 of file m2mb_ssl.h.
TLS protocol version enum.
Definition at line 110 of file m2mb_ssl.h.
enum M2MB_SSL_SSL_ROLE_E |
SSL object role.
Enumerator | |
---|---|
M2MB_SSL_SSL_ROLE_SERVER_E | Server role. |
M2MB_SSL_SSL_ROLE_CLIENT_E | Client role. |
Definition at line 277 of file m2mb_ssl.h.
Definition at line 209 of file m2mb_ssl.h.
enum SSL_CFG_PARAM |
Definition at line 85 of file m2mb_ssl.h.
INT32 m2mb_ssl_accept | ( | M2MB_SSL_CTXT_HANDLE | sslSvrContextHndl, |
M2MB_SOCKET_BSD_SOCKET | socket_fd, | ||
M2MB_SSL_CTXT_HANDLE * | sslClientCtxHndl | ||
) |
Accepts an incoming SSL connection from the client.
It creates a client context, sets configuration passed to the incoming client context, links a secure socket connection id to socket fd and accepts the incoming client connection. This should be called only by a server SSL object. This will respond to the incoming client hello message and complete the SSL handshake.
[in] | sslSvrContextHndl | specifies the SSL context of the server previously created through m2mb_ssl_init |
[in] | socket_fd | specifies the socket fd for the incoming client |
[out] | sslClientCtxHndl | client context handle |
Example
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] | sslCertType | Specifies the type of certificate to be deleted |
[in] | name | Specifies name of the SSL certificate to be deleted |
Example
INT32 m2mb_ssl_cert_get | ( | M2MB_SSL_CERT_TYPE_E | sslCertType, |
M2MB_SSL_CERT_LIST_T * | sslCertList | ||
) |
It gets the list of the certificates stored.
This command is used to get the list of the certificates.
[in] | sslCertType | |
[in] | sslCertList |
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] | sslCtxtHndl | Specifies the SSL context handle of the SSL connection |
[in] | sslCertType | Specifies the SSL certificate type |
[in] | name | Specifies name of the SSL certificate |
Example
INT32 m2mb_ssl_cert_search | ( | M2MB_SSL_CERT_TYPE_E | sslCertType, |
CHAR * | certName | ||
) |
Search for the given certificate in the system.
This command is used to find the certificate from the list of the certificates stored in the system.
[in] | sslCertType | |
[in] | certName |
Example
INT32 m2mb_ssl_cert_store | ( | M2MB_SSL_CERT_TYPE_E | sslCertType, |
M2MB_SSL_SEC_INFO_U | sslSecInfo, | ||
CHAR * | name, | ||
M2MB_SSL_CERT_FMT_E | format | ||
) |
Store certificates from buffer.
Store CA list or client certificate and key or PSK table depending on the first parameter(SSL cert type)
[in] | sslCertType | Specifies the SSL certificate type |
[in] | sslSecInfo | Specifies the SSL certificate(CA list or client certificate and key or PSK table depending on first parameter) |
[in] | name | Specifies name of the SSL certificate |
[in] | format | Specifies the ssl certificate format |
Example
void m2mb_ssl_close | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl | ) |
deletes an m2mb SSL context created during m2mb_ssl_init()
[in] | sslContextHndl |
Example
INT32 m2mb_ssl_connect | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl, |
M2MB_SOCKET_BSD_SOCKET | socket_fd | ||
) |
Performs SSL Client connection.
Performs SSL client connection
[in] | sslContextHndl | Specifies the sslContextHndl previously returned by m2mb_ssl_init |
[in] | socket_fd | Specifies the socket ID to make the connection. |
Example
UINT8 m2mb_ssl_get_certloadStatus | ( | M2MB_SSL_CTXT_HANDLE | sslCtxtHndl, |
M2MB_SSL_CERT_TYPE_E | sslCertType | ||
) |
Check if the certificate is loaded in the SSL context.
Check if the certificate is loaded in SSL context
[in] | sslCtxtHndl | Specifies the SSL context handle of the context to be loaded |
[in] | sslCertType | Specifies the SSL certificate type |
Example
UINT32 m2mb_ssl_get_internal_ssl_obj | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl | ) |
It get the list of certificates stored.
This command is used to get the list of certificates.
[in] | sslContextHndl | Specifies the SSL context handle previously created through m2mb_ssl_init |
Example
M2MB_SSL_CTXT_HANDLE m2mb_ssl_init | ( | M2MB_SSL_SSL_ROLE_E | role | ) |
Initialize SSL TLS context.
Creates SSL TLS context that which will be used in all the future calls to m2mb SSL module
[in] | role | Role of the SSL handle i.e. server or client |
Example
INT32 m2mb_ssl_read | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl, |
void * | buf, | ||
UINT32 | len | ||
) |
Read len bytes from SSL connection into buf.
[in] | sslContextHndl | Specifies the sslContextHndl previously created during m2mb_ssl_init |
[out] | buf | Specifies the read buffer |
[in] | len | Specifies the input len |
Example
INT32 m2mb_ssl_secure_protocol | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl, |
M2MB_SSL_UPPROTO_TYPE_E | protoType, | ||
VOID * | protoCtxHndl | ||
) |
Configures the SSL security on the given protocol connection.
Configures SSL configuration in the given protocol context.
[in] | sslContextHndl | Specifies the SSL context previously created through m2mb_ssl_init |
[in] | protoType | Specifies the protocol type M2MB_SSL_CLIENT M2MB_SSL_HTTPC M2MB_SSL_HTTPC, M2MB_SSL_HTTPD, M2MB_SSL_MQTT, M2MB_SSL_WEBSOCKET, |
[in] | protoCtxHndl | Specify the protocol context handle |
Example
INT32 m2mb_ssl_set_config | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl, |
SSL_CFG_PARAM_E | CONF_ID, | ||
INT8 * | CONF_VAL | ||
) |
Set SSL configuration on the previously created SSL context.
Set an SSL TLS configuration with specified configuration parameters and sets the config on the provided SSL context handle.
[in] | sslContextHndl | Specify the SSL context pointer created previously during m2mb_ssl_init(); |
[in] | CONF_ID | Specify the confd id as defined below: |
0 : Invalid config param 1 : To Set SSL Protocol Vertion 2 : To Set SSL CA Certificate 3 : To Set SSL Certificate 4 : To Set Cipher Information 5 : To Enable/Disable Time Validation 6 : To Enable/Disable SSL Alert 7 : To Set The Domain 8 : To Set the Max Fragment Length 9 : To Set Negotiation 10 : To Set the SNI 11 : To Set the ALPN Extension
[in] | CONF_VAL | Specifies string value specific to the configuration provided in CONF_ID.CONF_ID : CONF_VAL 0 : Invalid 1 : Values for CONF_VAL: 0 : TLS Version 1.0 1 : TLS Version 1_1 2 : TLS Version 1_2 3 : DTLS Version 1.0 4 : DTLS Version 1_2 2 : SSL CA Certificate Name 3 : SSL certificate Name 4 : Cipher Information 5 : Time Validation 0 : Disable Time validation 1 : Enable Time validation 6 : Enable/Disable SSL Alert 0 : Disable SSL Alert Indication 1 : Enable SSL Alert 7 : Domain name in String format 8 : Set the Max Fragment Length 9 : Set Negotiation 10 : To Set the SNI 11 : To Set the ALPN Extension |
Example
INT32 m2mb_ssl_status | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl | ) |
Returns the status of an SSL connection.
Returns the status of an SSL connection.
[in] | sslContextHndl | Specifies the SSL context handle previously created through m2mb_ssl_init |
Example
INT32 m2mb_ssl_write | ( | M2MB_SSL_CTXT_HANDLE | sslContextHndl, |
void * | buf, | ||
UINT32 | len | ||
) |
Writes data to the SSL connection.
[in] | sslContextHndl | Specifies the sslContextHndl |
[in] | buf | Specifies the input buffer |
[in] | len | Specifies the input len |
Example