From 8a7e1846baaa6084cf628456136d39f34c8c0b26 Mon Sep 17 00:00:00 2001 From: gitlab-runner Date: Thu, 28 Mar 2024 12:13:39 -0500 Subject: [PATCH] Upload lwip-network-interface-integration 1.3.1.331 [2307] --- RELEASE.md | 10 +- ...up__generic__lwip__whd__port__defines.html | 4 + ...roup__generic__lwip__whd__port__defines.js | 3 +- .../html/navtreeindex0.js | 1 + .../api_reference_manual/html/search/all_1.js | 25 +-- include/cy_network_mw_core.h | 15 +- source/cy_ethernetif.c | 2 +- source/cy_internal.h | 2 +- source/cy_lwip_dhcp_server.c | 2 +- source/cy_lwip_dhcp_server.h | 2 +- source/cy_lwip_log.h | 2 +- source/cy_network_mw_core.c | 153 +++++++++++++++++- source/cy_nw_mw_core_error.h | 4 +- source/cy_wifimwcore_eapol.h | 2 +- version.xml | 2 +- 15 files changed, 201 insertions(+), 28 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 19c164b..da2346f 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -6,6 +6,10 @@ See the [README.md](./README.md) for a complete description of the [lwIP network ## Changelog +### v1.3.1 + +- Added function to generate random number using trng + ### v1.3.0 - Minor changes in .cyignore @@ -45,10 +49,10 @@ This version of the library was validated for compatibility with the following s | Software and tools | Version | | :--- | :----: | -| ModusToolbox™ software environment | 3.1 | -| ModusToolbox™ Device Configurator | 4.10 | +| ModusToolbox™ software environment | 3.2 | +| ModusToolbox™ Device Configurator | 4.20 | | GCC compiler | 11.3.1 | -| IAR compiler | 9.30 | +| IAR compiler | 9.40.2 | | Arm® compiler 6 | 6.16 | diff --git a/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.html b/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.html index 7ed043f..7e2b4f3 100644 --- a/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.html +++ b/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.html @@ -213,6 +213,10 @@ #define CY_RSLT_NETWORK_LINK_NOT_UP   (CY_RSLT_NETWORK_PORT_ERR_BASE + 23)  Denotes that the Link is not up.
  + +#define CY_RSLT_NETWORK_ERROR_TRNG   (CY_RSLT_NETWORK_PORT_ERR_BASE + 24) + Denotes that the random number generation failed.

Macro Definition Documentation

diff --git a/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.js b/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.js index 4aa2848..44b4d26 100644 --- a/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.js +++ b/docs/api_reference_manual/html/group__generic__lwip__whd__port__defines.js @@ -22,5 +22,6 @@ var group__generic__lwip__whd__port__defines = [ "CY_RSLT_NETWORK_ERROR_NOMEM", "group__generic__lwip__whd__port__defines.html#ga1f0322ffd345df3120842c6d78c0f229", null ], [ "CY_RSLT_NETWORK_ERROR_RTOS", "group__generic__lwip__whd__port__defines.html#ga0c5b724f4d242fd2f465ba00cee17fa4", null ], [ "CY_RSLT_NETWORK_NOT_SUPPORTED", "group__generic__lwip__whd__port__defines.html#ga1ae343f44b7540a45f3680ba6d1a7226", null ], - [ "CY_RSLT_NETWORK_LINK_NOT_UP", "group__generic__lwip__whd__port__defines.html#gadd0ef95e5fb952dd62156060eaf25d2e", null ] + [ "CY_RSLT_NETWORK_LINK_NOT_UP", "group__generic__lwip__whd__port__defines.html#gadd0ef95e5fb952dd62156060eaf25d2e", null ], + [ "CY_RSLT_NETWORK_ERROR_TRNG", "group__generic__lwip__whd__port__defines.html#gac6ccfbb53bcd02d7017e9de24c3e0856", null ] ]; \ No newline at end of file diff --git a/docs/api_reference_manual/html/navtreeindex0.js b/docs/api_reference_manual/html/navtreeindex0.js index 0dfeafb..f38b4c8 100644 --- a/docs/api_reference_manual/html/navtreeindex0.js +++ b/docs/api_reference_manual/html/navtreeindex0.js @@ -21,6 +21,7 @@ var NAVTREEINDEX0 = "group__generic__lwip__whd__port__defines.html#gabc1d83188fe0b29bbe0de950519a52a8":[1,1,14], "group__generic__lwip__whd__port__defines.html#gabe7486b63b0e20d597c80f66b281a6c6":[1,1,3], "group__generic__lwip__whd__port__defines.html#gac2bfa236e9261ca5bab6e78d6f32d128":[1,1,13], +"group__generic__lwip__whd__port__defines.html#gac6ccfbb53bcd02d7017e9de24c3e0856":[1,1,23], "group__generic__lwip__whd__port__defines.html#gadd0ef95e5fb952dd62156060eaf25d2e":[1,1,22], "group__generic__lwip__whd__port__defines.html#gaf293c31318d2af1d62bac43bbdf4a462":[1,1,17], "group__generic__lwip__whd__port__defines.html#gafc24f9c602ae45614f7231508eb574bf":[1,1,11], diff --git a/docs/api_reference_manual/html/search/all_1.js b/docs/api_reference_manual/html/search/all_1.js index b2c5b97..902075a 100644 --- a/docs/api_reference_manual/html/search/all_1.js +++ b/docs/api_reference_manual/html/search/all_1.js @@ -45,16 +45,17 @@ var searchData= ['cy_5frslt_5fnetwork_5ferror_5frtos_42',['CY_RSLT_NETWORK_ERROR_RTOS',['../group__generic__lwip__whd__port__defines.html#ga0c5b724f4d242fd2f465ba00cee17fa4',1,'cy_nw_mw_core_error.h']]], ['cy_5frslt_5fnetwork_5ferror_5fstarting_5fdhcp_43',['CY_RSLT_NETWORK_ERROR_STARTING_DHCP',['../group__generic__lwip__whd__port__defines.html#gabe7486b63b0e20d597c80f66b281a6c6',1,'cy_nw_mw_core_error.h']]], ['cy_5frslt_5fnetwork_5ferror_5fstarting_5finternal_5fdhcp_44',['CY_RSLT_NETWORK_ERROR_STARTING_INTERNAL_DHCP',['../group__generic__lwip__whd__port__defines.html#gac2bfa236e9261ca5bab6e78d6f32d128',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5finterface_5fdoes_5fnot_5fexist_45',['CY_RSLT_NETWORK_INTERFACE_DOES_NOT_EXIST',['../group__generic__lwip__whd__port__defines.html#ga752aff5813b092f64fb7a7aa2f837a0c',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5finterface_5fexists_46',['CY_RSLT_NETWORK_INTERFACE_EXISTS',['../group__generic__lwip__whd__port__defines.html#ga66482668f42e202a2d493782ea856270',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5finterface_5fnetwork_5fnot_5fup_47',['CY_RSLT_NETWORK_INTERFACE_NETWORK_NOT_UP',['../group__generic__lwip__whd__port__defines.html#gabc1d83188fe0b29bbe0de950519a52a8',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5finvalid_5fsocket_48',['CY_RSLT_NETWORK_INVALID_SOCKET',['../group__generic__lwip__whd__port__defines.html#ga7325308cb997463c8372e84d4cdde4c7',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5fipv6_5finterface_5fnot_5fready_49',['CY_RSLT_NETWORK_IPV6_INTERFACE_NOT_READY',['../group__generic__lwip__whd__port__defines.html#ga0370d51c846f63d87078f684e27f93a7',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5flink_5fnot_5fup_50',['CY_RSLT_NETWORK_LINK_NOT_UP',['../group__generic__lwip__whd__port__defines.html#gadd0ef95e5fb952dd62156060eaf25d2e',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5fnot_5fsupported_51',['CY_RSLT_NETWORK_NOT_SUPPORTED',['../group__generic__lwip__whd__port__defines.html#ga1ae343f44b7540a45f3680ba6d1a7226',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5fport_5ferr_5fbase_52',['CY_RSLT_NETWORK_PORT_ERR_BASE',['../group__generic__lwip__whd__port__defines.html#ga64411e3dd47f1879323877c2370b9eec',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5fsocket_5fcreate_5ffail_53',['CY_RSLT_NETWORK_SOCKET_CREATE_FAIL',['../group__generic__lwip__whd__port__defines.html#ga0be1337ee3c34383be5bc25b9492321f',1,'cy_nw_mw_core_error.h']]], - ['cy_5frslt_5fnetwork_5fsocket_5ferror_54',['CY_RSLT_NETWORK_SOCKET_ERROR',['../group__generic__lwip__whd__port__defines.html#ga0402c74db5d2b1251c2bc8ba16520bb5',1,'cy_nw_mw_core_error.h']]], - ['cy_5fwifimwcore_5feapol_5fpacket_5fhandler_5ft_55',['cy_wifimwcore_eapol_packet_handler_t',['../group__group__wifimwcore__eapol__functions.html#ga5d501ebe6f09b2f93384fc33de1617a0',1,'cy_wifimwcore_eapol.h']]], - ['cy_5fwifimwcore_5feapol_5fregister_5freceive_5fhandler_56',['cy_wifimwcore_eapol_register_receive_handler',['../group__group__wifimwcore__eapol__functions.html#gab3477cb9900a5387811bf337cb7d42b1',1,'cy_wifimwcore_eapol.h']]] + ['cy_5frslt_5fnetwork_5ferror_5ftrng_45',['CY_RSLT_NETWORK_ERROR_TRNG',['../group__generic__lwip__whd__port__defines.html#gac6ccfbb53bcd02d7017e9de24c3e0856',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5finterface_5fdoes_5fnot_5fexist_46',['CY_RSLT_NETWORK_INTERFACE_DOES_NOT_EXIST',['../group__generic__lwip__whd__port__defines.html#ga752aff5813b092f64fb7a7aa2f837a0c',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5finterface_5fexists_47',['CY_RSLT_NETWORK_INTERFACE_EXISTS',['../group__generic__lwip__whd__port__defines.html#ga66482668f42e202a2d493782ea856270',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5finterface_5fnetwork_5fnot_5fup_48',['CY_RSLT_NETWORK_INTERFACE_NETWORK_NOT_UP',['../group__generic__lwip__whd__port__defines.html#gabc1d83188fe0b29bbe0de950519a52a8',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5finvalid_5fsocket_49',['CY_RSLT_NETWORK_INVALID_SOCKET',['../group__generic__lwip__whd__port__defines.html#ga7325308cb997463c8372e84d4cdde4c7',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5fipv6_5finterface_5fnot_5fready_50',['CY_RSLT_NETWORK_IPV6_INTERFACE_NOT_READY',['../group__generic__lwip__whd__port__defines.html#ga0370d51c846f63d87078f684e27f93a7',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5flink_5fnot_5fup_51',['CY_RSLT_NETWORK_LINK_NOT_UP',['../group__generic__lwip__whd__port__defines.html#gadd0ef95e5fb952dd62156060eaf25d2e',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5fnot_5fsupported_52',['CY_RSLT_NETWORK_NOT_SUPPORTED',['../group__generic__lwip__whd__port__defines.html#ga1ae343f44b7540a45f3680ba6d1a7226',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5fport_5ferr_5fbase_53',['CY_RSLT_NETWORK_PORT_ERR_BASE',['../group__generic__lwip__whd__port__defines.html#ga64411e3dd47f1879323877c2370b9eec',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5fsocket_5fcreate_5ffail_54',['CY_RSLT_NETWORK_SOCKET_CREATE_FAIL',['../group__generic__lwip__whd__port__defines.html#ga0be1337ee3c34383be5bc25b9492321f',1,'cy_nw_mw_core_error.h']]], + ['cy_5frslt_5fnetwork_5fsocket_5ferror_55',['CY_RSLT_NETWORK_SOCKET_ERROR',['../group__generic__lwip__whd__port__defines.html#ga0402c74db5d2b1251c2bc8ba16520bb5',1,'cy_nw_mw_core_error.h']]], + ['cy_5fwifimwcore_5feapol_5fpacket_5fhandler_5ft_56',['cy_wifimwcore_eapol_packet_handler_t',['../group__group__wifimwcore__eapol__functions.html#ga5d501ebe6f09b2f93384fc33de1617a0',1,'cy_wifimwcore_eapol.h']]], + ['cy_5fwifimwcore_5feapol_5fregister_5freceive_5fhandler_57',['cy_wifimwcore_eapol_register_receive_handler',['../group__group__wifimwcore__eapol__functions.html#gab3477cb9900a5387811bf337cb7d42b1',1,'cy_wifimwcore_eapol.h']]] ]; diff --git a/include/cy_network_mw_core.h b/include/cy_network_mw_core.h index 348c040..bf7c6a5 100644 --- a/include/cy_network_mw_core.h +++ b/include/cy_network_mw_core.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related @@ -43,6 +43,7 @@ #pragma once +#include #include "cy_result.h" #include "cy_nw_helper.h" #include "cy_nw_mw_core_error.h" @@ -337,6 +338,18 @@ cy_rslt_t cy_network_get_netmask_address(cy_network_interface_context *iface_con * */ cy_rslt_t cy_network_ping(void *if_ctx, cy_nw_ip_address_t *address, uint32_t timeout_ms, uint32_t* elapsed_time_ms); +#if defined(COMPONENT_CAT1) +/** + * Random number generate using PDL trng APIs + * + * @param[out] output : Data to fill + * @param[in] len : Maximum size to provide + * @param[out] olen : The actual amount of bytes put into the buffer (Can be 0) + * + * @return CY_RSLT_SUCCESS if successful; CY_RSLT_NETWORK_ERROR_TRNG if failure. + */ +cy_rslt_t cy_network_random_number_generate( unsigned char *output, size_t len, size_t *olen ); +#endif /** \} group_lwip_network_interface_integration_functions */ #ifdef __cplusplus diff --git a/source/cy_ethernetif.c b/source/cy_ethernetif.c index a129279..eb3ceea 100644 --- a/source/cy_ethernetif.c +++ b/source/cy_ethernetif.c @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/source/cy_internal.h b/source/cy_internal.h index bf7326e..c7a779f 100644 --- a/source/cy_internal.h +++ b/source/cy_internal.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/source/cy_lwip_dhcp_server.c b/source/cy_lwip_dhcp_server.c index 0ff99e4..5e77030 100644 --- a/source/cy_lwip_dhcp_server.c +++ b/source/cy_lwip_dhcp_server.c @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/source/cy_lwip_dhcp_server.h b/source/cy_lwip_dhcp_server.h index 0e1b8c8..7d8faf4 100644 --- a/source/cy_lwip_dhcp_server.h +++ b/source/cy_lwip_dhcp_server.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/source/cy_lwip_log.h b/source/cy_lwip_log.h index cbd1687..5cd3104 100644 --- a/source/cy_lwip_log.h +++ b/source/cy_lwip_log.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/source/cy_network_mw_core.c b/source/cy_network_mw_core.c index 61aba2b..ac30f05 100644 --- a/source/cy_network_mw_core.c +++ b/source/cy_network_mw_core.c @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related @@ -86,6 +86,10 @@ #endif +#if (COMPONENT_CAT1) +#include "cy_crypto_core.h" +#include "cy_crypto_core_trng_config.h" +#endif /* While using lwIP/sockets errno is required. Since IAR and ARMC6 doesn't define errno variable, the following definition is required for building it successfully. */ #if !( (defined(__GNUC__) && !defined(__ARMCC_VERSION)) ) int errno; @@ -154,6 +158,10 @@ int errno; #endif #endif +#if defined(COMPONENT_CAT1) +#define MAX_TRNG_BIT_SIZE (32UL) +#endif + /****************************************************** * Variable Definitions ******************************************************/ @@ -227,6 +235,11 @@ uint8_t *pRx_Q_buff_pool[CY_ETH_DEFINE_TOTAL_BD_PER_RXQUEUE]; #endif #endif +#if defined(COMPONENT_CAT1) +/** mutex to protect trng count */ +static cy_mutex_t trng_mutex; +#endif + /****************************************************** * Static Function Declarations ******************************************************/ @@ -255,6 +268,11 @@ cy_rslt_t cy_prng_get_random( void* buffer, uint32_t buffer_length ); cy_rslt_t cy_prng_add_entropy( const void* buffer, uint32_t buffer_length ); #endif +#if defined(COMPONENT_CAT1) +static int cy_trng_release( void ); +static int cy_trng_reserve( void ); +#endif + /****************************************************** * Function Definitions ******************************************************/ @@ -713,7 +731,6 @@ cy_rslt_t cy_network_init( void ) cy_rslt_t result; #endif #endif - cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "%s(): START \n", __FUNCTION__ ); if( connectivity_lib_init ) @@ -852,6 +869,18 @@ cy_rslt_t cy_network_init( void ) #endif #endif +#if defined(COMPONENT_CAT1) + if( cy_rtos_init_mutex(&trng_mutex) != CY_RSLT_SUCCESS ) + { + cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_ERR, "\n cy_rtos_init_mutex failed\n" ); +#if defined(CYBSP_ETHERNET_CAPABLE) + result = CY_RSLT_NETWORK_ERROR_NOMEM; + goto exit; +#else + return CY_RSLT_NETWORK_ERROR_NOMEM; +#endif + } +#endif connectivity_lib_init++; cm_cy_log_msg( CYLF_MIDDLEWARE, CY_LOG_DEBUG, "%s(): END \n", __FUNCTION__ ); @@ -910,6 +939,10 @@ cy_rslt_t cy_network_deinit( void ) cy_rtos_deinit_mutex(&tx_mutex); #endif +#endif + +#ifdef COMPONENT_CAT1 + cy_rtos_deinit_mutex(&trng_mutex); #endif } } @@ -1936,6 +1969,15 @@ cy_rslt_t cy_network_ping(void *iface_context, cy_nw_ip_address_t *address, uint cy_network_interface_context *if_ctx; if_ctx = (cy_network_interface_context *)iface_context; + /* + * If LPA is enabled, invoke the activity callback to resume the network stack, + * before invoking the LwIP APIs + */ + if (activity_callback) + { + activity_callback(true); + } + /* Open a local socket for pinging */ socket_for_ping = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP); if (socket_for_ping < 0) @@ -1948,6 +1990,16 @@ cy_rslt_t cy_network_ping(void *iface_context, cy_nw_ip_address_t *address, uint /* Convert the timeout into struct timeval */ timeout_val.tv_sec = (long)(timeout_ms / 1000); timeout_val.tv_usec = (long)((timeout_ms % 1000) * 1000); + + /* + * If LPA is enabled, invoke the activity callback to resume the network stack, + * before invoking the LwIP APIs + */ + if (activity_callback) + { + activity_callback(true); + } + /* Set the receive timeout on the local socket, so ping will time out */ if(lwip_setsockopt(socket_for_ping, SOL_SOCKET, SO_RCVTIMEO, &timeout_val, sizeof(struct timeval)) != ERR_OK) { @@ -1962,6 +2014,15 @@ cy_rslt_t cy_network_ping(void *iface_context, cy_nw_ip_address_t *address, uint memcpy(if_name, net_interface->name, sizeof(net_interface->name)); snprintf(&if_name[2], (PING_IF_NAME_LEN - 2), "%u", (uint8_t)(net_interface->num)); memcpy(iface.ifr_name, if_name, PING_IF_NAME_LEN); + + /* + * If LPA is enabled, invoke the activity callback to resume the network stack, + * before invoking the LwIP APIs + */ + if (activity_callback) + { + activity_callback(true); + } if(lwip_setsockopt(socket_for_ping, SOL_SOCKET, SO_BINDTODEVICE, &iface, sizeof(iface)) != ERR_OK) { result = CY_RSLT_NETWORK_ERROR_PING; @@ -1997,6 +2058,14 @@ cy_rslt_t cy_network_ping(void *iface_context, cy_nw_ip_address_t *address, uint /* Close the socket */ if(socket_for_ping >= 0) { + /* + * If LPA is enabled, invoke the activity callback to resume the network stack, + * before invoking the LwIP APIs + */ + if (activity_callback) + { + activity_callback(true); + } lwip_close(socket_for_ping); } return result; @@ -2049,6 +2118,14 @@ static err_t ping_send(int socket_hnd, const cy_nw_ip_address_t* address, struct to.sin_family = AF_INET; to.sin_addr.s_addr = address->ip.v4; + /* + * If LPA is enabled, invoke the activity callback to resume the network stack, + * before invoking the LwIP APIs + */ + if (activity_callback) + { + activity_callback(true); + } err = lwip_sendto(socket_hnd, iecho, sizeof(struct icmp_packet), 0, (struct sockaddr*) &to, sizeof(to)); return (err ? ERR_OK : ERR_VAL); @@ -2277,3 +2354,75 @@ cy_rslt_t cy_prng_add_entropy( const void* buffer, uint32_t buffer_length ) return CY_RSLT_SUCCESS; } #endif + +#if defined(COMPONENT_CAT1) +static int cy_trng_release() +{ + if (Cy_Crypto_Core_IsEnabled(CRYPTO)) + { + Cy_Crypto_Core_Disable(CRYPTO); + } + return 0; +} +static int cy_trng_reserve() +{ + cy_en_crypto_status_t crypto_status; + + crypto_status = Cy_Crypto_Core_Enable(CRYPTO); + if(crypto_status != CY_CRYPTO_SUCCESS) + { + cy_rtos_set_mutex(&trng_mutex); + cy_rtos_deinit_mutex(&trng_mutex); + return CY_RSLT_NETWORK_ERROR_TRNG; + } + return 0; +} + +cy_rslt_t cy_network_random_number_generate( unsigned char *output, size_t len, size_t *olen ) +{ + cy_rslt_t result = CY_RSLT_SUCCESS; + + *olen = 0; + /* temporary random data buffer */ + uint32_t random = 0u; + + result = cy_rtos_get_mutex(&trng_mutex, CY_RTOS_NEVER_TIMEOUT); + if(CY_RSLT_SUCCESS != result) + { + cy_rtos_deinit_mutex(&trng_mutex); + return CY_RSLT_NETWORK_ERROR_TRNG; + } + + if(cy_trng_reserve() != 0) + { + return CY_RSLT_NETWORK_ERROR_TRNG; + } + + /* Get Random byte */ + while (*olen < len) + { + if ( Cy_Crypto_Core_Trng(CRYPTO, CY_CRYPTO_DEF_TR_GARO, CY_CRYPTO_DEF_TR_FIRO, + MAX_TRNG_BIT_SIZE, &random) != CY_CRYPTO_SUCCESS) + { + return CY_RSLT_NETWORK_ERROR_TRNG; + } + else + { + for (uint8_t i = 0; (i < 4) && (*olen < len) ; i++) + { + *output++ = ((uint8_t *)&random)[i]; + *olen += 1; + } + } + } + random = 0uL; + + Cy_Crypto_Core_Trng_DeInit(CRYPTO); + if(cy_trng_release() != 0) + { + return CY_RSLT_NETWORK_ERROR_TRNG; + } + cy_rtos_set_mutex(&trng_mutex); + return result; +} +#endif diff --git a/source/cy_nw_mw_core_error.h b/source/cy_nw_mw_core_error.h index 4f29b18..8891537 100644 --- a/source/cy_nw_mw_core_error.h +++ b/source/cy_nw_mw_core_error.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related @@ -101,7 +101,7 @@ extern "C" { #define CY_RSLT_NETWORK_ERROR_RTOS (CY_RSLT_NETWORK_PORT_ERR_BASE + 21) /**< Denotes the failure from RTOS calls*/ #define CY_RSLT_NETWORK_NOT_SUPPORTED (CY_RSLT_NETWORK_PORT_ERR_BASE + 22) /**< Denotes that the feature is not supported*/ #define CY_RSLT_NETWORK_LINK_NOT_UP (CY_RSLT_NETWORK_PORT_ERR_BASE + 23) /**< Denotes that the Link is not up*/ - +#define CY_RSLT_NETWORK_ERROR_TRNG (CY_RSLT_NETWORK_PORT_ERR_BASE + 24) /**< Denotes that the random number generation failed*/ /** * \} */ diff --git a/source/cy_wifimwcore_eapol.h b/source/cy_wifimwcore_eapol.h index 52228c2..18da226 100644 --- a/source/cy_wifimwcore_eapol.h +++ b/source/cy_wifimwcore_eapol.h @@ -1,5 +1,5 @@ /* - * Copyright 2023, Cypress Semiconductor Corporation (an Infineon company) or + * Copyright 2024, Cypress Semiconductor Corporation (an Infineon company) or * an affiliate of Cypress Semiconductor Corporation. All rights reserved. * * This software, including source code, documentation and related diff --git a/version.xml b/version.xml index 8fb6881..759405e 100644 --- a/version.xml +++ b/version.xml @@ -1 +1 @@ -1.3.0.311 +1.3.1.331