TLS Socket header file. More...
#include "mcl_core/mcl_assert.h"
Go to the source code of this file.
Enumerations | |
enum | E_MCL_TLS_SOCKET_PARAMETER { MCL_TLS_SOCKET_PARAMETER_CERTIFICATE_CHAIN, MCL_TLS_SOCKET_PARAMETER_TIMEOUT, MCL_TLS_SOCKET_PARAMETER_END } |
Functions | |
mcl_error_t | mcl_tls_ca_chain_init (mcl_tls_ca_chain_handle *tls_ca_chain_handle) |
mcl_error_t | mcl_tls_ca_chain_add_certificate (mcl_tls_ca_chain_handle tls_ca_chain_handle, const char *certificate, mcl_bool_t is_file) |
void | mcl_tls_ca_chain_destroy (mcl_tls_ca_chain_handle *tls_ca_chain_handle) |
mcl_error_t | mcl_tls_socket_init (mcl_tls_socket_handle *tls_socket_handle) |
mcl_error_t | mcl_tls_socket_set_parameter (mcl_tls_socket_handle tls_socket_handle, E_MCL_TLS_SOCKET_PARAMETER parameter, const void *value) |
mcl_error_t | mcl_tls_socket_open (mcl_tls_socket_handle tls_socket_handle) |
mcl_error_t | mcl_tls_socket_connect (mcl_tls_socket_handle tls_socket_handle, const char *host, mcl_uint16_t port) |
mcl_error_t | mcl_tls_socket_send (mcl_tls_socket_handle tls_socket_handle, const mcl_uint8_t *buffer, mcl_size_t *buffer_length) |
mcl_error_t | mcl_tls_socket_receive (mcl_tls_socket_handle tls_socket_handle, mcl_uint8_t *buffer, mcl_size_t *buffer_length) |
void | mcl_tls_socket_destroy (mcl_tls_socket_handle *tls_socket_handle) |
TLS Socket header file.
Definition in file mcl_tls_socket.h.
Enumerator | |
---|---|
MCL_TLS_SOCKET_PARAMETER_CERTIFICATE_CHAIN | |
MCL_TLS_SOCKET_PARAMETER_TIMEOUT | |
MCL_TLS_SOCKET_PARAMETER_END |
Definition at line 22 of file mcl_tls_socket.h.
mcl_error_t mcl_tls_ca_chain_add_certificate | ( | mcl_tls_ca_chain_handle | tls_ca_chain_handle, |
const char * | certificate, | ||
mcl_bool_t | is_file | ||
) |
This function creates and initializes a #mcl_tls_ca_chain_handle.
[in] | tls_ca_chain_handle | Certificate chain handle. |
[in] | certificate | Certificate. |
[in] | is_file | MCL_TRUE if certificate is given as file, MCL_FALSE otherwise. |
Definition at line 126 of file tls_socket_mbedtls.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR_RETURN, MCL_IMPROPER_CERTIFICATE, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OPERATION_NOT_SUPPORTED, MCL_OUT_OF_MEMORY, mcl_string_util_strlen(), and MCL_TRUE.
Referenced by mcl_http_client_add_certificate(), and mcl_http_client_initialize().
void mcl_tls_ca_chain_destroy | ( | mcl_tls_ca_chain_handle * | tls_ca_chain_handle | ) |
This function destroys the #mcl_tls_ca_chain_handle and frees any memory allocated.
[in] | tls_ca_chain_handle | Preinitialized #mcl_tls_ca_chain_handle to destroy. |
Definition at line 166 of file tls_socket_mbedtls.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, and MCL_FREE.
Referenced by mcl_http_client_destroy().
mcl_error_t mcl_tls_ca_chain_init | ( | mcl_tls_ca_chain_handle * | tls_ca_chain_handle | ) |
This function creates and initializes a #mcl_tls_ca_chain_handle.
[out] | tls_ca_chain_handle | Certificate chain handle. |
Definition at line 102 of file tls_socket_mbedtls.c.
References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_MALLOC, MCL_OK, and MCL_OUT_OF_MEMORY.
Referenced by mcl_http_client_initialize().
mcl_error_t mcl_tls_socket_connect | ( | mcl_tls_socket_handle | tls_socket_handle, |
const char * | host, | ||
mcl_uint16_t | port | ||
) |
This function connects TLS socket to a remote host.
[in] | tls_socket_handle | TLS socket handle. |
[in] | host | Host to connect. |
[in] | port | Port. |
tls_socket_handle
or host
is NULL. Definition at line 294 of file tls_socket_mbedtls.c.
References MCL_COULD_NOT_CONNECT, MCL_COULD_NOT_RESOLVE_HOST, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_ERROR, MCL_FAIL, MCL_INVALID_PARAMETER, MCL_NULL, MCL_OK, MCL_OUT_OF_MEMORY, MCL_SERVER_CERTIFICATE_NOT_VERIFIED, MCL_SSL_HANDSHAKE_FAIL, mcl_string_util_snprintf(), MCL_TRIGGERED_WITH_NULL, and PORT_STRING_BUFFER_SIZE.
Referenced by start_http().
void mcl_tls_socket_destroy | ( | mcl_tls_socket_handle * | tls_socket_handle | ) |
This function destroys the #mcl_tls_socket_handle and frees any memory allocated.
[in] | tls_ca_chain_handle | Preinitialized #mcl_tls_socket_handle to destroy. |
Definition at line 489 of file tls_socket_mbedtls.c.
References MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FREE, and MCL_NULL.
Referenced by mcl_http_client_send(), and mcl_tls_socket_init().
mcl_error_t mcl_tls_socket_init | ( | mcl_tls_socket_handle * | tls_socket_handle | ) |
This function creates and initializes a #mcl_tls_socket_handle.
[out] | tls_socket_handle | TLS socket handle. |
Definition at line 179 of file tls_socket_mbedtls.c.
References entropy_string, mbedtls_debug_function(), MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FAIL, MCL_FUNCTION_LEAVE_LABEL, MCL_LOG_ENABLED_COMPILE_TIME, MCL_LOG_LEVEL_DEBUG, MCL_LOG_LEVEL_ERROR, MCL_LOG_LEVEL_VERBOSE, MCL_MALLOC, MCL_NULL, MCL_NULL_CHAR_SIZE, MCL_OK, MCL_OUT_OF_MEMORY, and mcl_tls_socket_destroy().
Referenced by mcl_http_client_send().
mcl_error_t mcl_tls_socket_open | ( | mcl_tls_socket_handle | tls_socket_handle | ) |
This function is used to open a TLS socket.
[in] | tls_socket_handle | TLS socket handle. |
tls_socket_handle
or value
is NULL. Definition at line 279 of file tls_socket_mbedtls.c.
References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, and MCL_OK.
Referenced by mcl_http_client_send().
mcl_error_t mcl_tls_socket_receive | ( | mcl_tls_socket_handle | tls_socket_handle, |
mcl_uint8_t * | buffer, | ||
mcl_size_t * | buffer_length | ||
) |
This function is used to receive data over TLS socket.
[in] | tls_socket_handle | TLS socket handle. |
[out] | buffer | Buffer to write the received data. |
[in,out] | buffer_length | Size of the buffer in bytes. It will be set to size of bytes successfully received. |
tls_socket_handle
or buffer_length
is NULL. Definition at line 451 of file tls_socket_mbedtls.c.
References MCL_ERROR, MCL_FAIL, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRIGGERED_WITH_NULL, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by receive_to_buffer(), and receive_until_lf().
mcl_error_t mcl_tls_socket_send | ( | mcl_tls_socket_handle | tls_socket_handle, |
const mcl_uint8_t * | buffer, | ||
mcl_size_t * | buffer_length | ||
) |
This function is used to send data over TLS socket.
[in] | tls_socket_handle | TLS socket handle. |
[in] | buffer | Buffer to be sent. |
[in,out] | buffer_length | Size of the buffer in bytes. It will be set to size of bytes successfully sent. |
tls_socket_handle
or buffer_length
is NULL. Definition at line 412 of file tls_socket_mbedtls.c.
References MCL_ERROR, MCL_FAIL, MCL_INVALID_PARAMETER, MCL_OK, MCL_TRIGGERED_WITH_NULL, MCL_VERBOSE_ENTRY, and MCL_VERBOSE_LEAVE.
Referenced by send_buffer().
mcl_error_t mcl_tls_socket_set_parameter | ( | mcl_tls_socket_handle | tls_socket_handle, |
E_MCL_TLS_SOCKET_PARAMETER | parameter, | ||
const void * | value | ||
) |
This function is used to set a parameter of a TLS socket handle.
[in] | tls_socket_handle | TLS socket handle. |
[in] | parameter | One of the parameters listed in E_MCL_TLS_SOCKET_PARAMETER. |
[in] | value | New value of the parameter . |
tls_socket_handle
or value
is NULL. parameter
is invalid. Definition at line 251 of file tls_socket_mbedtls.c.
References MCL_ASSERT_NOT_NULL, MCL_DEBUG_ENTRY, MCL_DEBUG_LEAVE, MCL_FUNCTION_LEAVE_LABEL, MCL_INVALID_PARAMETER, MCL_NULL, MCL_OK, MCL_TLS_SOCKET_PARAMETER_CERTIFICATE_CHAIN, and MCL_TLS_SOCKET_PARAMETER_TIMEOUT.
Referenced by mcl_http_client_send().