Skip to content

Commit

Permalink
Upload secure-sockets 3.3.0.2516 [1864]
Browse files Browse the repository at this point in the history
  • Loading branch information
gitlab-runner committed Sep 28, 2023
1 parent b52f891 commit f7508f9
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 132 deletions.
File renamed without changes.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ This library and its features are supported on the following Infineon MCUs:

- [PSoC™ 62S2 evaluation kit (CY8CEVAL-062S2-MUR-43439M2)](https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-evaluation-kit-cy8ceval-062s2)

- [XMC7200D-E272K8384 kit (KIT-XMC72-EVK)](https://www.infineon.com/KIT_XMC72_EVK)
- [XMC7200D-E272K8384 kit (KIT-XMC72-EVK)](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/)

- [XMC7200D-E272K8384 kit (KIT_XMC72_EVK_MUR_43439M2)](https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/)

## Send and receive timeout values

Expand Down
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ Refer to the [README.md](./README.md) for a complete description of the Secure S

## Changelog

### v3.3.0
* Resolved coverity warnings
* Added support for KIT_XMC72_EVK_MUR_43439M2 kit

### v3.2.2
* Minor bug fixes

Expand Down
3 changes: 2 additions & 1 deletion docs/api_reference_manual/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ <h1><a class="anchor" id="section_platforms"></a>
<li><a href="https://www.cypress.com/documentation/development-kitsboards/cyw954907aeval1f-evaluation-kit">CYW954907AEVAL1F Evaluation Kit(CYW954907AEVAL1F)</a></li>
<li><a href="https://www.cypress.com/documentation/development-kitsboards/cyw943907aeval1f-evaluation-kit">CYW943907AEVAL1F Evaluation Kit(CYW943907AEVAL1F)</a></li>
<li><a href="https://www.cypress.com/documentation/development-kitsboards/psoc-62s2-evaluation-kit-cy8ceval-062s2">PSoC&trade; 62S2 evaluation kit (CY8CEVAL-062S2-MUR-43439M2)</a></li>
<li><a href="https://www.infineon.com/KIT_XMC72_EVK">XMC7200D-E272K8384 kit (KIT-XMC72-EVK)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/">XMC7200D-E272K8384 kit (KIT-XMC72-EVK)</a></li>
<li><a href="https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc72_evk/">XMC7200D-E272K8384 kit (KIT_XMC72_EVK_MUR_43439M2)</a></li>
</ul>
<h1><a class="anchor" id="section_Send"></a>
Send and receive timeout values</h1>
Expand Down
2 changes: 1 addition & 1 deletion source/COMPONENT_LWIP/cy_secure_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ extern uint32_t cy_tls_get_bytes_avail(void *context);

static bool is_socket_valid(cy_socket_ctx_t* socket)
{
if((socket->socket_magic_header == SECURE_SOCKETS_MAGIC_HEADER) && (socket->socket_magic_footer == SECURE_SOCKETS_MAGIC_FOOTER))
if((socket != NULL) && (socket->socket_magic_header == SECURE_SOCKETS_MAGIC_HEADER) && (socket->socket_magic_footer == SECURE_SOCKETS_MAGIC_FOOTER))
{
return true;
}
Expand Down
136 changes: 22 additions & 114 deletions source/COMPONENT_NETXDUO/cy_secure_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@


#ifndef DEFAULT_TCP_WINDOW_SIZE
#define DEFAULT_TCP_WINDOW_SIZE (7 * 1024)
#define DEFAULT_TCP_WINDOW_SIZE (16 * 1024)
#endif

#ifndef DEFAULT_UDP_QUEUE_SIZE
Expand Down Expand Up @@ -229,7 +229,7 @@ static cy_nxd_sock_t socket_list[NUM_SOCKETS];

static bool is_socket_valid(cy_socket_ctx_t *socket)
{
if ((socket->socket_magic_header == SECURE_SOCKETS_MAGIC_HEADER) && (socket->socket_magic_footer == SECURE_SOCKETS_MAGIC_FOOTER))
if ((socket != NULL) && (socket->socket_magic_header == SECURE_SOCKETS_MAGIC_HEADER) && (socket->socket_magic_footer == SECURE_SOCKETS_MAGIC_FOOTER))
{
return true;
}
Expand Down Expand Up @@ -485,10 +485,10 @@ static bool str_to_ipv6(const char *str, uint32_t *ipv6_addr)
if (curr_segment_idx & 0x1)
{
ipv6_addr[addr_idx++] |= curr_segment_val;
}
}
else
{
ipv6_addr[addr_idx] = curr_segment_val << 16;
ipv6_addr[addr_idx] = curr_segment_val << 16;
}

curr_segment_idx++;
Expand All @@ -514,12 +514,12 @@ static bool str_to_ipv6(const char *str, uint32_t *ipv6_addr)
if (curr_segment_idx & 0x1)
{
addr_idx++;
}
}
else
{
ipv6_addr[addr_idx] = 0;
ipv6_addr[addr_idx] = 0;
}

curr_segment_idx++;
if (curr_segment_idx > (IPV6_SEGMENT_CNT-1))
{
Expand All @@ -544,12 +544,12 @@ static bool str_to_ipv6(const char *str, uint32_t *ipv6_addr)
if (curr_segment_idx & 0x1)
{
ipv6_addr[addr_idx++] |= curr_segment_val;
}
}

if (curr_segment_idx != (IPV6_SEGMENT_CNT-1))
{
return false;
}
}

return true;
}
Expand Down Expand Up @@ -793,84 +793,6 @@ static void free_socket(cy_socket_ctx_t *socket)
free(socket);
}

static unsigned char max_fragment_length_to_mfl_code(uint32_t max_fragment_length)
{
unsigned char mfl;
switch (max_fragment_length)
{
case 0:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_NONE;
break;
}
case 512:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_512;
break;
}
case 1024:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_1024;
break;
}
case 2048:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_2048;
break;
}
case 4096:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_4096;
break;
}
default:
{
mfl = SECURE_SOCKETS_MAX_FRAG_LEN_INVALID;
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "Invalid maximum fragment length\n");
}
}
return mfl;
}

static uint32_t mfl_code_to_max_fragment_length(unsigned char mfl_code)
{
uint32_t max_fragment_length=0;;

switch (mfl_code)
{
case SECURE_SOCKETS_MAX_FRAG_LEN_NONE:
{
max_fragment_length = 0;
break;
}
case SECURE_SOCKETS_MAX_FRAG_LEN_512:
{
max_fragment_length = 512;
break;
}
case SECURE_SOCKETS_MAX_FRAG_LEN_1024:
{
max_fragment_length = 1024;
break;
}
case SECURE_SOCKETS_MAX_FRAG_LEN_2048:
{
max_fragment_length = 2048;
break;
}
case SECURE_SOCKETS_MAX_FRAG_LEN_4096:
{
max_fragment_length = 4096;
break;
}
default:
{
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "Invalid mflcode %d\n", mfl_code);
}
}
return max_fragment_length;
}

static cy_rslt_t nxd_to_secure_socket_error(UINT error)
{
switch (error)
Expand Down Expand Up @@ -1075,7 +997,7 @@ static bool is_nx_tcp_send_available(NX_TCP_SOCKET *socket_ptr)
return is_tx_queue_free;
}

/* Check if a given UDP socket is available for sending data. */
/* Check if a given UDP socket is available for sending data. */
static bool is_nx_udp_send_available(NX_UDP_SOCKET *socket_ptr)
{
/* There is no queuing of data in UDP sockets. Data can be sent if the socket is bound to a port. */
Expand Down Expand Up @@ -1855,16 +1777,12 @@ cy_rslt_t cy_socket_setsockopt(cy_socket_t handle, int level, int optname, const

case CY_SOCKET_SO_TLS_MFL:
{
uint32_t mfl = *((uint32_t *)optval);
ctx->mfl_code = max_fragment_length_to_mfl_code(mfl);
if (SECURE_SOCKETS_MAX_FRAG_LEN_INVALID == ctx->mfl_code)
{
cy_rtos_set_mutex(&ctx->socket_mutex);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_DEBUG, "socket_mutex unlocked %s %d\n", __FILE__, __LINE__);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "Incompatible Socket option\n");

return CY_RSLT_MODULE_SECURE_SOCKETS_BADARG;
}
break;
cy_rtos_set_mutex(&ctx->socket_mutex);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_DEBUG, "socket_mutex unlocked %s %d\n", __FILE__, __LINE__);

return CY_RSLT_MODULE_SECURE_SOCKETS_OPTION_NOT_SUPPORTED;
}
case CY_SOCKET_SO_TRUSTED_ROOTCA_CERTIFICATE:
{
Expand Down Expand Up @@ -2550,22 +2468,12 @@ cy_rslt_t cy_socket_getsockopt(cy_socket_t handle, int level, int optname, void

case CY_SOCKET_SO_TLS_MFL:
{
uint32_t mfl;

if (*optlen < sizeof(mfl))
{
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "insufficient option value buffer\n");

cy_rtos_set_mutex(&ctx->socket_mutex);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_DEBUG, "socket_mutex unlocked %s %d\n", __FILE__, __LINE__);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_ERR, "Incompatible Socket option\n");

return CY_RSLT_MODULE_SECURE_SOCKETS_BADARG;
}
cy_rtos_set_mutex(&ctx->socket_mutex);
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_DEBUG, "socket_mutex unlocked %s %d\n", __FILE__, __LINE__);

mfl = mfl_code_to_max_fragment_length(ctx->mfl_code);
*((uint32_t *)optval) = mfl;
*optlen = sizeof(mfl);
break;
return CY_RSLT_MODULE_SECURE_SOCKETS_OPTION_NOT_SUPPORTED;
}
default:
{
Expand Down Expand Up @@ -3322,7 +3230,7 @@ cy_rslt_t cy_socket_sendto(cy_socket_t handle, const void *buffer, uint32_t leng
return CY_RSLT_MODULE_TLS_OUT_OF_HEAP_SPACE;
}

/* Add data to the packet's payload.
/* Add data to the packet's payload.
* The below API will automatically perform packet chaining, if enabled. If there isn't enough
* packets available in the packet pool for the amount of data to be sent, it will immediately
* return with error.
Expand Down Expand Up @@ -3583,7 +3491,7 @@ cy_rslt_t cy_socket_recvfrom(cy_socket_t handle, void *buffer, uint32_t length,
if (!ip_addrs_same(&addr, &remote) || port != src_addr->port)
{
ss_cy_log_msg(CYLF_MIDDLEWARE, CY_LOG_DEBUG, "Sender addr doesn't match src_filter\n");
continue;
/* Removing 'continue' here as this is a do while(0) loop and continue has no effect */
}
}
} while (0);
Expand Down Expand Up @@ -4428,7 +4336,7 @@ cy_rslt_t cy_socket_accept(cy_socket_t handle, cy_socket_sockaddr_t *address, ui
nx_tcp_socket_receive_notify(accept_ctx->nxd_socket.tcp, cy_tcp_receive_callback);

/*
* Ideally, the existing callbacks should not be copied. Typically the callers have
* Ideally, the existing callbacks should not be copied. Typically the callers have
* added a callback argument for the callback event. If we copy the callback
* info to the new socket, the callback argument will be same as that passed to the
* the listening socket, instead of it being unique to the connected client socket.
Expand Down
31 changes: 17 additions & 14 deletions source/COMPONENT_NETXSECURE/cy_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -466,20 +466,6 @@ static cy_rslt_t nxsecure_to_tls_error(UINT error)
}
}

/*-----------------------------------------------------------*/
/*
* @brief helper function to get the current time from RTC.
*/
ULONG get_current_time()
{
time_t current_time;

memset(&current_time, 0, sizeof(current_time));

current_time = time(&current_time);

return current_time;
}
/*-----------------------------------------------------------*/
/*
* @brief Network receive helper function.
Expand Down Expand Up @@ -755,6 +741,23 @@ cy_rslt_t cy_tls_create_context(void **context, cy_tls_params_t *params)
return CY_RSLT_SUCCESS;
}

#ifdef ENABLE_HAVE_DATE_TIME
/*-----------------------------------------------------------*/
/*
* @brief helper function to get the current time from RTC.
*/
ULONG get_current_time()
{
time_t current_time;

memset(&current_time, 0, sizeof(current_time));

current_time = time(&current_time);

return (current_time);
}
#endif /* ENABLE_HAVE_DATE_TIME */

/*-----------------------------------------------------------*/
cy_rslt_t cy_tls_connect(void *context, cy_tls_endpoint_type_t endpoint, uint32_t timeout)
{
Expand Down
2 changes: 1 addition & 1 deletion version.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<version>3.2.2.2447</version>
<version>3.3.0.2516</version>

0 comments on commit f7508f9

Please sign in to comment.